class SynapsePayRest::Statements

Wrapper class for /client endpoint

Constants

VALID_QUERY_PARAMS

Valid optional args for get @todo Should refactor this to HTTPClient

Attributes

client[RW]

@!attribute [rw] client

@return [SynapsePayRest::HTTPClient]

Public Class Methods

new(client) click to toggle source

@param client [SynapsePayRest::HTTPClient]

# File lib/synapse_pay_rest/api/statements.rb, line 14
def initialize(client)
  @client = client
end

Public Instance Methods

get(user_id:, node_id: nil, **options) click to toggle source

Sends a GET request /node or /user statments endpoint to retrieve statements, and returns the response.

@param user_id [String] @param node_id [String] optional

@raise [SynapsePayRest::Error] may return subclasses of error based on HTTP response from API

@return [Hash] API response

# File lib/synapse_pay_rest/api/statements.rb, line 28
def get(user_id:, node_id: nil, **options)
  params = VALID_QUERY_PARAMS.map do |p|
    options[p] ? "#{p}=#{options[p]}" : nil
  end.compact

  path = "/users/#{user_id}"
  path += "/nodes/#{node_id}" if node_id
  path += "/statements"
  path += '?' + params.join('&') if params.any?
  client.get(path)
end