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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5ac1d71e6683b6ee6412b6729022a1e552c286f
4
- data.tar.gz: 43e052b3b73f19fb6e1cb2b4dec497901ad27cc0
3
+ metadata.gz: cd22518ccf1e1582169aea1ede60b5f95c7fe857
4
+ data.tar.gz: bd395cbd11ac61590af64b483fa1b5c9fcfd2e37
5
5
  SHA512:
6
- metadata.gz: 2e39bf727a8082165a765124dc8c6063de06e0e41bf9699e5bc4be465230e73eb628221f9fda58cec2e2224a7186c7087c30a677b95a77b0c5b42e230b366c31
7
- data.tar.gz: 646178638f63360ca078b4044771c832962a01a25ea7d9dbcaa571bfa7f5d446fb57a3d6cbd84b71bea77ced13c9c35d627d7d48f6bd92e08c9380f5c1af601b
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
@@ -1,6 +1,6 @@
1
1
  module RdInsightly
2
2
  class Lead
3
- attr_reader :name, :last_name, :email, :company, :job_title, :phone, :website, :id
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
@@ -1,3 +1,3 @@
1
1
  module RdInsightly
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rd_insightly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Oliveira