Class: Io::Flow::V0::Clients::TaxRegistrations

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TaxRegistrations

Returns a new instance of TaxRegistrations.



3121
3122
3123
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3121

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

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



3152
3153
3154
3155
3156
3157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3152

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

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



3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3132

def get_details(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :order_number => HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), 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)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/tax/registrations/details").with_query(query).get
  ::Io::Flow::V0::Models::DetailedTaxRegistration.new(r)
end

#post(organization, tax_registration_form) ⇒ Object



3125
3126
3127
3128
3129
3130
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3125

def post(organization, tax_registration_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = tax_registration_form; x.is_a?(::Io::Flow::V0::Models::TaxRegistrationForm) ? x : ::Io::Flow::V0::Models::TaxRegistrationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/tax/registrations").with_json(tax_registration_form.to_json).post
  ::Io::Flow::V0::Models::TaxRegistration.new(r)
end

#put_by_key(organization, key, tax_registration_form) ⇒ Object



3144
3145
3146
3147
3148
3149
3150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3144

def put_by_key(organization, key, tax_registration_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  (x = tax_registration_form; x.is_a?(::Io::Flow::V0::Models::TaxRegistrationForm) ? x : ::Io::Flow::V0::Models::TaxRegistrationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/tax/registrations/#{CGI.escape(key)}").with_json(tax_registration_form.to_json).put
  ::Io::Flow::V0::Models::TaxRegistration.new(r)
end