active-campaign-rails 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ade81559c5a78ad24affe43bf695171b6fc44695
4
- data.tar.gz: d768fde656c1ceeff772a4d9996c2e74d2673ab9
3
+ metadata.gz: 7ce251507c3d05fa89a4b748bddce8a63dab79ae
4
+ data.tar.gz: 88f735f188e7d3881c6dcaaf1e3eb8dd699be6d3
5
5
  SHA512:
6
- metadata.gz: 128889350ba3ed02a106ce6aba658988eac345e1c950729fbb50ed186d253dda820c827dadb715bb83be546c9ef7038b0fef48a0a4502bd8037c881d7a9b8f06
7
- data.tar.gz: 57f569d9f47757a681331215a692308b45b17a3c620144e3ccdcc66ceca2f2628879d088773085aceeebfd09572330abe991e881b64b7c6eacfbbe58ecfdd5ce
6
+ metadata.gz: 76826c99ce2bd3b486ac8a90222614a20caa0378676c292756e7d392db6d580eff7035c15e942e0a6fa2c48bbb61582f60981dc485433010e1095ac11c87bd8d
7
+ data.tar.gz: 2d8e22e862ab2bdb0002479e0e001854dbf1c671320a0e06bf37df2182c5479fff43191c7b3e2bda3bbbc0c4dd65f4e356a496388e9f1af52ac1224b4ab31527
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Active::Campaign::Rails
1
+ # ActiveCampaignRails
2
2
 
