Class: Braintree::Address

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/address.rb,
lib/braintree/address/country_names.rb

Constant Summary collapse

CountryNames =
[
["Afghanistan", "AF", "AFG", "004"],
["Åland", "AX", "ALA", "248"],
["Albania", "AL", "ALB", "008"],
["Algeria", "DZ", "DZA", "012"],
["American Samoa", "AS", "ASM", "016"],
["Andorra", "AD", "AND", "020"],
["Angola", "AO", "AGO", "024"],
["Anguilla", "AI", "AIA", "660"],
["Antarctica", "AQ", "ATA", "010"],
["Antigua and Barbuda", "AG", "ATG", "028"],
["Argentina", "AR", "ARG", "032"],
["Armenia", "AM", "ARM", "051"],
["Aruba", "AW", "ABW", "533"],
["Australia", "AU", "AUS", "036"],
["Austria", "AT", "AUT", "040"],
["Azerbaijan", "AZ", "AZE", "031"],
["Bahamas", "BS", "BHS", "044"],
["Bahrain", "BH", "BHR", "048"],
["Bangladesh", "BD", "BGD", "050"],
["Barbados", "BB", "BRB", "052"],
["Belarus", "BY", "BLR", "112"],
["Belgium", "BE", "BEL", "056"],
["Belize", "BZ", "BLZ", "084"],
["Benin", "BJ", "BEN", "204"],
["Bermuda", "BM", "BMU", "060"],
["Bhutan", "BT", "BTN", "064"],
["Bolivia", "BO", "BOL", "068"],
["Bonaire, Sint Eustatius and Saba", "BQ", "BES", "535"],
["Bosnia and Herzegovina", "BA", "BIH", "070"],
["Botswana", "BW", "BWA", "072"],
["Bouvet Island", "BV", "BVT", "074"],
["Brazil", "BR", "BRA", "076"],
["British Indian Ocean Territory", "IO", "IOT", "086"],
["Brunei Darussalam", "BN", "BRN", "096"],
["Bulgaria", "BG", "BGR", "100"],
["Burkina Faso", "BF", "BFA", "854"],
["Burundi", "BI", "BDI", "108"],
["Cambodia", "KH", "KHM", "116"],
["Cameroon", "CM", "CMR", "120"],
["Canada", "CA", "CAN", "124"],
["Cape Verde", "CV", "CPV", "132"],
["Cayman Islands", "KY", "CYM", "136"],
["Central African Republic", "CF", "CAF", "140"],
["Chad", "TD", "TCD", "148"],
["Chile", "CL", "CHL", "152"],
["China", "CN", "CHN", "156"],
["Christmas Island", "CX", "CXR", "162"],
["Cocos (Keeling) Islands", "CC", "CCK", "166"],
["Colombia", "CO", "COL", "170"],
["Comoros", "KM", "COM", "174"],
["Congo (Brazzaville)", "CG", "COG", "178"],
["Congo (Kinshasa)", "CD", "COD", "180"],
["Cook Islands", "CK", "COK", "184"],
["Costa Rica", "CR", "CRI", "188"],
["Côte d'Ivoire", "CI", "CIV", "384"],
["Croatia", "HR", "HRV", "191"],
["Cuba", "CU", "CUB", "192"],
["Curaçao", "CW", "CUW", "531"],
["Cyprus", "CY", "CYP", "196"],
["Czech Republic", "CZ", "CZE", "203"],
["Denmark", "DK", "DNK", "208"],
["Djibouti", "DJ", "DJI", "262"],
["Dominica", "DM", "DMA", "212"],
["Dominican Republic", "DO", "DOM", "214"],
["Ecuador", "EC", "ECU", "218"],
["Egypt", "EG", "EGY", "818"],
["El Salvador", "SV", "SLV", "222"],
["Equatorial Guinea", "GQ", "GNQ", "226"],
["Eritrea", "ER", "ERI", "232"],
["Estonia", "EE", "EST", "233"],
["Ethiopia", "ET", "ETH", "231"],
["Falkland Islands", "FK", "FLK", "238"],
["Faroe Islands", "FO", "FRO", "234"],
["Fiji", "FJ", "FJI", "242"],
["Finland", "FI", "FIN", "246"],
["France", "FR", "FRA", "250"],
["French Guiana", "GF", "GUF", "254"],
["French Polynesia", "PF", "PYF", "258"],
["French Southern Lands", "TF", "ATF", "260"],
["Gabon", "GA", "GAB", "266"],
["Gambia", "GM", "GMB", "270"],
["Georgia", "GE", "GEO", "268"],
["Germany", "DE", "DEU", "276"],
["Ghana", "GH", "GHA", "288"],
["Gibraltar", "GI", "GIB", "292"],
["Greece", "GR", "GRC", "300"],
["Greenland", "GL", "GRL", "304"],
["Grenada", "GD", "GRD", "308"],
["Guadeloupe", "GP", "GLP", "312"],
["Guam", "GU", "GUM", "316"],
["Guatemala", "GT", "GTM", "320"],
["Guernsey", "GG", "GGY", "831"],
["Guinea", "GN", "GIN", "324"],
["Guinea-Bissau", "GW", "GNB", "624"],
["Guyana", "GY", "GUY", "328"],
["Haiti", "HT", "HTI", "332"],
["Heard and McDonald Islands", "HM", "HMD", "334"],
["Honduras", "HN", "HND", "340"],
["Hong Kong", "HK", "HKG", "344"],
["Hungary", "HU", "HUN", "348"],
["Iceland", "IS", "ISL", "352"],
["India", "IN", "IND", "356"],
["Indonesia", "ID", "IDN", "360"],
["Iran", "IR", "IRN", "364"],
["Iraq", "IQ", "IRQ", "368"],
["Ireland", "IE", "IRL", "372"],
["Isle of Man", "IM", "IMN", "833"],
["Israel", "IL", "ISR", "376"],
["Italy", "IT", "ITA", "380"],
["Jamaica", "JM", "JAM", "388"],
["Japan", "JP", "JPN", "392"],
["Jersey", "JE", "JEY", "832"],
["Jordan", "JO", "JOR", "400"],
["Kazakhstan", "KZ", "KAZ", "398"],
["Kenya", "KE", "KEN", "404"],
["Kiribati", "KI", "KIR", "296"],
["Korea, North", "KP", "PRK", "408"],
["Korea, South", "KR", "KOR", "410"],
["Kuwait", "KW", "KWT", "414"],
["Kyrgyzstan", "KG", "KGZ", "417"],
["Laos", "LA", "LAO", "418"],
["Latvia", "LV", "LVA", "428"],
["Lebanon", "LB", "LBN", "422"],
["Lesotho", "LS", "LSO", "426"],
["Liberia", "LR", "LBR", "430"],
["Libya", "LY", "LBY", "434"],
["Liechtenstein", "LI", "LIE", "438"],
["Lithuania", "LT", "LTU", "440"],
["Luxembourg", "LU", "LUX", "442"],
["Macau", "MO", "MAC", "446"],
["Macedonia", "MK", "MKD", "807"],
["Madagascar", "MG", "MDG", "450"],
["Malawi", "MW", "MWI", "454"],
["Malaysia", "MY", "MYS", "458"],
["Maldives", "MV", "MDV", "462"],
["Mali", "ML", "MLI", "466"],
["Malta", "MT", "MLT", "470"],
["Marshall Islands", "MH", "MHL", "584"],
["Martinique", "MQ", "MTQ", "474"],
["Mauritania", "MR", "MRT", "478"],
["Mauritius", "MU", "MUS", "480"],
["Mayotte", "YT", "MYT", "175"],
["Mexico", "MX", "MEX", "484"],
["Micronesia", "FM", "FSM", "583"],
["Moldova", "MD", "MDA", "498"],
["Monaco", "MC", "MCO", "492"],
["Mongolia", "MN", "MNG", "496"],
["Montenegro", "ME", "MNE", "499"],
["Montserrat", "MS", "MSR", "500"],
["Morocco", "MA", "MAR", "504"],
["Mozambique", "MZ", "MOZ", "508"],
["Myanmar", "MM", "MMR", "104"],
["Namibia", "NA", "NAM", "516"],
["Nauru", "NR", "NRU", "520"],
["Nepal", "NP", "NPL", "524"],
["Netherlands", "NL", "NLD", "528"],
["New Caledonia", "NC", "NCL", "540"],
["New Zealand", "NZ", "NZL", "554"],
["Nicaragua", "NI", "NIC", "558"],
["Niger", "NE", "NER", "562"],
["Nigeria", "NG", "NGA", "566"],
["Niue", "NU", "NIU", "570"],
["Norfolk Island", "NF", "NFK", "574"],
["Northern Mariana Islands", "MP", "MNP", "580"],
["Norway", "NO", "NOR", "578"],
["Oman", "OM", "OMN", "512"],
["Pakistan", "PK", "PAK", "586"],
["Palau", "PW", "PLW", "585"],
["Palestine", "PS", "PSE", "275"],
["Panama", "PA", "PAN", "591"],
["Papua New Guinea", "PG", "PNG", "598"],
["Paraguay", "PY", "PRY", "600"],
["Peru", "PE", "PER", "604"],
["Philippines", "PH", "PHL", "608"],
["Pitcairn", "PN", "PCN", "612"],
["Poland", "PL", "POL", "616"],
["Portugal", "PT", "PRT", "620"],
["Puerto Rico", "PR", "PRI", "630"],
["Qatar", "QA", "QAT", "634"],
["Reunion", "RE", "REU", "638"],
["Romania", "RO", "ROU", "642"],
["Russian Federation", "RU", "RUS", "643"],
["Rwanda", "RW", "RWA", "646"],
["Saint Barthélemy", "BL", "BLM", "652"],
["Saint Helena", "SH", "SHN", "654"],
["Saint Kitts and Nevis", "KN", "KNA", "659"],
["Saint Lucia", "LC", "LCA", "662"],
["Saint Martin (French part)", "MF", "MAF", "663"],
["Saint Pierre and Miquelon", "PM", "SPM", "666"],
["Saint Vincent and the Grenadines", "VC", "VCT", "670"],
["Samoa", "WS", "WSM", "882"],
["San Marino", "SM", "SMR", "674"],
["Sao Tome and Principe", "ST", "STP", "678"],
["Saudi Arabia", "SA", "SAU", "682"],
["Senegal", "SN", "SEN", "686"],
["Serbia", "RS", "SRB", "688"],
["Seychelles", "SC", "SYC", "690"],
["Sierra Leone", "SL", "SLE", "694"],
["Singapore", "SG", "SGP", "702"],
["Sint Maarten (Dutch part)", "SX", "SXM", "534"],
["Slovakia", "SK", "SVK", "703"],
["Slovenia", "SI", "SVN", "705"],
["Solomon Islands", "SB", "SLB", "090"],
["Somalia", "SO", "SOM", "706"],
["South Africa", "ZA", "ZAF", "710"],
["South Georgia and South Sandwich Islands", "GS", "SGS", "239"],
["South Sudan", "SS", "SSD", "728"],
["Spain", "ES", "ESP", "724"],
["Sri Lanka", "LK", "LKA", "144"],
["Sudan", "SD", "SDN", "736"],
["Suriname", "SR", "SUR", "740"],
["Svalbard and Jan Mayen Islands", "SJ", "SJM", "744"],
["Swaziland", "SZ", "SWZ", "748"],
["Sweden", "SE", "SWE", "752"],
["Switzerland", "CH", "CHE", "756"],
["Syria", "SY", "SYR", "760"],
["Taiwan", "TW", "TWN", "158"],
["Tajikistan", "TJ", "TJK", "762"],
["Tanzania", "TZ", "TZA", "834"],
["Thailand", "TH", "THA", "764"],
["Timor-Leste", "TL", "TLS", "626"],
["Togo", "TG", "TGO", "768"],
["Tokelau", "TK", "TKL", "772"],
["Tonga", "TO", "TON", "776"],
["Trinidad and Tobago", "TT", "TTO", "780"],
["Tunisia", "TN", "TUN", "788"],
["Turkey", "TR", "TUR", "792"],
["Turkmenistan", "TM", "TKM", "795"],
["Turks and Caicos Islands", "TC", "TCA", "796"],
["Tuvalu", "TV", "TUV", "798"],
["Uganda", "UG", "UGA", "800"],
["Ukraine", "UA", "UKR", "804"],
["United Arab Emirates", "AE", "ARE", "784"],
["United Kingdom", "GB", "GBR", "826"],
["United States Minor Outlying Islands", "UM", "UMI", "581"],
["United States of America", "US", "USA", "840"],
["Uruguay", "UY", "URY", "858"],
["Uzbekistan", "UZ", "UZB", "860"],
["Vanuatu", "VU", "VUT", "548"],
["Vatican City", "VA", "VAT", "336"],
["Venezuela", "VE", "VEN", "862"],
["Vietnam", "VN", "VNM", "704"],
["Virgin Islands, British", "VG", "VGB", "092"],
["Virgin Islands, U.S.", "VI", "VIR", "850"],
["Wallis and Futuna Islands", "WF", "WLF", "876"],
["Western Sahara", "EH", "ESH", "732"],
["Yemen", "YE", "YEM", "887"],
["Zambia", "ZM", "ZMB", "894"],
["Zimbabwe", "ZW", "ZWE", "716"]]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(gateway, attributes) ⇒ Address

