rd_insightly 0.1.6 → 0.1.7
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 +4 -4
- data/lib/rd_insightly/insightly/api_insightly.rb +8 -0
- data/lib/rd_insightly/lead.rb +18 -1
- data/lib/rd_insightly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd22518ccf1e1582169aea1ede60b5f95c7fe857
|
4
|
+
data.tar.gz: bd395cbd11ac61590af64b483fa1b5c9fcfd2e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c89826fc5fb466b1c757f768b7085e324490f094dbc57299bb862c77573da1e3732264617d37f4d955a96637f57a42857a0b7b172f6b63f310879411610b1cb9
|
7
|
+
data.tar.gz: b799a28e8db928ee73a7c42affde439d04fac2afe25b6951e7e0f3907af99a9497fe030c1610c543067780b494d68b00549e3f4c5346e0703d186aa23ec12500
|
@@ -35,6 +35,14 @@ module RdInsightly
|
|
35
35
|
raise LeadException, 'Lead não foi encontrado!'
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.update_lead(lead)
|
39
|
+
lead_hash = SerializerInsightly.lead_to_hash(lead)
|
40
|
+
response = RestClient.put('https://api.insight.ly/v2.1/leads', lead_hash.to_json, Authorization: authorization_string, accept: :json, content_type: :json)
|
41
|
+
SerializerInsightly.lead(JSON.parse(response))
|
42
|
+
rescue
|
43
|
+
raise LeadException, 'Lead não foi atualizado!'
|
44
|
+
end
|
45
|
+
|
38
46
|
def self.authorization_string
|
39
47
|
"Basic #{Base64.encode64(RdInsightly.api_token)}"
|
40
48
|
end
|
data/lib/rd_insightly/lead.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RdInsightly
|
2
2
|
class Lead
|
3
|
-
|
3
|
+
attr_accessor :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
|
@@ -39,5 +39,22 @@ module RdInsightly
|
|
39
39
|
fail ApiTokenException unless RdInsightly.authorized?
|
40
40
|
ApiInsightly.delete_lead @id
|
41
41
|
end
|
42
|
+
|
43
|
+
def update(lead_changes)
|
44
|
+
fail ApiTokenException unless RdInsightly.authorized?
|
45
|
+
|
46
|
+
lead_changes[:id] = @id
|
47
|
+
hash_to_lead(lead_changes)
|
48
|
+
|
49
|
+
ApiInsightly.update_lead self
|
50
|
+
end
|
51
|
+
|
52
|
+
def hash_to_lead(lead_changes)
|
53
|
+
lead_changes.each do |key, value|
|
54
|
+
self.class.send :define_method, key do
|
55
|
+
value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
42
59
|
end
|
43
60
|
end
|
data/lib/rd_insightly/version.rb
CHANGED