Class: Io::Flow::V0::Clients::Regions
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Regions
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(incoming = {}) ⇒ Object
Returns a list of regions.
-
#get_by_id(id) ⇒ Object
Returns the region with the specifed id.
-
#initialize(client) ⇒ Regions
constructor
A new instance of Regions.
Constructor Details
#initialize(client) ⇒ Regions
Returns a new instance of Regions.
5608 5609 5610 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5608 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(incoming = {}) ⇒ Object
Returns a list of regions.
5613 5614 5615 5616 5617 5618 5619 5620 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5613 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :q => (x = opts.delete(:q); x.nil? ? nil : HttpClient::Preconditions.assert_class('q', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/reference/regions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Region.new(x) } end |
#get_by_id(id) ⇒ Object
Returns the region with the specifed id.
5623 5624 5625 5626 5627 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5623 def get_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/reference/regions/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Region.new(r) end |