Returns a new instance of Address.



48
49
50
51
# File 'lib/braintree/address.rb', line 48

def initialize(gateway, attributes)
  @gateway = gateway
  set_instance_variables_from_hash(attributes)
end

Instance Attribute Details

#companyObject (readonly)

Returns the value of attribute company.



5
6
7
# File 'lib/braintree/address.rb', line 5

def company
  @company
end

#country_code_alpha2Object (readonly)

Returns the value of attribute country_code_alpha2.



6
7
8
# File 'lib/braintree/address.rb', line 6

def country_code_alpha2
  @country_code_alpha2
end

#country_code_alpha3Object (readonly)

Returns the value of attribute country_code_alpha3.



7
8
9
# File 'lib/braintree/address.rb', line 7

def country_code_alpha3
  @country_code_alpha3
end

#country_code_numericObject (readonly)

Returns the value of attribute country_code_numeric.



8
9
10
# File 'lib/braintree/address.rb', line 8

def country_code_numeric
  @country_code_numeric
end

#country_nameObject (readonly)

Returns the value of attribute country_name.



9
10
11
# File 'lib/braintree/address.rb', line 9

def country_name
  @country_name
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/braintree/address.rb', line 10

def created_at
  @created_at
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



11
12
13
# File 'lib/braintree/address.rb', line 11

