Class: Outreach::User

Inherits:
Object
  • Object
show all
Extended by:
Model
Defined in:
lib/outreach-ruby/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ User

Returns a new instance of User.



9
10
11
12
13
14
15
# File 'lib/outreach-ruby/user.rb', line 9

def initialize(attrs)
  @id = attrs['id']
  @first_name = attrs['first_name']
  @last_name = attrs['last_name']
  @email = attrs['email']
  @response = attrs['response']
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/outreach-ruby/user.rb', line 7

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



7
8
9
# File 'lib/outreach-ruby/user.rb', line 7

def first_name
  @first_name
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/outreach-ruby/user.rb', line 7

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name.



7
8
9
# File 'lib/outreach-ruby/user.rb', line 7

def last_name
  @last_name
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/outreach-ruby/user.rb', line 7

def response
  @response
end

Class Method Details

.build_from_attributes_hash(data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/outreach-ruby/user.rb', line 17

def self.build_from_attributes_hash(data)
  result = {}
  result['id'] = data['id']
  result['first_name'] = nested_hash_value(
    data,
    %w[attributes firstName]
  )
  result['last_name'] = nested_hash_value(
    data,
    %w[attributes lastName]
  )
  result['email'] = nested_hash_value(
    data,
    %w[attributes email]
  )
  result['response'] = data
  new(result)
end