Class: NewStoreApi::Price1

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

Overview

Price1 Model.

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(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

#grossFloat

Gross price for the gift wrapping.

Returns:

  • (Float)


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

def gross
  @gross
end

#netFloat

Net price for gift wrapping.

Returns:

  • (Float)


18
19
20
# File 'lib/new_store_api/models/price1.rb', line 18

def net
  @net
end

#taxFloat

Tax amount for the gift wrapping

Returns:

  • (Float)


22
23
24
# File 'lib/new_store_api/models/price1.rb', line 22

def tax
  @tax
end

#tax_codeString

Tax code (also known as tax class) for gift wrapping.

Returns:

  • (String)


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

.namesObject

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

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/new_store_api/models/price1.rb', line 46

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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