ractive_campaign 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -1
  3. data/Gemfile.lock +7 -7
  4. data/README.md +52 -9
  5. data/lib/active_campaign/api_attributes.rb +6 -17
  6. data/lib/active_campaign/api_http.rb +7 -1
  7. data/lib/active_campaign/models/account.rb +7 -0
  8. data/lib/active_campaign/models/account_contact.rb +9 -0
  9. data/lib/active_campaign/models/address.rb +7 -0
  10. data/lib/active_campaign/models/campaign.rb +7 -0
  11. data/lib/active_campaign/models/contact.rb +41 -28
  12. data/lib/active_campaign/models/contact_automation.rb +7 -0
  13. data/lib/active_campaign/models/contact_deal.rb +7 -0
  14. data/lib/active_campaign/models/contact_tag.rb +35 -2
  15. data/lib/active_campaign/models/custom_deal_field.rb +21 -0
  16. data/lib/active_campaign/models/custom_deal_field_value.rb +20 -0
  17. data/lib/active_campaign/models/deal.rb +17 -0
  18. data/lib/active_campaign/models/email_activity.rb +7 -0
  19. data/lib/active_campaign/models/field.rb +13 -0
  20. data/lib/active_campaign/models/field_value.rb +9 -0
  21. data/lib/active_campaign/models/list.rb +2 -38
  22. data/lib/active_campaign/models/model.rb +11 -7
  23. data/lib/active_campaign/models/note.rb +7 -0
  24. data/lib/active_campaign/models/pipeline.rb +18 -0
  25. data/lib/active_campaign/models/stage.rb +22 -0
  26. data/lib/active_campaign/models/tag.rb +1 -7
  27. data/lib/active_campaign/models/task.rb +23 -0
  28. data/lib/active_campaign/models/task_outcome.rb +7 -0
  29. data/lib/active_campaign/models/task_type.rb +13 -0
  30. data/lib/active_campaign/models/user.rb +15 -0
  31. data/lib/active_campaign/version.rb +1 -1
  32. data/lib/active_campaign.rb +0 -1
  33. data/lib/ractive_campaign.rb +3 -0
  34. metadata +30 -42
  35. data/lib/active_campaign/api_errors.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bea9a04deb5b0cdfadc355f3e4ee086355a97bab723e4cdff4c1b6b7caf5b2ee
4
- data.tar.gz: d7725b4597f94558074d7b56c2592f9ad30b18c6afb5f0df90dd2cc215b0abed
3
+ metadata.gz: 138c40a5a3a11cfdaca62219657f9757cade906aadda7ec72d34c742370c0963
4
+ data.tar.gz: 1dc92c8d3b8653899c9133485d094536266d6e8e452473229ec04ca464d50f65
5
5
  SHA512:
6
- metadata.gz: 17b27596b7f367df37952a6b4256d906d1e5cc5bd1697088b94dccd4c9cfe93f52f637af47db98db9d85111f8ef571877b0ea7c0e5d93c61a554f82df35c3a3d
7
- data.tar.gz: 9770a5164db9c6d2923025db4a5e3c5a1a87d1e83db4a9c74fd175630e1144ee8f4bedd3db6c5281a4eeb0167d3ccffbc9cd1f1b084ad39ebfc16ebc6e0fff25
6
+ metadata.gz: 44e8d36dda391fa212172e35f1b5059477e61f517906a23289accc539b516234593633526624d9904429ce15581a3f807e08d7c18f315ad15e965889cffbd009
7
+ data.tar.gz: c1dffb39c97ad93b7d72004f0e625e4e09387d2b916c9d0792dde586deb8a57ebbda4e5e22b59949db9f30ff10fc1ea301b6580e9e801fb2a19254f674c47ec8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2021-11-10
3
+ ## [0.1.4] - 2021-11-19
4
+ ### Changed
5
+
6
+ - loading endpoint result into the correct model class
7
+ - README section on `install and require`
8
+
9
+ ## [0.1.3] - 2021-11-18
10
+ ### Added
11
+
12
+ - account contact
13
+ - campaign
14
+ - contact automatin
15
+ - etc
16
+
17
+ ### Changed
18
+
19
+ - attrs config
20
+ - README config info
21
+
22
+ ## [0.1.2] - 2021-11-17
23
+ ### Added
24
+
25
+ - list
26
+ - etc
27
+
28
+ ## [0.1.0] - 2021-11-13
29
+ ### Added
30
+
31
+ - contact
32
+ - tags
33
+ - etc
34
+
35
+ ## [0.0.1] - 2021-11-10
4
36
 
