Class: Lita::GoogleAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/google_account.rb

Overview

A GSuite account

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, alternate_email:, primary_domain:, created_at:, language:, phone_number:, address_line1: nil, address_line2: nil, address_line3: nil, contact_name: nil, country_code: nil, organization_name: nil, postal_code: nil, region: nil) ⇒ GoogleAccount



27
28
29
30
31
32
33
34
# File 'lib/lita/google_account.rb', line 27

def initialize(id:, alternate_email:, primary_domain:, created_at:, language:, phone_number:, address_line1: nil, address_line2: nil, address_line3: nil, contact_name: nil, country_code: nil, organization_name: nil, postal_code: nil, region: nil)
  @id, @alternate_email, @created_at = id, alternate_email, created_at
  @primary_domain = primary_domain
  @language, @phone_number = language, phone_number
  @address_line1, @address_line2, @address_line3 = address_line1, address_line2, address_line3
  @contact_name, @country_code, @organization_name = contact_name, country_code, organization_name
  @postal_code, @region = postal_code, region
end

Instance Attribute Details

#address_line1Object (readonly)

Returns the value of attribute address_line1.



6
7
8
# File 'lib/lita/google_account.rb', line 6

def address_line1
  @address_line1
end

#address_line2Object (readonly)

Returns the value of attribute address_line2.



6
7
8
# File 'lib/lita/google_account.rb', line 6

def address_line2
  @address_line2
end

#address_line3Object (readonly)

Returns the value of attribute address_line3.



6
7
8
# File 'lib/lita/google_account.rb', line 6

def address_line3
  @address_line3
end

#alternate_emailObject (readonly)

Returns the value of attribute alternate_email.



4
5
6
# File 'lib/lita/google_account.rb', line 4

def alternate_email
  @alternate_email
end

#contact_nameObject (readonly)

Returns the value of attribute contact_name.



7
8
9
# File 'lib/lita/google_account.rb', line 7

def contact_name
  @contact_name
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



7
8
9
# File 'lib/lita/google_account.rb', line 7

def country_code
  @country_code
end

#created_atObject (readonly)

Returns the value of attribute created_at.



4
5
6
# File 'lib/lita/google_account.rb', line 4

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/lita/google_account.rb', line 4

def id
  @id
end

#languageObject (readonly)

Returns the value of attribute language.



4
5
6
# File 'lib/lita/google_account.rb', line 4

def language
  @language
end

#organization_nameObject (readonly)

Returns the value of attribute organization_name.



7
8
9
# File 'lib/lita/google_account.rb', line 7

def organization_name
  @organization_name
end

#phone_numberObject (readonly)

Returns the value of attribute phone_number.



4
5
6
# File 'lib/lita/google_account.rb', line 4

def phone_number
  @phone_number
end

#postal_codeObject (readonly)

Returns the value of attribute postal_code.



7
8
9
# File 'lib/lita/google_account.rb', line 7

def postal_code
  @postal_code
end

#primary_domainObject (readonly)

Returns the value of attribute primary_domain.



5
6
7
# File 'lib/lita/google_account.rb', line 5

def primary_domain
  @primary_domain
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/lita/google_account.rb', line 7

def region
  @region
end

Class Method Details

.from_api(account) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lita/google_account.rb', line 9

def self.from_api()
  GoogleAccount.new(
    id: .id,
    alternate_email: .alternate_email,
    created_at: .customer_creation_time,
    primary_domain: .customer_domain,
    language: .language,
    phone_number: .phone_number,
    address_line1: .postal_address.address_line1,
    address_line2: .postal_address.address_line2,
    address_line3: .postal_address.address_line3,
    contact_name: .postal_address.contact_name,
    country_code: .postal_address.country_code,
    postal_code: .postal_address.postal_code,
    region: .postal_address.region
  )
end

Instance Method Details

#==(other) ⇒ Object



36
37
38
# File 'lib/lita/google_account.rb', line 36

def ==(other)
  @id == other.id
end

#addressObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/lita/google_account.rb', line 40

def address
  [
    address_line1,
    address_line2,
    address_line3,
    region,
    postal_code,
    country_code
  ].reject(&:nil?).join(", ")
end

#to_sObject



51
52
53
# File 'lib/lita/google_account.rb', line 51

def to_s
  "Account #{@id}"
end