class Io::Flow::V0::Clients::Provinces

Public Class Methods

new(client) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 5582
def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Public Instance Methods

get(incoming={}) click to toggle source

Returns a list of provinces.

# File lib/flow_commerce/flow_api_v0_client.rb, line 5587
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)),
    :countries => (x = opts.delete(:countries); x.nil? ? nil : HttpClient::Preconditions.assert_class('countries', x, Array).map { |v| HttpClient::Preconditions.assert_class('countries', v, String) })
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/reference/provinces").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Province.new(x) }
end
get_by_id(id) click to toggle source

Returns the province with the specifed id.

# File lib/flow_commerce/flow_api_v0_client.rb, line 5598
def get_by_id(id)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/reference/provinces/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::Province.new(r)
end