def customer_id
  @customer_id
end

#extended_addressObject (readonly)

Returns the value of attribute extended_address.



12
13
14
# File 'lib/braintree/address.rb', line 12

def extended_address
  @extended_address
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



13
14
15
# File 'lib/braintree/address.rb', line 13

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/braintree/address.rb', line 14

def id
  @id
end

#international_phoneObject (readonly)

Returns the value of attribute international_phone.



15
16
17
# File 'lib/braintree/address.rb', line 15

def international_phone
  @international_phone
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



16
17
18
# File 'lib/braintree/address.rb', line 16

def last_name
  @last_name
end

#localityObject (readonly)

Returns the value of attribute locality.



17
18
19
# File 'lib/braintree/address.rb', line 17

def locality
  @locality
end

#phone_numberObject (readonly)

Returns the value of attribute phone_number.



18
19
20
# File 'lib/braintree/address.rb', line 18

def phone_number
  @phone_number
end

#postal_codeObject (readonly)

Returns the value of attribute postal_code.



19
20
21
# File 'lib/braintree/address.rb', line 19

def postal_code
  @postal_code
end

#regionObject (readonly)

Returns the value of attribute region.



20
21
22
# File 'lib/braintree/address.rb', line 20

def region
  @region
end

#street_addressObject (readonly)

