active_campaign 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51738f35b3fdb61fa2e068ddcca2735c3e1a24ca
4
- data.tar.gz: 335f4331bdb56d952ea512b73c95b9ca83de8524
3
+ metadata.gz: 8398a60d8813e841f5afa215ffeb6066a4ff395d
4
+ data.tar.gz: afa4838934daf586899e694c9713a891c240d937
5
5
  SHA512:
6
- metadata.gz: 672b2039bb992045ac56ba02113b9eeb17dcc534a0dc7a88af8325e660b2b62816b6939945955e3557ec98461c40c2ef58269b9bc06c7d10ee0c9bfff51b6544
7
- data.tar.gz: dba4079c479ee6bb751754421b5e07eed513f2b2e0791b3c2216444bea323050ba2657eeae8fe4fb3ac03655d8dc441ddfa22f8d1c488fbf92bb8ce8c1f7e6f7
6
+ metadata.gz: 82e27167097b9400cc7ef1b8af42b6dc21b674ab53789a1a9d65903d74ef7e058e156834bb8b14d8e6712312eeff0c0ddbb89a4384eb3bc227d74774862c2622
7
+ data.tar.gz: 34b35346dac58e002fcc86e882cd1edccab5b92375b8efaa457ec11f11e89bca187603f57ad3de17acb9d771554a054483caa978a804af3c8002fef9db670082
@@ -17,12 +17,6 @@ module ActiveCampaign
17
17
  instance_variable_set(:"@#{key}", options[key] ||
18
18
  ActiveCampaign.instance_variable_get(:"@#{key}"))
19
19
  end
20
-
21
- unless debug
22
- HTTPI.log = false
23
- HTTPI.log_level = :info
24
- HTTPI.logger = Rails.logger
25
- end
26
20
  end
27
21
 
28
22
  # Compares client options to a Hash of requested options
@@ -55,6 +49,7 @@ module ActiveCampaign
55
49
 
56
50
  def request(method, api_method, data)
57
51
  req = create_request method, api_method, data
52
+
58
53
  response = HTTPI.send(method, req)
59
54
  response = JSON.parse(response.body)
60
55
  normalize(response)
@@ -64,15 +59,25 @@ module ActiveCampaign
64
59
  def create_request(method, api_method, options = {})
65
60
  request = HTTPI::Request.new :url => File.join(api_endpoint, api_path)
66
61
  request.headers = {"User-Agent" => user_agent}
67
- request.query = {
62
+ request.query = query(method, api_method, options)
63
+ request.body = options.to_query if method == :post
64
+
65
+ request
66
+ end
67
+
68
+ def query(method, api_method, options = {})
69
+ q = options.delete(:query) { Hash.new }
70
+ q.merge!({
68
71
  :api_key => api_key,
69
72
  :api_action => api_method.to_s,
70
73
  :api_output => api_output
71
- }.merge(options.delete(:query))
74
+ })
72
75
 
73
- request.body = options.to_query if method == :post
76
+ if method == :get
77
+ q.merge!(options)
78
+ end
74
79
 
75
- request
80
+ q
76
81
  end
77
82
 
78
83
  def normalize(response)
@@ -10,7 +10,9 @@ module ActiveCampaign
10
10
  :api_output,
11
11
  :api_endpoint,
12
12
  :user_agent,
13
- :debug,
13
+ :log,
14
+ :log_level,
15
+ :logger,
14
16
  :mash,
15
17
  ]
16
18
 
@@ -35,6 +37,11 @@ module ActiveCampaign
35
37
  ActiveCampaign::Configurable.keys.each do |key|
36
38
  instance_variable_set(:"@#{key}", ActiveCampaign::Default.options[key])
37
39
  end
40
+
41
+ HTTPI.logger = self.logger if self.logger
42
+ HTTPI.log = self.log
43
+ HTTPI.log_level = self.log_level
44
+
38
45
  self
39
46
  end
40
47
  alias setup reset!
