Class: StickyIoRestfulApiV2025731::Shipping

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/models/shipping.rb

Overview

Shipping 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(first_name:, last_name:, address:, address2:, city:, state:, zip:, country:, country_iso2:, additional_properties: nil) ⇒ Shipping

Returns a new instance of Shipping.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 73

def initialize(first_name:, last_name:, address:, address2:, city:, state:,
               zip:, country:, country_iso2:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @first_name = first_name
  @last_name = last_name
  @address = address
  @address2 = address2
  @city = city
  @state = state
  @zip = zip
  @country = country
  @country_iso2 = country_iso2
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 22

def address
  @address
end

#address2String

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 26

def address2
  @address2
end

#cityString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 30

def city
  @city
end

#countryString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 42

def country
  @country
end

#country_iso2String

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 46

def country_iso2
  @country_iso2
end

#first_nameString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 14

def first_name
  @first_name
end

#last_nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 18

def last_name
  @last_name
end

#stateString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 34

def state
  @state
end

#zipString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 38

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash.key?('first_name') ? hash['first_name'] : nil
  last_name = hash.key?('last_name') ? hash['last_name'] : nil
  address = hash.key?('address') ? hash['address'] : nil
  address2 = hash.key?('address2') ? hash['address2'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  state = hash.key?('state') ? hash['state'] : nil
  zip = hash.key?('zip') ? hash['zip'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  country_iso2 = hash.key?('country_iso2') ? hash['country_iso2'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Shipping.new(first_name: first_name,
               last_name: last_name,
               address: address,
               address2: address2,
               city: city,
               state: state,
               zip: zip,
               country: country,
               country_iso2: country_iso2,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['address'] = 'address'
  @_hash['address2'] = 'address2'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['zip'] = 'zip'
  @_hash['country'] = 'country'
  @_hash['country_iso2'] = 'country_iso2'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



64
65
66
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 64

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



135
136
137
138
139
140
141
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 135

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} first_name: #{@first_name.inspect}, last_name: #{@last_name.inspect},"\
  " address: #{@address.inspect}, address2: #{@address2.inspect}, city: #{@city.inspect},"\
  " state: #{@state.inspect}, zip: #{@zip.inspect}, country: #{@country.inspect},"\
  " country_iso2: #{@country_iso2.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



126
127
128
129
130
131
132
# File 'lib/sticky_io_restful_api_v2025731/models/shipping.rb', line 126

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} first_name: #{@first_name}, last_name: #{@last_name}, address: #{@address},"\
  " address2: #{@address2}, city: #{@city}, state: #{@state}, zip: #{@zip}, country:"\
  " #{@country}, country_iso2: #{@country_iso2}, additional_properties:"\
  " #{@additional_properties}>"
end