class TransparentData::Request

Public Class Methods

call(client, method, query: {}, json: {}) click to toggle source
# File lib/transparent_data/request.rb, line 6
def call(client, method, query: {}, json: {})
  response = client.post(build_path(method, query), json.to_json)

  TransparentData::Response::Struct.new(response)
end

Private Class Methods

build_path(method, query) click to toggle source
# File lib/transparent_data/request.rb, line 14
def build_path(method, query)
  base_path = "/#{TransparentData.key}/#{method}"

  return base_path unless query&.any?

  base_path.concat("?#{convert_params_to_query(query)}")
end
convert_params_to_query(params) click to toggle source
# File lib/transparent_data/request.rb, line 22
def convert_params_to_query(params)
  params.map { |pair| pair.join('=') }.join('&')
end