Class: Merge::Crm::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/crm/types/address.rb

Overview

# The Address Object

### Description
The `Address` object is used to represent an entity's address.
### Usage Example
TODO

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(created_at: OMIT, modified_at: OMIT, street_1: OMIT, street_2: OMIT, city: OMIT, state: OMIT, postal_code: OMIT, country: OMIT, address_type: OMIT, additional_properties: nil) ⇒ Merge::Crm::Address



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/merge_ruby_client/crm/types/address.rb', line 556

def initialize(created_at: OMIT, modified_at: OMIT, street_1: OMIT, street_2: OMIT, city: OMIT, state: OMIT,
               postal_code: OMIT, country: OMIT, address_type: OMIT, additional_properties: nil)
  @created_at = created_at if created_at != OMIT
  @modified_at = modified_at if modified_at != OMIT
  @street_1 = street_1 if street_1 != OMIT
  @street_2 = street_2 if street_2 != OMIT
  @city = city if city != OMIT
  @state = state if state != OMIT
  @postal_code = postal_code if postal_code != OMIT
  @country = country if country != OMIT
  @address_type = address_type if address_type != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "created_at": created_at,
    "modified_at": modified_at,
    "street_1": street_1,
    "street_2": street_2,
    "city": city,
    "state": state,
    "postal_code": postal_code,
    "country": country,
    "address_type": address_type
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



287
288
289
# File 'lib/merge_ruby_client/crm/types/address.rb', line 287

def additional_properties
  @additional_properties
end

#address_typeMerge::Crm::AddressTypeEnum (readonly)



285
286
287
# File 'lib/merge_ruby_client/crm/types/address.rb', line 285

def address_type
  @address_type
end

#cityString (readonly)



26
27
28
# File 'lib/merge_ruby_client/crm/types/address.rb', line 26

def city
  @city
end

#countryMerge::Crm::CountryEnum (readonly)



281
282
283
# File 'lib/merge_ruby_client/crm/types/address.rb', line 281

def country
  @country
end

#created_atDateTime (readonly)



18
19
20
# File 'lib/merge_ruby_client/crm/types/address.rb', line 18

def created_at
  @created_at
end

#modified_atDateTime (readonly)



20
21
22
# File 'lib/merge_ruby_client/crm/types/address.rb', line 20

def modified_at
  @modified_at
end

#postal_codeString (readonly)



30
31
32
# File 'lib/merge_ruby_client/crm/types/address.rb', line 30

def postal_code
  @postal_code
end

#stateString (readonly)



28
29
30
# File 'lib/merge_ruby_client/crm/types/address.rb', line 28

def state
  @state
end

#street_1String (readonly)



22
23
24
# File 'lib/merge_ruby_client/crm/types/address.rb', line 22

def street_1
  @street_1
end

#street_2String (readonly)



24
25
26
# File 'lib/merge_ruby_client/crm/types/address.rb', line 24

def street_2
  @street_2
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Crm::Address

Deserialize a JSON object to an instance of Address



587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/merge_ruby_client/crm/types/address.rb', line 587

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?)
  street_1 = parsed_json["street_1"]
  street_2 = parsed_json["street_2"]
  city = parsed_json["city"]
  state = parsed_json["state"]
  postal_code = parsed_json["postal_code"]
  country = parsed_json["country"]
  address_type = parsed_json["address_type"]
  new(
    created_at: created_at,
    modified_at: modified_at,
    street_1: street_1,
    street_2: street_2,
    city: city,
    state: state,
    postal_code: postal_code,
    country: country,
    address_type: address_type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


626
627
628
629
630
631
632
633
634
635
636
# File 'lib/merge_ruby_client/crm/types/address.rb', line 626

def self.validate_raw(obj:)
  obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.")
  obj.street_1&.is_a?(String) != false || raise("Passed value for field obj.street_1 is not the expected type, validation failed.")
  obj.street_2&.is_a?(String) != false || raise("Passed value for field obj.street_2 is not the expected type, validation failed.")
  obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.")
  obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.")
  obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.")
  obj.country&.is_a?(Merge::Crm::CountryEnum) != false || raise("Passed value for field obj.country is not the expected type, validation failed.")
  obj.address_type&.is_a?(Merge::Crm::AddressTypeEnum) != false || raise("Passed value for field obj.address_type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Address to a JSON object



616
617
618
# File 'lib/merge_ruby_client/crm/types/address.rb', line 616

def to_json(*_args)
  @_field_set&.to_json
end