Class: PaypalServerSdk::SimplePostalAddressCoarseGrained

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

Overview

A simple postal address with coarse-grained fields. Do not use for an international address. Use for backward compatibility only. Does not contain phone.

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:, city:, country_code:, line2: SKIP, state: SKIP, postal_code: SKIP) ⇒ SimplePostalAddressCoarseGrained

Returns a new instance of SimplePostalAddressCoarseGrained.



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

def initialize(line1:, city:, country_code:, line2: SKIP, state: SKIP,
               postal_code: SKIP)
  @line1 = line1
  @line2 = line2 unless line2 == SKIP
  @city = city
  @state = state unless state == SKIP
  @country_code = country_code
  @postal_code = postal_code unless postal_code == SKIP
end

Instance Attribute Details

#cityString

The city name.

Returns:

  • (String)


24
25
26
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 24

def city
  @city
end

#country_codeString

The [two-character ISO 3166-1 code](/docs/integration/direct/rest/country-codes/) that identifies the country or region. Note: 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.

Returns:

  • (String)


50
51
52
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 50

def country_code
  @country_code
end

#line1String

The first line of the address. For example, number or street.

Returns:

  • (String)


16
17
18
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 16

def line1
  @line1
end

#line2String

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

Returns:

  • (String)


20
21
22
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 20

def line2
  @line2
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)


56
57
58
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 56

def postal_code
  @postal_code
end

#stateString

The [code](/docs/api/reference/state-codes/) for a US state or the equivalent for other countries. Required for transactions if the address is in one of these countries: [Argentina](/docs/api/reference/state-codes/#argentina), [Brazil](/docs/api/reference/state-codes/#brazil), [Canada](/docs/api/reference/state-codes/#canada), [China](/docs/api/reference/state-codes/#china), [India](/docs/api/reference/state-codes/#india), [Italy](/docs/api/reference/state-codes/#italy), [Japan](/docs/api/reference/state-codes/#japan), [Mexico](/docs/api/reference/state-codes/#mexico), [Thailand](/docs/api/reference/state-codes/#thailand), or [United States](/docs/api/reference/state-codes/#usa). Maximum length is 40 single-byte characters.

Returns:

  • (String)


41
42
43
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 41

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  line1 = hash.key?('line1') ? hash['line1'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  line2 = hash.key?('line2') ? hash['line2'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : SKIP

  # Create object from extracted values.

  SimplePostalAddressCoarseGrained.new(line1: line1,
                                       city: city,
                                       country_code: country_code,
                                       line2: line2,
                                       state: state,
                                       postal_code: postal_code)
end

.namesObject

A mapping from model property names to API property names.



59
60
61
62
63
64
65
66
67
68
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 59

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['line1'] = 'line1'
  @_hash['line2'] = 'line2'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['country_code'] = 'country_code'
  @_hash['postal_code'] = 'postal_code'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



71
72
73
74
75
76
77
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 71

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 123

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

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
# File 'lib/paypal_server_sdk/models/simple_postal_address_coarse_grained.rb', line 116

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