Class: Outreach::Prospect

Inherits:
Object
  • Object
show all
Defined in:
lib/outreach/prospect.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Prospect

Returns a new instance of Prospect.



5
6
7
8
9
10
11
12
# File 'lib/outreach/prospect.rb', line 5

def initialize(attrs)
  @id = attrs['id']
  @first_name = attrs['first_name']
  @last_name = attrs['last_name']
  @company = attrs['company']
  @contact = attrs['contact']
  @tags = attrs['tags']
end

Instance Attribute Details

#companyObject

Returns the value of attribute company.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def company
  @company
end

#contactObject

Returns the value of attribute contact.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def contact
  @contact
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def first_name
  @first_name
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def last_name
  @last_name
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/outreach/prospect.rb', line 3

def tags
  @tags
end

Class Method Details

.build_from_attributes_hash(attrs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/outreach/prospect.rb', line 14

def self.build_from_attributes_hash(attrs)
  result = {}
  result['first_name'] = nested_hash_value(attrs, ['attributes', 'personal',
                                                  'name', 'first'])
  result['last_name'] = nested_hash_value(attrs, ['attributes', 'personal',
                                                 'name', 'last'])
  result['company'] = to_ostruct(attrs['attributes'].fetch('company', {}))
  result['contact'] = to_ostruct(attrs['attributes'].fetch('contact', {}))
  result['tags'] = nested_hash_value(attrs, ['attributes', 'metadata',
                                            'tags'])
  result['id'] = attrs['id']
  new(result)
end