Class: Mass::Enrichment

Inherits:
BlackStack::Base
  • Object
show all
Defined in:
lib/base-line/enrichment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ Enrichment

Returns a new instance of Enrichment.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/base-line/enrichment.rb', line 9

def initialize(h)
    super(h)
    self.type = Mass::EnrichmentType.new(h['enrichment_type_desc']) if h['enrichment_type_desc']
    self.profile = Mass::Profile.new(h['profile']).child_class_instance if h['profile']
    self.lead = Mass::Lead.new(h['lead']) if h['lead']
    self.company = Mass::Company.new(h['company']) if h['company']
    self.profile_type = Mass::ProfileType.page(
        id_account: h['id_account'],
        page: 1,
        limit: 1,
        filters: {
            name: h['profile_type']
        }
    ).first.child_class_instance if h['profile_type']
end

Instance Attribute Details

#companyObject

Returns the value of attribute company.



3
4
5
# File 'lib/base-line/enrichment.rb', line 3

def company
  @company
end

#leadObject

Returns the value of attribute lead.



3
4
5
# File 'lib/base-line/enrichment.rb', line 3

def lead
  @lead
end

#profileObject

Returns the value of attribute profile.



3
4
5
# File 'lib/base-line/enrichment.rb', line 3

def profile
  @profile
end

#profile_typeObject

Returns the value of attribute profile_type.



3
4
5
# File 'lib/base-line/enrichment.rb', line 3

def profile_type
  @profile_type
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/base-line/enrichment.rb', line 3

def type
  @type
end

Class Method Details

.object_nameObject



5
6
7
# File 'lib/base-line/enrichment.rb', line 5

def self.object_name
    'enrichment'
end

Instance Method Details

#child_class_instanceObject

crate an instance of the profile type using the class defined in the ‘desc` attribute. override the base method



34
35
36
37
38
39
40
# File 'lib/base-line/enrichment.rb', line 34

def child_class_instance
    enrichment_type = self.desc['enrichment_type']
    key = self.class_name_from_enrichment_type
    raise "Source code of enrichment type #{enrichment_type} not found. Create a class #{key} in the folder `/lib` of your mass-sdk." unless Kernel.const_defined?(key)
    ret = Kernel.const_get(key).new(self.desc)
    return ret
end

#class_name_from_enrichment_typeObject

convert the enrichment_type into the ruby class to create an instance. example: Apollo –> Mass::ApolloAPI



27
28
29
30
# File 'lib/base-line/enrichment.rb', line 27

def class_name_from_enrichment_type
    enrichment_type = self.desc['enrichment_type']
    "Mass::#{enrichment_type}" 
end

#do(logger: nil) ⇒ Object

Update the lead or company with new information.



44
45
46
47
48
# File 'lib/base-line/enrichment.rb', line 44

def do(
    logger:nil
)
    # TODO: Code Me!
end