Class: Io::Flow::V0::Clients::HsCodes
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::HsCodes
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(incoming = {}) ⇒ Object
Search harmonization codes.
-
#get_by_code(code) ⇒ Object
Returns information about a specific harmonization code.
-
#initialize(client) ⇒ HsCodes
constructor
A new instance of HsCodes.
Constructor Details
#initialize(client) ⇒ HsCodes
Returns a new instance of HsCodes.
2305 2306 2307 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2305 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(incoming = {}) ⇒ Object
Search harmonization codes. Always paginated.
2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2310 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :code => (x = opts.delete(:code); x.nil? ? nil : HttpClient::Preconditions.assert_class('code', x, Array).map { |v| HttpClient::Preconditions.assert_class('code', v, String) }), :parent => (x = opts.delete(:parent); x.nil? ? nil : HttpClient::Preconditions.assert_class('parent', x, String)), :has_parent => (x = opts.delete(:has_parent); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('has_parent', x)), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "code" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/harmonization/codes").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::HsCode.new(x) } end |
#get_by_code(code) ⇒ Object
Returns information about a specific harmonization code.
2325 2326 2327 2328 2329 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2325 def get_by_code(code) HttpClient::Preconditions.assert_class('code', code, String) r = @client.request("/harmonization/codes/#{CGI.escape(code)}").get ::Io::Flow::V0::Models::HsCode.new(r) end |