@@ -45,6 +45,18 @@ module ActiveCampaign
45
45
  ENV['ACTIVE_CAMPAIGN_API_KEY']
46
46
  end
47
47
 
48
+ def log
49
+ false
50
+ end
51
+
52
+ def logger
53
+ nil
54
+ end
55
+
56
+ def log_level
57
+ :warn
58
+ end
59
+
48
60
  def debug
49
61
  false
50
62
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveCampaign
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1 @@
1
+ {"http_interactions":[{"request":{"method":"post","uri":"\u003CAPI_ENDPOINT\u003Eadmin/api.php?api_action=contact_sync\u0026api_key=\u003CAPI_KEY\u003E\u0026api_output=json","body":{"encoding":"US-ASCII","base64_string":"ZW1haWw9bWhlbnJpeG9uJTQwbWUuY29tJmZpcnN0X25hbWU9TWlrYWVsJmlk\nPTEmaW5zdGFudHJlc3BvbmRlcnMlNUIxJTVEPTEmaXA0PTEyNy4wLjAuMSZs\nYXN0X25hbWU9SGVucmlrc3NvbiZwJTVCMSU1RD0xJnF1ZXJ5JTVCbGlzdGlk\nJTVEPTEmc3RhdHVzJTVCMSU1RD0x\n"},"headers":{"User-Agent":["ActiveCampaign Ruby Gem 0.1.3"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"X-Powered-By":["PHP/5.3.3"],"Set-Cookie":["PHPSESSID=eub036nutku58dgp7tctml34p4; path=/; Secure","em_acp_globalauth_cookie=cdb9730a7400f13b7fc0e8e8a8689d611; path=/; domain=casinosaga.activehosted.com; secure","em_acp_globalauth_cookie=deleted; expires=Tue, 16-Oct-2012 19:30:10 GMT; path=/; domain=casinosaga.activehosted.com; secure"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Pragma":["no-cache"],"Content-Type":["application/json; charset=utf-8"],"Cache-Control":["no-store, max-age=0, must-revalidate"],"Transfer-Encoding":["chunked"],"Date":["Wed, 16 Oct 2013 19:30:11 GMT"],"Server":["lighttpd/1.4.31"],"Connection":["Keep-alive"],"Keep-Alive":["timeout=15, max=100"],"Via":["1.1 ID-0001242756263011 uproxy-3"]},"body":{"encoding":"UTF-8","base64_string":"eyJzdWJzY3JpYmVyX2lkIjoyLCJzZW5kbGFzdF9zaG91bGQiOjAsInNlbmRs\nYXN0X2RpZCI6MCwicmVzdWx0X2NvZGUiOjEsInJlc3VsdF9tZXNzYWdlIjoi\nQ29udGFjdCB1cGRhdGVkIiwicmVzdWx0X291dHB1dCI6Impzb24ifQ==\n"},"http_version":null},"recorded_at":"Wed, 16 Oct 2013 19:30:11 GMT"}],"recorded_with":"VCR 2.6.0"}
@@ -0,0 +1 @@
1
+ {"http_interactions":[{"request":{"method":"get","uri":"\u003CAPI_ENDPOINT\u003Eadmin/api.php?api_action=contact_view\u0026api_key=\u003CAPI_KEY\u003E\u0026api_output=json\u0026id=2","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"User-Agent":["ActiveCampaign Ruby Gem 0.1.3"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"X-Powered-By":["PHP/5.3.3"],"Set-Cookie":["PHPSESSID=3c8269482jo6boi8h2qik5s9b4; path=/; Secure","em_acp_globalauth_cookie=cdb9730a7400f13b7fc0e8e8a8689d611; path=/; domain=casinosaga.activehosted.com; secure","em_acp_globalauth_cookie=deleted; expires=Tue, 16-Oct-2012 19:31:02 GMT; path=/; domain=casinosaga.activehosted.com; secure"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Pragma":["no-cache"],"Content-Type":["application/json; charset=utf-8"],"Cache-Control":["no-store, max-age=0, must-revalidate"],"Transfer-Encoding":["chunked"],"Date":["Wed, 16 Oct 2013 19:31:03 GMT"],"Server":["lighttpd/1.4.31"],"Connection":["Keep-alive"],"Keep-Alive":["timeout=15, max=100"],"Via":["1.1 ID-0001242756263011 uproxy-5"]},"body":{"encoding":"UTF-8","base64_string":"eyJpZCI6IjIiLCJzdWJzY3JpYmVyaWQiOiIyIiwibGlzdGlkIjoiMiIsImZv\ncm1pZCI6IjAiLCJzZGF0ZSI6IjIwMTMtMTAtMTYgMTM6MjQ6MDEiLCJ1ZGF0\nZSI6IjIwMTMtMTAtMTYgMTQ6MjA6NTciLCJzdGF0dXMiOiIyIiwicmVzcG9u\nZGVyIjoiMSIsInN5bmMiOiIwIiwidW5zdWJyZWFzb24iOm51bGwsInVuc3Vi\nY2FtcGFpZ25pZCI6IjAiLCJ1bnN1Ym1lc3NhZ2VpZCI6IjAiLCJmaXJzdF9u\nYW1lIjoiTWlrYWVsIiwibGFzdF9uYW1lIjoiSGVucmlrc3NvbiIsImlw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dCI6IjEiLCJyb3dzIjoiMCIsImNvbHMi\nOiIwIiwidmlzaWJsZSI6IjEiLCJzZXJ2aWNlIjoiIiwidmFsIjpudWxsLCJy\nZWxpZCI6IjAiLCJkYXRhaWQiOiIwIiwiZWxlbWVudCI6ImhpZGRlbiIsInRh\nZyI6IiVYUCUifX0sImFjdGlvbnMiOltdLCJjYW1wYWlnbl9oaXN0b3J5Ijpb\nXSwiYm91bmNlcyI6eyJtYWlsaW5nIjpbXSwibWFpbGluZ3MiOjAsInJlc3Bv\nbmRlciI6W10sInJlc3BvbmRlcnMiOjB9LCJib3VuY2VzY250IjowLCJyZXN1\nbHRfY29kZSI6MSwicmVzdWx0X21lc3NhZ2UiOiJTdWNjZXNzOiBTb21ldGhp\nbmcgaXMgcmV0dXJuZWQiLCJyZXN1bHRfb3V0cHV0IjoianNvbiJ9\n"},"http_version":null},"recorded_at":"Wed, 16 Oct 2013 19:31:03 GMT"}],"recorded_with":"VCR 2.6.0"}
@@ -0,0 +1 @@
1
+ {"http_interactions":[{"request":{"method":"get","uri":"\u003CAPI_ENDPOINT\u003Eadmin/api.php?api_action=list_list\u0026api_key=\u003CAPI_KEY\u003E\u0026api_output=json\u0026ids=all","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"User-Agent":["ActiveCampaign Ruby Gem 0.1.3"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"X-Powered-By":["PHP/5.3.3"],"Set-Cookie":["PHPSESSID=0pelvglhm8t0n9ds59aemhu211; path=/; Secure","em_acp_globalauth_cookie=cdb9730a7400f13b7fc0e8e8a8689d611; path=/; domain=casinosaga.activehosted.com; secure","em_acp_globalauth_cookie=deleted; expires=Tue, 16-Oct-2012 19:23:27 GMT; path=/; domain=casinosaga.activehosted.com; secure"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Pragma":["no-cache"],"Content-Type":["application/json; charset=utf-8"],"Cache-Control":["no-store, max-age=0, must-revalidate"],"Transfer-Encoding":["chunked"],"Date":["Wed, 16 Oct 2013 19:23:28 GMT"],"Server":["lighttpd/1.4.31"],"Connection":["Keep-alive"],"Keep-Alive":["timeout=15, max=100"],"Via":["1.1 ID-0001242756263011 uproxy-3"]},"body":{"encoding":"UTF-8","base64_string":"eyIwIjp7ImlkIjoiMSIsIm5hbWUiOiJwbGF5ZXJzX3N2IiwiY2RhdGUiOiIy\nMDEzLTEwLTE2IDA0OjMwOjAxIiwicHJpdmF0ZSI6IjAiLCJ1c2VyaWQiOiIx\nIiwic3Vic2NyaWJlcl9jb3VudCI6MX0sIjEiOnsiaWQiOiIyIiwibmFtZSI6\nInBsYXllcnNfbm8iLCJjZGF0ZSI6IjIwMTMtMTAtMTYgMDQ6MzA6NDMiLCJw\ncml2YXRlIjoiMCIsInVzZXJpZCI6IjEiLCJzdWJzY3JpYmVyX2NvdW50Ijow\nfSwiMiI6eyJpZCI6IjMiLCJuYW1lIjoicGxheWVyc19maSIsImNkYXRlIjoi\nMjAxMy0xMC0xNiAwNDozMToyMiIsInByaXZhdGUiOiIwIiwidXNlcmlkIjoi\nMSIsInN1YnNjcmliZXJfY291bnQiOjB9LCIzIjp7ImlkIjoiNCIsIm5hbWUi\nOiJwbGF5ZXJzX2VuIiwiY2RhdGUiOiIyMDEzLTEwLTE2IDA0OjMxOjQ4Iiwi\ncHJpdmF0ZSI6IjAiLCJ1c2VyaWQiOiIxIiwic3Vic2NyaWJlcl9jb3VudCI6\nMH0sInJlc3VsdF9jb2RlIjoxLCJyZXN1bHRfbWVzc2FnZSI6IlN1Y2Nlc3M6\nIFNvbWV0aGluZyBpcyByZXR1cm5lZCIsInJlc3VsdF9vdXRwdXQiOiJqc29u\nIn0=\n"},"http_version":null},"recorded_at":"Wed, 16 Oct 2013 19:23:28 GMT"}],"recorded_with":"VCR 2.6.0"}
@@ -0,0 +1 @@
1
+ {"http_interactions":[{"request":{"method":"get","uri":"\u003CAPI_ENDPOINT\u003Eadmin/api.php?api_action=list_view\u0026api_key=\u003CAPI_KEY\u003E\u0026api_output=json\u0026id=1","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"User-Agent":["ActiveCampaign Ruby Gem 0.1.3"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"X-Powered-By":["PHP/5.3.3"],"Set-Cookie":["PHPSESSID=mll68on7a38r2sggkbpdck0ku0; path=/; Secure","em_acp_globalauth_cookie=cdb9730a7400f13b7fc0e8e8a8689d611; path=/; domain=casinosaga.activehosted.com; secure","em_acp_globalauth_cookie=deleted; expires=Tue, 16-Oct-2012 19:23:25 GMT; path=/; domain=casinosaga.activehosted.com; secure"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Pragma":["no-cache"],"Content-Type":["application/json; charset=utf-8"],"Cache-Control":["no-store, max-age=0, must-revalidate"],"Transfer-Encoding":["chunked"],"Date":["Wed, 16 Oct 2013 19:23:26 GMT"],"Server":["lighttpd/1.4.31"],"Connection":["Keep-alive"],"Keep-Alive":["timeout=15, max=100"],"Via":["1.1 ID-0001242756263011 uproxy-2"]},"body":{"encoding":"UTF-8","base64_string":"eyJpZCI6IjEiLCJzdHJpbmdpZCI6InBsYXllcnNfc3YiLCJ1c2VyaWQiOiIx\nIiwibmFtZSI6InBsYXllcnNfc3YiLCJjZGF0ZSI6IjIwMTMtMTAtMTYgMDQ6\nMzA6MDEiLCJwX3VzZV90cmFja2luZyI6IjEiLCJwX3VzZV9hbmFseXRpY3Nf\ncmVhZCI6IjAiLCJwX3VzZV9hbmFseXRpY3NfbGluayI6IjAiLCJwX3VzZV90\nd2l0dGVyIjoiMCIsInBfdXNlX2ZhY2Vib29rIjoiMCIsInBfZW1iZWRfaW1h\nZ2UiOiIxIiwicF91c2VfY2FwdGNoYSI6IjEiLCJzZW5kX2xhc3RfYnJvYWRj\nYXN0IjoiMCIsInByaXZhd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sIjoi\naHR0cHM6XC9cL3d3dy5mYWNlYm9vay5jb21cL2RpYWxvZ1wvb2F1dGg/Y2xp\nZW50X2lkPTExODUwNjQ4MTU1NTA5MyZyZWRpcmVjdF91cmk9aHR0cHMlM0El\nMkYlMkZjYXNpbm9zYWdhLmFjdGl2ZWhvc3RlZC5jb20lMkZhZG1pbiUyRm1h\naW4ucGhwJTNGYWN0aW9uJTNEbGlzdCUyNmZvcm1pZCUzRDEmc2NvcGU9cHVi\nbGlzaF9zdHJlYW0sbWFuYWdlX3BhZ2VzIiwiZmFjZWJvb2tfb2F1dGhfbWUi\nOm51bGwsInJlc3VsdF9jb2RlIjoxLCJyZXN1bHRfbWVzc2FnZSI6IlN1Y2Nl\nc3M6IFNvbWV0aGluZyBpcyByZXR1cm5lZCIsInJlc3VsdF9vdXRwdXQiOiJq\nc29uIn0=\n"},"http_version":null},"recorded_at":"Wed, 16 Oct 2013 19:23:27 GMT"}],"recorded_with":"VCR 2.6.0"}
@@ -1,36 +1,37 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe ActiveCampaign::Client::Contacts do
4
+ describe ActiveCampaign::Client::Contacts, :vcr do
5
5
 
6
6
  initialize_new_client
7
7
 
8
- pending "syncs a contact" do
9
- params = {
10
- id: 1,
11
- email: 'mhenrixon@me.com',
12
- first_name: 'Mikael',
13
- last_name: 'Henriksson',
14
- "p" => {"1" => 1, "2" => 2},
15
- "status" => {"1" => 1, "2" => 2},
16
- "instantresponders" => {"1" => 1, "2" => 2},
17
- "field[%BALANCE%,0]" => 100,
18
- ip4: '127.0.0.1',
19
- }.stringify_keys
8
+ describe ".contact_sync" do
9
+ context "when successful" do
10
+ let(:params) do
11
+ {
12
+ query: { listid: 1 },
13
+ id: 1,
14
+ email: 'mhenrixon@me.com',
15
+ first_name: 'Mikael',
16
+ last_name: 'Henriksson',
17
+ "p" => {"1" => 1},
18
+ "status" => {"1" => 1},
19
+ "instantresponders" => {"1" => 1},
20
+ ip4: '127.0.0.1',
21
+ }.stringify_keys
22
+ end
20
23
 
21
- stub_post("contact_sync").
22
- to_return json_response("contact_sync.json")
24
+ subject(:response) { @client.contact_sync params }
23
25
 
24
- @client.contact_sync params
26
+ it "returns 1 for result_code" do
27
+ expect(response.result_code).to eq 1
28
+ end
29
+ end
25
30
  end
26
31
 
27
32
  describe ".contact_view" do
28
- it "returns the right contact" do
29
- stub_get("contact_view", email: "mikael@zoolutions.se").
30
- with(email: "mikael@zoolutions.se").
31
- to_return json_response("contact_view.json")
32
-
33
- contact = @client.contact_view(email: "mikael@zoolutions.se")
33
+ it "can find contact by id" do
34
+ contact = @client.contact_view id: 2
34
35
  expect(contact.first_name).to eq "Mikael"
35
36
  expect(contact.last_name).to eq "Henriksson"
36
37
  end
@@ -1,44 +1,40 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe ActiveCampaign::Client::Lists do
4
+ describe ActiveCampaign::Client::Lists, :vcr do
5
5
 
6
6
  initialize_new_client
7
7
 
8
- pending "add a list" do
9
- params = {
10
- "id" => 1,
11
- "email" => 'mhenrixon@me.com',
12
- "first_name"=> 'Mikael',
13
- "last_name" => 'Henriksson',
14
- "p[1]" => 1,
15
- "status[1]" => 1,
16
- "instantresponders[1]" => 1,
17
- "field[%BALANCE%,0]" => 100,
18
- "ip4" => '127.0.0.1',
19
- "status[2]" => 2,
20
- "listid" => 1
21
- }.stringify_keys
22
-
23
- list = ActiveCampaign.list_add params
24
- end
8
+ # it "add a list", :vcr do
9
+ # params = {
10
+ # "id" => 1,
11
+ # "email" => 'mhenrixon@me.com',
12
+ # "name"=> 'Mikael',
13
+ # "last_name" => 'Henriksson',
14
+ # "p[1]" => 1,
15
+ # "status[1]" => 1,
16
+ # "instantresponders[1]" => 1,
17
+ # "field[%BALANCE%,0]" => 100,
18
+ # "ip4" => '127.0.0.1',
19
+ # "status[2]" => 2,
20
+ # "listid" => 1
21
+ # }.stringify_keys
22
+
23
+ # list = ActiveCampaign.list_add params
24
+ # end
25
25
 
26
26
  describe ".list_view" do
27
- it "returns the right list" do
28
- stub_get("list_view", id: 1).
29
- to_return json_response("list_view.json")
30
-
27
+ it "can find lists by id" do
31
28
  list = @client.list_view id: 1
32
- expect(list.name).to eq "Swedish Players"
29
+ expect(list.name).to eq "players_sv"
33
30
  end
31
+ end
34
32
 
35
- pending "returns the right list list" do
36
- WebMock.allow_net_connect!
37
- # stub_get("list_view", name: "Swedish Players").
38
- # to_return json_response("list_view.json")
33
+ describe ".list_list" do
34
+ it "can find a list of lists" do
39
35
 
40
36
  lists = @client.list_list "ids" => 'all'
41
- expect(lists.results[0].name).to eq "Swedish Players"
37
+ expect(lists.results[0].name).to eq "players_sv"
42
38
  end
43
39
  end
44
40
  end
@@ -1,5 +1,6 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
+ require 'pry'
3
4
  require "codeclimate-test-reporter"
4
5
  formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
5
6
 
@@ -31,7 +32,11 @@ require 'vcr'
31
32
  VCR.configure do |c|
32
33
  c.configure_rspec_metadata!
33
34
  c.filter_sensitive_data('<API_KEY>') do
34
- ENV['ACTIVE_CAMPAIGN_API_KEY']
35
+ ENV['ACTIVE_CAMPAIGN_API_KEY']
36
+ end
37
+
38
+ c.filter_sensitive_data('<API_ENDPOINT>') do
39
+ ENV['ACTIVE_CAMPAIGN_API_ENDPOINT']
35
40
  end
36
41
 
37
42
  c.default_cassette_options = {
@@ -39,97 +44,42 @@ VCR.configure do |c|
39
44
  # TODO: Track down UTF-8 issue and remove
40
45
  preserve_exact_body_bytes: true,
41
46
  decode_compressed_response: true,
42
- record: ENV['TRAVIS'] ? :none : :once
47
+ record: ENV['CI'] ? :none : :once
43
48
  }
44
49
  c.cassette_library_dir = 'spec/cassettes'
45
50
  c.hook_into :webmock
46
51
  c.ignore_hosts 'codeclimate.com'
47
52
  end
48
53
 
49
- def a_delete(url, options = {})
50
- a_request(:delete, active_campaign_url(url, options))
51
- end
52
-
53
- def a_get(url, options = {})
54
- a_request(:get, active_campaign_url(url, options))
55
- end
56
-
57
- def a_patch(url, options = {})
58
- a_request(:patch, active_campaign_url(url, options))
59
- end
60
-
61
- def a_post(url, options = {})
62
- a_request(:post, active_campaign_url(url, options))
63
- end
64
-
65
- def a_put(url, options = {})
66
- a_request(:put, active_campaign_url(url, options))
67
- end
68
-
69
- def stub_delete(url, options = {})
70
- stub_request(:delete, active_campaign_url(url, options))
71
- end
72
-
73
- def stub_get(url, options = {})
74
- stub_request(:get, active_campaign_url(url, options))
75
- end
76
-
77
- def stub_head(url, options = {})
78
- stub_request(:head, active_campaign_url(url, options))
79
- end
80
-
81
- def stub_patch(url, options = {})
82
- stub_request(:patch, active_campaign_url(url, options))
83
- end
84
-
85
- def stub_post(url, options = {})
86
- stub_request(:post, active_campaign_url(url, options))
87
- end
88
-
89
- def stub_put(url, options = {})
90
- stub_request(:put, active_campaign_url(url, options))
54
+ def test_api_endpoint
55
+ ENV.fetch 'ACTIVE_CAMPAIGN_API_ENDPOINT'
91
56
  end
92
57
 
93
- def fixture_path
94
- File.expand_path("../fixtures", __FILE__)
95
- end
96
-
97
- def fixture(file)
98
- File.new(fixture_path + '/' + file)
99
- end
100
-
101
- def json_response(file)
102
- {
103
- :body => fixture(file),
104
- :headers => {
105
- :content_type => 'application/json; charset=utf-8'
106
- }
107
- }
108
- end
109
-
110
- def active_campaign_url(url, options = {})
111
- if url =~ /^http/
112
- url
113
- else
114
- uri = "https://yourdomain.activehosted.com/admin/api.php?api_action=#{url}&api_key=YOURAPIKEY&api_output=json"
115
- params = options.map{|k,v| "#{k}=#{v}" }.join("&")
116
- "#{uri}&#{params}"
117
- end
58
+ def test_api_key
59
+ ENV.fetch 'ACTIVE_CAMPAIGN_API_KEY'
118
60
  end
119
61
 
120
62
  def initialize_new_client
121
63
  before do
122
- initialize_active_campaign
123
- @client = ActiveCampaign::Client.new mash: true, debug: true
64
+ @client = ActiveCampaign::Client.new({
65
+ mash: true,
66
+ debug: true,
67
+ api_endpoint: test_api_endpoint,
68
+ api_key: test_api_key,
69
+ log_level: :debug,
70
+ log: true
71
+ })
124
72
  end
125
73
  end
126
74
 
127
75
  def initialize_active_campaign
128
76
  ActiveCampaign.configure do |config|
129
- config.api_endpoint = "https://yourdomain.activehosted.com/"
130
- config.api_key = "YOURAPIKEY"
77
+ config.api_endpoint = test_api_endpoint
78
+ config.api_key = test_api_key
131
79
  config.api_output = "json"
132
80
  config.debug = true
81
+ config.log_level = :debug
82
+ config.log = true
133
83
  config.mash = true
134
84
  end
135
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_campaign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
@@ -67,6 +67,10 @@ files:
67
67
  - lib/active_campaign/error.rb
68
68
  - lib/active_campaign/version.rb
69
69
  - spec/active_campaign_spec.rb
70
+ - spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.json
71
+ - spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.json
72
+ - spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.json
73
+ - spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.json
70
74
  - spec/client/contacts_spec.rb
71
75
  - spec/client/lists_spec.rb
72
76
  - spec/client_spec.rb
@@ -100,6 +104,10 @@ specification_version: 4
100
104
  summary: See http://www.activecampaign.com/api/overview.php for more information
101
105
  test_files:
102
106
  - spec/active_campaign_spec.rb
107
+ - spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.json
108
+ - spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.json
109
+ - spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.json
110
+ - spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.json
103
111
  - spec/client/contacts_spec.rb
104
112
  - spec/client/lists_spec.rb
105
113
  - spec/client_spec.rb