Class: EmailHunter::Leads

Inherits:
Object
  • Object
show all
Defined in:
lib/email_hunter/leads.rb

Constant Summary collapse

API_URL =
'https://api.hunter.io/v2/leads'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, action: :list, lead_id: nil, data: nil, params: {}) ⇒ Leads

Returns a new instance of Leads.



13
14
15
16
17
18
19
# File 'lib/email_hunter/leads.rb', line 13

def initialize(key, action: :list, lead_id: nil, data: nil, params: {})
  @key = key
  @action = action
  @lead_id = lead_id
  @data = data
  @params = params
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



11
12
13
# File 'lib/email_hunter/leads.rb', line 11

def action
  @action
end

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/email_hunter/leads.rb', line 11

def data
  @data
end

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/email_hunter/leads.rb', line 11

def key
  @key
end

#lead_idObject (readonly)

Returns the value of attribute lead_id.



11
12
13
# File 'lib/email_hunter/leads.rb', line 11

def lead_id
  @lead_id
end

#paramsObject (readonly)

Returns the value of attribute params.



11
12
13
# File 'lib/email_hunter/leads.rb', line 11

def params
  @params
end

Instance Method Details

#huntObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/email_hunter/leads.rb', line 21

def hunt
  case action
  when :list
    list_leads
  when :create
    create_lead
  when :update
    update_lead
  when :delete
    delete_lead
  else
    raise ArgumentError, "Unknown action: #{action}"
  end
end