Returns the value of attribute street_address.



21
22
23
# File 'lib/braintree/address.rb', line 21

def street_address
  @street_address
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



22
23
24
# File 'lib/braintree/address.rb', line 22

def updated_at
  @updated_at
end

Class Method Details

._new(*args) ⇒ Object



62
63
64
# File 'lib/braintree/address.rb', line 62

def self._new(*args)
  self.new(*args)
end

.create(*args) ⇒ Object



24
25
26
# File 'lib/braintree/address.rb', line 24

def self.create(*args)
  Configuration.gateway.address.create(*args)
end

.create!(*args) ⇒ Object



28
29
30
# File 'lib/braintree/address.rb', line 28

def self.create!(*args)
  Configuration.gateway.address.create!(*args)
end

.delete(*args) ⇒ Object



32
33
34
# File 'lib/braintree/address.rb', line 32

def self.delete(*args)
  Configuration.gateway.address.delete(*args)
end

.find(*args) ⇒ Object



36
37
38
# File 'lib/braintree/address.rb', line 36

def self.find(*args)
  Configuration.gateway.address.find(*args)
end

.update(*args) ⇒ Object



40
41
42
# File 'lib/braintree/address.rb', line 40

def self.update(*args)
  Configuration.gateway.address.update(*args)
end

.update!(*args) ⇒ Object



44
45
46
# File 'lib/braintree/address.rb', line 44

def self.update!(*args)
  Configuration.gateway.address.update!(*args)
end

Instance Method Details

#==(other) ⇒ Object



53
54
55
56
# File 'lib/braintree/address.rb', line 53

def ==(other)
  return false unless other.is_a?(Address)
  id == other.id && customer_id == other.customer_id
end