rd_insightly 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6909119a72da5bc6d0ca0dc5b9c20ec9d58fce2f
4
- data.tar.gz: 188e96d292d989d0ef973389c46e226f7d8e6d3d
3
+ metadata.gz: 46c593870e880109064f872ee1dd53a259edcd61
4
+ data.tar.gz: 35cde802b768b34258e564775dc8cd30011144a4
5
5
  SHA512:
6
- metadata.gz: 72b8938efd20c86d20dbc8d5625120a7fcad3bcea14bd0ef5d8628f9ceb3915e96d19f1b1acb27fe8cfa2d0e6c31e2a8138e6bd44efa0a1cb3d9cab6065f47f2
7
- data.tar.gz: 5222f2a1dc5674b9331ec5462c3386f2980e479bbd5b03ae544a26febbdbc49fc2792cdfcae99afa057fcc321f9ce315682de6709b210171550349beb4fb3dd5
6
+ metadata.gz: a444ea7843dd9e214ae1c37f7f3466c4282c51c9c16f7a9f8fdc8110e809499abc450de75bf53482dbddcf08aa26c0e1685504544c42dd226cf5aebb821c568f
7
+ data.tar.gz: c1168deb6dd98db648d75656b16356c24c41f303c6862c52279c6a072b98fb7b53533342209a90a4f793f3ecdb064050329311da2f0325ca5bab6693414b17f1
@@ -22,6 +22,12 @@ module RdInsightly
22
22
  lead
23
23
  end
24
24
 
25
+ def self.delete_lead(lead_id)
26
+ RestClient.delete("https://api.insight.ly/v2.1/leads/#{lead_id}", Authorization: authorization_string, accept: :json, content_type: :json)
27
+ rescue
28
+ raise LeadException, 'Lead não pode ser excluido!'
29
+ end
30
+
25
31
  def self.authorization_string
26
32
  "Basic #{Base64.encode64(RdInsightly.api_token)}"
27
33
  end
@@ -7,13 +7,21 @@ module RdInsightly
7
7
  JOB_TITLE_FIELD = 'TITLE'
8
8
  PHONE_FIELD = 'PHONE_NUMBER'
9
9
  WEBSITE_FIELD = 'WEBSITE_URL'
10
+ ID_FIELD = 'LEAD_ID'
11
+ FIELDS = [NAME_FIELD, EMAIL_FIELD, COMPANY_FIELD, JOB_TITLE_FIELD, PHONE_FIELD, WEBSITE_FIELD, ID_FIELD]
10
12
 
11
13
  def self.lead(lead_json)
12
- Lead.new lead_json[LAST_NAME_FIELD], name: lead_json[NAME_FIELD], email: lead_json[EMAIL_FIELD], company: lead_json[COMPANY_FIELD], job_title: lead_json[JOB_TITLE_FIELD], phone: lead_json[PHONE_FIELD], website: lead_json[WEBSITE_FIELD]
14
+ Lead.new lead_json[LAST_NAME_FIELD], name: lead_json[NAME_FIELD], email: lead_json[EMAIL_FIELD], company: lead_json[COMPANY_FIELD], job_title: lead_json[JOB_TITLE_FIELD], phone: lead_json[PHONE_FIELD], website: lead_json[WEBSITE_FIELD], id: lead_json[ID_FIELD]
13
15
  end
14
16
 
15
17
  def self.lead_to_hash(lead)
16
18
  lead_hash = {}
19
+ lead_hash = get_values_not_required(lead_hash, lead)
20
+ lead_hash.delete_if { |_key, value| value.nil? }
21
+ lead_hash
22
+ end
23
+
24
+ def self.get_values_not_required(lead_hash, lead)
17
25
  lead_hash[LAST_NAME_FIELD] = lead.last_name
18
26
  lead_hash[NAME_FIELD] = lead.name
19
27
  lead_hash[EMAIL_FIELD] = lead.email
@@ -21,6 +29,7 @@ module RdInsightly
21
29
  lead_hash[JOB_TITLE_FIELD] = lead.job_title
22
30
  lead_hash[PHONE_FIELD] = lead.phone
23
31
  lead_hash[WEBSITE_FIELD] = lead.website
32
+ lead_hash[ID_FIELD] = lead.id
24
33
  lead_hash
25
34
  end
26
35
  end
@@ -1,6 +1,6 @@
1
1
  module RdInsightly
2
2
  class Lead
3
- attr_reader :name, :last_name, :email, :company, :job_title, :phone, :website
3
+ attr_reader :name, :last_name, :email, :company, :job_title, :phone, :website, :id
4
4
 
5
5
  def initialize(last_name = nil, attributes = {})
6
6
  @last_name = last_name
@@ -10,6 +10,7 @@ module RdInsightly
10
10
  @job_title = attributes.fetch(:job_title, nil)
11
11
  @phone = attributes.fetch(:phone, nil)
12
12
  @website = attributes.fetch(:website, nil)
13
+ @id = attributes.fetch(:id, nil)
13
14
  end
14
15
 
15
16
  def self.create(last_name = nil, attributes = {})
@@ -28,5 +29,10 @@ module RdInsightly
28
29
  end
29
30
  leads_result
30
31
  end
32
+
33
+ def delete
34
+ fail ApiTokenException unless RdInsightly.authorized?
35
+ ApiInsightly.delete_lead @id
36
+ end
31
37
  end
32
38
  end
@@ -1,3 +1,3 @@
1
1
  module RdInsightly
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rd_insightly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-27 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client