Class: PaypalServerSdk::PortablePostalAddressMediumGrained

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb

Overview

The portable international postal address. Maps to [AddressValidationMetadata](github.com/googlei18n/libaddressinput/wi ki/AddressValidationMetadata) and HTML 5.1 [Autofilling form controls: the autocomplete attribute](www.w3.org/TR/html51/sec-forms.html#autofilling-form-cont rols-the-autocomplete-attribute).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(country_code:, address_line_1: SKIP, address_line_2: SKIP, admin_area_2: SKIP, admin_area_1: SKIP, postal_code: SKIP) ⇒ PortablePostalAddressMediumGrained

Returns a new instance of PortablePostalAddressMediumGrained.



83
84
85
86
87
88
89
90
91
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 83

def initialize(country_code:, address_line_1: SKIP, address_line_2: SKIP,
               admin_area_2: SKIP, admin_area_1: SKIP, postal_code: SKIP)
  @address_line_1 = address_line_1 unless address_line_1 == SKIP
  @address_line_2 = address_line_2 unless address_line_2 == SKIP
  @admin_area_2 = admin_area_2 unless admin_area_2 == SKIP
  @admin_area_1 = admin_area_1 unless admin_area_1 == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @country_code = country_code
end

Instance Attribute Details

#address_line_1String

The first line of the address, such as number and street, for example, ‘173 Drury Lane`. Needed for data entry, and Compliance and Risk checks. This field needs to pass the full address.

Returns:

  • (String)


21
22
23
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 21

def address_line_1
  @address_line_1
end

#address_line_2String

The second line of the address, for example, a suite or apartment number.

Returns:

  • (String)


25
26
27
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 25

def address_line_2
  @address_line_2
end

#admin_area_1String

The highest-level sub-division in a country, which is usually a province, state, or ISO-3166-2 subdivision. This data is formatted for postal delivery, for example, ‘CA` and not `California`. Value, by country, is:<ul><li>UK. A county.</li><li>US. A state.</li><li>Canada. A province.</li><li>Japan. A prefecture.</li><li>Switzerland. A kanton.</li></ul>

Returns:

  • (String)


38
39
40
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 38

def admin_area_1
  @admin_area_1
end

#admin_area_2String

A city, town, or village. Smaller than ‘admin_area_level_1`.

Returns:

  • (String)


29
30
31
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 29

def admin_area_2
  @admin_area_2
end

#country_codeString

The [2-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is GB and not UK as used in the top-level domain names for that country. Use the ‘C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote>

Returns:

  • (String)


53
54
55
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 53

def country_code
  @country_code
end

#postal_codeString

The postal code, which is the ZIP code or equivalent. Typically required for countries with a postal code or an equivalent. See [postal code](en.wikipedia.org/wiki/Postal_code).

Returns:

  • (String)


44
45
46
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 44

def postal_code
  @postal_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  address_line_1 =
    hash.key?('address_line_1') ? hash['address_line_1'] : SKIP
  address_line_2 =
    hash.key?('address_line_2') ? hash['address_line_2'] : SKIP
  admin_area_2 = hash.key?('admin_area_2') ? hash['admin_area_2'] : SKIP
  admin_area_1 = hash.key?('admin_area_1') ? hash['admin_area_1'] : SKIP
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : SKIP

  # Create object from extracted values.
  PortablePostalAddressMediumGrained.new(country_code: country_code,
                                         address_line_1: address_line_1,
                                         address_line_2: address_line_2,
                                         admin_area_2: admin_area_2,
                                         admin_area_1: admin_area_1,
                                         postal_code: postal_code)
end

.namesObject

A mapping from model property names to API property names.



56
57
58
59
60
61
62
63
64
65
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 56

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address_line_1'] = 'address_line_1'
  @_hash['address_line_2'] = 'address_line_2'
  @_hash['admin_area_2'] = 'admin_area_2'
  @_hash['admin_area_1'] = 'admin_area_1'
  @_hash['postal_code'] = 'postal_code'
  @_hash['country_code'] = 'country_code'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



68
69
70
71
72
73
74
75
76
# File 'lib/paypal_server_sdk/models/portable_postal_address_medium_grained.rb', line 68

def self.optionals
  %w[
    address_line_1
    address_line_2
    admin_area_2
    admin_area_1
    postal_code
  ]
end