active_campaign_wrapper 0.3.0 → 0.4.0

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
  SHA256:
3
- metadata.gz: 1590dc0b398aa32233b19bcf394874316aa2d5c1a0b38b569fdfe57d333ab97e
4
- data.tar.gz: 2946ac23c953474593a0dbde6e5aafa27e2843acb60e660139044eb7a9b3d943
3
+ metadata.gz: a735bcf1cf52db420446e13c246621ba8eb009a5d776e1889c68355bd11e811f
4
+ data.tar.gz: b154ef14ee4a7e9ff35f68cd65bb198e335b3de3071cf331be79a200fa14035c
5
5
  SHA512:
6
- metadata.gz: 920d304e2e617f68af61d8238e67b3f23b5d6e9a44f99a930e6316b5a9781ae5184f846985db7aec4e7677b466a26b71b3a7d0d0bc675afd9ea23373873c35ae
7
- data.tar.gz: 72e5fa0c1a16b06de14dc775f975cdfbc331f019841bbd049b9d991cc82640ff222de2d1e2b8b5395c7a55110166ee51f19eea9032ad1175a3248cda8d2f067e
6
+ metadata.gz: 3eea2118267ad4e4be0a012f6e04f8a10c66aa7b82045bd828ac984a073afc5decc1c59252483239e517a6e86ac74a2264482434415ffb3d976536eecac0cc65
7
+ data.tar.gz: c61f5a8c3f8fd38d79dd556a8bf8bacd80ffcf773c5e3868eb5586472469c688eb4d2902603c7734e8ebcaa1a1b70eee57bcffa1559da4578c917d0cae384dae
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Test Coverage](https://codecov.io/gh/anmol-yousaf/active_campaign_wrapper/graph/badge.svg)](https://codecov.io/gh/anmol-yousaf/active_campaign_wrapper)
5
5
 
6
6
  This library is designed to help ruby/rails based applications communicate with the publicly available REST API for ActiveCampaign.
7
+ It also supports a lot of functionality which is currently undocumented in the REST API.
7
8
 
8
9
  If you are unfamiliar with the ActiveCampaign REST API, you should first read the documentation located at https://developers.activecampaign.com/reference.
9
10
 
@@ -30,6 +31,7 @@ Or install it yourself as:
30
31
  * [Initialize](#initialize)
31
32
  * [Tags](#tags)
32
33
  * [Lists](#lists)
34
+ * [List Groups](#list-groups)
33
35
  * [Contacts](#contacts)
34
36
  * [Contact Tags](#contact-tags)
35
37
  * [Contact Automations](#contact-automations)
@@ -38,7 +40,9 @@ Or install it yourself as:
38
40
  * [Custom Fields](#custom-fields)
39
41
  * [Custom Field Options](#custom-field-options)
40
42
  * [Custom Field Values](#custom-field-values)
41
-
43
+ * [Users](#users)
44
+ * [Groups](#groups)
45
+ * [Templates](#templates)
42
46
 
43
47
  <a name="initialize"/>
44
48
 
@@ -168,9 +172,43 @@ client.lists.all
168
172
  **QUERY PARAMS** (Optional)
169
173
  - filters[name] (string): Filter by the name of the list.
170
174
 
175
+ <a name="list-groups"/>
176
+
177
+ ### List Groups - [Api Reference](https://developers.activecampaign.com/reference#create-a-list-group-permission)
178
+
179
+ #### Create a list group permission
180
+
181
+ ```ruby
182
+ client.list_groups.create({
183
+ listid: list_id,
184
+ groupid: group_id
185
+ })
186
+ ```
187
+ **BODY PARAMS**
188
+ - listid* (integer): ID of the list
189
+ - groupid* (integer): ID of the group that list should be associated with
190
+
191
+ #### Retrieve a list group permission
192
+
193
+ ```ruby
194
+ client.list_groups.find(list_group_id)
195
+ ```
196
+
197
+ #### Delete a list group permission
198
+
199
+ ```ruby
200
+ client.list_groups.delete(list_group_id)
201
+ ```
202
+
203
+ #### Retrieve all list group permissions
204
+
205
+ ```ruby
206
+ client.list_groups.all
207
+ ```
208
+
171
209
  <a name="contacts"/>
172
210
 
173
- #### Contacts - [Api Reference](https://developers.activecampaign.com/reference#contact)
211
+ ### Contacts - [Api Reference](https://developers.activecampaign.com/reference#contact)
174
212
 
175
213
  #### Create a contact
176
214
 
@@ -184,12 +222,6 @@ client.contacts.create({
184
222
 
185
223
  **BODY PARAMS**
186
224
  - email* (string): Email address of the new contact. Example: 'test@example.com'
187
- - status (integer) Status of your contact. Possible Values: -1..3
188
- - -1 Any
189
- - 0 Unconfirmed
190
- - 1 Active
191
- - 2 Unsubscribed
192
- - 3 Bounced
193
225
  - first_name (string): First name of the new contact.
194
226
  - last_name (string): Last name of the new contact.
195
227
  - phone (integer): Phone number of the contact.
@@ -218,7 +250,14 @@ client.contacts.update_list_status({
218
250
  **BODY PARAMS**
219
251
  - list* (string/integer):ID of the list to subscribe the contact to
220
252
  - contact* (string/integer): ID of the contact to subscribe to the list
221
- - status* (string/integer): Set to "1" to subscribe the contact to the list. Set to "2" to unsubscribe the contact from the list. WARNING: If you change a status from unsubscribed to active, you can re-subscribe a contact to a list from which they had manually unsubscribed.
253
+ - status* (string/integer): Possible Values: -1..3
254
+ - -1 Any
255
+ - 0 Unconfirmed
256
+ - 1 Active
257
+ - 2 Unsubscribed
258
+ - 3 Bounced
259
+
260
+ Set to "1" to subscribe the contact to the list. Set to "2" to unsubscribe the contact from the list. WARNING: If you change a status from unsubscribed to active, you can re-subscribe a contact to a list from which they had manually unsubscribed.
222
261
  - sourceid (integer): Set to "4" when re-subscribing a contact to a list
223
262
 
224
263
  #### Retrieve a contact
@@ -259,7 +298,6 @@ client.contacts.all
259
298
  - search (string): Filter contacts that match the given value in the contact names, organization, phone or email
260
299
  - segmentid (integer): Return only contacts that match a list segment (this param initially returns segment information, when it is run a second time it will return contacts that match the segment)
261
300
  - seriesid (integer): Filter contacts associated with the given automation
262
- - status (integer): -1..3
263
301
  - tagid (integer): Filter contacts associated with the given tag
264
302
  - filters[created_before] (date) Filter contacts that were created prior to this date
265
303
  - filters[created_after] (date): Filter contacts that were created after this date
@@ -525,6 +563,192 @@ client.custom_field_values.delete(field_value_id)
525
563
  ```ruby
526
564
  client.custom_field_values.all
527
565
  ```
566
+ <a name="users"/>
567
+
568
+ ### Users - [Api Reference](https://developers.activecampaign.com/reference#users)
569
+
570
+ #### Create a user
571
+
572
+ ```ruby
573
+ client.users.create({
574
+ first_name: 'Phoebe',
575
+ last_name: 'Buffay',
576
+ username: 'raginaphalange',
577
+ password: 'smellycat',
578
+ email: 'ragina.phalange@smellycat.com'
579
+ })
580
+ ```
581
+ **BODY PARAMS**
582
+ - username* (string): Username
583
+ - email (string): Email address
584
+ - first_name (string): First name
585
+ - last_name (string): Last name
586
+ - group (string/integer): Group ID
587
+ - password (string): Plain text password
588
+
589
+ #### Retrieve a user
590
+
591
+ ```ruby
592
+ client.users.find(user_id)
593
+ ```
594
+
595
+ #### Retrieve logged in user
596
+
597
+ ```ruby
598
+ client.users.logged_in
599
+ ```
600
+
601
+ #### Retrieve a user by email
602
+
603
+ ```ruby
604
+ client.users.find_by_email(email)
605
+ ```
606
+
607
+ #### Retrieve a user by username
608
+
609
+ ```ruby
610
+ client.users.find_by_username(username)
611
+ ```
612
+
613
+ #### Update a user
614
+
615
+ ```ruby
616
+ client.users.update(user_id, {
617
+ password: 'newsmellycat',
618
+ group: group_id
619
+ })
620
+ ```
621
+ *Note*: Group ID is mandatory in update.
622
+
623
+ #### Delete a user
624
+
625
+ ```ruby
626
+ client.users.delete(user_id)
627
+ ```
628
+
629
+ #### List all users
630
+
631
+ ```ruby
632
+ client.users.all
633
+ ```
634
+
635
+ <a name="groups"/>
636
+
637
+ ### Groups - [Api Reference](https://developers.activecampaign.com/reference#groups)
638
+
639
+ #### Create a group
640
+
641
+ ```ruby
642
+ client.groups.create({
643
+ title: 'Admin',
644
+ descript: 'This is a group for admin users (people that can manage content)'
645
+ })
646
+ ```
647
+ **BODY PARAMS**
648
+ - title* (string): Title of the group to be created
649
+ - descript (string): Group description
650
+ - pg_message_add (boolean): Permission for adding messages
651
+ - unsubscribelink (boolean): Whether or not to force unsubscribe links
652
+ - optinconfirm (boolean): Whether or not to force optin confirm for this group
653
+ - pg_list_add (boolean): Permission for adding lists
654
+ - pg_list_edit (boolean): Permission for editing lists
655
+ - pg_list_delete (boolean): Permission for deleting lists
656
+ - pg_list_headers (boolean): Permission for managing custom email headers
657
+ - pg_list_emailaccount (boolean): Permission for managing Unsubscribe By Email
658
+ - pg_list_bounce (boolean): Permission for accessing list bounce settings
659
+ - pg_message_edit (boolean): Permission for editing messages
660
+ - pg_message_delete (boolean): Permission for deleting messages
661
+ - pg_message_send (boolean): Permission for sending messages
662
+ - pg_contact_add (boolean): Permission for adding contacts
663
+ - pg_contact_edit (boolean): Permission for editing contacts
664
+ - pg_contact_delete (boolean): Permission for deleting contacts
665
+ - pg_contact_merge (boolean): Permission for merging contacts
666
+ - pg_contact_import (boolean): Permission for importing contacts
667
+ - pg_contact_approve (boolean): Permission for approving contacts
668
+ - pg_contact_export (boolean): Permission for exporting contacts
669
+ - pg_contact_sync (boolean): Permission for syncing contacts
670
+ - pg_contact_filters (boolean): Permission for managing contact list segments
671
+ - pg_contact_actions (boolean): Permission for managing contact actions
672
+ - pg_contact_fields (boolean): Permission for managing contact custom fields
673
+ - pg_user_add (boolean): Permission for adding users
674
+ - pg_user_edit (boolean): Permission for editing users
675
+ - pg_user_delete (boolean): Permission for deleting users
676
+ - pg_group_add (boolean): Permission for adding groups
677
+ - pg_group_edit (boolean): Permission for editing groups
678
+ - pg_group_delete (boolean): Permission for deleting groups
679
+ - pg_template_add (boolean): Permission for adding templates
680
+ - pg_template_edit (boolean): Permission for editing templates
681
+ - pg_template_delete (boolean): Permission for deleting templates
682
+ - pg_personalization_add (boolean): Permission for adding personalization tags
683
+ - pg_personalization_edit (boolean): Permission for editing personalization tags
684
+ - pg_personalization_delete (boolean): Permission for deleting personalization tags
685
+ - pg_automation_manage (boolean): pgFormEdit (boolean): Permission for editing subscription forms
686
+ - pg_reports_campaign (boolean): Permission for viewing campaign reports
687
+ - pg_reports_list (boolean): Permission for viewing list reports
688
+ - pg_reports_user (boolean): Permission for viewing user reports
689
+ - pg_startup_reports (boolean): Campaign ID of last campaign report viewed to decide whether to show link on startup
690
+ - pg_reports_trend (boolean): Permission for viewing trend reports
691
+ - pg_startup_gettingstarted (boolean): Whether or not to show the "getting started" tutorial on overview page
692
+ - pg_deal (boolean): Permission for viewing deals
693
+ - pg_deal_delete (boolean): Permission for deleting deals
694
+ - pg_deal_reassign (boolean): Permission for reassigning deals
695
+ - pg_deal_group_add (boolean): Permission for adding deal groups
696
+ - pg_deal_group_edit (boolean): Permission for editing deal groups
697
+ - pg_deal_group_delete (boolean): Permission for deleting deals groups
698
+ - pg_saved_responses_manage (boolean): Permission for managing saved responses
699
+ - pg_tag_manage (boolean): Permission for managing tags
700
+ - req_approval (boolean): Whether or not this group requires all campaigns to be approved
701
+ - req_approval_1st (boolean): Whether or not this group requires first campaign to be approved
702
+ - req_approval_notify_string (string): Who to notify for approval related issues (email)
703
+ - socialdata (boolean): Whether or not to show social links in campaigns sent from this group
704
+
705
+ #### Retrieve a group
706
+
707
+ ```ruby
708
+ client.groups.find(group_id)
709
+ ```
710
+
711
+ #### Update a group
712
+
713
+ ```ruby
714
+ client.groups.update(group_id, {
715
+ title: 'Updated Group Title'
716
+ })
717
+ ```
718
+
719
+ #### Delete a group
720
+
721
+ ```ruby
722
+ client.groups.delete(group_id)
723
+ ```
724
+
725
+ #### List all groups
726
+
727
+ ```ruby
728
+ client.groups.all
729
+ ```
730
+
731
+ <a name="templates"/>
732
+
733
+ ### Templates - [Api Reference](https://developers.activecampaign.com/reference#templates)
734
+
735
+ #### Retrieve a template
736
+
737
+ ```ruby
738
+ client.templates.find(template_id)
739
+ ```
740
+
741
+ #### Delete a template
742
+
743
+ ```ruby
744
+ client.templates.delete(templates_id)
745
+ ```
746
+
747
+ #### List all templates
748
+
749
+ ```ruby
750
+ client.templates.all
751
+ ```
528
752
 
529
753
  ## Contributing
530
754
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaignWrapper
4
+ module Api
5
+ module Group
6
+ module Arguments
7
+ SNAKE_CASED = {
8
+ create: %i[
9
+ pg_user_add
10
+ pg_user_edit
11
+ pg_user_delete
12
+ ]
13
+ }.freeze
14
+ end
15
+ end
16
+ end
17
+ end
@@ -12,10 +12,15 @@ require 'active_campaign_wrapper/core/custom_field_value_gateway'
12
12
  require 'active_campaign_wrapper/core/contact_tag_gateway'
13
13
  require 'active_campaign_wrapper/core/contact_automation_gateway'
14
14
  require 'active_campaign_wrapper/core/contact_score_value_gateway'
15
+ require 'active_campaign_wrapper/core/group_gateway'
16
+ require 'active_campaign_wrapper/core/list_group_gateway'
17
+ require 'active_campaign_wrapper/core/user_gateway'
18
+ require 'active_campaign_wrapper/core/template_gateway'
15
19
 
16
20
  require 'active_campaign_wrapper/api/contact/arguments'
17
21
  require 'active_campaign_wrapper/api/list/arguments'
18
22
  require 'active_campaign_wrapper/api/custom_field/arguments'
23
+ require 'active_campaign_wrapper/api/group/arguments'
19
24
 
20
25
  module ActiveCampaignWrapper
21
26
  class Client
@@ -31,43 +36,59 @@ module ActiveCampaignWrapper
31
36
  end
32
37
 
33
38
  def tags
34
- TagGateway.new(self)
39
+ @tags ||= TagGateway.new(self)
35
40
  end
36
41
 
37
42
  def contacts
38
- ContactGateway.new(self)
43
+ @contacts ||= ContactGateway.new(self)
39
44
  end
40
45
 
41
46
  def email_activities
42
- EmailActivityGateway.new(self)
47
+ @email_activities ||= EmailActivityGateway.new(self)
43
48
  end
44
49
 
45
50
  def contact_tags
46
- ContactTagGateway.new(self)
51
+ @contact_tags ||= ContactTagGateway.new(self)
47
52
  end
48
53
 
49
54
  def contact_score_values
50
- ContactScoreValueGateway.new(self)
55
+ @contact_score_values ||= ContactScoreValueGateway.new(self)
51
56
  end
52
57
 
53
58
  def contact_automations
54
- ContactAutomationGateway.new(self)
59
+ @contact_automations ||= ContactAutomationGateway.new(self)
55
60
  end
56
61
 
57
62
  def custom_fields
58
- CustomFieldGateway.new(self)
63
+ @custom_fields ||= CustomFieldGateway.new(self)
59
64
  end
60
65
 
61
66
  def custom_field_options
62
- CustomFieldOptionGateway.new(self)
67
+ @custom_field_options ||= CustomFieldOptionGateway.new(self)
63
68
  end
64
69
 
65
70
  def custom_field_values
66
- CustomFieldValueGateway.new(self)
71
+ @custom_field_values ||= CustomFieldValueGateway.new(self)
67
72
  end
68
73
 
69
74
  def lists
70
- ListGateway.new(self)
75
+ @lists ||= ListGateway.new(self)
76
+ end
77
+
78
+ def groups
79
+ @groups ||= GroupGateway.new(self)
80
+ end
81
+
82
+ def list_groups
83
+ @list_groups ||= ListGroupGateway.new(self)
84
+ end
85
+
86
+ def users
87
+ @users ||= UserGateway.new(self)
88
+ end
89
+
90
+ def templates
91
+ @templates ||= TemplateGateway.new(self)
71
92
  end
72
93
  end
73
94
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaignWrapper
4
+ module Core
5
+ class GroupGateway
6
+ def initialize(client)
7
+ @client = client
8
+ @config = client.config
9
+ end
10
+
11
+ def all(**params)
12
+ @config.get('/groups', query: params)
13
+ end
14
+
15
+ def create(params)
16
+ params = { group: params }
17
+ @config.post(
18
+ '/groups',
19
+ body: ActiveCampaignWrapper::Helpers.normalize_body(
20
+ params,
21
+ ActiveCampaignWrapper::Api::Group::Arguments::SNAKE_CASED[:create]
22
+ )
23
+ )
24
+ end
25
+
26
+ def delete(group_id)
27
+ @config.delete("/groups/#{group_id}")
28
+ end
29
+
30
+ def update(group_id, params)
31
+ params = { group: params }
32
+ @config.put(
33
+ "/groups/#{group_id}",
34
+ body: ActiveCampaignWrapper::Helpers.normalize_body(
35
+ params,
36
+ ActiveCampaignWrapper::Api::Group::Arguments::SNAKE_CASED[:create]
37
+ )
38
+ )
39
+ end
40
+
41
+ def find(group_id)
42
+ @config.get("/groups/#{group_id}")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaignWrapper
4
+ module Core
5
+ class ListGroupGateway
6
+ def initialize(client)
7
+ @client = client
8
+ @config = client.config
9
+ end
10
+
11
+ def all(**params)
12
+ @config.get('/listGroups', query: params)
13
+ end
14
+
15
+ def create(params)
16
+ params = { list_group: params }
17
+ @config.post(
18
+ '/listGroups',
19
+ body: ActiveCampaignWrapper::Helpers.normalize_body(params)
20
+ )
21
+ end
22
+
23
+ def delete(list_group_id)
24
+ @config.delete("/listGroups/#{list_group_id}")
25
+ end
26
+
27
+ def find(list_group_id)
28
+ @config.get("/listGroups/#{list_group_id}")
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaignWrapper
4
+ module Core
5
+ class TemplateGateway
6
+ def initialize(client)
7
+ @client = client
8
+ @config = client.config
9
+ end
10
+
11
+ def all(**params)
12
+ @config.get('/templates', query: params)
13
+ end
14
+
15
+ def delete(template_id)
16
+ @config.delete("/templates/#{template_id}")
17
+ end
18
+
19
+ def find(template_id)
20
+ @config.get("/templates/#{template_id}")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaignWrapper
4
+ module Core
5
+ class UserGateway
6
+ def initialize(client)
7
+ @client = client
8
+ @config = client.config
9
+ end
10
+
11
+ def all(**params)
12
+ @config.get('/users', query: params)
13
+ end
14
+
15
+ def create(params)
16
+ params = { user: params }
17
+ @config.post(
18
+ '/users',
19
+ body: ActiveCampaignWrapper::Helpers.normalize_body(params)
20
+ )
21
+ end
22
+
23
+ def delete(user_id)
24
+ @config.delete("/users/#{user_id}")
25
+ end
26
+
27
+ def update(user_id, params)
28
+ params = { user: params }
29
+ @config.put(
30
+ "/users/#{user_id}", body:
31
+ ActiveCampaignWrapper::Helpers.normalize_body(params)
32
+ )
33
+ end
34
+
35
+ def find(user_id)
36
+ @config.get("/users/#{user_id}")
37
+ end
38
+
39
+ def find_by_email(email)
40
+ @config.get("/users/email/#{email}")
41
+ end
42
+
43
+ def find_by_username(username)
44
+ @config.get("/users/username/#{username}")
45
+ end
46
+
47
+ def logged_in
48
+ @config.get('/users/me')
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaignWrapper
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_campaign_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anmol Yousaf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-30 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -255,6 +255,7 @@ files:
255
255
  - lib/active_campaign_wrapper.rb
256
256
  - lib/active_campaign_wrapper/api/contact/arguments.rb
257
257
  - lib/active_campaign_wrapper/api/custom_field/arguments.rb
258
+ - lib/active_campaign_wrapper/api/group/arguments.rb
258
259
  - lib/active_campaign_wrapper/api/list/arguments.rb
259
260
  - lib/active_campaign_wrapper/client.rb
260
261
  - lib/active_campaign_wrapper/configuration.rb
@@ -266,8 +267,12 @@ files:
266
267
  - lib/active_campaign_wrapper/core/custom_field_option_gateway.rb
267
268
  - lib/active_campaign_wrapper/core/custom_field_value_gateway.rb
268
269
  - lib/active_campaign_wrapper/core/email_activity_gateway.rb
270
+ - lib/active_campaign_wrapper/core/group_gateway.rb
269
271
  - lib/active_campaign_wrapper/core/list_gateway.rb
272
+ - lib/active_campaign_wrapper/core/list_group_gateway.rb
270
273
  - lib/active_campaign_wrapper/core/tag_gateway.rb
274
+ - lib/active_campaign_wrapper/core/template_gateway.rb
275
+ - lib/active_campaign_wrapper/core/user_gateway.rb
271
276
  - lib/active_campaign_wrapper/helpers.rb
272
277
  - lib/active_campaign_wrapper/version.rb
273
278
  homepage: https://github.com/anmol-yousaf/active_campaign_wrapper