Class: ZATCA::UBL::CommonAggregateComponents::PostalAddress

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/zatca/ubl/common_aggregate_components/postal_address.rb

Constant Summary collapse

SCHEMA =
Dry::Schema.Params do
  required(:street_name).filled(:string)
  required(:additional_street_name).filled(:string)
  required(:building_number).filled(:string)
  required(:plot_identification).filled(:string)
  required(:city_subdivision_name).filled(:string)
  required(:city_name).filled(:string)
  required(:postal_zone).filled(:string)
  required(:country_subentity).filled(:string)
  required(:country_identification_code).filled(:string)
end

Constants inherited from BaseComponent

BaseComponent::ArrayOfBaseComponentOrNil

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#attributes, #index, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#[], build, #build_xml, #dig, #find_nested_element_by_path, #generate_xml, #schema, #to_h, #to_xml

Constructor Details

#initialize(street_name:, building_number:, plot_identification:, city_subdivision_name:, city_name:, postal_zone:, country_subentity:, additional_street_name: nil, country_identification_code: "SA") ⇒ PostalAddress

Returns a new instance of PostalAddress.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 24

def initialize(
  street_name:, building_number:, plot_identification:,
  city_subdivision_name:, city_name:, postal_zone:, country_subentity:,
  additional_street_name: nil, country_identification_code: "SA"
)
  @street_name = street_name
  @additional_street_name = additional_street_name
  @building_number = building_number
  @plot_identification = plot_identification
  @city_subdivision_name = city_subdivision_name
  @city_name = city_name
  @postal_zone = postal_zone
  @country_subentity = country_subentity
  @country_identification_code = country_identification_code
end

Instance Attribute Details

#additional_street_nameObject

Returns the value of attribute additional_street_name.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def additional_street_name
  @additional_street_name
end

#building_numberObject

Returns the value of attribute building_number.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def building_number
  @building_number
end

#city_nameObject

Returns the value of attribute city_name.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def city_name
  @city_name
end

#city_subdivision_nameObject

Returns the value of attribute city_subdivision_name.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def city_subdivision_name
  @city_subdivision_name
end

#countryObject

Returns the value of attribute country.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def country
  @country
end

#country_subentityObject

Returns the value of attribute country_subentity.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def country_subentity
  @country_subentity
end

#plot_identificationObject

Returns the value of attribute plot_identification.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def plot_identification
  @plot_identification
end

#postal_zoneObject

Returns the value of attribute postal_zone.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def postal_zone
  @postal_zone
end

#street_nameObject

Returns the value of attribute street_name.



2
3
4
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 2

def street_name
  @street_name
end

Instance Method Details

#elementsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 44

def elements
  [
    ZATCA::UBL::BaseComponent.build(name: "cbc:StreetName", value: @street_name),
    ZATCA::UBL::BaseComponent.build(name: "cbc:AdditionalStreetName", value: @additional_street_name),
    ZATCA::UBL::BaseComponent.build(name: "cbc:BuildingNumber", value: @building_number),
    ZATCA::UBL::BaseComponent.build(name: "cbc:PlotIdentification", value: @plot_identification),
    ZATCA::UBL::BaseComponent.build(name: "cbc:CitySubdivisionName", value: @city_subdivision_name),
    ZATCA::UBL::BaseComponent.build(name: "cbc:CityName", value: @city_name),
    ZATCA::UBL::BaseComponent.build(name: "cbc:PostalZone", value: @postal_zone),
    ZATCA::UBL::BaseComponent.build(name: "cbc:CountrySubentity", value: @country_subentity),
    ZATCA::UBL::BaseComponent.build(name: "cac:Country", elements: [
      ZATCA::UBL::BaseComponent.build(name: "cbc:IdentificationCode", value: @country_identification_code)
    ])
  ]
end

#nameObject



40
41
42
# File 'lib/zatca/ubl/common_aggregate_components/postal_address.rb', line 40

def name
  "cac:PostalAddress"
end