5
37
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,13 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ractive_campaign (0.1.0)
4
+ ractive_campaign (0.1.4)
5
5
  activemodel (~> 6.1.4)
6
- activesupport (~> 6.1.4)
7
- dry-configurable (~> 0.7.0)
6
+ dry-configurable (~> 0.12.1)
8
7
  faraday (~> 1.8.0)
9
8
  faraday_middleware (~> 1.2.0)
10
- oj (>= 3.0, < 4.0)
11
9
 
12
10
  GEM
13
11
  remote: https://rubygems.org/
@@ -30,7 +28,10 @@ GEM
30
28
  rexml
31
29
  diff-lcs (1.4.4)
32
30
  dotenv (2.7.6)
33
- dry-configurable (0.7.0)
31
+ dry-configurable (0.12.1)
32
+ concurrent-ruby (~> 1.0)
33
+ dry-core (~> 0.5, >= 0.5.0)
34
+ dry-core (0.7.1)
34
35
  concurrent-ruby (~> 1.0)
35
36
  faraday (1.8.0)
36
37
  faraday-em_http (~> 1.0)
@@ -62,7 +63,6 @@ GEM
62
63
  method_source (1.0.0)
63
64
  minitest (5.14.4)
64
65
  multipart-post (2.1.1)
65
- oj (3.13.9)
66
66
  parallel (1.21.0)
67
67
  parser (3.0.2.0)
68
68
  ast (~> 2.4.1)
@@ -91,7 +91,7 @@ GEM
91
91
  diff-lcs (>= 1.2.0, < 2.0)
92
92
  rspec-support (~> 3.10.0)
93
93
  rspec-support (3.10.3)
94
- rubocop (1.22.3)
94
+ rubocop (1.23.0)
95
95
  parallel (~> 1.10)
96
96
  parser (>= 3.0.0.0)
97
97
  rainbow (>= 2.2.2, < 4.0)
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # RactiveCampaign
1
+ [![Gem Version](https://badge.fury.io/rb/ractive_campaign.svg)](https://badge.fury.io/rb/ractive_campaign) [![Maintainability](https://api.codeclimate.com/v1/badges/c23221fc334b63af9a07/maintainability)](https://codeclimate.com/github/wedsonlima/ractive_campaign/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/c23221fc334b63af9a07/test_coverage)](https://codeclimate.com/github/wedsonlima/ractive_campaign/test_coverage)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ractive_campaign`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ # RactiveCampaign
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Ruby API wrapper for ActiveCampaign API v3
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'ractive_campaign'
12
+ gem "ractive_campaign"
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -22,17 +22,60 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### Config
26
+
27
+ ```ruby
28
+ # config/initializers/ractive_campaign.rb
29
+
30
+ ActiveCampaign.configure do |config|
31
+ config.api_url = ENV["AC_API_URL"] # ex.: https://mystartup.api-us1.com/api/3
32
+ config.api_key = ENV["AC_API_KEY"]
33
+ end
34
+ ```
35
+
36
+ ### Examples
37
+
38
+ #### Contact
39
+
40
+ ```ruby
41
+ # new
42
+ harry = ActiveCampaign::Contact.new firstName: "Harry",
43
+ lastName: "Potter",
44
+ email: "potter.hurray@hogwash.com"
45
+ harry.save
46
+
47
+ # create
48
+ hermione = ActiveCampaign::Contact.new firstName: "Hermione",
49
+ lastName: "Granger",
50
+ email: "mione@drtooth.com"
51
+
52
+ # update
53
+ ron = ActiveCampaign::Contact.create email: "ron1988@hogwash.com", lastName: "Weasley"
54
+ ron.firstName = "Ron"
55
+ ron.save
56
+ ```
57
+
58
+ #### Tag
26
59
 
27
- ## Development
60
+ ```ruby
61
+ ActiveCampaign::Tag.create tag: "hogwarts"
62
+ ```
28
63
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+ #### Contact tags
30
65
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+ ```ruby
67
+ harry = ActiveCampaign::Contact.find_by email: "potter.hurray@hogwash.com"
68
+
69
+ # add a contact tag
70
+ harry.add_tag "hogwargs"
71
+
72
+ # remove a tag
73
+ harry.remove_tag "hogwarts"
74
+ ```
32
75
 
33
76
  ## Contributing
34
77
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ractive_campaign. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ractive_campaign/blob/master/CODE_OF_CONDUCT.md).
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wedsonlima/ractive_campaign. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ractive_campaign/blob/master/CODE_OF_CONDUCT.md).
36
79
 
