Class: SplititWebApiV4::OffersStoreLocation

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/splitit_web_api_v4/models/offers_store_location.rb

Overview

OffersStoreLocation 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(line1:, postal_code:, country:, line2: SKIP, city: SKIP, state: SKIP, additional_properties: nil) ⇒ OffersStoreLocation

Returns a new instance of OffersStoreLocation.



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 62

def initialize(line1:, postal_code:, country:, line2: SKIP, city: SKIP,
               state: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @line1 = line1
  @line2 = line2 unless line2 == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @postal_code = postal_code
  @country = country
  @additional_properties = additional_properties
end

Instance Attribute Details

#cityString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 22

def city
  @city
end

#countryString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 34

def country
  @country
end

#line1String

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 14

def line1
  @line1
end

#line2String

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 18

def line2
  @line2
end

#postal_codeString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 30

def postal_code
  @postal_code
end

#stateString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 26

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  line1 = hash.key?('Line1') ? hash['Line1'] : nil
  postal_code = hash.key?('PostalCode') ? hash['PostalCode'] : nil
  country = hash.key?('Country') ? hash['Country'] : nil
  line2 = hash.key?('Line2') ? hash['Line2'] : SKIP
  city = hash.key?('City') ? hash['City'] : SKIP
  state = hash.key?('State') ? hash['State'] : SKIP

  # 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.
  OffersStoreLocation.new(line1: line1,
                          postal_code: postal_code,
                          country: country,
                          line2: line2,
                          city: city,
                          state: state,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['line1'] = 'Line1'
  @_hash['line2'] = 'Line2'
  @_hash['city'] = 'City'
  @_hash['state'] = 'State'
  @_hash['postal_code'] = 'PostalCode'
  @_hash['country'] = 'Country'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 49

def self.optionals
  %w[
    line2
    city
    state
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} line1: #{@line1.inspect}, line2: #{@line2.inspect}, city: #{@city.inspect},"\
  " state: #{@state.inspect}, postal_code: #{@postal_code.inspect}, country:"\
  " #{@country.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



106
107
108
109
110
111
# File 'lib/splitit_web_api_v4/models/offers_store_location.rb', line 106

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} line1: #{@line1}, line2: #{@line2}, city: #{@city}, state: #{@state},"\
  " postal_code: #{@postal_code}, country: #{@country}, additional_properties:"\
  " #{@additional_properties}>"
end