Class: ConnectWise::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/connectwise-ruby-sdk/models/country.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Country

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 79

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'defaultFlag')
    self.default_flag = attributes[:'defaultFlag']
  end

  if attributes.has_key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.has_key?(:'cityCaption')
    self.city_caption = attributes[:'cityCaption']
  end

  if attributes.has_key?(:'stateCaption')
    self.state_caption = attributes[:'stateCaption']
  end

  if attributes.has_key?(:'zipCaption')
    self.zip_caption = attributes[:'zipCaption']
  end

  if attributes.has_key?(:'zipMinimumLength')
    self.zip_minimum_length = attributes[:'zipMinimumLength']
  end

  if attributes.has_key?(:'dialingPrefix')
    self.dialing_prefix = attributes[:'dialingPrefix']
  end

  if attributes.has_key?(:'addressFormat')
    self.address_format = attributes[:'addressFormat']
  end

  if attributes.has_key?(:'countryCode')
    self.country_code = attributes[:'countryCode']
  end

  if attributes.has_key?(:'localizationCaptionOne')
    self.localization_caption_one = attributes[:'localizationCaptionOne']
  end

  if attributes.has_key?(:'localizationValueOne')
    self.localization_value_one = attributes[:'localizationValueOne']
  end

  if attributes.has_key?(:'_info')
    self._info = attributes[:'_info']
  end

end

Instance Attribute Details

#_infoObject

Metadata of the entity



34
35
36
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 34

def _info
  @_info
end

#address_formatObject

Returns the value of attribute address_format.



25
26
27
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 25

def address_format
  @address_format
end

#city_captionObject

Returns the value of attribute city_caption.



15
16
17
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 15

def city_caption
  @city_caption
end

#country_codeObject

Returns the value of attribute country_code.



27
28
29
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 27

def country_code
  @country_code
end

#currencyObject

Returns the value of attribute currency.



13
14
15
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 13

def currency
  @currency
end

#default_flagObject

Returns the value of attribute default_flag.



11
12
13
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 11

def default_flag
  @default_flag
end

#dialing_prefixObject

Returns the value of attribute dialing_prefix.



23
24
25
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 23

def dialing_prefix
  @dialing_prefix
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 7

def id
  @id
end

#localization_caption_oneObject

Returns the value of attribute localization_caption_one.



29
30
31
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 29

def localization_caption_one
  @localization_caption_one
end

#localization_value_oneObject

Returns the value of attribute localization_value_one.



31
32
33
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 31

def localization_value_one
  @localization_value_one
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 9

def name
  @name
end

#state_captionObject

Returns the value of attribute state_caption.



17
18
19
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 17

def state_caption
  @state_caption
end

#zip_captionObject

Returns the value of attribute zip_caption.



19
20
21
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 19

def zip_caption
  @zip_caption
end

#zip_minimum_lengthObject

Returns the value of attribute zip_minimum_length.



21
22
23
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 21

def zip_minimum_length
  @zip_minimum_length
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 38

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'default_flag' => :'defaultFlag',
    :'currency' => :'currency',
    :'city_caption' => :'cityCaption',
    :'state_caption' => :'stateCaption',
    :'zip_caption' => :'zipCaption',
    :'zip_minimum_length' => :'zipMinimumLength',
    :'dialing_prefix' => :'dialingPrefix',
    :'address_format' => :'addressFormat',
    :'country_code' => :'countryCode',
    :'localization_caption_one' => :'localizationCaptionOne',
    :'localization_value_one' => :'localizationValueOne',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 58

