active_campaign_wrapper 0.1.0 → 0.6.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: 1644a0094a6302f78117f2de1f93d72494bc0d9f612c22fca8d4b3998b2a9e03
4
- data.tar.gz: 3276a2d8d3cd37cfc0cc9913c7f7afc6c25805e20a170e7b5246eebd0d98de5d
3
+ metadata.gz: 550a77cc8d3977f538a43b652e7b718abea6aa83759b30551eac82a0ec914e1c
4
+ data.tar.gz: f96a647161149950034b3912ad91e044081925b4b07f7791c23569e86c2a9f28
5
5
  SHA512:
6
- metadata.gz: 5777d3e25b2425ebe0a831da6e1195bd5e608929c377d22e5c38135f2e4568b05f70112b1b987323b70571f10ed19913caca282757cbdfeafff597b6cc88090e
7
- data.tar.gz: 784401487b377b973748b1aa672b7bd7d9d8f45649eb287abd0a3eb68bb9d2eda5d008c8febb5dfda7cb3166b45b7f16aafbc5a8436e089cc6d07ecbbb80f2ec
6
+ metadata.gz: 11f14ca8ced5c3466fa3e10ff920bb6aec46e7b2301feb2a83b8b059df096dadb274c83df4ba00cd91a6d6e600a63dc0126f003c47ab1a280ef5a89769f9d062
7
+ data.tar.gz: 5a90300b674ef5ed4aab05a99e87c4aae054d774ab2c9f537eccb6396ce0e3658b668b60629ef212e079c7568dff7b3de875900a1748b47d59e4674acfb7b574
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,15 +31,19 @@ Or install it yourself as:
30
31
  * [Initialize](#initialize)
31
32
  * [Tags](#tags)
32
33
  * [Lists](#lists)
33
- * [Contacts](#tags)
34
+ * [List Groups](#list-groups)
35
+ * [Contacts](#contacts)
34
36
  * [Contact Tags](#contact-tags)
35
37
  * [Contact Automations](#contact-automations)
36
38
  * [Contact Score Values](#contact-score-values)
39
+ * [Email Activities](#email-activities)
37
40
  * [Custom Fields](#custom-fields)
38
41
  * [Custom Field Options](#custom-field-options)
39
42
  * [Custom Field Values](#custom-field-values)
40
- * [Email Activities](#email-activities)
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
- #### Contacts - [Api Reference](https://developers.activecampaign.com/reference#contact)
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): 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.
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
@@ -313,7 +352,7 @@ client.contacts.bulk_import({
313
352
  - params (array of objects): A list of parameters to include in the callback request. Add each parameter in the form of a key-value pair. For a GET request, each parameter will be appended to the end of the URL in a query string. For a POST request, parameters will be included in the body of the request.
314
353
  - headers (array of objects): A list of headers to include in the callback request. Add each header in the form of a key-value pair.
315
354
 
316
- <a name="#contact-tags"/>
355
+ <a name="contact-tags"/>
317
356
 
318
357
  ### Contact Tags - [Api Reference](https://developers.activecampaign.com/reference#contact-tags)
319
358
 
@@ -346,7 +385,7 @@ client.contact_tags.find(contact_tag_id)
346
385
  ```ruby
347
386
  client.contact_tags.delete(contact_tag_id)
348
387
  ```
349
- <a name="#contact-automations"/>
388
+ <a name="contact-automations"/>
350
389
 
351
390
  ### Contact Automations - [Api Reference](https://developers.activecampaign.com/reference#list-all-contactautomations-for-contact)
352
391
 
@@ -356,7 +395,7 @@ client.contact_tags.delete(contact_tag_id)
356
395
  client.contact_automations.all(contact_id)
357
396
  ```
358
397
 
359
- <a name="#contact-score-values"/>
398
+ <a name="contact-score-values"/>
360
399
 
361
400
  ### Contact Score Values - [Api Reference](https://developers.activecampaign.com/reference#list-all-contactautomations-for-contact)
362
401
 
@@ -366,7 +405,7 @@ client.contact_automations.all(contact_id)
366
405
  client.contact_score_values.all(contact_id)
367
406
  ```
368
407
 
369
- <a name="#email-activities"/>
408
+ <a name="email-activities"/>
370
409
 
371
410
  ### Email Activities - [Api Reference](https://developers.activecampaign.com/reference#email-emailactivities)
372
411
 
@@ -380,7 +419,7 @@ client.email_activities.all
380
419
  - filters[subscriberid] (integer): Set this parameter to return only email activities belonging to a given subscriber.
381
420
  - filters[dealId] (integer): Set this parameter to return only email activities belonging to a given deal.
382
421
 
383
- <a name="#custom-fields"/>
422
+ <a name="custom-fields"/>
384
423
 
385
424
  ### Custom Fields - [Api Reference](https://developers.activecampaign.com/reference#fields)
386
425
 
@@ -438,7 +477,13 @@ client.custom_fields.all
438
477
  **QUERY PARAMS** (Optional)
439
478
  - limit (integer): The number of fields returned per request.
440
479
 
441
- <a name="#custom-field-options"/>
480
+ #### Link a custom field to a list
481
+
482
+ ```ruby
483
+ client.custom_fields.link_to_list(field_id, list_id)
484
+ ```
485
+
486
+ <a name="custom-field-options"/>
442
487
 
443
488
  ### Custom Fields Options - [Api Reference](https://developers.activecampaign.com/reference#create-custom-field-options)
444
489
 
@@ -478,7 +523,7 @@ client.custom_field_options.find(field_option_id)
478
523
  client.custom_field_options.delete(field_option_id)
479
524
  ```
480
525
 
481
- <a name="#custom-field-values"/>
526
+ <a name="custom-field-values"/>
482
527
 
483
528
  ### Custom Fields Values - [Api Reference](https://developers.activecampaign.com/reference#fieldvalues)
484
529
 
@@ -489,14 +534,14 @@ client.custom_field_values.create({
489
534
  contact: contact_id,
490
535
  field: field_id,
491
536
  value: value
492
- }, useDefaults: true)
537
+ }, use_defaults: true)
493
538
  ```
494
539
 
495
540
  **BODY PARAMS**
496
541
  - contact* (string/integer): ID of the contact whose field value you're updating
497
542
  - field* (string/integer): ID of the custom field whose value you're updating for the contact
498
543
  - value* (string): Value for the field that you're updating. For multi-select options this needs to be in the format of ||option1||option2||
499
- - useDefaults: If true, this will populate the missing required fields for this contact with default values
544
+ - use_defaults: If true, this will populate the missing required fields for this contact with default values
500
545
 
501
546
  #### Retrieve a custom field value
502
547
 
@@ -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
 
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
- spec.add_dependency 'activesupport', '>= 5.2.4.3'
33
- spec.add_dependency 'httparty', '>= 0.14'
32
+ spec.add_dependency 'activesupport', '>= 4.0', '< 8.0'
33
+ spec.add_dependency 'httparty', '>= 0.14', '< 0.19'
34
34
 
35
35
  spec.add_development_dependency 'bundler', '~> 2.1.4'
36
36
  spec.add_development_dependency 'codecov', '~> 0.1'
@@ -17,5 +17,11 @@ module ActiveCampaignWrapper
17
17
 
18
18
  class Error < StandardError; end
19
19
 
20
- class AuthorizationError < StandardError; end
20
+ class Forbidden < StandardError; end
21
+
22
+ class UnprocessableEntity < StandardError; end
23
+
24
+ class NotFound < StandardError; end
25
+
26
+ class TooManyRequests < StandardError; end
21
27
  end
@@ -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,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: { api_token: @api_token }
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
@@ -7,8 +7,11 @@ module ActiveCampaignWrapper
7
7
  module_function
8
8
 
9
9
  def normalize_response(response)
10
- raise ActiveCampaignWrapper::AuthorizationError, response.message if response.unauthorized?
11
- raise ActiveCampaignWrapper::Error, response.message unless response.success?
10
+ raise ActiveCampaignWrapper::Forbidden, response['message'] if response.forbidden?
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?
12
15
 
13
16
  if response&.body.present?
14
17
  transform_keys(response, [:underscore])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaignWrapper
4
- VERSION = '0.1.0'
4
+ VERSION = '0.6.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.1.0
4
+ version: 0.6.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-24 00:00:00.000000000 Z
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.4.3
19
+ version: '4.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 5.2.4.3
29
+ version: '4.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: httparty
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: '0.14'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.19'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,9 @@ dependencies:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: '0.14'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.19'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: bundler
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +255,7 @@ files:
243
255
  - lib/active_campaign_wrapper.rb
244
256
  - lib/active_campaign_wrapper/api/contact/arguments.rb
245
257
  - lib/active_campaign_wrapper/api/custom_field/arguments.rb
258
+ - lib/active_campaign_wrapper/api/group/arguments.rb
246
259
  - lib/active_campaign_wrapper/api/list/arguments.rb
247
260
  - lib/active_campaign_wrapper/client.rb
248
261
  - lib/active_campaign_wrapper/configuration.rb
@@ -254,8 +267,13 @@ files:
254
267
  - lib/active_campaign_wrapper/core/custom_field_option_gateway.rb
255
268
  - lib/active_campaign_wrapper/core/custom_field_value_gateway.rb
256
269
  - lib/active_campaign_wrapper/core/email_activity_gateway.rb
270
+ - lib/active_campaign_wrapper/core/group_gateway.rb
257
271
  - lib/active_campaign_wrapper/core/list_gateway.rb
272
+ - lib/active_campaign_wrapper/core/list_group_gateway.rb
258
273
  - lib/active_campaign_wrapper/core/tag_gateway.rb
274
+ - lib/active_campaign_wrapper/core/task_type_gateway.rb
275
+ - lib/active_campaign_wrapper/core/template_gateway.rb
276
+ - lib/active_campaign_wrapper/core/user_gateway.rb
259
277
  - lib/active_campaign_wrapper/helpers.rb
260
278
  - lib/active_campaign_wrapper/version.rb
261
279
  homepage: https://github.com/anmol-yousaf/active_campaign_wrapper