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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ca4def3ae4c9a4298c9799fbef10fef6bfbda7e
4
- data.tar.gz: 3c7ecb7385d9203f2f456630ef18065bf42aa798
3
+ metadata.gz: 6a0ea8d7dfed73f05b596b231d36c7606e2e1299
4
+ data.tar.gz: a6dce36560bf7b615d9bf622293eb641348a8c71
5
5
  SHA512:
6
- metadata.gz: e7e02b30bd6af49e4dcfd26d997531d8c86e4beae03e52a768f0e8038de49b35c0f7fcc59e6acc9edba47865f8534bc0c9aade4d1d57d81bec5b488c9c480536
7
- data.tar.gz: 3bbecdbafc8e87294f4d82617b3f825d6e2192d959232ed9417db98b8550957805acd9628f9ffe1f84e7080befe4a323e6eb3dd4ed389e431596b41953efa6e6
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('https://api.insight.ly/v2.1/contacts', Authorization: authorization_string, accept: :json)
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('https://api.insight.ly/v2.1/leads', Authorization: authorization_string, accept: :json))
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('https://api.insight.ly/v2.1/leads', lead_hash.to_json, Authorization: authorization_string, accept: :json, content_type: :json)
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("https://api.insight.ly/v2.1/leads/#{lead_id}", Authorization: authorization_string, accept: :json, content_type: :json)
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("https://api.insight.ly/v2.1/leads/#{lead_id}", Authorization: authorization_string, accept: :json))
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('https://api.insight.ly/v2.1/leads', lead_hash.to_json, Authorization: authorization_string, accept: :json, content_type: :json)
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!'
@@ -1,3 +1,3 @@
1
1
  module RdInsightly
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
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
 
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Oliveira