37
80
  ## License
38
81
 
@@ -4,20 +4,6 @@ module ActiveCampaign
4
4
  module Attributes # :nodoc:
5
5
  extend ActiveSupport::Concern
6
6
 
7
- attr_accessor :all_attrs
8
-
9
- DEFAULT_ATTRS = %i[
10
- id
11
- cdate
12
- created_timestamp
13
- updated_timestamp
14
- created_utc_timestamp
15
- updated_utc_timestamp
16
- created_by
17
- updated_by
18
- links
19
- ].freeze
20
-
21
7
  def only_changes_to_params
22
8
  return nil unless changed?
23
9
 
@@ -29,7 +15,7 @@ module ActiveCampaign
29
15
  end
30
16
 
31
17
  def to_params
32
- iv = instance_variables - DEFAULT_ATTRS.map { |da| :"@#{da}" } - %i[@mutations_from_database @mutations_before_last_save]
18
+ iv = instance_variables - %i[@mutations_from_database @mutations_before_last_save]
33
19
 
34
20
  {
35
21
  self.class.root_element => iv.map { |v| [v.to_s.delete("@"), instance_variable_get(v)] }.to_h
@@ -39,6 +25,7 @@ module ActiveCampaign
39
25
  module ClassMethods # :nodoc:
40
26
  def define_attributes(*attrs)
41
27
  attrs.each do |attr|
28
+ # ActiveModel's define_attribute_methods
42
29
  define_attribute_methods attr
43
30
 
44
31
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -63,6 +50,8 @@ module ActiveCampaign
63
50
  end
64
51
 
65
52
  def instantiate_record(klass, data)
53
+ define_attributes(*data.keys)
54
+
66
55
  record = klass.new data
67
56
  record.clear_changes_information
68
57
  record
@@ -75,11 +64,11 @@ module ActiveCampaign
75
64
  end
76
65
 
77
66
  def endpoint
78
- name.demodulize.underscore.pluralize
67
+ name.demodulize.camelize(:lower).pluralize
79
68
  end
80
69
 
81
70
  def root_element
82
- name.demodulize.underscore.to_sym
71
+ name.demodulize.camelize(:lower).to_sym
83
72
  end
84
73
 
85
74
  def root_elements
@@ -14,7 +14,13 @@ module ActiveCampaign
14
14
  return {} unless [200, 201].include?(parsed_data[:status_code])
15
15
  return {} unless parsed_data[:data].present?
16
16
 
17
- data = parsed_data[:data].first.last
17
+ data = if parsed_data[:data].keys.include?(root_element.to_sym)
18
+ parsed_data[:data][root_element.to_sym]
19
+ elsif parsed_data[:data].keys.include?(root_elements.to_sym)
20
+ parsed_data[:data][root_elements.to_sym]
21
+ else
22
+ parsed_data[:data]
23
+ end
18
24
 
19
25
  if data.is_a?(Array)
20
26
  new_records data
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Account < Model # :nodoc:
5
+ define_attributes :name, :accountUrl
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class AccountContact < Model # :nodoc:
5
+ define_attributes :contact,
6
+ :account,
7
+ :jobTitle
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Address < Model # :nodoc:
5
+ define_attributes :company_name, :address_1, :country
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Campaign < Model # :nodoc:
5
+ # REVIEW: only list
6
+ end
7
+ end
@@ -1,36 +1,49 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaign
4
- class Contact < Model # :nodoc:
4
+ #
5
+ # @example Contacts
6
+ #
7
+ # ActiveCampaign::Contact.find(1)
8
+ # ActiveCampaign::Contact.find_by email: "contact-1@mail.com"
9
+ # ActiveCampaign::Contact.find(1).destroy
10
+ # ActiveCampaign::Contact.find(1).contact_tags
11
+ #
12
+ class Contact < Model
5
13
  define_attributes :email,
6
14
  :phone,
7
15
  :firstName,
8
- :lastName,
9
- :orgid,
10
- :orgname,
11
- :segmentio_id,
12
- :bounced_hard,
13
- :bounced_soft,
14
- :bounced_date,
15
- :ip,
16
- :ua,
17
- :hash,
18
- :socialdata_lastcheck,
19
- :email_local,
20
- :email_domain,
21
- :sentcnt,
22
- :rating_tstamp,
23
- :gravatar,
24
- :deleted,
25
- :anonymized,
26
- :adate,
27
- :udate,
28
- :edate,
29
- :deleted_at,
30
- :email_empty,
31
- :mpp_tracking,
32
- :scoreValues,
33
- :accountContacts,
34
- :organization
16
+ :lastName
17
+
18
+ # @example Find contact's tags.
19
+ #
20
+ # ActiveCampaign::Contact.find(1).contact_tags
21
+ # ActiveCampaign::Contact.find(1).contact_tags.last.destroy
22
+ #
23
+ def contact_tags
24
+ ContactTag.get "#{self.class.endpoint}/#{id}/contactTags"
25
+ end
26
+
27
+ # @example Apply a tag to a contact.
28
+ #
29
+ # ActiveCampaign::Contact.find(1).add_tag "tag-name"
30
+ #
31
+ def add_tag(tag)
32
+ tag_id = Tag.find_by(tag: tag)&.id
33
+
34
+ ActiveCampaign::ContactTag.create contact: id, tag: tag_id if tag_id
35
+ end
36
+
37
+ # @example Remove a tag from a contact.
38
+ #
39
+ # ActiveCampaign::Contact.find(1).remove_tag "tag-name"
40
+ #
41
+ def remove_tag(tag)
42
+ tag_id = Tag.find_by(tag: tag)&.id
43
+
44
+ contact_tag = contact_tags.filter_map { |ct| ct if ct.tag == tag_id }.last
45
+
46
+ contact_tag&.destroy
47
+ end
35
48
  end
36
49
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class ContactAutomation < Model # :nodoc:
5
+ define_attributes :contact, :automation
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class ContactDeal < Model # :nodoc:
5
+ define_attributes :contact, :deal
6
+ end
7
+ end
@@ -1,7 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaign
4
- class ContactTag < Model # :nodoc:
5
- define_attributes :tag_id, :contact_id
4
+ #
5
+ # @example ContactTags
6
+ #
7
+ # contact = ActiveCampaign::Contact.find(1)
8
+ # tag = ActiveCampaign::Tag.find(1)
9
+ #
10
+ # ActiveCampaing::ContactTag.create contact: contact, tag: tag
11
+ #
12
+ class ContactTag < Model
13
+ define_attributes :contact, :tag
14
+
15
+ def create
16
+ self.tag = extract_id_from_tag(tag)
17
+ self.contact = extract_id_from_contact(contact)
18
+
19
+ super
20
+ end
21
+
22
+ private
23
+
24
+ def extract_id_from_tag(tag)
25
+ case tag
26
+ when ::ActiveCampaign::Tag then tag.id
27
+ else
28
+ tag
29
+ end
30
+ end
31
+
32
+ def extract_id_from_contact(contact)
33
+ case contact
34
+ when ::ActiveCampaign::Contact then contact.id
35
+ else
36
+ contact
37
+ end
38
+ end
6
39
  end
7
40
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class CustomDealField < Model # :nodoc:
5
+ define_attributes :fieldLabel,
6
+ :fieldType,
7
+ :fieldDefault,
8
+ :isFormVisible,
9
+ :displayOrder
10
+
11
+ class << self
12
+ def endpoint
13
+ "dealCustomFieldMeta"
14
+ end
15
+
16
+ def root_element
17
+ :dealCustomFieldMetum
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class CustomDealFieldValue < Model # :nodoc:
5
+ define_attributes :dealId,
6
+ :customFieldId,
7
+ :fieldValue,
8
+ :fieldCurrency
9
+
10
+ class << self
11
+ def endpoint
12
+ "dealCustomFieldData"
13
+ end
14
+
15
+ def root_element
16
+ :dealCustomFieldDatum
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Deal < Model # :nodoc:
5
+ define_attributes :contact,
6
+ :account,
7
+ :description,
8
+ :currency,
9
+ :group,
10
+ :owner,
11
+ :percent,
12
+ :stage,
13
+ :status,
14
+ :title,
15
+ :value
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class EmailActivity < Model # :nodoc:
5
+ # REVIEW: only listing
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Field < Model # :nodoc:
5
+ define_attributes :type,
6
+ :title,
7
+ :descript,
8
+ :perstag,
9
+ :defval,
10
+ :visible,
11
+ :ordernum
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class FieldValue < Model # :nodoc:
5
+ define_attributes :contact,
6
+ :field,
7
+ :value
8
+ end
9
+ end
@@ -2,46 +2,10 @@
2
2
 
3
3
  module ActiveCampaign
4
4
  class List < Model # :nodoc:
5
- define_attributes :stringid,
6
- :userid,
7
- :name,
8
- :p_use_tracking,
9
- :p_use_analytics_read,
10
- :p_use_analytics_link,
11
- :p_use_twitter,
12
- :p_use_facebook,
13
- :p_embed_image,
14
- :p_use_captcha,
15
- :send_last_broadcast,
16
- :private,
17
- :analytics_domains,
18
- :analytics_source,
19
- :analytics_ua,
20
- :twitter_token,
21
- :twitter_token_secret,
22
- :facebook_session,
23
- :carboncopy,
24
- :subscription_notify,
25
- :unsubscription_notify,
26
- :require_name,
27
- :get_unsubscribe_reason,
28
- :to_name,
29
- :optinoptout,
30
- :sender_name,
31
- :sender_addr1,
32
- :sender_addr2,
33
- :sender_city,
34
- :sender_state,
35
- :sender_zip,
36
- :sender_country,
37
- :sender_phone,
5
+ define_attributes :name,
6
+ :stringid,
38
7
  :sender_url,
39
8
  :sender_reminder,
40
- :fulladdress,
41
- :optinmessageid,
42
- :optoutconf,
43
- :deletestamp,
44
- :udate,
45
9
  :user
46
10
  end
47
11
  end
@@ -8,19 +8,19 @@ module ActiveCampaign
8
8
  include ActiveCampaign::ApiHttp
9
9
  include ActiveCampaign::Attributes
10
10
 
11
- define_attributes(*DEFAULT_ATTRS)
12
-
13
11
  class << self
14
12
  def all
15
13
  get endpoint
16
14
  end
17
15
 
18
16
  def filter(args = {})
19
- get "#{endpoint}?#{args}"
17
+ query = args.map { |k, v| "filters[#{k}]=#{v}" }.join "&"
18
+
19
+ get "#{endpoint}?#{query}"
20
20
  end
21
21
 
22
22
  def find_by(args = {})
23
- filter(args.to_query).last
23
+ filter(args).last
24
24
  end
25
25
 
26
26
  def find(id)
@@ -37,7 +37,7 @@ module ActiveCampaign
37
37
  end
38
38
 
39
39
  def save
40
- return update if id.present?
40
+ return update if defined?(id) && id.present?
41
41
 
42
42
  create
43
43
  end
@@ -47,17 +47,21 @@ module ActiveCampaign
47
47
 
48
48
  result = self.class.put "#{self.class.endpoint}/#{id}", only_changes_to_params
49
49
 
50
+ assign_attributes result.to_params.first.last
51
+
50
52
  changes_applied
51
53
 
52
- result
54
+ self
53
55
  end
54
56
 
55
57
  def create
56
58
  result = self.class.post self.class.endpoint, to_params
57
59
 
60
+ assign_attributes result.to_params.first.last
61
+
58
62
  changes_applied
59
63
 
60
- result
64
+ self
61
65
  end
62
66
 
63
67
  def destroy
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Note < Model # :nodoc:
5
+ define_attributes :note, :relid, :reltype
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Pipeline < Model # :nodoc:
5
+ define_attributes :allgroups,
6
+ :allusers,
7
+ :autoassign,
8
+ :currency,
9
+ :title,
10
+ :users
11
+
12
+ class << self
13
+ def endpoint
14
+ "dealGroups"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Stage < Model # :nodoc:
5
+ define_attributes :cardRegion1,
6
+ :cardRegion2,
7
+ :cardRegion3,
8
+ :cardRegion4,
9
+ :cardRegion5,
10
+ :color,
11
+ :dealOrder,
12
+ :group,
13
+ :order,
14
+ :title,
15
+ :width
16
+ class << self
17
+ def endpoint
18
+ "dealStages"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,12 +2,6 @@
2
2
 
3
3
  module ActiveCampaign
4
4
  class Tag < Model # :nodoc:
5
- define_attributes :tagType, :tag, :description, :subscriber_count
6
-
7
- class << self
8
- def find_by(tag:)
9
- filter({ tags: { tag: tag } }.to_query).last
10
- end
11
- end
5
+ define_attributes :tag, :tagType, :description
12
6
  end
13
7
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class Task < Model # :nodoc:
5
+ define_attributes :title,
6
+ :ownerType,
7
+ :relid,
8
+ :status,
9
+ :note,
10
+ :duedate,
11
+ :edate,
12
+ :dealTasktype,
13
+ :assignee,
14
+ :triggerAutomationOnCreate,
15
+ :doneAutomation
16
+
17
+ class << self
18
+ def endpoint
19
+ "dealTasks"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class TaskOutcome < Model # :nodoc:
5
+ define_attributes :title, :sentiment
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class TaskType < Model # :nodoc:
5
+ define_attributes :title, :status
6
+
7
+ class << self
8
+ def endpoint
9
+ "dealTasktypes"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class User < Model # :nodoc:
5
+ class << self
6
+ def find_by_email(email)
7
+ get "#{endpoint}/email/#{email}"
8
+ end
9
+
10
+ def find_by_username(username)
11
+ get "#{endpoint}/username/#{username}"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaign
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -12,7 +12,6 @@ require "active_support/inflector"
12
12
  require "active_campaign/version"
13
13
  require "active_campaign/parser"
14
14
  require "active_campaign/api_attributes"
15
- require "active_campaign/api_errors"
16
15
  require "active_campaign/api"
17
16
  require "active_campaign/api_http"
18
17
 
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_campaign"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ractive_campaign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wedson Lima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-13 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -24,34 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 6.1.4
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 6.1.4
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 6.1.4
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: dry-configurable
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 0.7.0
33
+ version: 0.12.1
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 0.7.0
40
+ version: 0.12.1
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: faraday
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,27 +66,7 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: 1.2.0
83
- - !ruby/object:Gem::Dependency
84
- name: oj
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '3.0'
90
- - - "<"
91
- - !ruby/object:Gem::Version
92
- version: '4.0'
93
- type: :runtime
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '3.0'
100
- - - "<"
101
- - !ruby/object:Gem::Version
102
- version: '4.0'
103
- description: Active Campaign - API v3
69
+ description: Ruby API wrapper for ActiveCampaign API v3
104
70
  email:
105
71
  - wedson.sousa.lima@gmail.com
106
72
  executables: []
@@ -121,19 +87,41 @@ files:
121
87
  - lib/active_campaign.rb
122
88
  - lib/active_campaign/api.rb
123
89
  - lib/active_campaign/api_attributes.rb
124
- - lib/active_campaign/api_errors.rb
125
90
  - lib/active_campaign/api_http.rb
91
+ - lib/active_campaign/models/account.rb
92
+ - lib/active_campaign/models/account_contact.rb
93
+ - lib/active_campaign/models/address.rb
94
+ - lib/active_campaign/models/campaign.rb
126
95
  - lib/active_campaign/models/contact.rb
96
+ - lib/active_campaign/models/contact_automation.rb
97
+ - lib/active_campaign/models/contact_deal.rb
127
98
  - lib/active_campaign/models/contact_tag.rb
99
+ - lib/active_campaign/models/custom_deal_field.rb
100
+ - lib/active_campaign/models/custom_deal_field_value.rb
101
+ - lib/active_campaign/models/deal.rb
102
+ - lib/active_campaign/models/email_activity.rb
103
+ - lib/active_campaign/models/field.rb
104
+ - lib/active_campaign/models/field_value.rb
128
105
  - lib/active_campaign/models/list.rb
129
106
  - lib/active_campaign/models/model.rb
107
+ - lib/active_campaign/models/note.rb
108
+ - lib/active_campaign/models/pipeline.rb
109
+ - lib/active_campaign/models/stage.rb
130
110
  - lib/active_campaign/models/tag.rb
111
+ - lib/active_campaign/models/task.rb
112
+ - lib/active_campaign/models/task_outcome.rb
113
+ - lib/active_campaign/models/task_type.rb
114
+ - lib/active_campaign/models/user.rb
131
115
  - lib/active_campaign/parser.rb
132
116
  - lib/active_campaign/version.rb
117
+ - lib/ractive_campaign.rb
133
118
  homepage: https://github.com/wedsonlima/ractive_campaign
134
119
  licenses:
135
120
  - MIT
136
- metadata: {}
121
+ metadata:
122
+ homepage_uri: https://github.com/wedsonlima/ractive_campaign
123
+ source_code_uri: https://github.com/wedsonlima/ractive_campaign
124
+ changelog_uri: https://github.com/wedsonlima/ractive_campaign/blob/main/CHANGELOG.md
137
125
  post_install_message:
138
126
  rdoc_options: []
139
127
  require_paths:
@@ -152,5 +140,5 @@ requirements: []
152
140
  rubygems_version: 3.0.3.1
153
141
  signing_key:
154
142
  specification_version: 4
155
- summary: Active Campaign - API v3
143
+ summary: Ruby API wrapper for ActiveCampaign API v3
156
144
  test_files: []
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveCampaign
4
- class Error < RuntimeError # :nodoc:
5
- def initialize(response = nil, exception = nil)
6
- super
7
-
8
- self.response = response
9
- @exception = exception
10
- end
11
-
12
- def message
13
- if response.nil?
14
- super
15
- else
16
- <<~MESSAGE
17
- STATUS: #{response.status}
18
- URL: #{env.url}
19
- REQUEST HEADERS: #{env.request_headers}
20
- RESPONSE_HEADERS: #{env.response_headers}
21
- REQUEST_BODY: #{env.request_body}\n\n"
22
- RESPONSE_BODY: #{response.body}\n\n"
23
- MESSAGE
24
- end
25
- end
26
-
27
- private
28
-
29
- def env
30
- @env ||= response.env
31
- end
32
-
33
- attr_accessor :response
34
- end
35
-
36
- class ClientError < Error
37
- end
38
-
39
- class UnauthorizedError < ClientError
40
- end
41
-
42
- class ResourceNotFound < ClientError
43
- end
44
-
45
- class UnprocessableEntityError < ClientError
46
- end
47
- end