Class: SynapsePayRest::Statements
- Inherits:
-
Object
- Object
- SynapsePayRest::Statements
- Defined in:
- lib/synapse_pay_rest/api/statements.rb
Overview
Wrapper class for /client endpoint
Constant Summary collapse
- VALID_QUERY_PARAMS =
TODO:
Should refactor this to HTTPClient
Valid optional args for #get
[:page, :per_page].freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#get(user_id:, node_id: nil, **options) ⇒ Hash
Sends a GET request /node or /user statments endpoint to retrieve statements, and returns the response.
-
#initialize(client) ⇒ Statements
constructor
A new instance of Statements.
Constructor Details
#initialize(client) ⇒ Statements
Returns a new instance of Statements.
14 15 16 |
# File 'lib/synapse_pay_rest/api/statements.rb', line 14 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ SynapsePayRest::HTTPClient
11 12 13 |
# File 'lib/synapse_pay_rest/api/statements.rb', line 11 def client @client end |
Instance Method Details
#get(user_id:, node_id: nil, **options) ⇒ Hash
Sends a GET request /node or /user statments endpoint to retrieve statements, and returns the response.
HTTP response from API
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/synapse_pay_rest/api/statements.rb', line 28 def get(user_id:, node_id: nil, **) params = VALID_QUERY_PARAMS.map do |p| [p] ? "#{p}=#{[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 |