active_campaign 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +25 -3
- data/.rubocop.yml +21 -9
- data/.simplecov +9 -0
- data/.travis.yml +32 -12
- data/Changelog.md +14 -3
- data/Gemfile +2 -19
- data/README.md +13 -3
- data/Rakefile +4 -2
- data/active_campaign.gemspec +16 -3
- data/lib/active_campaign.rb +13 -15
- data/lib/active_campaign/client.rb +32 -29
- data/lib/active_campaign/client/campaigns.rb +86 -15
- data/lib/active_campaign/client/contacts.rb +90 -18
- data/lib/active_campaign/client/deals.rb +80 -14
- data/lib/active_campaign/client/forms.rb +7 -7
- data/lib/active_campaign/client/groups.rb +22 -10
- data/lib/active_campaign/client/lists.rb +52 -13
- data/lib/active_campaign/client/messages.rb +62 -14
- data/lib/active_campaign/client/tracks.rb +48 -11
- data/lib/active_campaign/client/users.rb +44 -9
- data/lib/active_campaign/configuration.rb +38 -13
- data/lib/active_campaign/core_ext.rb +8 -3
- data/lib/active_campaign/version.rb +3 -1
- data/spec/lib/active_campaign/client/contacts_spec.rb +2 -1
- data/spec/lib/active_campaign/client/lists_spec.rb +2 -1
- data/spec/lib/active_campaign/client_spec.rb +8 -0
- data/spec/lib/active_campaign_spec.rb +15 -20
- data/spec/spec_helper.rb +6 -5
- data/spec/support/vcr.rb +2 -0
- data/spec/support/webmock.rb +2 -0
- metadata +175 -13
- data/.coveralls.yml +0 -1
- data/lib/active_campaign/method_creator.rb +0 -32
- data/spec/support/coverage.rb +0 -18
@@ -1,20 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveCampaign
|
2
4
|
class Client
|
3
5
|
module Messages
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
#
|
7
|
+
# POST methods
|
8
|
+
#
|
9
|
+
def message_add(options = {})
|
10
|
+
post __method__, options
|
11
|
+
end
|
12
|
+
|
13
|
+
def message_edit(options = {})
|
14
|
+
post __method__, options
|
15
|
+
end
|
16
|
+
|
17
|
+
def message_template_edit(options = {})
|
18
|
+
post __method__, options
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# GET methods
|
23
|
+
#
|
24
|
+
def message_delete_list(options = {})
|
25
|
+
get(__method__, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def message_delete(options = {})
|
29
|
+
get(__method__, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def message_list(options = {})
|
33
|
+
get(__method__, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def message_template_add(options = {})
|
37
|
+
get(__method__, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def message_template_delete_list(options = {})
|
41
|
+
get(__method__, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def message_template_delete(options = {})
|
45
|
+
get(__method__, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def message_template_export(options = {})
|
49
|
+
get(__method__, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def message_template_import(options = {})
|
53
|
+
get(__method__, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def message_template_list(options = {})
|
57
|
+
get(__method__, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
def message_template_view(options = {})
|
61
|
+
get(__method__, options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def message_view(options = {})
|
65
|
+
get(__method__, options)
|
18
66
|
end
|
19
67
|
end
|
20
68
|
end
|
@@ -1,17 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveCampaign
|
2
4
|
class Client
|
3
5
|
module Tracks
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
#
|
7
|
+
# POST methods
|
8
|
+
#
|
9
|
+
|
10
|
+
def track_event_status_edit(options = {})
|
11
|
+
post __method__, options
|
12
|
+
end
|
13
|
+
|
14
|
+
def track_site_status_edit(options = {})
|
15
|
+
post __method__, options
|
16
|
+
end
|
17
|
+
|
18
|
+
def track_event_add(options = {})
|
19
|
+
post __method__, options
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# PUT methods
|
24
|
+
#
|
25
|
+
|
26
|
+
def track_site_whitelist_add(options = {})
|
27
|
+
put __method__, options
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# GET methods
|
32
|
+
#
|
33
|
+
|
34
|
+
def track_event_list(options = {})
|
35
|
+
get __method__, options
|
36
|
+
end
|
37
|
+
|
38
|
+
def track_site_list(options = {})
|
39
|
+
get __method__, options
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# DELETE methods
|
44
|
+
#
|
45
|
+
|
46
|
+
def track_event_delete(options = {})
|
47
|
+
delete __method__, options
|
48
|
+
end
|
49
|
+
|
50
|
+
def track_site_whitelist_delete(options = {})
|
51
|
+
delete __method__, options
|
15
52
|
end
|
16
53
|
end
|
17
54
|
end
|
@@ -1,15 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveCampaign
|
2
4
|
class Client
|
3
5
|
module Users
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
#
|
7
|
+
# POST methods
|
8
|
+
#
|
9
|
+
|
10
|
+
def user_add(options = {})
|
11
|
+
post __method__, options
|
12
|
+
end
|
13
|
+
|
14
|
+
def user_edit(options = {})
|
15
|
+
post __method__, options
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# GET methods
|
20
|
+
#
|
21
|
+
|
22
|
+
def user_delete(options = {})
|
23
|
+
get __method__, options
|
24
|
+
end
|
25
|
+
|
26
|
+
def user_delete_list(options = {})
|
27
|
+
get __method__, options
|
28
|
+
end
|
29
|
+
|
30
|
+
def user_list(options = {})
|
31
|
+
get __method__, options
|
32
|
+
end
|
33
|
+
|
34
|
+
def user_me(options = {})
|
35
|
+
get __method__, options
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_view(options = {})
|
39
|
+
get __method__, options
|
40
|
+
end
|
41
|
+
|
42
|
+
def user_view_email(options = {})
|
43
|
+
get __method__, options
|
44
|
+
end
|
45
|
+
|
46
|
+
def user_view_username(options = {})
|
47
|
+
get __method__, options
|
13
48
|
end
|
14
49
|
end
|
15
50
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveCampaign
|
2
4
|
class Configuration
|
3
|
-
API_ENDPOINT ||= 'https://subdomain.activehosted.com/admin/api.php'
|
4
|
-
USER_AGENT ||= "ActiveCampaign Ruby Gem #{ActiveCampaign::VERSION}"
|
5
|
-
API_OUTPUT ||= 'json'
|
5
|
+
API_ENDPOINT ||= 'https://subdomain.activehosted.com/admin/api.php'
|
6
|
+
USER_AGENT ||= "ActiveCampaign Ruby Gem #{ActiveCampaign::VERSION}"
|
7
|
+
API_OUTPUT ||= 'json'
|
6
8
|
|
7
9
|
attr_accessor :api_key, :api_endpoint, :api_output, :user_agent,
|
8
10
|
:log, :logger, :log_level, :mash, :debug
|
@@ -15,11 +17,10 @@ module ActiveCampaign
|
|
15
17
|
@log = false
|
16
18
|
@logger = nil
|
17
19
|
@log_level = :info
|
18
|
-
@mash = false
|
19
20
|
@debug = false
|
20
21
|
end
|
21
22
|
|
22
|
-
def to_h
|
23
|
+
def to_h
|
23
24
|
{
|
24
25
|
api_key: api_key,
|
25
26
|
api_endpoint: api_endpoint,
|
@@ -28,7 +29,6 @@ module ActiveCampaign
|
|
28
29
|
log: log,
|
29
30
|
logger: logger,
|
30
31
|
log_level: log_level,
|
31
|
-
mash: mash,
|
32
32
|
debug: debug
|
33
33
|
}
|
34
34
|
end
|
@@ -40,16 +40,41 @@ module ActiveCampaign
|
|
40
40
|
self
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def ==(other)
|
44
|
+
other.is_a?(ActiveCampaign::Configuration) &&
|
45
|
+
all_api_info_equal &&
|
46
|
+
user_agent == other.user_agent &&
|
47
|
+
all_log_info_equal &&
|
48
|
+
debug == other.debug
|
49
|
+
end
|
50
|
+
alias eql? ==
|
51
|
+
|
52
|
+
def hash
|
53
|
+
[
|
54
|
+
api_key,
|
55
|
+
api_endpoint,
|
56
|
+
api_output,
|
57
|
+
user_agent,
|
58
|
+
log,
|
59
|
+
logger,
|
60
|
+
log_level,
|
61
|
+
debug,
|
62
|
+
ActiveCampaign::Configuration
|
63
|
+
].hash
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def all_api_info_equal
|
44
69
|
api_key == other.api_key &&
|
45
70
|
api_endpoint == other.api_endpoint &&
|
46
|
-
api_output == other.api_output
|
47
|
-
|
48
|
-
|
71
|
+
api_output == other.api_output
|
72
|
+
end
|
73
|
+
|
74
|
+
def all_log_info_equal
|
75
|
+
log == other.log &&
|
49
76
|
logger == other.logger &&
|
50
|
-
log_level == other.log_level
|
51
|
-
mash == other.mash &&
|
52
|
-
debug == other.debug
|
77
|
+
log_level == other.log_level
|
53
78
|
end
|
54
79
|
end
|
55
80
|
end
|
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Hash
|
4
|
+
# unless respo?(:to_query)
|
2
5
|
def to_query(namespace = nil)
|
3
6
|
collect do |key, value|
|
4
7
|
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
5
8
|
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
6
9
|
end
|
7
10
|
end.compact.sort! * '&'
|
8
|
-
end
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
class Array
|
@@ -13,6 +16,7 @@ class Array
|
|
13
16
|
collect(&:to_param).join '/'
|
14
17
|
end
|
15
18
|
|
19
|
+
# unless respo?(:to_query)
|
16
20
|
def to_query(key)
|
17
21
|
prefix = "#{key}[]"
|
18
22
|
|
@@ -21,13 +25,14 @@ class Array
|
|
21
25
|
else
|
22
26
|
collect { |value| value.to_query(prefix) }.join '&'
|
23
27
|
end
|
24
|
-
end
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
class Object
|
32
|
+
# unless respo?(:to_query)
|
28
33
|
def to_query(key)
|
29
34
|
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
30
|
-
end
|
35
|
+
end
|
31
36
|
|
32
37
|
def to_param
|
33
38
|
to_s
|
@@ -1,6 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module ActiveCampaign
|
4
6
|
describe Client do
|
7
|
+
describe '.new' do
|
8
|
+
subject(:client) { described_class.new(api_key: 'testing') }
|
9
|
+
let(:client_two) { described_class.new(api_key: 'somekey') }
|
10
|
+
|
11
|
+
it { is_expected.not_to eq(client_two) }
|
12
|
+
end
|
5
13
|
end
|
6
14
|
end
|
@@ -1,18 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ActiveCampaign do
|
4
6
|
# rubocop:disable LineLength
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
unless defined?(API_CALLS)
|
8
|
+
API_CALLS = %w[
|
9
|
+
campaign_create campaign_delete campaign_delete_list campaign_list campaign_paginator campaign_report_bounce_list campaign_report_bounce_totals campaign_report_forward_list campaign_report_forward_totals campaign_report_link_list campaign_report_link_totals campaign_report_open_list campaign_report_open_totals campaign_report_totals campaign_report_unopen_list campaign_report_unsubscription_list campaign_report_unsubscription_totals campaign_send campaign_status
|
10
|
+
contact_add contact_automation_list contact_delete contact_delete_list contact_edit contact_list contact_note_add contact_note_delete contact_note_edit contact_paginator contact_sync contact_tag_add contact_tag_remove contact_view contact_view_email contact_view_hash
|
11
|
+
deal_add deal_delete deal_edit deal_get deal_list deal_note_add deal_note_edit deal_pipeline_add deal_pipeline_delete deal_pipeline_edit deal_pipeline_list deal_stage_add deal_stage_delete deal_stage_edit deal_stage_list deal_task_add deal_task_edit deal_tasktype_add deal_tasktype_delete deal_tasktype_edit
|
12
|
+
form_getforms form_html
|
13
|
+
group_add group_delete group_delete_list group_edit group_list group_view
|
14
|
+
list_add list_delete list_delete_list list_edit list_field_add list_field_delete list_field_edit list_field_view list_list list_paginator list_view
|
15
|
+
message_add message_delete message_delete_list message_edit message_list message_template_add message_template_delete message_template_delete_list message_template_edit message_template_export message_template_import message_template_list message_template_view message_view
|
16
|
+
user_add user_delete user_delete_list user_edit user_list user_me user_view user_view_email user_view_username
|
17
|
+
track_event_delete track_event_list track_event_status_edit track_site_list track_site_status_edit track_site_whitelist_add track_site_whitelist_delete track_event_add
|
18
|
+
].freeze
|
19
|
+
end
|
16
20
|
# rubocop:enable LineLength
|
17
21
|
|
18
22
|
before do
|
@@ -37,15 +41,6 @@ describe ActiveCampaign do
|
|
37
41
|
it 'caches the client when the same options are passed' do
|
38
42
|
expect(ActiveCampaign.client).to eq ActiveCampaign.client
|
39
43
|
end
|
40
|
-
|
41
|
-
it 'returns a fresh client when options are not the same' do
|
42
|
-
client = ActiveCampaign.client
|
43
|
-
ActiveCampaign.config.api_key = 'somekey'
|
44
|
-
client_two = ActiveCampaign.client
|
45
|
-
client_three = ActiveCampaign.client
|
46
|
-
expect(client_three).to eql client_two
|
47
|
-
expect(client).to_not eql client_two
|
48
|
-
end
|
49
44
|
end
|
50
45
|
|
51
46
|
describe '.configure' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'simplecov'
|
2
4
|
|
3
5
|
require 'pry'
|
@@ -6,8 +8,8 @@ require 'active_campaign'
|
|
6
8
|
require_relative 'support/webmock'
|
7
9
|
require_relative 'support/vcr'
|
8
10
|
|
9
|
-
TEST_API_ENDPOINT ||= 'https://zoolutions.api-us1.com/admin/api.php'
|
10
|
-
TEST_API_KEY ||= '1b85f597c38b74fc842a04efe00f10d547a839487dcb05e2c639e92c450d53a366d96f84'
|
11
|
+
TEST_API_ENDPOINT ||= 'https://zoolutions.api-us1.com/admin/api.php'
|
12
|
+
TEST_API_KEY ||= '1b85f597c38b74fc842a04efe00f10d547a839487dcb05e2c639e92c450d53a366d96f84'
|
11
13
|
|
12
14
|
RSpec.configure do |config|
|
13
15
|
config.filter_run focus: true
|
@@ -24,7 +26,7 @@ RSpec.configure do |config|
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
def initialize_new_client
|
29
|
+
def initialize_new_client
|
28
30
|
before do
|
29
31
|
@client = ActiveCampaign::Client.new(
|
30
32
|
api_endpoint: TEST_API_ENDPOINT,
|
@@ -32,8 +34,7 @@ def initialize_new_client # rubocop:disable MethodLength
|
|
32
34
|
api_output: 'json',
|
33
35
|
debug: false,
|
34
36
|
log_level: :fatal,
|
35
|
-
log: false
|
36
|
-
mash: false
|
37
|
+
log: false
|
37
38
|
)
|
38
39
|
end
|
39
40
|
end
|