active_campaign 0.1.13 → 0.1.14

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -3
  3. data/.travis.yml +15 -7
  4. data/Gemfile +3 -2
  5. data/README.md +1 -1
  6. data/active_campaign.gemspec +0 -2
  7. data/lib/active_campaign.rb +16 -8
  8. data/lib/active_campaign/client.rb +11 -15
  9. data/lib/active_campaign/client/campaigns.rb +7 -7
  10. data/lib/active_campaign/client/contacts.rb +9 -11
  11. data/lib/active_campaign/client/deals.rb +7 -7
  12. data/lib/active_campaign/client/forms.rb +5 -5
  13. data/lib/active_campaign/client/groups.rb +7 -7
  14. data/lib/active_campaign/client/lists.rb +12 -10
  15. data/lib/active_campaign/client/messages.rb +7 -7
  16. data/lib/active_campaign/client/tracks.rb +8 -12
  17. data/lib/active_campaign/client/users.rb +6 -11
  18. data/lib/active_campaign/configuration.rb +44 -24
  19. data/lib/active_campaign/core_ext.rb +53 -0
  20. data/lib/active_campaign/version.rb +1 -1
  21. data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_add/when_successful/returns_1_for_result_code.yml +96 -0
  22. data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.yml +96 -0
  23. data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.yml +150 -0
  24. data/spec/cassettes/ActiveCampaign_Client_Lists/_list_add/add_a_list.yml +48 -0
  25. data/spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.yml +106 -0
  26. data/spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.yml +102 -0
  27. data/spec/lib/active_campaign/client/contacts_spec.rb +15 -5
  28. data/spec/lib/active_campaign/client/lists_spec.rb +26 -18
  29. data/spec/lib/active_campaign/client_spec.rb +0 -1
  30. data/spec/lib/active_campaign_spec.rb +2 -2
  31. data/spec/spec_helper.rb +12 -14
  32. data/spec/support/coverage.rb +6 -2
  33. data/spec/support/vcr.rb +7 -5
  34. metadata +15 -40
  35. data/circle.yml +0 -15
  36. data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.json +0 -1
  37. data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.json +0 -1
  38. data/spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.json +0 -1
  39. data/spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.json +0 -1
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<API_ENDPOINT>?api_action=list_add&api_key=<API_KEY>&api_output=json"
6
+ body:
7
+ encoding: UTF-8
8
+ string: carboncopy=mikael%40zoolutions.se&get_unsubscribe_reason=1&name=Swedish+Players&p_use_captcha=0&private=0&require_name=1&send_last_broadcast=1&sender_addr1=%25C3%2596sterv%25C3%25A5ngsplan%252015&sender_city=Landskrona&sender_country=Sweden&sender_name=Zoolutions%2520AB&sender_zip=26144&stringid=swedish-players&subscription_notify=mikael%40zoolutions.se&to_name=Recipient&unsubscription_notify=mikael%40zoolutions.se
9
+ headers:
10
+ User-Agent:
11
+ - ActiveCampaign Ruby Gem 0.1.13
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Powered-By:
22
+ - PHP/5.3.3
23
+ Set-Cookie:
24
+ - PHPSESSID=5b0o8l8b4jqn8sr51ahnngdbi2; path=/
25
+ - em_acp_globalauth_cookie=c6ead9798fb11b728939168ee2d579611; path=/; domain=zoolutions.api-us1.com;
26
+ secure
27
+ - em_acp_globalauth_cookie=deleted; expires=Wed, 12-Aug-2015 08:19:05 GMT; path=/;
28
+ domain=zoolutions.api-us1.com
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Pragma:
32
+ - no-cache
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Cache-Control:
36
+ - no-store, max-age=0, must-revalidate
37
+ Transfer-Encoding:
38
+ - chunked
39
+ Date:
40
+ - Thu, 11 Aug 2016 08:19:06 GMT
41
+ Server:
42
+ - lighttpd/1.4.37
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":11,"result_code":1,"result_message":"List added","result_output":"json"}'
46
+ http_version:
47
+ recorded_at: Thu, 11 Aug 2016 08:19:06 GMT
48
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,106 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<API_ENDPOINT>/?api_action=list_list&api_key=<API_KEY>&api_output=json&ids=all"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - ActiveCampaign Ruby Gem 0.1.13
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 302
19
+ message: Found
20
+ headers:
21
+ X-Powered-By:
22
+ - PHP/5.3.3
23
+ Set-Cookie:
24
+ - PHPSESSID=8ev4eknm8r6s20s6obihjcbac3; path=/
25
+ - em_acp_globalauth_cookie=deleted; expires=Wed, 12-Aug-2015 07:54:06 GMT; path=/;
26
+ domain=zoolutions.api-us1.com
27
+ Expires:
28
+ - Thu, 19 Nov 1981 08:52:00 GMT
29
+ Cache-Control:
30
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
31
+ Pragma:
32
+ - no-cache
33
+ Location:
34
+ - http://zoolutions.activehosted.com
35
+ Vary:
36
+ - Accept-Encoding
37
+ Content-Type:
38
+ - text/html
39
+ Transfer-Encoding:
40
+ - chunked
41
+ Date:
42
+ - Thu, 11 Aug 2016 07:54:07 GMT
43
+ Server:
44
+ - lighttpd/1.4.37
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Thu, 11 Aug 2016 07:54:07 GMT
50
+ - request:
51
+ method: get
52
+ uri: "<API_ENDPOINT>?api_action=list_list&api_key=<API_KEY>&api_output=json&ids=all"
53
+ body:
54
+ encoding: US-ASCII
55
+ string: ''
56
+ headers:
57
+ User-Agent:
58
+ - ActiveCampaign Ruby Gem 0.1.13
59
+ Accept-Encoding:
60
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
+ Accept:
62
+ - "*/*"
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ X-Powered-By:
69
+ - PHP/5.3.3
70
+ Set-Cookie:
71
+ - PHPSESSID=mtidul4kr8djuf59uecffi0tg0; path=/
72
+ - em_acp_globalauth_cookie=c6ead9798fb11b728939168ee2d579611; path=/; domain=zoolutions.api-us1.com;
73
+ secure
74
+ - em_acp_globalauth_cookie=deleted; expires=Wed, 12-Aug-2015 08:19:06 GMT; path=/;
75
+ domain=zoolutions.api-us1.com
76
+ Expires:
77
+ - Thu, 19 Nov 1981 08:52:00 GMT
78
+ Pragma:
79
+ - no-cache
80
+ Content-Type:
81
+ - application/json; charset=utf-8
82
+ Cache-Control:
83
+ - no-store, max-age=0, must-revalidate
84
+ Transfer-Encoding:
85
+ - chunked
86
+ Date:
87
+ - Thu, 11 Aug 2016 08:19:07 GMT
88
+ Server:
89
+ - lighttpd/1.4.37
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"0":{"id":"1","name":"Swedish Players","cdate":"2016-08-11 10:02:18","private":"0","userid":"1","subscriber_count":1},"1":{"id":"2","name":"Swedish
93
+ Players","cdate":"2016-08-11 10:04:00","private":"1","userid":"1","subscriber_count":0},"2":{"id":"3","name":"Swedish
94
+ Players","cdate":"2016-08-11 10:08:42","private":"1","userid":"1","subscriber_count":0},"3":{"id":"4","name":"Swedish
95
+ Players","cdate":"2016-08-11 10:08:58","private":"1","userid":"1","subscriber_count":0},"4":{"id":"5","name":"Swedish
96
+ Players","cdate":"2016-08-11 10:13:21","private":"1","userid":"1","subscriber_count":0},"5":{"id":"6","name":"Swedish
97
+ Players","cdate":"2016-08-11 10:14:51","private":"1","userid":"1","subscriber_count":0},"6":{"id":"7","name":"Swedish
98
+ Players","cdate":"2016-08-11 10:15:32","private":"1","userid":"1","subscriber_count":1},"7":{"id":"8","name":"Swedish
99
+ Players","cdate":"2016-08-11 10:17:26","private":"1","userid":"1","subscriber_count":0},"8":{"id":"9","name":"Swedish
100
+ Players","cdate":"2016-08-11 10:17:58","private":"1","userid":"1","subscriber_count":0},"9":{"id":"10","name":"Swedish
101
+ Players","cdate":"2016-08-11 10:18:21","private":"1","userid":"1","subscriber_count":0},"10":{"id":"11","name":"Swedish
102
+ Players","cdate":"2016-08-11 10:19:06","private":"1","userid":"1","subscriber_count":0},"result_code":1,"result_message":"Success:
103
+ Something is returned","result_output":"json"}'
104
+ http_version:
105
+ recorded_at: Thu, 11 Aug 2016 08:19:07 GMT
106
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,102 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<API_ENDPOINT>/?api_action=list_view&api_key=<API_KEY>&api_output=json&id=1"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - ActiveCampaign Ruby Gem 0.1.13
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 302
19
+ message: Found
20
+ headers:
21
+ X-Powered-By:
22
+ - PHP/5.3.3
23
+ Set-Cookie:
24
+ - PHPSESSID=n4r7a65tfahaitchoc2opqo3j3; path=/
25
+ - em_acp_globalauth_cookie=deleted; expires=Wed, 12-Aug-2015 07:54:07 GMT; path=/;
26
+ domain=zoolutions.api-us1.com
27
+ Expires:
28
+ - Thu, 19 Nov 1981 08:52:00 GMT
29
+ Cache-Control:
30
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
31
+ Pragma:
32
+ - no-cache
33
+ Location:
34
+ - http://zoolutions.activehosted.com
35
+ Vary:
36
+ - Accept-Encoding
37
+ Content-Type:
38
+ - text/html
39
+ Transfer-Encoding:
40
+ - chunked
41
+ Date:
42
+ - Thu, 11 Aug 2016 07:54:08 GMT
43
+ Server:
44
+ - lighttpd/1.4.37
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Thu, 11 Aug 2016 07:54:08 GMT
50
+ - request:
51
+ method: get
52
+ uri: "<API_ENDPOINT>?api_action=list_view&api_key=<API_KEY>&api_output=json&id=1"
53
+ body:
54
+ encoding: US-ASCII
55
+ string: ''
56
+ headers:
57
+ User-Agent:
58
+ - ActiveCampaign Ruby Gem 0.1.13
59
+ Accept-Encoding:
60
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
+ Accept:
62
+ - "*/*"
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ X-Powered-By:
69
+ - PHP/5.3.3
70
+ Set-Cookie:
71
+ - PHPSESSID=kkjvn5o5597m11scubeb74igg4; path=/
72
+ - em_acp_globalauth_cookie=c6ead9798fb11b728939168ee2d579611; path=/; domain=zoolutions.api-us1.com;
73
+ secure
74
+ - em_acp_globalauth_cookie=deleted; expires=Wed, 12-Aug-2015 08:19:03 GMT; path=/;
75
+ domain=zoolutions.api-us1.com
76
+ Expires:
77
+ - Thu, 19 Nov 1981 08:52:00 GMT
78
+ Pragma:
79
+ - no-cache
80
+ Content-Type:
81
+ - application/json; charset=utf-8
82
+ Cache-Control:
83
+ - no-store, max-age=0, must-revalidate
84
+ Transfer-Encoding:
85
+ - chunked
86
+ Date:
87
+ - Thu, 11 Aug 2016 08:19:04 GMT
88
+ Server:
89
+ - lighttpd/1.4.37
90
+ body:
91
+ encoding: UTF-8
92
+ string: '{"id":"1","stringid":"swedish-players","userid":"1","name":"Swedish
93
+ Players","cdate":"2016-08-11 10:02:18","p_use_tracking":"1","p_use_analytics_read":"0","p_use_analytics_link":"0","p_use_twitter":"0","p_use_facebook":"0","p_embed_image":"1","p_use_captcha":"1","send_last_broadcast":"0","private":"0","analytics_domains":null,"analytics_source":"","analytics_ua":"","twitter_token":"","twitter_token_secret":"","facebook_session":"","carboncopy":"mikael@zoolutions.se","subscription_notify":"mikael@zoolutions.se","unsubscription_notify":"mikael@zoolutions.se","require_name":"0","get_unsubscribe_reason":"0","to_name":"Subscriber","optinoptout":"1","sender_name":"Zoolutions%20AB","sender_addr1":"%C3%96sterv%C3%A5ngsplan%2015","sender_addr2":"","sender_city":"Landskrona","sender_state":"","sender_zip":"26144","sender_country":"SE","sender_phone":"","sender_url":"","sender_reminder":"","fulladdress":"Zoolutions%20AB,
94
+ %C3%96sterv%C3%A5ngsplan%2015, Landskrona 26144, Sweden","optinmessageid":"0","optoutconf":"0","deletestamp":null,"listid":"1","p_admin":"1","p_list_add":"1","p_list_edit":"1","p_list_delete":"1","p_list_sync":"1","p_list_filter":"1","p_message_add":"1","p_message_edit":"1","p_message_delete":"1","p_message_send":"1","p_subscriber_add":"1","p_subscriber_edit":"1","p_subscriber_delete":"1","p_subscriber_import":"1","p_subscriber_approve":"1","luserid":"1","subscribers":"1","subscribers_active":"1","fields":[],"groups":{"3":{"id":"3","title":"Admin","descript":"This
95
+ is a group for admin users (people that can manage content)","unsubscribelink":"0","optinconfirm":"0","p_admin":"1","pg_list_add":"1","pg_list_edit":"1","pg_list_delete":"1","pg_list_headers":"1","pg_list_emailaccount":"1","pg_list_bounce":"1","pg_message_add":"1","pg_message_edit":"1","pg_message_delete":"1","pg_message_send":"1","pg_subscriber_add":"1","pg_subscriber_edit":"1","pg_subscriber_delete":"1","pg_subscriber_import":"1","pg_subscriber_approve":"1","pg_subscriber_export":"1","pg_subscriber_sync":"1","pg_subscriber_filters":"1","pg_subscriber_actions":"0","pg_subscriber_fields":"1","pg_user_add":"1","pg_user_edit":"1","pg_user_delete":"1","pg_group_add":"1","pg_group_edit":"1","pg_group_delete":"1","pg_template_add":"1","pg_template_edit":"1","pg_template_delete":"1","pg_personalization_add":"1","pg_personalization_edit":"1","pg_personalization_delete":"1","pg_form_edit":"1","pg_reports_campaign":"1","pg_reports_list":"1","pg_reports_user":"1","pg_reports_trend":"1","pg_startup_reports":"1","pg_startup_gettingstarted":"1","sdate":"2016-08-10
96
+ 20:15:54","req_approval":"0","req_approval_1st":"2","req_approval_notify":"","socialdata":"0","listid":"1","groupid":"3","p_list_add":"0","p_list_edit":"0","p_list_delete":"0","p_list_sync":"1","p_list_filter":"1","p_message_add":"1","p_message_edit":"1","p_message_delete":"1","p_message_send":"1","p_subscriber_add":"1","p_subscriber_edit":"1","p_subscriber_delete":"1","p_subscriber_import":"1","p_subscriber_approve":"1"},"1":{"id":"1","title":"Visitor","descript":"This
97
+ is a group for site visitors (people that are not logged in)","unsubscribelink":"0","optinconfirm":"0","p_admin":"0","pg_list_add":"0","pg_list_edit":"0","pg_list_delete":"0","pg_list_headers":"0","pg_list_emailaccount":"0","pg_list_bounce":"0","pg_message_add":"0","pg_message_edit":"0","pg_message_delete":"0","pg_message_send":"0","pg_subscriber_add":"0","pg_subscriber_edit":"0","pg_subscriber_delete":"0","pg_subscriber_import":"0","pg_subscriber_approve":"0","pg_subscriber_export":"0","pg_subscriber_sync":"0","pg_subscriber_filters":"0","pg_subscriber_actions":"0","pg_subscriber_fields":"0","pg_user_add":"0","pg_user_edit":"0","pg_user_delete":"0","pg_group_add":"0","pg_group_edit":"0","pg_group_delete":"0","pg_template_add":"0","pg_template_edit":"0","pg_template_delete":"0","pg_personalization_add":"0","pg_personalization_edit":"0","pg_personalization_delete":"0","pg_form_edit":"0","pg_reports_campaign":"0","pg_reports_list":"0","pg_reports_user":"0","pg_reports_trend":"0","pg_startup_reports":"0","pg_startup_gettingstarted":"0","sdate":"2016-08-10
98
+ 20:15:54","req_approval":"0","req_approval_1st":"2","req_approval_notify":"","socialdata":"0","listid":"1","groupid":"1","p_list_add":"0","p_list_edit":"0","p_list_delete":"0","p_list_sync":"0","p_list_filter":"0","p_message_add":"0","p_message_edit":"0","p_message_delete":"0","p_message_send":"0","p_subscriber_add":"0","p_subscriber_edit":"0","p_subscriber_delete":"0","p_subscriber_import":"0","p_subscriber_approve":"0"}},"groupsCnt":2,"bounces":[{"id":"1","userid":"1","type":"pipe","email":"bounce-289042@s11.avl3.acemsrvc.com","host":null,"port":"110","user":null,"pass":null,"method":"","limit_hard":"1","limit_soft":"3","emails_per_batch":"120"}],"analytics_domains_list":[],"facebook_oauth_logout_url":"","facebook_oauth_login_url":"https:\/\/www.facebook.com\/v2.6\/dialog\/oauth?client_id=118506481555093&redirect_uri=https%3A%2F%2Fzoolutions.api-us1.com%2Fadmin%2Fmain.php%3Faction%3Dlist%26formid%3D1&scope=publish_actions,manage_pages","facebook_oauth_me":null,"result_code":1,"result_message":"Success:
99
+ Something is returned","result_output":"json"}'
100
+ http_version:
101
+ recorded_at: Thu, 11 Aug 2016 08:19:05 GMT
102
+ recorded_with: VCR 3.0.3
@@ -11,7 +11,7 @@ describe ActiveCampaign::Client::Contacts, :vcr do
11
11
  'email' => 'mhenrixon@me.com',
12
12
  'first_name' => 'Mikael',
13
13
  'last_name' => 'Henriksson',
14
- 'p' => { 1 => 1 },
14
+ 'p' => { 1 => 7 },
15
15
  'status' => { 1 => 1 },
16
16
  'instantresponders' => { 1 => 1 },
17
17
  'ip4' => '127.0.0.1'
@@ -23,18 +23,28 @@ describe ActiveCampaign::Client::Contacts, :vcr do
23
23
  subject(:response) { @client.contact_sync params }
24
24
 
25
25
  it 'returns 1 for result_code' do
26
- expect(response.result_code).to eq 1
26
+ expect(response['result_code']).to eq 1
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '.contact_add' do
32
+ context 'when successful' do
33
+ subject(:response) { @client.contact_add params }
34
+
35
+ it 'returns 1 for result_code' do
36
+ expect(response['result_code']).to eq 1
27
37
  end
28
38
  end
29
39
  end
30
40
 
31
41
  describe '.contact_view' do
32
- let(:subscriber_id) { @client.contact_sync(params).subscriber_id }
42
+ let(:subscriber_id) { @client.contact_sync(params)['subscriber_id'] }
33
43
 
34
44
  it 'can find contact by id' do
35
45
  contact = @client.contact_view id: subscriber_id
36
- expect(contact.first_name).to eq 'Mikael'
37
- expect(contact.last_name).to eq 'Henriksson'
46
+ expect(contact['first_name']).to eq 'Mikael'
47
+ expect(contact['last_name']).to eq 'Henriksson'
38
48
  end
39
49
  end
40
50
  end
@@ -4,35 +4,43 @@ require 'spec_helper'
4
4
  describe ActiveCampaign::Client::Lists, :vcr do
5
5
  initialize_new_client
6
6
 
7
- # it "add a list", :vcr do
8
- # params = {
9
- # "id" => 1,
10
- # "email" => 'mhenrixon@me.com',
11
- # "name"=> 'Mikael',
12
- # "last_name" => 'Henriksson',
13
- # "p[1]" => 1,
14
- # "status[1]" => 1,
15
- # "instantresponders[1]" => 1,
16
- # "field[%BALANCE%,0]" => 100,
17
- # "ip4" => '127.0.0.1',
18
- # "status[2]" => 2,
19
- # "listid" => 1
20
- # }.stringify_keys
7
+ describe '.list_add' do
8
+ it 'add a list' do
9
+ params = {
10
+ 'name' => 'Swedish Players',
11
+ 'stringid' => 'swedish-players',
12
+ 'subscription_notify' => 'mikael@zoolutions.se',
13
+ 'unsubscription_notify' => 'mikael@zoolutions.se',
14
+ 'to_name' => 'Recipient',
15
+ 'carboncopy' => 'mikael@zoolutions.se',
16
+ 'sender_name' => 'Zoolutions%20AB',
17
+ 'sender_addr1' => '%C3%96sterv%C3%A5ngsplan%2015',
18
+ 'sender_city' => 'Landskrona',
19
+ 'sender_zip' => '26144',
20
+ 'sender_country' => 'Sweden',
21
+ 'p_use_captcha' => 0,
22
+ 'get_unsubscribe_reason' => 1,
23
+ 'send_last_broadcast' => 1,
24
+ 'require_name' => 1,
25
+ 'private' => 0
26
+ }
21
27
 
22
- # list = ActiveCampaign.list_add params
23
- # end
28
+ list = @client.list_add params
29
+ expect(list['id']).to be_a(Integer)
30
+ end
31
+ end
24
32
 
25
33
  describe '.list_view' do
26
34
  it 'can find lists by id' do
27
35
  list = @client.list_view id: 1
28
- expect(list.name).to eq 'players_sv'
36
+ expect(list['name']).to eq 'Swedish Players'
29
37
  end
30
38
  end
31
39
 
32
40
  describe '.list_list' do
33
41
  it 'can find a list of lists' do
34
42
  lists = @client.list_list 'ids' => 'all'
35
- expect(lists.results[0].name).to eq 'players_sv'
43
+ expect(lists['results'][0]['name']).to eq 'Swedish Players'
36
44
  end
37
45
  end
38
46
  end
@@ -2,6 +2,5 @@ require 'spec_helper'
2
2
 
3
3
  module ActiveCampaign
4
4
  describe Client do
5
-
6
5
  end
7
6
  end
@@ -50,11 +50,11 @@ describe ActiveCampaign do
50
50
 
51
51
  describe '.configure' do
52
52
  ActiveCampaign.config.to_h.keys.each do |key|
53
- it "sets the #{key.to_s.gsub('_', ' ')}" do
53
+ it "sets the #{key.to_s.tr('_', ' ')}" do
54
54
  ActiveCampaign.configure do |config|
55
55
  config.send("#{key}=", key)
56
56
  end
57
- expect(ActiveCampaign.configuration[key]).to eq key
57
+ expect(ActiveCampaign.config.send(key)).to eq key
58
58
  end
59
59
  end
60
60
  end
@@ -1,8 +1,13 @@
1
- require_relative 'support/coverage'
1
+ require 'simplecov'
2
2
 
3
3
  require 'pry'
4
4
  require 'rspec'
5
5
  require 'active_campaign'
6
+ require_relative 'support/webmock'
7
+ require_relative 'support/vcr'
8
+
9
+ TEST_API_ENDPOINT ||= 'https://zoolutions.api-us1.com/admin/api.php'.freeze
10
+ TEST_API_KEY ||= '1b85f597c38b74fc842a04efe00f10d547a839487dcb05e2c639e92c450d53a366d96f84'.freeze
6
11
 
7
12
  RSpec.configure do |config|
8
13
  config.filter_run focus: true
@@ -13,29 +18,22 @@ RSpec.configure do |config|
13
18
  end
14
19
 
15
20
  config.before(:suite) do
16
- HTTPI.log = false
21
+ HTTPI.log = false
22
+ HTTPI.logger = nil
17
23
  HTTPI.log_level = :fatal
18
24
  end
19
25
  end
20
26
 
21
- def test_api_endpoint
22
- ENV.fetch 'ACTIVE_CAMPAIGN_API_ENDPOINT'
23
- end
24
-
25
- def test_api_key
26
- ENV.fetch 'ACTIVE_CAMPAIGN_API_KEY'
27
- end
28
-
29
- def initialize_new_client
27
+ def initialize_new_client # rubocop:disable MethodLength
30
28
  before do
31
29
  @client = ActiveCampaign::Client.new(
32
- api_endpoint: test_api_endpoint,
33
- api_key: test_api_key,
30
+ api_endpoint: TEST_API_ENDPOINT,
31
+ api_key: TEST_API_KEY,
34
32
  api_output: 'json',
35
33
  debug: false,
36
34
  log_level: :fatal,
37
35
  log: false,
38
- mash: true
36
+ mash: false
39
37
  )
40
38
  end
41
39
  end
@@ -1,9 +1,13 @@
1
- require 'simplecov'
1
+ require 'simplecov-json'
2
2
  require 'coveralls'
3
3
  Coveralls.wear!
4
4
 
5
5
  require 'codeclimate-test-reporter'
6
- formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
6
+ formatters = [
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ SimpleCov::Formatter::JSONFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
7
11
 
8
12
  if ENV['CODECLIMATE_REPO_TOKEN']
9
13
  formatters << CodeClimate::TestReporter::Formatter