active-campaign-rails 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/active-campaign-rails.gemspec +2 -0
- data/lib/active-campaign-rails.rb +30 -9
- data/lib/active-campaign-rails/client.rb +166 -162
- data/lib/active-campaign-rails/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6860716d43937203ea659333cd7ec527df29294f
|
4
|
+
data.tar.gz: 0de4fbd20d3da3a8164df71c820320369e8b4174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcd43cfdf6a397462d00cc77b4e961c14e0094efd0fb05b3b3ab758f1741851f0a69adcda40c02a978ca404d06c645e343ddcc3e260a97d94589789630b45013
|
7
|
+
data.tar.gz: eb27c18dcde283860dc4b9814f363eb283e41711344ac34e240f37d5e01b15795ec59d2ac79ae056223d4f364d924d1ff3a5e8b5c628b939c90cf7054cbe4243
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Simple gem for ActiveCampaign API wrapper
|
|
4
4
|
|
5
5
|
[![Build Status](https://semaphoreci.com/api/v1/ekyfauzi/active-campaign-rails/branches/master/badge.svg)](https://semaphoreci.com/ekyfauzi/active-campaign-rails)
|
6
6
|
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/active-campaign-rails.svg)](https://badge.fury.io/rb/active-campaign-rails)
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "rest-client"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
spec.add_development_dependency "rspec", "~> 0"
|
@@ -4,7 +4,7 @@ require "active-campaign-rails/client"
|
|
4
4
|
class ActiveCampaign
|
5
5
|
|
6
6
|
# Makes the Client's methods available to an instance of the ActiveCampaign class
|
7
|
-
include Client
|
7
|
+
include ActiveCampaign::Client
|
8
8
|
|
9
9
|
attr_reader :api_endpoint, :api_key
|
10
10
|
|
@@ -37,31 +37,52 @@ class ActiveCampaign
|
|
37
37
|
api_url = (api_params.present?) ? "#{api_url}&#{api_params}" : api_url
|
38
38
|
|
39
39
|
# Make a call to API server with GET method
|
40
|
-
response =
|
41
|
-
|
40
|
+
response = RestClient.get(api_url)
|
41
|
+
|
42
42
|
# Return response from API server
|
43
43
|
# Default to JSON
|
44
|
-
return response
|
44
|
+
return response.body
|
45
45
|
|
46
46
|
when 'post'
|
47
47
|
|
48
48
|
# API parameters for POST method
|
49
49
|
api_params = args.first
|
50
50
|
|
51
|
+
# For event tracking the visit param must have a json value
|
52
|
+
if visit = api_params[:visit]
|
53
|
+
api_params[:visit] = visit.to_json if visit.is_a?(Hash)
|
54
|
+
end
|
55
|
+
|
51
56
|
# Make a call to API server with POST method
|
52
|
-
response =
|
57
|
+
response = RestClient.post(api_url, api_params)
|
58
|
+
|
59
|
+
# Return response from API server
|
60
|
+
# Default to JSON
|
61
|
+
return response.body
|
62
|
+
|
63
|
+
when 'delete'
|
64
|
+
|
65
|
+
# API parameters for DELETE method
|
66
|
+
api_params = args.first.merge(api_key: @api_key, api_output: @api_output)
|
67
|
+
|
68
|
+
api_url = "#{action_calls[api_action][:endpoint] || @api_endpoint}#{action_calls[api_action][:path] || '/admin/api.php'}"
|
69
|
+
|
70
|
+
# Make a call to API server with DELETE method
|
71
|
+
response = RestClient::Request.execute(method: :delete, url: api_url, headers: { params: api_params })
|
53
72
|
|
54
73
|
# Return response from API server
|
55
74
|
# Default to JSON
|
56
75
|
return response.body
|
57
|
-
|
76
|
+
|
58
77
|
end
|
59
78
|
|
60
79
|
end
|
61
80
|
|
62
81
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
82
|
+
def generate_api_url api_action
|
83
|
+
host = action_calls[api_action][:endpoint] || @api_endpoint
|
84
|
+
path = action_calls[api_action][:path] || '/admin/api.php'
|
66
85
|
|
86
|
+
"#{host}#{path}?api_key=#{@api_key}&api_action=#{api_action.to_s}&api_output=#{@api_output}"
|
87
|
+
end
|
67
88
|
end
|
@@ -1,164 +1,168 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
1
|
+
class ActiveCampaign
|
2
|
+
module Client
|
3
|
+
# List for all Active Campaign API and their method
|
4
|
+
# For more information visit http://www.activecampaign.com/api/overview.php
|
5
|
+
# TODO: Refactor this!
|
6
|
+
# Need best practice to grouping APIs
|
7
|
+
def action_calls
|
8
|
+
api_list = {
|
9
|
+
# Account View
|
10
|
+
account_view: { method: 'get' },
|
11
|
+
|
12
|
+
# Automation
|
13
|
+
automation_contact_add: { method: 'post' },
|
14
|
+
automation_contact_list: { method: 'get' },
|
15
|
+
automation_contact_remove: { method: 'post' },
|
16
|
+
automation_contact_view: { method: 'get' },
|
17
|
+
automation_list: { method: 'get' },
|
18
|
+
|
19
|
+
# Branding
|
20
|
+
branding_edit: { method: 'post' },
|
21
|
+
branding_view: { method: 'get' },
|
22
|
+
|
23
|
+
# Campaign
|
24
|
+
campaign_create: { method: 'post' },
|
25
|
+
campaign_delete: { method: 'get' },
|
26
|
+
campaign_delete_list: { method: 'get' },
|
27
|
+
campaign_list: { method: 'get' },
|
28
|
+
campaign_paginator: { method: 'get' },
|
29
|
+
campaign_report_bounce_list: { method: 'get' },
|
30
|
+
campaign_report_bounce_totals: { method: 'get' },
|
31
|
+
campaign_report_forward_list: { method: 'get' },
|
32
|
+
campaign_report_forward_totals: { method: 'get' },
|
33
|
+
campaign_report_link_list: { method: 'get' },
|
34
|
+
campaign_report_link_totals: { method: 'get' },
|
35
|
+
campaign_report_open_list: { method: 'get' },
|
36
|
+
campaign_report_open_totals: { method: 'get' },
|
37
|
+
campaign_report_totals: { method: 'get' },
|
38
|
+
campaign_report_unopen_list: { method: 'get' },
|
39
|
+
campaign_report_unsubscription_list: { method: 'get' },
|
40
|
+
campaign_report_unsubscription_totals: { method: 'get' },
|
41
|
+
campaign_send: { method: 'post' },
|
42
|
+
campaign_status: { method: 'get' },
|
43
|
+
|
44
|
+
# Contact
|
45
|
+
contact_add: { method: 'post' },
|
46
|
+
contact_automation_list: { method: 'get' },
|
47
|
+
contact_delete: { method: 'get' },
|
48
|
+
contact_delete_list: { method: 'post' },
|
49
|
+
contact_edit: { method: 'post' },
|
50
|
+
contact_list: { method: 'get' },
|
51
|
+
contact_note_add: { method: 'post' },
|
52
|
+
contact_note_delete: { method: 'get' },
|
53
|
+
contact_note_edit: { method: 'post' },
|
54
|
+
contact_paginator: { method: 'get' },
|
55
|
+
contact_sync: { method: 'post' },
|
56
|
+
contact_tag_add: { method: 'post' },
|
57
|
+
contact_tag_remove: { method: 'post' },
|
58
|
+
contact_view: { method: 'get' },
|
59
|
+
contact_view_email: { method: 'get' },
|
60
|
+
contact_view_hash: { method: 'get' },
|
61
|
+
|
62
|
+
# Deal
|
63
|
+
deal_add: { method: 'post' },
|
64
|
+
deal_delete: { method: 'post' },
|
65
|
+
deal_edit: { method: 'post' },
|
66
|
+
deal_get: { method: 'get' },
|
67
|
+
deal_list: { method: 'get' },
|
68
|
+
deal_note_add: { method: 'post' },
|
69
|
+
deal_note_edit: { method: 'post' },
|
70
|
+
deal_pipeline_add: { method: 'post' },
|
71
|
+
deal_pipeline_delete: { method: 'post' },
|
72
|
+
deal_pipeline_edit: { method: 'post' },
|
73
|
+
deal_pipeline_list: { method: 'get' },
|
74
|
+
deal_stage_add: { method: 'post' },
|
75
|
+
deal_stage_delete: { method: 'post' },
|
76
|
+
deal_stage_edit: { method: 'post' },
|
77
|
+
deal_stage_list: { method: 'get' },
|
78
|
+
deal_task_add: { method: 'post' },
|
79
|
+
deal_task_edit: { method: 'post' },
|
80
|
+
deal_tasktype_add: { method: 'post' },
|
81
|
+
deal_tasktype_delete: { method: 'post' },
|
82
|
+
deal_tasktype_edit: { method: 'post' },
|
83
|
+
|
84
|
+
# Form
|
85
|
+
form_getforms: { method: 'get' },
|
86
|
+
form_html: { method: 'get' },
|
87
|
+
|
88
|
+
# Group
|
89
|
+
group_add: { method: 'post' },
|
90
|
+
group_delete: { method: 'get' },
|
91
|
+
group_delete_list: { method: 'get' },
|
92
|
+
group_edit: { method: 'post' },
|
93
|
+
group_list: { method: 'get' },
|
94
|
+
group_view: { method: 'get' },
|
95
|
+
|
96
|
+
# List
|
97
|
+
list_add: { method: 'post' },
|
98
|
+
list_delete: { method: 'get' },
|
99
|
+
list_delete_list: { method: 'get' },
|
100
|
+
list_edit: { method: 'post' },
|
101
|
+
list_field_add: { method: 'post' },
|
102
|
+
list_field_delete: { method: 'post' },
|
103
|
+
list_field_edit: { method: 'post' },
|
104
|
+
list_field_view: { method: 'get' },
|
105
|
+
list_list: { method: 'get' },
|
106
|
+
list_paginator: { method: 'get' },
|
107
|
+
list_view: { method: 'get' },
|
108
|
+
|
109
|
+
# Message
|
110
|
+
message_add: { method: 'post' },
|
111
|
+
message_delete: { method: 'get' },
|
112
|
+
message_delete_list: { method: 'get' },
|
113
|
+
message_edit: { method: 'post' },
|
114
|
+
message_list: { method: 'get' },
|
115
|
+
message_template_add: { method: 'post' },
|
116
|
+
message_template_delete: { method: 'post' },
|
117
|
+
message_template_delete_list: { method: 'post' },
|
118
|
+
message_template_edit: { method: 'post' },
|
119
|
+
message_template_export: { method: 'get' },
|
120
|
+
message_template_import: { method: 'get' },
|
121
|
+
message_template_list: { method: 'get' },
|
122
|
+
message_template_view: { method: 'get' },
|
123
|
+
message_view: { method: 'get' },
|
124
|
+
|
125
|
+
# Organization
|
126
|
+
organization_list: { method: 'get' },
|
127
|
+
|
128
|
+
# Settings
|
129
|
+
settings_edit: { method: 'post' },
|
130
|
+
|
131
|
+
# Single Sign On
|
132
|
+
singlesignon: { method: 'post' },
|
133
|
+
|
134
|
+
# Site & Event Tracking
|
135
|
+
track_event_delete: { method: 'delete', path: '/2/track/event' },
|
136
|
+
track_event_list: { method: 'get', path: '/2/track/event' },
|
137
|
+
track_event_status_edit: { method: 'post', path: '/2/track/event' },
|
138
|
+
track_site_list: { method: 'get', path: '/2/track/site' },
|
139
|
+
track_site_status_edit: { method: 'post', path: '/2/track/site' },
|
140
|
+
track_site_whitelist_add: { method: 'post', path: '/2/track/site' },
|
141
|
+
track_site_whitelist_delete: { method: 'delete', path: '/2/track/site' },
|
142
|
+
track_event_add: { method: 'post', endpoint: 'https://trackcmp.net', path: '/event' },
|
143
|
+
|
144
|
+
# Tag
|
145
|
+
tags_list: { method: 'get' },
|
146
|
+
|
147
|
+
# User
|
148
|
+
user_add: { method: 'post' },
|
149
|
+
user_delete: { method: 'get' },
|
150
|
+
user_delete_list: { method: 'get' },
|
151
|
+
user_edit: { method: 'post' },
|
152
|
+
user_list: { method: 'get' },
|
153
|
+
user_me: { method: 'get' },
|
154
|
+
user_view: { method: 'get' },
|
155
|
+
user_view_email: { method: 'get' },
|
156
|
+
user_view_username: { method: 'get' },
|
157
|
+
|
158
|
+
# Webhook
|
159
|
+
webhook_add: { method: 'post' },
|
160
|
+
webhook_delete: { method: 'get' },
|
161
|
+
webhook_edit: { method: 'post' },
|
162
|
+
webhook_events: { method: 'get' },
|
163
|
+
webhook_list: { method: 'get' },
|
164
|
+
webhook_view: { method: 'get' }
|
165
|
+
}
|
166
|
+
end
|
162
167
|
end
|
163
|
-
|
164
168
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-campaign-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eky Fauzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
105
|
version: '0'
|
92
106
|
requirements: []
|
93
107
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.5.1
|
95
109
|
signing_key:
|
96
110
|
specification_version: 4
|
97
111
|
summary: Simple rails wrapper for ActiveCampaign API
|