active_campaign 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -3
- data/.travis.yml +15 -7
- data/Gemfile +3 -2
- data/README.md +1 -1
- data/active_campaign.gemspec +0 -2
- data/lib/active_campaign.rb +16 -8
- data/lib/active_campaign/client.rb +11 -15
- data/lib/active_campaign/client/campaigns.rb +7 -7
- data/lib/active_campaign/client/contacts.rb +9 -11
- data/lib/active_campaign/client/deals.rb +7 -7
- data/lib/active_campaign/client/forms.rb +5 -5
- data/lib/active_campaign/client/groups.rb +7 -7
- data/lib/active_campaign/client/lists.rb +12 -10
- data/lib/active_campaign/client/messages.rb +7 -7
- data/lib/active_campaign/client/tracks.rb +8 -12
- data/lib/active_campaign/client/users.rb +6 -11
- data/lib/active_campaign/configuration.rb +44 -24
- data/lib/active_campaign/core_ext.rb +53 -0
- data/lib/active_campaign/version.rb +1 -1
- data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_add/when_successful/returns_1_for_result_code.yml +96 -0
- data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.yml +96 -0
- data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.yml +150 -0
- data/spec/cassettes/ActiveCampaign_Client_Lists/_list_add/add_a_list.yml +48 -0
- data/spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.yml +106 -0
- data/spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.yml +102 -0
- data/spec/lib/active_campaign/client/contacts_spec.rb +15 -5
- data/spec/lib/active_campaign/client/lists_spec.rb +26 -18
- data/spec/lib/active_campaign/client_spec.rb +0 -1
- data/spec/lib/active_campaign_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -14
- data/spec/support/coverage.rb +6 -2
- data/spec/support/vcr.rb +7 -5
- metadata +15 -40
- data/circle.yml +0 -15
- data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_sync/when_successful/returns_1_for_result_code.json +0 -1
- data/spec/cassettes/ActiveCampaign_Client_Contacts/_contact_view/can_find_contact_by_id.json +0 -1
- data/spec/cassettes/ActiveCampaign_Client_Lists/_list_list/can_find_a_list_of_lists.json +0 -1
- data/spec/cassettes/ActiveCampaign_Client_Lists/_list_view/can_find_lists_by_id.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f959a6cbb68c5711716a5039eaacce4d89e8858d
|
4
|
+
data.tar.gz: 5661a144faa672e737d400d37c8b46dccebf9249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492bfc8ce519fa91f47a2a86776a0d5611cba71405fa0a6d8a381b9cbbf63ae20be3b750f95a54b7409d0ebd1cf752e1b64a75ca789fa04539009b1a48a9dc17
|
7
|
+
data.tar.gz: 77e704860971e8ee2fc591fc3288a8144ce03dfbb501657eaa0e90c03d663fd9daba04afd313576f7b65516a5d7c217274119d67cf29d3d951ec091631f2fafc
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
before_install:
|
5
|
+
- rvm get head
|
6
|
+
- gem update --system
|
7
|
+
- gem install bundler
|
2
8
|
|
3
9
|
language: ruby
|
4
10
|
|
5
11
|
rvm:
|
6
12
|
- jruby-19mode
|
7
|
-
- rbx-
|
8
|
-
- 1.
|
9
|
-
-
|
10
|
-
- 2.
|
11
|
-
|
12
|
-
|
13
|
+
- rbx-3
|
14
|
+
- 2.1.8
|
15
|
+
- 2.2.4
|
16
|
+
- 2.3.1
|
17
|
+
|
18
|
+
addons:
|
19
|
+
code_climate:
|
20
|
+
repo_token: e199bdc9d2cf5ceaa7e46425f118470e43880940098f815a4c972a923102b12b
|
data/Gemfile
CHANGED
@@ -5,12 +5,13 @@ gem 'rubysl', '~> 2', platform: :rbx
|
|
5
5
|
|
6
6
|
group :test do
|
7
7
|
gem 'pry'
|
8
|
-
gem 'simplecov'
|
8
|
+
gem 'simplecov'
|
9
|
+
gem 'simplecov-json'
|
9
10
|
gem 'rubinius-coverage', platform: :rbx
|
10
11
|
gem 'codeclimate-test-reporter', require: false
|
11
12
|
gem 'coveralls', require: false
|
12
13
|
gem 'rb-fsevent'
|
13
|
-
gem 'rspec', '
|
14
|
+
gem 'rspec', '>= 3.2'
|
14
15
|
gem 'vcr'
|
15
16
|
gem 'webmock'
|
16
17
|
gem 'rubocop'
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ client = ::ActiveCampaign::Client.new(
|
|
33
33
|
# or configure globally for all clients
|
34
34
|
::ActiveCampaign.configure do |config|
|
35
35
|
config.api_endpoint = 'YOUR-ENDPOINT', # e.g. 'https://yourendpoint.api-us1.com'
|
36
|
-
config.api_key = 'YOUR-API-KEY'
|
36
|
+
config.api_key = 'YOUR-API-KEY' # e.g. 'a4e60a1ba200595d5cc37ede5732545184165e'
|
37
37
|
end
|
38
38
|
|
39
39
|
```
|
data/active_campaign.gemspec
CHANGED
data/lib/active_campaign.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
require 'active_support/core_ext'
|
3
|
-
require 'active_support/core_ext/module/delegation'
|
4
1
|
require 'active_campaign/version'
|
5
2
|
require 'active_campaign/client'
|
6
3
|
require 'active_campaign/configuration'
|
4
|
+
require 'active_campaign/core_ext'
|
7
5
|
|
8
6
|
module ActiveCampaign
|
9
|
-
extend Configuration
|
10
|
-
|
11
7
|
module_function
|
12
8
|
|
13
9
|
# API client based on configured options {Configurable}
|
14
10
|
#
|
15
11
|
# @return [ActiveCampaign::Client] API wrapper
|
16
12
|
def client
|
17
|
-
unless defined?(@client) && @client.same_options?(
|
18
|
-
@client = ActiveCampaign::Client.new(
|
13
|
+
unless defined?(@client) && @client.same_options?(config)
|
14
|
+
@client = ActiveCampaign::Client.new(config)
|
19
15
|
end
|
20
16
|
|
21
17
|
@client
|
@@ -24,13 +20,25 @@ module ActiveCampaign
|
|
24
20
|
# @private
|
25
21
|
def respond_to_missing?(method_name, include_private = false)
|
26
22
|
client.respond_to?(method_name, include_private)
|
27
|
-
end
|
23
|
+
end
|
28
24
|
|
29
25
|
# @private
|
30
26
|
def respond_to?(method_name, include_private = false)
|
31
27
|
client.respond_to?(method_name, include_private) || super
|
32
28
|
end if RUBY_VERSION < '1.9'
|
33
29
|
|
30
|
+
def config
|
31
|
+
@config ||= Configuration.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def configure
|
35
|
+
yield config if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
def reset!
|
39
|
+
@config = Configuration.new
|
40
|
+
end
|
41
|
+
|
34
42
|
private
|
35
43
|
|
36
44
|
def method_missing(method_name, *args, &block)
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'httpi'
|
2
|
-
require 'hashie'
|
3
|
-
|
4
2
|
require 'active_campaign/method_creator'
|
5
3
|
|
6
4
|
require 'active_campaign/client/campaigns'
|
@@ -17,6 +15,7 @@ module ActiveCampaign
|
|
17
15
|
class Client
|
18
16
|
include Comparable
|
19
17
|
extend ActiveCampaign::MethodCreator
|
18
|
+
extend Forwardable
|
20
19
|
|
21
20
|
include ActiveCampaign::Client::Campaigns
|
22
21
|
include ActiveCampaign::Client::Contacts
|
@@ -28,14 +27,11 @@ module ActiveCampaign
|
|
28
27
|
include ActiveCampaign::Client::Tracks
|
29
28
|
include ActiveCampaign::Client::Users
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
attr_accessor :config
|
30
|
+
def_delegators :@config, :api_key, :api_output, :api_endpoint,
|
31
|
+
:user_agent, :log, :log_level, :logger, :mash, :debug
|
35
32
|
|
36
|
-
def initialize(
|
37
|
-
|
38
|
-
self.config ||= ActiveCampaign.configuration
|
33
|
+
def initialize(options = {})
|
34
|
+
@config ||= ActiveCampaign.config.merge(options)
|
39
35
|
end
|
40
36
|
|
41
37
|
# Compares client options to a Hash of requested options
|
@@ -43,7 +39,7 @@ module ActiveCampaign
|
|
43
39
|
# @param opts [Hash] Options to compare with current client options
|
44
40
|
# @return [Boolean]
|
45
41
|
def same_options?(other_config)
|
46
|
-
config.to_h.sort == other_config.to_h.sort
|
42
|
+
@config.to_h.sort == other_config.to_h.sort
|
47
43
|
end
|
48
44
|
|
49
45
|
# Make a HTTP GET request
|
@@ -56,12 +52,12 @@ module ActiveCampaign
|
|
56
52
|
end
|
57
53
|
|
58
54
|
def hash
|
59
|
-
[config, Client].hash
|
55
|
+
[@config, Client].hash
|
60
56
|
end
|
61
57
|
|
62
58
|
def <=>(other)
|
63
59
|
other.is_a?(ActiveCampaign::Client) &&
|
64
|
-
config.to_h.sort <=> other.config.to_h.sort
|
60
|
+
@config.to_h.sort <=> other.config.to_h.sort
|
65
61
|
end
|
66
62
|
|
67
63
|
# Make a HTTP POST request
|
@@ -79,6 +75,7 @@ module ActiveCampaign
|
|
79
75
|
req = create_request method, api_method, data
|
80
76
|
response = HTTPI.send(method, req)
|
81
77
|
response = JSON.parse(response.body)
|
78
|
+
|
82
79
|
normalize(response)
|
83
80
|
end
|
84
81
|
|
@@ -119,12 +116,11 @@ module ActiveCampaign
|
|
119
116
|
def normalize(response)
|
120
117
|
keys, values = keys_values(response)
|
121
118
|
if keys.all? { |key| numeric?(key) }
|
122
|
-
response[
|
119
|
+
response['results'] = values
|
123
120
|
keys.each { |key| response.delete(key) }
|
124
121
|
end
|
125
122
|
|
126
|
-
|
127
|
-
ActiveSupport::HashWithIndifferentAccess.new(response)
|
123
|
+
response
|
128
124
|
end
|
129
125
|
|
130
126
|
def numeric?(string)
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Campaigns
|
4
|
-
GET_METHODS
|
4
|
+
GET_METHODS ||= %w(
|
5
5
|
create delete_list delete list paginator report_bounce_list
|
6
6
|
report_bounce_totals report_forward_list report_forward_totals
|
7
7
|
report_link_list report_link_totals report_open_list report_open_totals
|
8
8
|
report_totals report_unopen_list report_unsubscription_list
|
9
9
|
report_unsubscription_totals send status
|
10
|
-
).freeze
|
11
|
-
POST_METHODS
|
12
|
-
|
13
|
-
extend ActiveSupport::Concern
|
10
|
+
).freeze
|
11
|
+
POST_METHODS ||= %w(create).freeze
|
14
12
|
|
15
13
|
# TODO: Create proper methods with parameter validation and possible
|
16
14
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
17
|
-
included
|
18
|
-
|
15
|
+
def self.included(base)
|
16
|
+
base.class_exec do
|
17
|
+
define_api_calls(:campaign, GET_METHODS, POST_METHODS)
|
18
|
+
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,25 +1,23 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
|
3
1
|
module ActiveCampaign
|
4
2
|
class Client
|
5
3
|
module Contacts
|
6
|
-
GET_METHODS
|
4
|
+
GET_METHODS ||= %w(
|
7
5
|
automation_list delete_list delete list paginator view view_email
|
8
6
|
view_hash note_delete
|
9
|
-
).freeze
|
7
|
+
).freeze
|
10
8
|
|
11
|
-
POST_METHODS
|
9
|
+
POST_METHODS ||= %w(
|
12
10
|
add edit sync tag_add tag_remove
|
13
11
|
note_edit note_add
|
14
|
-
).freeze
|
15
|
-
|
16
|
-
extend ActiveSupport::Concern
|
12
|
+
).freeze
|
17
13
|
|
18
14
|
# TODO: Create proper methods with parameter validation and possible naming
|
19
15
|
# fixes since this is one the worst APIs I have ever worked with.
|
20
|
-
included
|
21
|
-
|
22
|
-
|
16
|
+
def self.included(base)
|
17
|
+
base.class_exec do
|
18
|
+
%w(contact subscriber).each do |name|
|
19
|
+
define_api_calls(name, GET_METHODS, POST_METHODS)
|
20
|
+
end
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Deals
|
4
|
-
GET_METHODS
|
4
|
+
GET_METHODS ||= %w(get list pipeline_list stage_list).freeze
|
5
5
|
|
6
|
-
POST_METHODS
|
6
|
+
POST_METHODS ||= %w(
|
7
7
|
add delete edit note_add note_edit pipeline_add pipeline_delete
|
8
8
|
pipeline_edit stage_add stage_delete stage_edit task_add task_edit
|
9
9
|
tasktype_add tasktype_delete tasktype_edit
|
10
|
-
).freeze
|
11
|
-
|
12
|
-
extend ActiveSupport::Concern
|
10
|
+
).freeze
|
13
11
|
|
14
12
|
# TODO: Create proper methods with parameter validation and possible
|
15
13
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
16
|
-
included
|
17
|
-
|
14
|
+
def self.included(base)
|
15
|
+
base.class_exec do
|
16
|
+
define_api_calls(:deal, GET_METHODS, POST_METHODS)
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Forms
|
4
|
-
GET_METHODS
|
5
|
-
|
6
|
-
extend ActiveSupport::Concern
|
4
|
+
GET_METHODS ||= %w(getforms html).freeze
|
7
5
|
|
8
6
|
# TODO: Create proper methods with parameter validation and possible
|
9
7
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
10
|
-
included
|
11
|
-
|
8
|
+
def self.included(base)
|
9
|
+
base.class_exec do
|
10
|
+
define_api_calls(:form, GET_METHODS)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Groups
|
4
|
-
GET_METHODS
|
4
|
+
GET_METHODS ||= %w(
|
5
5
|
delete delete_list list view
|
6
|
-
).freeze
|
6
|
+
).freeze
|
7
7
|
|
8
|
-
POST_METHODS
|
9
|
-
|
10
|
-
extend ActiveSupport::Concern
|
8
|
+
POST_METHODS ||= %w(add edit).freeze
|
11
9
|
|
12
10
|
# TODO: Create proper methods with parameter validation and possible
|
13
11
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
14
|
-
included
|
15
|
-
|
12
|
+
def self.included(base)
|
13
|
+
base.class_exec do
|
14
|
+
define_api_calls(:group, GET_METHODS, POST_METHODS)
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Lists
|
4
|
-
GET_METHODS
|
5
|
-
delete_list delete
|
6
|
-
|
7
|
-
).freeze
|
8
|
-
POST_METHODS
|
9
|
-
|
4
|
+
GET_METHODS ||= %w(
|
5
|
+
delete_list delete field_delete
|
6
|
+
field_view list paginator view
|
7
|
+
).freeze
|
8
|
+
POST_METHODS ||= %w(
|
9
|
+
add edit field_add field_edit
|
10
|
+
).freeze
|
11
|
+
DELETE_METHODS ||= [].freeze
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def self.included(base)
|
14
|
+
base.class_exec do
|
15
|
+
define_api_calls(:list, GET_METHODS, POST_METHODS, DELETE_METHODS)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Messages
|
4
|
-
GET_METHODS
|
4
|
+
GET_METHODS ||= %w(
|
5
5
|
delete_list delete list template_add template_delete_list
|
6
6
|
template_delete template_edit template_export template_import
|
7
7
|
template_list template_view view
|
8
|
-
).freeze
|
8
|
+
).freeze
|
9
9
|
|
10
|
-
POST_METHODS
|
11
|
-
|
12
|
-
extend ActiveSupport::Concern
|
10
|
+
POST_METHODS ||= %w(add edit).freeze
|
13
11
|
|
14
12
|
# TODO: Create proper methods with parameter validation and possible
|
15
13
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
16
|
-
included
|
17
|
-
|
14
|
+
def self.included(base)
|
15
|
+
base.class_exec do
|
16
|
+
define_api_calls(:message, GET_METHODS, POST_METHODS)
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
module ActiveCampaign
|
2
2
|
class Client
|
3
3
|
module Tracks
|
4
|
-
GET_METHODS
|
5
|
-
PUT_METHODS
|
6
|
-
POST_METHODS
|
7
|
-
|
8
|
-
).freeze unless defined?(POST_METHODS)
|
9
|
-
DELETE_METHODS = %w(
|
10
|
-
event_delete site_whitelist_delete
|
11
|
-
).freeze unless defined?(DELETE_METHODS)
|
12
|
-
|
13
|
-
extend ActiveSupport::Concern
|
4
|
+
GET_METHODS ||= %w(event_list site_list).freeze
|
5
|
+
PUT_METHODS ||= %w(site_whitelist_add).freeze
|
6
|
+
POST_METHODS ||= %w(event_status_edit site_status_edit event_add).freeze
|
7
|
+
DELETE_METHODS ||= %w(event_delete site_whitelist_delete).freeze
|
14
8
|
|
15
9
|
# TODO: Create proper methods with parameter validation and possible
|
16
10
|
# naming fixes since this is one the worst APIs I have ever worked with.
|
17
|
-
included
|
18
|
-
|
11
|
+
def self.included(base)
|
12
|
+
base.class_exec do
|
13
|
+
define_api_calls(:track, GET_METHODS, POST_METHODS, DELETE_METHODS, PUT_METHODS)
|
14
|
+
end
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|