active_campaign_wrapper 0.3.0 → 0.7.1
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 +4 -4
- data/README.md +286 -10
- data/lib/active_campaign_wrapper.rb +14 -5
- data/lib/active_campaign_wrapper/api/group/arguments.rb +17 -0
- data/lib/active_campaign_wrapper/client.rb +36 -10
- data/lib/active_campaign_wrapper/codecov.yml +2 -0
- data/lib/active_campaign_wrapper/configuration.rb +1 -1
- data/lib/active_campaign_wrapper/core/custom_field_gateway.rb +10 -0
- data/lib/active_campaign_wrapper/core/group_gateway.rb +46 -0
- data/lib/active_campaign_wrapper/core/list_group_gateway.rb +32 -0
- data/lib/active_campaign_wrapper/core/task_type_gateway.rb +48 -0
- data/lib/active_campaign_wrapper/core/template_gateway.rb +24 -0
- data/lib/active_campaign_wrapper/core/user_gateway.rb +52 -0
- data/lib/active_campaign_wrapper/helpers.rb +22 -5
- data/lib/active_campaign_wrapper/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9b3a33ce7dc71fbb514aae9f0b173b5d2bf77f5b0bfafb8e180beab80cdefae
|
4
|
+
data.tar.gz: 71939cda10a78b20daaaa569b0c3a403264191c018d5039925009b0e6d5d83f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e43ae2a7fbcae9a060b88ead7259d1431abddb56355f4bc5cf4690858c45cfe4f83b32ce1573093aeba61f8568608d81fd2264a2dd06054bfb1ea0dee1722d93
|
7
|
+
data.tar.gz: 7dd1786e4595c9d881b5d78ddadc8b73adf29adb99087211d99377381efe4421f28c4d20a66b2803e1b37385a6ab4d5388e3e0a1258f3de915991563039440ea
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[](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,10 @@ 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)
|
46
|
+
* [Task Types](#task-types)
|
42
47
|
|
43
48
|
<a name="initialize"/>
|
44
49
|
|
@@ -168,9 +173,43 @@ client.lists.all
|
|
168
173
|
**QUERY PARAMS** (Optional)
|
169
174
|
- filters[name] (string): Filter by the name of the list.
|
170
175
|
|
176
|
+
<a name="list-groups"/>
|
177
|
+
|
178
|
+
### List Groups - [Api Reference](https://developers.activecampaign.com/reference#create-a-list-group-permission)
|
179
|
+
|
180
|
+
#### Create a list group permission
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
client.list_groups.create({
|
184
|
+
listid: list_id,
|
185
|
+
groupid: group_id
|
186
|
+
})
|
187
|
+
```
|
188
|
+
**BODY PARAMS**
|
189
|
+
- listid* (integer): ID of the list
|
190
|
+
- groupid* (integer): ID of the group that list should be associated with
|
191
|
+
|
192
|
+
#### Retrieve a list group permission
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
client.list_groups.find(list_group_id)
|
196
|
+
```
|
197
|
+
|
198
|
+
#### Delete a list group permission
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
client.list_groups.delete(list_group_id)
|
202
|
+
```
|
203
|
+
|
204
|
+
#### Retrieve all list group permissions
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
client.list_groups.all
|
208
|
+
```
|
209
|
+
|
171
210
|
<a name="contacts"/>
|
172
211
|
|
173
|
-
|
212
|
+
### Contacts - [Api Reference](https://developers.activecampaign.com/reference#contact)
|
174
213
|
|
175
214
|
#### Create a contact
|
176
215
|
|
@@ -184,12 +223,6 @@ client.contacts.create({
|
|
184
223
|
|
185
224
|
**BODY PARAMS**
|
186
225
|
- 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
226
|
- first_name (string): First name of the new contact.
|
194
227
|
- last_name (string): Last name of the new contact.
|
195
228
|
- phone (integer): Phone number of the contact.
|
@@ -218,7 +251,14 @@ client.contacts.update_list_status({
|
|
218
251
|
**BODY PARAMS**
|
219
252
|
- list* (string/integer):ID of the list to subscribe the contact to
|
220
253
|
- contact* (string/integer): ID of the contact to subscribe to the list
|
221
|
-
- status* (string/integer):
|
254
|
+
- status* (string/integer): Possible Values: -1..3
|
255
|
+
- -1 Any
|
256
|
+
- 0 Unconfirmed
|
257
|
+
- 1 Active
|
258
|
+
- 2 Unsubscribed
|
259
|
+
- 3 Bounced
|
260
|
+
|
261
|
+
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
262
|
- sourceid (integer): Set to "4" when re-subscribing a contact to a list
|
223
263
|
|
224
264
|
#### Retrieve a contact
|
@@ -259,7 +299,6 @@ client.contacts.all
|
|
259
299
|
- search (string): Filter contacts that match the given value in the contact names, organization, phone or email
|
260
300
|
- 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
301
|
- seriesid (integer): Filter contacts associated with the given automation
|
262
|
-
- status (integer): -1..3
|
263
302
|
- tagid (integer): Filter contacts associated with the given tag
|
264
303
|
- filters[created_before] (date) Filter contacts that were created prior to this date
|
265
304
|
- filters[created_after] (date): Filter contacts that were created after this date
|
@@ -438,6 +477,12 @@ client.custom_fields.all
|
|
438
477
|
**QUERY PARAMS** (Optional)
|
439
478
|
- limit (integer): The number of fields returned per request.
|
440
479
|
|
480
|
+
#### Link a custom field to a list
|
481
|
+
|
482
|
+
```ruby
|
483
|
+
client.custom_fields.link_to_list(field_id, list_id)
|
484
|
+
```
|
485
|
+
|
441
486
|
<a name="custom-field-options"/>
|
442
487
|
|
443
488
|
### Custom Fields Options - [Api Reference](https://developers.activecampaign.com/reference#create-custom-field-options)
|
@@ -525,6 +570,237 @@ client.custom_field_values.delete(field_value_id)
|
|
525
570
|
```ruby
|
526
571
|
client.custom_field_values.all
|
527
572
|
```
|
573
|
+
<a name="users"/>
|
574
|
+
|
575
|
+
### Users - [Api Reference](https://developers.activecampaign.com/reference#users)
|
576
|
+
|
577
|
+
#### Create a user
|
578
|
+
|
579
|
+
```ruby
|
580
|
+
client.users.create({
|
581
|
+
first_name: 'Phoebe',
|
582
|
+
last_name: 'Buffay',
|
583
|
+
username: 'raginaphalange',
|
584
|
+
password: 'smellycat',
|
585
|
+
email: 'ragina.phalange@smellycat.com'
|
586
|
+
})
|
587
|
+
```
|
588
|
+
**BODY PARAMS**
|
589
|
+
- username* (string): Username
|
590
|
+
- email (string): Email address
|
591
|
+
- first_name (string): First name
|
592
|
+
- last_name (string): Last name
|
593
|
+
- group (string/integer): Group ID
|
594
|
+
- password (string): Plain text password
|
595
|
+
|
596
|
+
#### Retrieve a user
|
597
|
+
|
598
|
+
```ruby
|
599
|
+
client.users.find(user_id)
|
600
|
+
```
|
601
|
+
|
602
|
+
#### Retrieve logged in user
|
603
|
+
|
604
|
+
```ruby
|
605
|
+
client.users.logged_in
|
606
|
+
```
|
607
|
+
|
608
|
+
#### Retrieve a user by email
|
609
|
+
|
610
|
+
```ruby
|
611
|
+
client.users.find_by_email(email)
|
612
|
+
```
|
613
|
+
|
614
|
+
#### Retrieve a user by username
|
615
|
+
|
616
|
+
```ruby
|
617
|
+
client.users.find_by_username(username)
|
618
|
+
```
|
619
|
+
|
620
|
+
#### Update a user
|
621
|
+
|
622
|
+
```ruby
|
623
|
+
client.users.update(user_id, {
|
624
|
+
password: 'newsmellycat',
|
625
|
+
group: group_id
|
626
|
+
})
|
627
|
+
```
|
628
|
+
*Note*: Group ID is mandatory in update.
|
629
|
+
|
630
|
+
#### Delete a user
|
631
|
+
|
632
|
+
```ruby
|
633
|
+
client.users.delete(user_id)
|
634
|
+
```
|
635
|
+
|
636
|
+
#### List all users
|
637
|
+
|
638
|
+
```ruby
|
639
|
+
client.users.all
|
640
|
+
```
|
641
|
+
|
642
|
+
<a name="groups"/>
|
643
|
+
|
644
|
+
### Groups - [Api Reference](https://developers.activecampaign.com/reference#groups)
|
645
|
+
|
646
|
+
#### Create a group
|
647
|
+
|
648
|
+
```ruby
|
649
|
+
client.groups.create({
|
650
|
+
title: 'Admin',
|
651
|
+
descript: 'This is a group for admin users (people that can manage content)'
|
652
|
+
})
|
653
|
+
```
|
654
|
+
**BODY PARAMS**
|
655
|
+
- title* (string): Title of the group to be created
|
656
|
+
- descript (string): Group description
|
657
|
+
- pg_message_add (boolean): Permission for adding messages
|
658
|
+
- unsubscribelink (boolean): Whether or not to force unsubscribe links
|
659
|
+
- optinconfirm (boolean): Whether or not to force optin confirm for this group
|
660
|
+
- pg_list_add (boolean): Permission for adding lists
|
661
|
+
- pg_list_edit (boolean): Permission for editing lists
|
662
|
+
- pg_list_delete (boolean): Permission for deleting lists
|
663
|
+
- pg_list_headers (boolean): Permission for managing custom email headers
|
664
|
+
- pg_list_emailaccount (boolean): Permission for managing Unsubscribe By Email
|
665
|
+
- pg_list_bounce (boolean): Permission for accessing list bounce settings
|
666
|
+
- pg_message_edit (boolean): Permission for editing messages
|
667
|
+
- pg_message_delete (boolean): Permission for deleting messages
|
668
|
+
- pg_message_send (boolean): Permission for sending messages
|
669
|
+
- pg_contact_add (boolean): Permission for adding contacts
|
670
|
+
- pg_contact_edit (boolean): Permission for editing contacts
|
671
|
+
- pg_contact_delete (boolean): Permission for deleting contacts
|
672
|
+
- pg_contact_merge (boolean): Permission for merging contacts
|
673
|
+
- pg_contact_import (boolean): Permission for importing contacts
|
674
|
+
- pg_contact_approve (boolean): Permission for approving contacts
|
675
|
+
- pg_contact_export (boolean): Permission for exporting contacts
|
676
|
+
- pg_contact_sync (boolean): Permission for syncing contacts
|
677
|
+
- pg_contact_filters (boolean): Permission for managing contact list segments
|
678
|
+
- pg_contact_actions (boolean): Permission for managing contact actions
|
679
|
+
- pg_contact_fields (boolean): Permission for managing contact custom fields
|
680
|
+
- pg_user_add (boolean): Permission for adding users
|
681
|
+
- pg_user_edit (boolean): Permission for editing users
|
682
|
+
- pg_user_delete (boolean): Permission for deleting users
|
683
|
+
- pg_group_add (boolean): Permission for adding groups
|
684
|
+
- pg_group_edit (boolean): Permission for editing groups
|
685
|
+
- pg_group_delete (boolean): Permission for deleting groups
|
686
|
+
- pg_template_add (boolean): Permission for adding templates
|
687
|
+
- pg_template_edit (boolean): Permission for editing templates
|
688
|
+
- pg_template_delete (boolean): Permission for deleting templates
|
689
|
+
- pg_personalization_add (boolean): Permission for adding personalization tags
|
690
|
+
- pg_personalization_edit (boolean): Permission for editing personalization tags
|
691
|
+
- pg_personalization_delete (boolean): Permission for deleting personalization tags
|
692
|
+
- pg_automation_manage (boolean): pgFormEdit (boolean): Permission for editing subscription forms
|
693
|
+
- pg_reports_campaign (boolean): Permission for viewing campaign reports
|
694
|
+
- pg_reports_list (boolean): Permission for viewing list reports
|
695
|
+
- pg_reports_user (boolean): Permission for viewing user reports
|
696
|
+
- pg_startup_reports (boolean): Campaign ID of last campaign report viewed to decide whether to show link on startup
|
697
|
+
- pg_reports_trend (boolean): Permission for viewing trend reports
|
698
|
+
- pg_startup_gettingstarted (boolean): Whether or not to show the "getting started" tutorial on overview page
|
699
|
+
- pg_deal (boolean): Permission for viewing deals
|
700
|
+
- pg_deal_delete (boolean): Permission for deleting deals
|
701
|
+
- pg_deal_reassign (boolean): Permission for reassigning deals
|
702
|
+
- pg_deal_group_add (boolean): Permission for adding deal groups
|
703
|
+
- pg_deal_group_edit (boolean): Permission for editing deal groups
|
704
|
+
- pg_deal_group_delete (boolean): Permission for deleting deals groups
|
705
|
+
- pg_saved_responses_manage (boolean): Permission for managing saved responses
|
706
|
+
- pg_tag_manage (boolean): Permission for managing tags
|
707
|
+
- req_approval (boolean): Whether or not this group requires all campaigns to be approved
|
708
|
+
- req_approval_1st (boolean): Whether or not this group requires first campaign to be approved
|
709
|
+
- req_approval_notify_string (string): Who to notify for approval related issues (email)
|
710
|
+
- socialdata (boolean): Whether or not to show social links in campaigns sent from this group
|
711
|
+
|
712
|
+
#### Retrieve a group
|
713
|
+
|
714
|
+
```ruby
|
715
|
+
client.groups.find(group_id)
|
716
|
+
```
|
717
|
+
|
718
|
+
#### Update a group
|
719
|
+
|
720
|
+
```ruby
|
721
|
+
client.groups.update(group_id, {
|
722
|
+
title: 'Updated Group Title'
|
723
|
+
})
|
724
|
+
```
|
725
|
+
|
726
|
+
#### Delete a group
|
727
|
+
|
728
|
+
```ruby
|
729
|
+
client.groups.delete(group_id)
|
730
|
+
```
|
731
|
+
|
732
|
+
#### List all groups
|
733
|
+
|
734
|
+
```ruby
|
735
|
+
client.groups.all
|
736
|
+
```
|
737
|
+
|
738
|
+
<a name="templates"/>
|
739
|
+
|
740
|
+
### Templates - [Api Reference](https://developers.activecampaign.com/reference#templates)
|
741
|
+
|
742
|
+
#### Retrieve a template
|
743
|
+
|
744
|
+
```ruby
|
745
|
+
client.templates.find(template_id)
|
746
|
+
```
|
747
|
+
|
748
|
+
#### Delete a template
|
749
|
+
|
750
|
+
```ruby
|
751
|
+
client.templates.delete(template_id)
|
752
|
+
```
|
753
|
+
|
754
|
+
#### List all templates
|
755
|
+
|
756
|
+
```ruby
|
757
|
+
client.templates.all
|
758
|
+
```
|
759
|
+
|
760
|
+
<a name="task-types"/>
|
761
|
+
|
762
|
+
### Task Types - [Api Reference](https://developers.activecampaign.com/reference#deal-task-types)
|
763
|
+
|
764
|
+
#### Create a task type
|
765
|
+
|
766
|
+
```ruby
|
767
|
+
client.task_types.create({
|
768
|
+
title: 'Call'
|
769
|
+
})
|
770
|
+
```
|
771
|
+
**BODY PARAMS**
|
772
|
+
- title* (string): Deal task type's title. The title should be unique among deal task types.
|
773
|
+
|
774
|
+
#### Retrieve a task type
|
775
|
+
|
776
|
+
```ruby
|
777
|
+
client.task_types.find(task_type_id)
|
778
|
+
```
|
779
|
+
#### Update a task type
|
780
|
+
|
781
|
+
```ruby
|
782
|
+
client.task_types.update(task_type_id, {
|
783
|
+
title: 'New super cool title'
|
784
|
+
})
|
785
|
+
```
|
786
|
+
|
787
|
+
#### Delete a task type
|
788
|
+
|
789
|
+
```ruby
|
790
|
+
client.task_types.delete(task_type_id)
|
791
|
+
```
|
792
|
+
|
793
|
+
#### List all task types
|
794
|
+
|
795
|
+
```ruby
|
796
|
+
client.task_types.all
|
797
|
+
```
|
798
|
+
|
799
|
+
#### Move tasks to another task type
|
800
|
+
|
801
|
+
```ruby
|
802
|
+
client.task_types.move_tasks(from_task_type_id, to_task_type_id)
|
803
|
+
```
|
528
804
|
|
529
805
|
## Contributing
|
530
806
|
|
@@ -15,13 +15,22 @@ module ActiveCampaignWrapper
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
# :nocov:
|
19
|
+
class Error < StandardError
|
20
|
+
attr_accessor :response
|
19
21
|
|
20
|
-
|
22
|
+
def initialize(response)
|
23
|
+
super
|
24
|
+
@response = response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Forbidden < Error; end
|
21
29
|
|
22
|
-
class UnprocessableEntity <
|
30
|
+
class UnprocessableEntity < Error; end
|
23
31
|
|
24
|
-
class NotFound <
|
32
|
+
class NotFound < Error; end
|
25
33
|
|
26
|
-
class TooManyRequests <
|
34
|
+
class TooManyRequests < Error; end
|
35
|
+
# :nocov:
|
27
36
|
end
|
@@ -12,10 +12,16 @@ 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'
|
19
|
+
require 'active_campaign_wrapper/core/task_type_gateway'
|
15
20
|
|
16
21
|
require 'active_campaign_wrapper/api/contact/arguments'
|
17
22
|
require 'active_campaign_wrapper/api/list/arguments'
|
18
23
|
require 'active_campaign_wrapper/api/custom_field/arguments'
|
24
|
+
require 'active_campaign_wrapper/api/group/arguments'
|
19
25
|
|
20
26
|
module ActiveCampaignWrapper
|
21
27
|
class Client
|
@@ -31,43 +37,63 @@ module ActiveCampaignWrapper
|
|
31
37
|
end
|
32
38
|
|
33
39
|
def tags
|
34
|
-
TagGateway.new(self)
|
40
|
+
@tags ||= TagGateway.new(self)
|
35
41
|
end
|
36
42
|
|
37
43
|
def contacts
|
38
|
-
ContactGateway.new(self)
|
44
|
+
@contacts ||= ContactGateway.new(self)
|
39
45
|
end
|
40
46
|
|
41
47
|
def email_activities
|
42
|
-
EmailActivityGateway.new(self)
|
48
|
+
@email_activities ||= EmailActivityGateway.new(self)
|
43
49
|
end
|
44
50
|
|
45
51
|
def contact_tags
|
46
|
-
ContactTagGateway.new(self)
|
52
|
+
@contact_tags ||= ContactTagGateway.new(self)
|
47
53
|
end
|
48
54
|
|
49
55
|
def contact_score_values
|
50
|
-
ContactScoreValueGateway.new(self)
|
56
|
+
@contact_score_values ||= ContactScoreValueGateway.new(self)
|
51
57
|
end
|
52
58
|
|
53
59
|
def contact_automations
|
54
|
-
ContactAutomationGateway.new(self)
|
60
|
+
@contact_automations ||= ContactAutomationGateway.new(self)
|
55
61
|
end
|
56
62
|
|
57
63
|
def custom_fields
|
58
|
-
CustomFieldGateway.new(self)
|
64
|
+
@custom_fields ||= CustomFieldGateway.new(self)
|
59
65
|
end
|
60
66
|
|
61
67
|
def custom_field_options
|
62
|
-
CustomFieldOptionGateway.new(self)
|
68
|
+
@custom_field_options ||= CustomFieldOptionGateway.new(self)
|
63
69
|
end
|
64
70
|
|
65
71
|
def custom_field_values
|
66
|
-
CustomFieldValueGateway.new(self)
|
72
|
+
@custom_field_values ||= CustomFieldValueGateway.new(self)
|
67
73
|
end
|
68
74
|
|
69
75
|
def lists
|
70
|
-
ListGateway.new(self)
|
76
|
+
@lists ||= ListGateway.new(self)
|
77
|
+
end
|
78
|
+
|
79
|
+
def groups
|
80
|
+
@groups ||= GroupGateway.new(self)
|
81
|
+
end
|
82
|
+
|
83
|
+
def list_groups
|
84
|
+
@list_groups ||= ListGroupGateway.new(self)
|
85
|
+
end
|
86
|
+
|
87
|
+
def users
|
88
|
+
@users ||= UserGateway.new(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
def templates
|
92
|
+
@templates ||= TemplateGateway.new(self)
|
93
|
+
end
|
94
|
+
|
95
|
+
def task_types
|
96
|
+
@task_types ||= TaskTypeGateway.new(self)
|
71
97
|
end
|
72
98
|
end
|
73
99
|
end
|
@@ -16,7 +16,7 @@ module ActiveCampaignWrapper
|
|
16
16
|
@api_token = api_token.presence || ActiveCampaignWrapper.api_token
|
17
17
|
|
18
18
|
self.class.base_uri "#{@endpoint_url}/api/#{ActiveCampaignWrapper::API_VERSION}"
|
19
|
-
self.class.default_options.merge! headers: {
|
19
|
+
self.class.default_options.merge! headers: { 'Api-Token' => @api_token }
|
20
20
|
end
|
21
21
|
|
22
22
|
def post(*args)
|
@@ -41,6 +41,16 @@ module ActiveCampaignWrapper
|
|
41
41
|
def find(field_id)
|
42
42
|
@config.get("/fields/#{field_id}")
|
43
43
|
end
|
44
|
+
|
45
|
+
def link_to_list(field_id, list_id)
|
46
|
+
params = { field_rel: { field: field_id, relid: list_id } }
|
47
|
+
@config.post(
|
48
|
+
'/fieldRels',
|
49
|
+
body: ActiveCampaignWrapper::Helpers.normalize_body(
|
50
|
+
params
|
51
|
+
)
|
52
|
+
)
|
53
|
+
end
|
44
54
|
end
|
45
55
|
end
|
46
56
|
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,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveCampaignWrapper
|
4
|
+
module Core
|
5
|
+
class TaskTypeGateway
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
@config = client.config
|
9
|
+
end
|
10
|
+
|
11
|
+
def all(**params)
|
12
|
+
@config.get('/dealTasktypes', query: params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(params)
|
16
|
+
params = { deal_tasktype: params }
|
17
|
+
@config.post(
|
18
|
+
'/dealTasktypes',
|
19
|
+
body: ActiveCampaignWrapper::Helpers.normalize_body(params)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(task_type_id)
|
24
|
+
@config.delete("/dealTasktypes/#{task_type_id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def update(task_type_id, params)
|
28
|
+
params = { deal_tasktype: params }
|
29
|
+
@config.put(
|
30
|
+
"/dealTasktypes/#{task_type_id}", body:
|
31
|
+
ActiveCampaignWrapper::Helpers.normalize_body(params)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def find(task_type_id)
|
36
|
+
@config.get("/dealTasktypes/#{task_type_id}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def move_tasks(from_task_type_id, to_task_type_id)
|
40
|
+
params = { deal_task: { deal_tasktype: to_task_type_id } }
|
41
|
+
@config.put(
|
42
|
+
"/dealTasktypes/#{from_task_type_id}/dealTasks",
|
43
|
+
body: ActiveCampaignWrapper::Helpers.normalize_body(params)
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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
|
@@ -2,16 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'active_support/core_ext/string'
|
4
4
|
|
5
|
+
# :nocov:
|
5
6
|
module ActiveCampaignWrapper
|
6
7
|
module Helpers
|
7
8
|
module_function
|
8
9
|
|
9
10
|
def normalize_response(response)
|
10
|
-
|
11
|
-
raise ActiveCampaignWrapper::NotFound, response['message'] if response.not_found?
|
12
|
-
raise ActiveCampaignWrapper::UnprocessableEntity, response['errors']&.join(', ') || response['error'] if response.unprocessable_entity?
|
13
|
-
raise ActiveCampaignWrapper::TooManyRequests, response['message'] if response.too_many_requests?
|
14
|
-
raise ActiveCampaignWrapper::Error, response['message'] unless response.success?
|
11
|
+
handle_errors(response)
|
15
12
|
|
16
13
|
if response&.body.present?
|
17
14
|
transform_keys(response, [:underscore])
|
@@ -87,5 +84,25 @@ module ActiveCampaignWrapper
|
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
87
|
+
|
88
|
+
def handle_errors(response)
|
89
|
+
return if response.success?
|
90
|
+
|
91
|
+
class_name = if response.forbidden?
|
92
|
+
ActiveCampaignWrapper::Forbidden
|
93
|
+
elsif response.not_found?
|
94
|
+
ActiveCampaignWrapper::NotFound
|
95
|
+
elsif response.unprocessable_entity?
|
96
|
+
ActiveCampaignWrapper::UnprocessableEntity
|
97
|
+
elsif response.too_many_requests?
|
98
|
+
ActiveCampaignWrapper::TooManyRequests
|
99
|
+
else
|
100
|
+
ActiveCampaignWrapper::Error
|
101
|
+
end
|
102
|
+
raise class_name.new(response),
|
103
|
+
response['message'] || response['errors']&.join(', ') || response['error'],
|
104
|
+
caller
|
105
|
+
end
|
90
106
|
end
|
91
107
|
end
|
108
|
+
# :nocov:
|
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.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -255,8 +255,10 @@ 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
|
261
|
+
- lib/active_campaign_wrapper/codecov.yml
|
260
262
|
- lib/active_campaign_wrapper/configuration.rb
|
261
263
|
- lib/active_campaign_wrapper/core/contact_automation_gateway.rb
|
262
264
|
- lib/active_campaign_wrapper/core/contact_gateway.rb
|
@@ -266,8 +268,13 @@ files:
|
|
266
268
|
- lib/active_campaign_wrapper/core/custom_field_option_gateway.rb
|
267
269
|
- lib/active_campaign_wrapper/core/custom_field_value_gateway.rb
|
268
270
|
- lib/active_campaign_wrapper/core/email_activity_gateway.rb
|
271
|
+
- lib/active_campaign_wrapper/core/group_gateway.rb
|
269
272
|
- lib/active_campaign_wrapper/core/list_gateway.rb
|
273
|
+
- lib/active_campaign_wrapper/core/list_group_gateway.rb
|
270
274
|
- lib/active_campaign_wrapper/core/tag_gateway.rb
|
275
|
+
- lib/active_campaign_wrapper/core/task_type_gateway.rb
|
276
|
+
- lib/active_campaign_wrapper/core/template_gateway.rb
|
277
|
+
- lib/active_campaign_wrapper/core/user_gateway.rb
|
271
278
|
- lib/active_campaign_wrapper/helpers.rb
|
272
279
|
- lib/active_campaign_wrapper/version.rb
|
273
280
|
homepage: https://github.com/anmol-yousaf/active_campaign_wrapper
|