def self.swagger_types
  {
    :'id' => :'Integer',
    :'name' => :'String',
    :'default_flag' => :'BOOLEAN',
    :'currency' => :'CurrencyReference',
    :'city_caption' => :'String',
    :'state_caption' => :'String',
    :'zip_caption' => :'String',
    :'zip_minimum_length' => :'Integer',
    :'dialing_prefix' => :'String',
    :'address_format' => :'AddressFormatReference',
    :'country_code' => :'String',
    :'localization_caption_one' => :'String',
    :'localization_value_one' => :'String',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 324

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      default_flag == o.default_flag &&
      currency == o.currency &&
      city_caption == o.city_caption &&
      state_caption == o.state_caption &&
      zip_caption == o.zip_caption &&
      zip_minimum_length == o.zip_minimum_length &&
      dialing_prefix == o.dialing_prefix &&
      address_format == o.address_format &&
      country_code == o.country_code &&
      localization_caption_one == o.localization_caption_one &&
      localization_value_one == o.localization_value_one &&
      _info == o._info
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 379

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = ConnectWise.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 445

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map{ |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 358

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


345
346
347
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 345

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



351
352
353
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 351

def hash
  [id, name, default_flag, currency, city_caption, state_caption, zip_caption, zip_minimum_length, dialing_prefix, address_format, country_code, localization_caption_one, localization_value_one, _info].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 145

def list_invalid_properties
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push("invalid value for 'name', name cannot be nil.")
  end

  if @name.to_s.length > 50
    invalid_properties.push("invalid value for 'name', the character length must be smaller than or equal to 50.")
  end

  if @currency.nil?
    invalid_properties.push("invalid value for 'currency', currency cannot be nil.")
  end

  if !@city_caption.nil? && @city_caption.to_s.length > 25
    invalid_properties.push("invalid value for 'city_caption', the character length must be smaller than or equal to 25.")
  end

  if !@state_caption.nil? && @state_caption.to_s.length > 25
    invalid_properties.push("invalid value for 'state_caption', the character length must be smaller than or equal to 25.")
  end

  if !@zip_caption.nil? && @zip_caption.to_s.length > 25
    invalid_properties.push("invalid value for 'zip_caption', the character length must be smaller than or equal to 25.")
  end

  if !@zip_minimum_length.nil? && @zip_minimum_length > 10
    invalid_properties.push("invalid value for 'zip_minimum_length', must be smaller than or equal to 10.")
  end

  if !@zip_minimum_length.nil? && @zip_minimum_length < 1
    invalid_properties.push("invalid value for 'zip_minimum_length', must be greater than or equal to 1.")
  end

  if !@dialing_prefix.nil? && @dialing_prefix.to_s.length > 5
    invalid_properties.push("invalid value for 'dialing_prefix', the character length must be smaller than or equal to 5.")
  end

  if !@country_code.nil? && @country_code.to_s.length > 2
    invalid_properties.push("invalid value for 'country_code', the character length must be smaller than or equal to 2.")
  end

  if !@localization_caption_one.nil? && @localization_caption_one.to_s.length > 25
    invalid_properties.push("invalid value for 'localization_caption_one', the character length must be smaller than or equal to 25.")
  end

  if !@localization_value_one.nil? && @localization_value_one.to_s.length > 50
    invalid_properties.push("invalid value for 'localization_value_one', the character length must be smaller than or equal to 50.")
  end

  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



425
426
427
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 425

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



431
432
433
434
435
436
437
438
439
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 431

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



419
420
421
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 419

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/connectwise-ruby-sdk/models/country.rb', line 200

def valid?
  return false if @name.nil?
  return false if @name.to_s.length > 50
  return false if @currency.nil?
  return false if !@city_caption.nil? && @city_caption.to_s.length > 25
  return false if !@state_caption.nil? && @state_caption.to_s.length > 25
  return false if !@zip_caption.nil? && @zip_caption.to_s.length > 25
  return false if !@zip_minimum_length.nil? && @zip_minimum_length > 10
  return false if !@zip_minimum_length.nil? && @zip_minimum_length < 1
  return false if !@dialing_prefix.nil? && @dialing_prefix.to_s.length > 5
  return false if !@country_code.nil? && @country_code.to_s.length > 2
  return false if !@localization_caption_one.nil? && @localization_caption_one.to_s.length > 25
  return false if !@localization_value_one.nil? && @localization_value_one.to_s.length > 50
  return true
end