rd_insightly 0.1.8 → 0.1.9
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 +6 -6
- data/lib/rd_insightly/version.rb +1 -1
- data/lib/rd_insightly.rb +3 -0
- 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: 6a0ea8d7dfed73f05b596b231d36c7606e2e1299
|
4
|
+
data.tar.gz: a6dce36560bf7b615d9bf622293eb641348a8c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 426ee86e49e1b3d08cceb8cab8cbe37d06dab476329d1a0ba9712923f39940818d6474e5624aa87b3054c8731d98d307e1cf02c7033fff7c8ebef67d09f9b656
|
7
|
+
data.tar.gz: de64a09848a71c17f71ea5821cde7fd4be1222ef740a07915862f16585a87097b9dee4753f2d3cb2d9de7a50a0f5f57d37e06dcc352e4847cadddbab4ce42051
|
@@ -4,32 +4,32 @@ module RdInsightly
|
|
4
4
|
UNAUTHORIZED = false
|
5
5
|
|
6
6
|
def self.authentication
|
7
|
-
RestClient.get(
|
7
|
+
RestClient.get("#{BASE_URL}contacts", Authorization: authorization_string, accept: :json)
|
8
8
|
AUTHORIZED
|
9
9
|
rescue
|
10
10
|
UNAUTHORIZED
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.leads
|
14
|
-
JSON.parse(RestClient.get(
|
14
|
+
JSON.parse(RestClient.get("#{BASE_URL}leads", Authorization: authorization_string, accept: :json))
|
15
15
|
rescue
|
16
16
|
nil
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.create_lead(lead)
|
20
20
|
lead_hash = SerializerInsightly.lead_to_hash(lead)
|
21
|
-
RestClient.post(
|
21
|
+
RestClient.post("#{BASE_URL}leads", lead_hash.to_json, Authorization: authorization_string, accept: :json, content_type: :json)
|
22
22
|
lead
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.delete_lead(lead_id)
|
26
|
-
RestClient.delete("
|
26
|
+
RestClient.delete("#{BASE_URL}leads/#{lead_id}", Authorization: authorization_string, accept: :json, content_type: :json)
|
27
27
|
rescue
|
28
28
|
raise LeadException, 'Lead não pode ser excluido!'
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.find_lead(lead_id)
|
32
|
-
lead_json = JSON.parse(RestClient.get("
|
32
|
+
lead_json = JSON.parse(RestClient.get("#{BASE_URL}leads/#{lead_id}", Authorization: authorization_string, accept: :json))
|
33
33
|
SerializerInsightly.lead(lead_json)
|
34
34
|
rescue
|
35
35
|
raise LeadException, 'Lead não foi encontrado!'
|
@@ -37,7 +37,7 @@ module RdInsightly
|
|
37
37
|
|
38
38
|
def self.update_lead(lead)
|
39
39
|
lead_hash = SerializerInsightly.lead_to_hash(lead)
|
40
|
-
response = RestClient.put(
|
40
|
+
response = RestClient.put("#{BASE_URL}leads", lead_hash.to_json, Authorization: authorization_string, accept: :json, content_type: :json)
|
41
41
|
SerializerInsightly.lead(JSON.parse(response))
|
42
42
|
rescue
|
43
43
|
raise LeadException, 'Lead não foi atualizado!'
|
data/lib/rd_insightly/version.rb
CHANGED
data/lib/rd_insightly.rb
CHANGED
@@ -10,12 +10,15 @@ require 'base64'
|
|
10
10
|
require 'singleton'
|
11
11
|
|
12
12
|
module RdInsightly
|
13
|
+
BASE_URL = 'https://api.insight.ly/v2.1/'
|
13
14
|
@auth = nil
|
15
|
+
|
14
16
|
def self.create_authorization(api_token)
|
15
17
|
@auth = Auth.create(api_token)
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.authorized?
|
21
|
+
return false if @auth.nil?
|
19
22
|
@auth.authorized?
|
20
23
|
end
|
21
24
|
|