Class: Io::Flow::V0::Clients::TaxSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TaxSettings

Returns a new instance of TaxSettings.



8880
8881
8882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8880

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete(organization) ⇒ Object



8905
8906
8907
8908
8909
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8905

def delete(organization)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  r = @client.request("/#{CGI.escape(organization)}/tax/settings").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object

Returns the tax settings for the organization.



8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8885

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :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? ? "-created_at" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/tax/settings").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::TaxSetting.from_json(x) }
end

#put(organization, tax_setting) ⇒ Object



8898
8899
8900
8901
8902
8903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8898

def put(organization, tax_setting)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = tax_setting; x.is_a?(::Io::Flow::V0::Models::TaxSetting) ? x : ::Io::Flow::V0::Models::TaxSetting.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/tax/settings").with_json(tax_setting.to_json).put
  ::Io::Flow::V0::Models::TaxSetting.from_json(r)
end