class ApplicationService
  def self.call(*args, &block)
    new(*args, &block).call
  end

  private
    def json_parse(json)
      ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(json))
    end

    def rest_client_request(method, path, body: {}, headers: {})
      JSON.parse(RestClient::Request.execute(
        method: method,
        url: path,
        headers: headers,
        payload: body
      ).body)
    rescue RestClient::Exception => e
      { success: false, error: e.response&.body, http_code: e.http_code }
    end
end
