rd_insightly 0.1.2 → 0.1.3

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: 162605b4daef4ae591114b4b199573adc4545751
4
- data.tar.gz: 438964354298cfa8aa84a722bac760e90143c2c9
3
+ metadata.gz: cb2d9d58a5eb9ba6f110642c7d99a38935b2f274
4
+ data.tar.gz: 315e5795906d9bb222c2f6c392fab71f4dc689f7
5
5
  SHA512:
6
- metadata.gz: 08b32097a2df356314daccd1ffdccd78dd994eaa5401335255d075452b3a9821fcaba69f0adc4215445c3a250b09c4a360128987137ee28ea6eacec9191f4b24
7
- data.tar.gz: f30d7fb288dd21fa1998040825d0f52d4b0f8cdae5ee1b94a35493b9a3b272d728a3bfcfb42418464de1d4110ed5aa97dfd999899a5836869d8582e85a17b3f5
6
+ metadata.gz: 56e1bf29b482ef41594cbe647682256fda86229e8ec7aa2c67c11f6d2ed55629adfce15ee4ca63c49f8d2dd58b92044bab4e136d7bfe9a7ba678fd99aaf71c8a
7
+ data.tar.gz: cd371e0aa15c182927ad1c50b48af8822599b8983daf5260ef30779cf6024a515da80a466f8596da5d841dfa554e5e39a65b4ffb720527387178315be772171a
@@ -11,7 +11,7 @@ module RdInsightly
11
11
  end
12
12
 
13
13
  def self.leads
14
- RestClient.get('https://api.insight.ly/v2.1/leads', Authorization: authorization_string, accept: :json)
14
+ JSON.parse(RestClient.get('https://api.insight.ly/v2.1/leads', Authorization: authorization_string, accept: :json))
15
15
  rescue
16
16
  nil
17
17
  end
@@ -1,4 +1,15 @@
1
1
  module RdInsightly
2
2
  module SerializerInsightly
3
+ LAST_NAME_FIELD = 'LAST_NAME'
4
+ NAME_FIELD = 'FIRST_NAME'
5
+ EMAIL_FIELD = 'EMAIL_ADDRESS'
6
+ COMPANY_FIELD = 'ORGANIZATION_NAME'
7
+ JOB_TITLE_FIELD = 'TITLE'
8
+ PHONE_FIELD = 'PHONE_NUMBER'
9
+ WEBSITE_FIELD = 'WEBSITE_URL'
10
+
11
+ 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]
13
+ end
3
14
  end
4
15
  end
@@ -1,20 +1,31 @@
1
1
  module RdInsightly
2
2
  class Lead
3
- attr_reader :name
3
+ attr_reader :name, :last_name, :email, :company, :job_title, :phone, :website
4
4
 
5
- def initialize(name)
6
- @name = name
5
+ def initialize(last_name = nil, attributes = {})
6
+ @last_name = last_name
7
+ @name = attributes.fetch(:name, nil)
8
+ @email = attributes.fetch(:email, nil)
9
+ @company = attributes.fetch(:company, nil)
10
+ @job_title = attributes.fetch(:job_title, nil)
11
+ @phone = attributes.fetch(:phone, nil)
12
+ @website = attributes.fetch(:website, nil)
7
13
  end
8
14
 
9
- def self.create(name = nil)
10
- fail LeadException if name.nil?
15
+ def self.create(last_name = nil, attributes = {})
16
+ fail LeadException if last_name.nil?
11
17
  fail ApiTokenException unless RdInsightly.authorized?
12
- Lead.new name
18
+ Lead.new last_name, attributes
13
19
  end
14
20
 
15
21
  def self.all
16
22
  fail ApiTokenException unless RdInsightly.authorized?
17
- ApiInsightly.leads
23
+ leads_result = []
24
+ leads_json = ApiInsightly.leads
25
+ leads_json.each do |lead_json|
26
+ leads_result << SerializerInsightly.lead(lead_json)
27
+ end
28
+ leads_result
18
29
  end
19
30
  end
20
31
  end
@@ -1,3 +1,3 @@
1
1
  module RdInsightly
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
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.2
4
+ version: 0.1.3
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-25 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client