3
- TODO: Write a gem description
3
+ Simple rails wrapper for ActiveCampaign API
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,11 +20,60 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ Read their [API documentation](http://www.activecampaign.com/api/overview.php)for how to use this gem.
24
+
25
+ ```ruby
26
+ # To setup the active_campaign
27
+ active_campaign = ActiveCampaign.new(
28
+ api_endpoint: 'YOUR-ENDPOINT', # e.g. 'https://yourendpoint.api-us1.com'
29
+ api_key: 'YOUR-API-KEY') # e.g. 'a4e60a1ba200595d5cc37ede5732545184165e'
30
+
31
+ # After connected, you can call Active Campaign API like this:
32
+
33
+ # To fetch your Active Campaign account data
34
+ active_campaign.account_view
35
+
36
+ # To fetch all lists
37
+ active_campaign.list_list ids: 'all'
38
+
39
+ # NOTE: For view all available API please visit http://www.activecampaign.com/api/overview.php
40
+
41
+ ```
42
+
43
+ ## Response
44
+
45
+ Here's an example JSON response for `active_campaign.list_list ids: 'all'`
46
+
47
+ ```ruby
48
+ {
49
+ "result_code" => 1,
50
+ "result_message" => "Success: Something is returned",
51
+ "result_output" => "json",
52
+ "results" => [
53
+ {
54
+ "id" => "1",
55
+ "name" => "John Doe",
56
+ "cdate" => "2015-06-30 10:07:36",
57
+ "private" => "0",
58
+ "userid" => "1",
59
+ "subscriber_count" => 2
60
+ },
61
+ {
62
+ "id" => "2",
63
+ "name" => "Jane Doe",
64
+ "cdate" => "2015-06-30 10:09:15",
65
+ "private" => "0",
66
+ "userid" => "1",
67
+ "subscriber_count" => 0
68
+ }
69
+ ]
70
+ }
71
+ ```
72
+
24
73
 
25
74
  ## Contributing
26
75
 
27
- 1. Fork it ( https://github.com/[my-github-username]/active-campaign-rails/fork )
76
+ 1. Fork it ( https://github.com/ekyfauzi/active-campaign-rails/fork )
28
77
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
78
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
79
  4. Push to the branch (`git push origin my-new-feature`)
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ActiveCampaignRails::VERSION
9
9
  spec.authors = ["Eky Fauzi"]
10
10
  spec.email = ["ekyfauzi@hotmail.com"]
11
- spec.summary = %q{Simple rails wrapper ActiveCampaign API}
11
+ spec.summary = %q{Simple rails wrapper for ActiveCampaign API}
12
12
  spec.description = %q{See http://www.activecampaign.com/api/overview.php for more information}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
23
25
  end
@@ -1,46 +1,205 @@
1
1
  require "active-campaign-rails/version"
2
- require "active-campaign-rails/configuration"
3
2
 
4
- module ActiveCampaignRails
5
- def self.configuration
6
- @configuration ||= Configuration.new
7
- end
3
+ class ActiveCampaign
4
+
5
+ attr_reader :api_endpoint, :api_key
6
+
7
+ def initialize args
8
+
9
+ # Parse args into instance_variable
10
+ args.each do |k,v|
11
+ instance_variable_set("@#{k}", v) unless v.nil?
12
+ end
13
+
14
+ # Set default api_output to json
15
+ @api_output = 'json'
8
16
 
9
- def self.configure
10
- yield(configuration) if block_given?
11
17
  end
12
18
 
13
- def method_missing(api_action, *args, &block)
14
- client = {
15
- list_list: {
16
- method: 'get'
17
- },
18
- contact_add: {
19
- method: 'post'
20
- }
21
- }
22
- api_endpoint = @configuration.api_endpoint # e.g. 'https://yourendpoint.api-us1.com'
23
- api_key = @configuration.api_key # e.g. 'a4e60a1ba200595d5cc37ede5732545184165e'
24
- api_output = @configuration.api_output
25
- api_url = "#{api_endpoint}/admin/api.php?api_key=#{api_key}&api_action=#{api_action.to_s}&api_output=#{api_output}"
26
19
 
27
- case client[api_action][:method]
20
+ def method_missing(api_action, *args, &block)
28
21
 
22
+ # Generate api_url
23
+ api_url = "#{@api_endpoint}/admin/api.php?api_key=#{@api_key}&api_action=#{api_action.to_s}&api_output=#{@api_output}"
29
24
 
25
+ # Check method for api_action given
26
+ case client[api_action][:method]
30
27
  when 'get'
31
- # Get
28
+
32
29
  url_params = (args.present?) ? args.first.map{|k,v| "#{k}=#{v}"}.join('su&') : nil
33
30
  api_url = (url_params.present?) ? "#{api_url}&#{url_params}" : api_url
34
31
  response = Net::HTTP.get(URI.parse("#{api_url}"))
35
32
 
36
33
  when 'post'
37
- params = { :email => 'user2@test.com', :first_name => 'User2', :last_name => 'Last2'}
38
- response = Net::HTTP.post_form(URI.parse("#{api_url}"), params)
39
- end
40
34
 
41
- # Post
42
- # binding.pry
35
+ response = Net::HTTP.post_form(URI.parse("#{api_url}"), args.first)
36
+
37
+ end
38
+
43
39
  return response
44
40
 
45
41
  end
42
+
43
+ # List for all Active Campaign API and their method
44
+ # For more information visit http://www.activecampaign.com/api/overview.php
45
+ # TODO: Refactor this!
46
+ def client
47
+
48
+ api_list = {
49
+ # Account View
50
+ account_view: { method: 'get' },
51
+
52
+ # Automation
53
+ automation_contact_add: { method: 'post' },
54
+ automation_contact_list: { method: 'get' },
55
+ automation_contact_remove: { method: 'post' },
56
+ automation_contact_view: { method: 'get' },
57
+ automation_list: { method: 'get' },
58
+
59
+ # Branding
60
+ branding_edit: { method: 'post' },
61
+ branding_view: { method: 'get' },
62
+
63
+ # Campaign
64
+ campaign_create: { method: 'post' },
65
+ campaign_delete: { method: 'post' },
66
+ campaign_delete_list: { method: 'post' },
67
+ campaign_list: { method: 'get' },
68
+ campaign_paginator: { method: 'get' },
69
+ campaign_report_bounce_list: { method: 'get' },
70
+ campaign_report_bounce_totals: { method: 'get' },
71
+ campaign_report_forward_list: { method: 'get' },
72
+ campaign_report_forward_totals: { method: 'get' },
73
+ campaign_report_link_list: { method: 'get' },
74
+ campaign_report_link_totals: { method: 'get' },
75
+ campaign_report_open_list: { method: 'get' },
76
+ campaign_report_open_totals: { method: 'get' },
77
+ campaign_report_totals: { method: 'get' },
78
+ campaign_report_unopen_list: { method: 'get' },
79
+ campaign_report_unsubscription_list: { method: 'get' },
80
+ campaign_report_unsubscription_totals: { method: 'get' },
81
+ campaign_send: { method: 'post' },
82
+ campaign_status: { method: 'get' },
83
+
84
+ # Contact
85
+ contact_add: { method: 'post' },
86
+ contact_automation_list: { method: 'get' },
87
+ contact_delete: { method: 'post' },
88
+ contact_delete_list: { method: 'post' },
89
+ contact_edit: { method: 'post' },
90
+ contact_list: { method: 'get' },
91
+ contact_note_add: { method: 'post' },
92
+ contact_note_delete: { method: 'post' },
93
+ contact_note_edit: { method: 'post' },
94
+ contact_paginator: { method: 'get' },
95
+ contact_sync: { method: 'post' },
96
+ contact_tag_add: { method: 'post' },
97
+ contact_tag_remove: { method: 'post' },
98
+ contact_view: { method: 'get' },
99
+ contact_view_email: { method: 'get' },
100
+ contact_view_hash: { method: 'get' },
101
+
102
+ # Deal
103
+ deal_add: { method: 'post' },
104
+ deal_delete: { method: 'post' },
105
+ deal_edit: { method: 'post' },
106
+ deal_get: { method: 'get' },
107
+ deal_list: { method: 'get' },
108
+ deal_note_add: { method: 'post' },
109
+ deal_note_edit: { method: 'post' },
110
+ deal_pipeline_add: { method: 'post' },
111
+ deal_pipeline_delete: { method: 'post' },
112
+ deal_pipeline_edit: { method: 'post' },
113
+ deal_pipeline_list: { method: 'get' },
114
+ deal_stage_add: { method: 'post' },
115
+ deal_stage_delete: { method: 'post' },
116
+ deal_stage_edit: { method: 'post' },
117
+ deal_stage_list: { method: 'get' },
118
+ deal_task_add: { method: 'post' },
119
+ deal_task_edit: { method: 'post' },
120
+ deal_tasktype_add: { method: 'post' },
121
+ deal_tasktype_delete: { method: 'post' },
122
+ deal_tasktype_edit: { method: 'post' },
123
+
124
+ # Form
125
+ # form_getforms: { method: 'get' },
126
+ # form_html: { method: 'get' },
127
+
128
+ # Group
129
+ group_add: { method: 'post' },
130
+ group_delete: { method: 'post' },
131
+ group_delete_list: { method: 'post' },
132
+ group_edit: { method: 'post' },
133
+ group_list: { method: 'get' },
134
+ group_view: { method: 'get' },
135
+
136
+ # List
137
+ list_add: { method: 'post' },
138
+ list_delete: { method: 'post' },
139
+ list_delete_list: { method: 'post' },
140
+ list_edit: { method: 'post' },
141
+ list_field_add: { method: 'post' },
142
+ list_field_delete: { method: 'post' },
143
+ list_field_edit: { method: 'post' },
144
+ list_field_view: { method: 'get' },
145
+ list_list: { method: 'get' },
146
+ list_paginator: { method: 'get' },
147
+ list_view: { method: 'get' },
148
+
149
+ # Message
150
+ message_add: { method: 'post' },
151
+ message_delete: { method: 'post' },
152
+ message_delete_list: { method: 'post' },
153
+ message_edit: { method: 'post' },
154
+ message_list: { method: 'get' },
155
+ message_template_add: { method: 'post' },
156
+ message_template_delete: { method: 'post' },
157
+ message_template_delete_list: { method: 'post' },
158
+ message_template_edit: { method: 'post' },
159
+ message_template_export: { method: 'get' },
160
+ message_template_import: { method: 'get' },
161
+ message_template_list: { method: 'get' },
162
+ message_template_view: { method: 'get' },
163
+ message_view: { method: 'get' },
164
+
165
+ # Organization
166
+ organization_list: { method: 'get' },
167
+
168
+ # Settings
169
+ settings_edit: { method: 'post' },
170
+
171
+ # Single Sign On
172
+ # singlesignon: { method: 'get' },
173
+
174
+ # Site & Event Tracking
175
+ track_event_delete: { method: 'post' },
176
+ track_event_list: { method: 'get' },
177
+ track_event_status_edit: { method: 'post' },
178
+ track_site_list: { method: 'get' },
179
+ track_site_status_edit: { method: 'post' },
180
+ track_site_whitelist_add: { method: 'post' },
181
+ track_site_whitelist_delete: { method: 'post' },
182
+ track_event_add: { method: 'post' },
183
+
184
+ # User
185
+ user_add: { method: 'post' },
186
+ user_delete: { method: 'post' },
187
+ user_delete_list: { method: 'post' },
188
+ user_edit: { method: 'post' },
189
+ user_list: { method: 'get' },
190
+ user_me: { method: 'get' },
191
+ user_view: { method: 'get' },
192
+ user_view_email: { method: 'get' },
193
+ user_view_username: { method: 'get' },
194
+
195
+ # Webhook
196
+ webhook_add: { method: 'post' },
197
+ webhook_delete: { method: 'post' },
198
+ webhook_edit: { method: 'post' },
199
+ webhook_events: { method: 'get' },
200
+ webhook_list: { method: 'get' },
201
+ webhook_view: { method: 'get' }
202
+ }
203
+ end
204
+
46
205
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveCampaignRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-campaign-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eky Fauzi
@@ -52,7 +52,6 @@ files:
52
52
  - Rakefile
53
53
  - active-campaign-rails.gemspec
54
54
  - lib/active-campaign-rails.rb
55
- - lib/active-campaign-rails/configuration.rb
56
55
  - lib/active-campaign-rails/version.rb
57
56
  homepage: ''
58
57
  licenses:
@@ -66,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - ">="
68
67
  - !ruby/object:Gem::Version
69
- version: '0'
68
+ version: 2.0.0
70
69
  required_rubygems_version: !ruby/object:Gem::Requirement
71
70
  requirements:
72
71
  - - ">="
@@ -77,5 +76,5 @@ rubyforge_project:
77
76
  rubygems_version: 2.4.5
78
77
  signing_key:
79
78
  specification_version: 4
80
- summary: Simple rails wrapper ActiveCampaign API
79
+ summary: Simple rails wrapper for ActiveCampaign API
81
80
  test_files: []
@@ -1,12 +0,0 @@
1
- module ActiveCampaignRails
2
-
3
- class Configuration
4
- attr_accessor :api_endpoint, :api_key, :api_output
5
-
6
- def initialize
7
- self.api_endpoint = nil
8
- self.api_key = nil
9
- self.api_output = 'json'
10
- end
11
- end
12
- end