Class: NewStoreApi::Price1
- Defined in:
- lib/new_store_api/models/price1.rb
Overview
Price1 Model.
Instance Attribute Summary collapse
-
#gross ⇒ Float
Gross price for the gift wrapping.
-
#net ⇒ Float
Net price for gift wrapping.
-
#tax ⇒ Float
Tax amount for the gift wrapping.
-
#tax_code ⇒ String
Tax code (also known as tax class) for gift wrapping.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(gross = nil, net = nil, tax = nil, tax_code = SKIP) ⇒ Price1
constructor
A new instance of Price1.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(gross = nil, net = nil, tax = nil, tax_code = SKIP) ⇒ Price1
Returns a new instance of Price1.
50 51 52 53 54 55 |
# File 'lib/new_store_api/models/price1.rb', line 50 def initialize(gross = nil, net = nil, tax = nil, tax_code = SKIP) @gross = gross @net = net @tax = tax @tax_code = tax_code unless tax_code == SKIP end |
Instance Attribute Details
#gross ⇒ Float
Gross price for the gift wrapping.
14 15 16 |
# File 'lib/new_store_api/models/price1.rb', line 14 def gross @gross end |
#net ⇒ Float
Net price for gift wrapping.
18 19 20 |
# File 'lib/new_store_api/models/price1.rb', line 18 def net @net end |
#tax ⇒ Float
Tax amount for the gift wrapping
22 23 24 |
# File 'lib/new_store_api/models/price1.rb', line 22 def tax @tax end |
#tax_code ⇒ String
Tax code (also known as tax class) for gift wrapping.
26 27 28 |
# File 'lib/new_store_api/models/price1.rb', line 26 def tax_code @tax_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/new_store_api/models/price1.rb', line 58 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. gross = hash.key?('gross') ? hash['gross'] : nil net = hash.key?('net') ? hash['net'] : nil tax = hash.key?('tax') ? hash['tax'] : nil tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP # Create object from extracted values. Price1.new(gross, net, tax, tax_code) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/new_store_api/models/price1.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['gross'] = 'gross' @_hash['net'] = 'net' @_hash['tax'] = 'tax' @_hash['tax_code'] = 'tax_code' @_hash end |
.nullables ⇒ Object
An array for nullable fields
46 47 48 |
# File 'lib/new_store_api/models/price1.rb', line 46 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 |
# File 'lib/new_store_api/models/price1.rb', line 39 def self.optionals %w[ tax_code ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
81 82 83 84 85 |
# File 'lib/new_store_api/models/price1.rb', line 81 def inspect class_name = self.class.name.split('::').last "<#{class_name} gross: #{@gross.inspect}, net: #{@net.inspect}, tax: #{@tax.inspect},"\ " tax_code: #{@tax_code.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
75 76 77 78 |
# File 'lib/new_store_api/models/price1.rb', line 75 def to_s class_name = self.class.name.split('::').last "<#{class_name} gross: #{@gross}, net: #{@net}, tax: #{@tax}, tax_code: #{@tax_code}>" end |