Class: Workarea::GlobalE::AddressDetails

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/address_details.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, address) ⇒ AddressDetails

Returns a new instance of AddressDetails.



6
7
8
9
# File 'app/services/workarea/global_e/address_details.rb', line 6

def initialize(user, address)
  @user = user
  @address = address
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



4
5
6
# File 'app/services/workarea/global_e/address_details.rb', line 4

def address
  @address
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'app/services/workarea/global_e/address_details.rb', line 4

def user
  @user
end

Instance Method Details

#address1String

Address line 1

Returns:

  • (String)


125
126
127
# File 'app/services/workarea/global_e/address_details.rb', line 125

def address1
  address.street
end

#address2String

Address line 2

Returns:

  • (String)


133
134
135
# File 'app/services/workarea/global_e/address_details.rb', line 133

def address2
  address.street_2
end

#address_book_idString

Id of the current address from within the address book

Returns:

  • (String)


213
214
215
# File 'app/services/workarea/global_e/address_details.rb', line 213

def address_book_id
  address.id.to_s
end

#as_json(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/workarea/global_e/address_details.rb', line 11

def as_json(*args)
  {
    UserIdNumber: user_id_number,
    UserIdNumberType: user_id_number_type,
    FirstName: first_name,
    LastName: last_name,
    MiddleName: middle_name,
    Salutation: salutation,
    Phone1: phone1,
    Phone2: phone2,
    Fax: fax,
    Email: email,
    Company: company,
    Address1: address1,
    Address2: address2,
    City: city,
    StateOrProvice: state_or_province,
    StateCode: state_code,
    Zip: zip,
    CountryCode: country_code,
    IsShipping: is_shipping,
    IsBilling: is_billing,
    IsDefaultShipping: is_default_shipping,
    IsDefaultBilling: is_default_billing,
    AddressBookId: address_book_id
  }.compact
end

#cityString

City name

Returns:

  • (String)


141
142
143
# File 'app/services/workarea/global_e/address_details.rb', line 141

def city
  address.city
end

#companyObject

Company name

@return [String]


117
118
119
# File 'app/services/workarea/global_e/address_details.rb', line 117

def company
  address.company
end

#country_codeString

2-char ISO country code

Returns:

  • (String)


173
174
175
# File 'app/services/workarea/global_e/address_details.rb', line 173

def country_code
  address.country.alpha2
end

#emailString

E-mail address

Returns:

  • (String)


109
110
111
# File 'app/services/workarea/global_e/address_details.rb', line 109

def email
  user.email
end

#faxString

Fax

Returns:

  • (String)


102
103
# File 'app/services/workarea/global_e/address_details.rb', line 102

def fax
end

#first_nameString

First name

Returns:

  • (String)


57
58
59
# File 'app/services/workarea/global_e/address_details.rb', line 57

def first_name
  address.first_name
end

#is_billingBoolean

Indicates that the current address can be used as a billing address

Returns:

  • (Boolean)


189
190
191
# File 'app/services/workarea/global_e/address_details.rb', line 189

def is_billing
  address.last_billed_at.present?
end

#is_default_billingBoolean

Indicates that the current address is the default billing address

Returns:

  • (Boolean)


205
206
207
# File 'app/services/workarea/global_e/address_details.rb', line 205

def is_default_billing
  user.default_billing_address == address
end

#is_default_shippingBoolean

Indicates that the current address is the default shipping address

Returns:

  • (Boolean)


197
198
199
# File 'app/services/workarea/global_e/address_details.rb', line 197

def is_default_shipping
  user.default_shipping_address == address
end

#is_shippingBoolean

Indicates that the current address can be used as a shipping address

Returns:

  • (Boolean)


181
182
183
# File 'app/services/workarea/global_e/address_details.rb', line 181

def is_shipping
  address.last_shipped_at.present?
end

#last_nameString

Last name

Returns:

  • (String)


65
66
67
# File 'app/services/workarea/global_e/address_details.rb', line 65

def last_name
  address.last_name
end

#middle_nameString

Middle name

Returns:

  • (String)

    String



73
74
# File 'app/services/workarea/global_e/address_details.rb', line 73

def middle_name
end

#phone1String

Phone 1

Returns:

  • (String)


87
88
89
# File 'app/services/workarea/global_e/address_details.rb', line 87

def phone1
  address.phone_number
end

#phone2String

Phone 2

Returns:

  • (String)


95
96
# File 'app/services/workarea/global_e/address_details.rb', line 95

def phone2
end

#salutationString

Salutation or title (e.g. Dr., Mr., etc.)

Returns:

  • (String)


80
81
# File 'app/services/workarea/global_e/address_details.rb', line 80

def salutation
end

#state_codeString

State or province ISO code such as AZ for Arizona (if applicable)

Returns:

  • (String)


157
158
159
# File 'app/services/workarea/global_e/address_details.rb', line 157

def state_code
  address.region
end

#state_or_provinceString

State or province name

Returns:

  • (String)


149
150
151
# File 'app/services/workarea/global_e/address_details.rb', line 149

def state_or_province
  address.country.subdivisions[address.region].name rescue nil
end

#user_id_numberString

User’s personal ID document number

Returns:

  • (String)


43
44
# File 'app/services/workarea/global_e/address_details.rb', line 43

def user_id_number
end

#user_id_number_typeObject

User’s personal ID document type (e.g. Passport, ID card, etc.)

UserIdNumberType



50
51
# File 'app/services/workarea/global_e/address_details.rb', line 50

def user_id_number_type
end

#zipString

Zip or postal code

Returns:

  • (String)


165
166
167
# File 'app/services/workarea/global_e/address_details.rb', line 165

def zip
  address.postal_code
end