Class: NewStoreApi::Pricing

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/pricing.rb

Overview

Currency and tax treatment for all prices in the payload.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(currency = nil, method = nil, tax_exemption = SKIP) ⇒ Pricing

Returns a new instance of Pricing.



48
49
50
51
52
# File 'lib/new_store_api/models/pricing.rb', line 48

def initialize(currency = nil, method = nil, tax_exemption = SKIP)
  @currency = currency
  @method = method
  @tax_exemption = tax_exemption unless tax_exemption == SKIP
end

Instance Attribute Details

#currencyCurrency1Enum

The currency for all the prices contained within this payload.

Returns:



14
15
16
# File 'lib/new_store_api/models/pricing.rb', line 14

def currency
  @currency
end

#methodPricingMethodEnum

Specifies whether all item and fulfillment prices include tax (tax_included) or exclude it (tax_excluded).

Returns:



19
20
21
# File 'lib/new_store_api/models/pricing.rb', line 19

def method
  @method
end

#tax_exemptionTaxExemption

Optional order-level tax exemption to apply to all prices in the payload.

Returns:



23
24
25
# File 'lib/new_store_api/models/pricing.rb', line 23

def tax_exemption
  @tax_exemption
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/models/pricing.rb', line 55

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency = hash.key?('currency') ? hash['currency'] : nil
  method = hash.key?('method') ? hash['method'] : nil
  tax_exemption = TaxExemption.from_hash(hash['tax_exemption']) if hash['tax_exemption']

  # Create object from extracted values.
  Pricing.new(currency,
              method,
              tax_exemption)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/new_store_api/models/pricing.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['currency'] = 'currency'
  @_hash['method'] = 'method'
  @_hash['tax_exemption'] = 'tax_exemption'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
45
46
# File 'lib/new_store_api/models/pricing.rb', line 42

def self.nullables
  %w[
    tax_exemption
  ]
end

.optionalsObject

An array for optional fields



35
36
37
38
39
# File 'lib/new_store_api/models/pricing.rb', line 35

def self.optionals
  %w[
    tax_exemption
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
81
# File 'lib/new_store_api/models/pricing.rb', line 77

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency.inspect}, method: #{@method.inspect}, tax_exemption:"\
  " #{@tax_exemption.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



70
71
72
73
74
# File 'lib/new_store_api/models/pricing.rb', line 70

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency}, method: #{@method}, tax_exemption:"\
  " #{@tax_exemption}>"
end