active-campaign-rails 0.2.1 → 0.2.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: 94834028c88d81ad832621e6ab369f7c79280354
4
- data.tar.gz: fa8e044a76ee6e8c1efb063030881bd7c0e4b918
3
+ metadata.gz: 6860716d43937203ea659333cd7ec527df29294f
4
+ data.tar.gz: 0de4fbd20d3da3a8164df71c820320369e8b4174
5
5
  SHA512:
6
- metadata.gz: 3f6480da7365761bebe7f2327d07aeea524d2859d68a91a286887da1fd6e5b9b413783a6cea6e82bdd9e1477ebbd4c45492c361ec3cbb7eb741a74c144915b01
7
- data.tar.gz: d1f8f785a6a6b95f284df7064b6cc777f85d3e7a3fe60a5f10c213ea938aa9c6a9af007dd158e774f8d77955e7e1bec95083ae99b03c0315a34729c1ae0a005e
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 = Net::HTTP.get(URI.parse("#{api_url}"))
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 = Net::HTTP.post_form(URI.parse("#{api_url}"), api_params)
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
- def generate_api_url api_action
64
- return "#{@api_endpoint}/admin/api.php?api_key=#{@api_key}&api_action=#{api_action.to_s}&api_output=#{@api_output}"
65
- end
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
- module Client
2
- # List for all Active Campaign API and their method
3
- # For more information visit http://www.activecampaign.com/api/overview.php
4
- # TODO: Refactor this!
5
- # Need best practice to grouping APIs
6
- def action_calls
7
- api_list = {
8
- # Account View
9
- account_view: { method: 'get' },
10
-
11
- # Automation
12
- automation_contact_add: { method: 'post' },
13
- automation_contact_list: { method: 'get' },
14
- automation_contact_remove: { method: 'post' },
15
- automation_contact_view: { method: 'get' },
16
- automation_list: { method: 'get' },
17
-
18
- # Branding
19
- branding_edit: { method: 'post' },
20
- branding_view: { method: 'get' },
21
-
22
- # Campaign
23
- campaign_create: { method: 'post' },
24
- campaign_delete: { method: 'post' },
25
- campaign_delete_list: { method: 'post' },
26
- campaign_list: { method: 'get' },
27
- campaign_paginator: { method: 'get' },
28
- campaign_report_bounce_list: { method: 'get' },
29
- campaign_report_bounce_totals: { method: 'get' },
30
- campaign_report_forward_list: { method: 'get' },
31
- campaign_report_forward_totals: { method: 'get' },
32
- campaign_report_link_list: { method: 'get' },
33
- campaign_report_link_totals: { method: 'get' },
34
- campaign_report_open_list: { method: 'get' },
35
- campaign_report_open_totals: { method: 'get' },
36
- campaign_report_totals: { method: 'get' },
37
- campaign_report_unopen_list: { method: 'get' },
38
- campaign_report_unsubscription_list: { method: 'get' },
39
- campaign_report_unsubscription_totals: { method: 'get' },
40
- campaign_send: { method: 'post' },
41
- campaign_status: { method: 'get' },
42
-
43
- # Contact
44
- contact_add: { method: 'post' },
45
- contact_automation_list: { method: 'get' },
46
- contact_delete: { method: 'post' },
47
- contact_delete_list: { method: 'post' },
48
- contact_edit: { method: 'post' },
49
- contact_list: { method: 'get' },
50
- contact_note_add: { method: 'post' },
51
- contact_note_delete: { method: 'post' },
52
- contact_note_edit: { method: 'post' },
53
- contact_paginator: { method: 'get' },
54
- contact_sync: { method: 'post' },
55
- contact_tag_add: { method: 'post' },
56
- contact_tag_remove: { method: 'post' },
57
- contact_view: { method: 'get' },
58
- contact_view_email: { method: 'get' },
59
- contact_view_hash: { method: 'get' },
60
-
61
- # Deal
62
- deal_add: { method: 'post' },
63
- deal_delete: { method: 'post' },
64
- deal_edit: { method: 'post' },
65
- deal_get: { method: 'get' },
66
- deal_list: { method: 'get' },
67
- deal_note_add: { method: 'post' },
68
- deal_note_edit: { method: 'post' },
69
- deal_pipeline_add: { method: 'post' },
70
- deal_pipeline_delete: { method: 'post' },
71
- deal_pipeline_edit: { method: 'post' },
72
- deal_pipeline_list: { method: 'get' },
73
- deal_stage_add: { method: 'post' },
74
- deal_stage_delete: { method: 'post' },
75
- deal_stage_edit: { method: 'post' },
76
- deal_stage_list: { method: 'get' },
77
- deal_task_add: { method: 'post' },
78
- deal_task_edit: { method: 'post' },
79
- deal_tasktype_add: { method: 'post' },
80
- deal_tasktype_delete: { method: 'post' },
81
- deal_tasktype_edit: { method: 'post' },
82
-
83
- # Form
84
- form_getforms: { method: 'get' },
85
- form_html: { method: 'get' },
86
-
87
- # Group
88
- group_add: { method: 'post' },
89
- group_delete: { method: 'post' },
90
- group_delete_list: { method: 'post' },
91
- group_edit: { method: 'post' },
92
- group_list: { method: 'get' },
93
- group_view: { method: 'get' },
94
-
95
- # List
96
- list_add: { method: 'post' },
97
- list_delete: { method: 'post' },
98
- list_delete_list: { method: 'post' },
99
- list_edit: { method: 'post' },
100
- list_field_add: { method: 'post' },
101
- list_field_delete: { method: 'post' },
102
- list_field_edit: { method: 'post' },
103
- list_field_view: { method: 'get' },
104
- list_list: { method: 'get' },
105
- list_paginator: { method: 'get' },
106
- list_view: { method: 'get' },
107
-
108
- # Message
109
- message_add: { method: 'post' },
110
- message_delete: { method: 'post' },
111
- message_delete_list: { method: 'post' },
112
- message_edit: { method: 'post' },
113
- message_list: { method: 'get' },
114
- message_template_add: { method: 'post' },
115
- message_template_delete: { method: 'post' },
116
- message_template_delete_list: { method: 'post' },
117
- message_template_edit: { method: 'post' },
118
- message_template_export: { method: 'get' },
119
- message_template_import: { method: 'get' },
120
- message_template_list: { method: 'get' },
121
- message_template_view: { method: 'get' },
122
- message_view: { method: 'get' },
123
-
124
- # Organization
125
- organization_list: { method: 'get' },
126
-
127
- # Settings
128
- settings_edit: { method: 'post' },
129
-
130
- # Single Sign On
131
- # singlesignon: { method: 'get' },
132
-
133
- # Site & Event Tracking
134
- track_event_delete: { method: 'post' },
135
- track_event_list: { method: 'get' },
136
- track_event_status_edit: { method: 'post' },
137
- track_site_list: { method: 'get' },
138
- track_site_status_edit: { method: 'post' },
139
- track_site_whitelist_add: { method: 'post' },
140
- track_site_whitelist_delete: { method: 'post' },
141
- track_event_add: { method: 'post' },
142
-
143
- # User
144
- user_add: { method: 'post' },
145
- user_delete: { method: 'post' },
146
- user_delete_list: { method: 'post' },
147
- user_edit: { method: 'post' },
148
- user_list: { method: 'get' },
149
- user_me: { method: 'get' },
150
- user_view: { method: 'get' },
151
- user_view_email: { method: 'get' },
152
- user_view_username: { method: 'get' },
153
-
154
- # Webhook
155
- webhook_add: { method: 'post' },
156
- webhook_delete: { method: 'post' },
157
- webhook_edit: { method: 'post' },
158
- webhook_events: { method: 'get' },
159
- webhook_list: { method: 'get' },
160
- webhook_view: { method: 'get' }
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
@@ -1,3 +1,3 @@
1
1
  module ActiveCampaignRails
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  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.1
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: 2016-03-31 00:00:00.000000000 Z
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.2.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