ractive_campaign 0.0.1 → 0.1.3

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -7
  3. data/README.md +52 -9
  4. data/lib/active_campaign/api_attributes.rb +6 -17
  5. data/lib/active_campaign/api_http.rb +7 -1
  6. data/lib/active_campaign/models/account.rb +7 -0
  7. data/lib/active_campaign/models/account_contact.rb +9 -0
  8. data/lib/active_campaign/models/address.rb +7 -0
  9. data/lib/active_campaign/models/campaign.rb +7 -0
  10. data/lib/active_campaign/models/contact.rb +41 -28
  11. data/lib/active_campaign/models/contact_automation.rb +7 -0
  12. data/lib/active_campaign/models/contact_deal.rb +7 -0
  13. data/lib/active_campaign/models/contact_tag.rb +35 -2
  14. data/lib/active_campaign/models/custom_deal_field.rb +21 -0
  15. data/lib/active_campaign/models/custom_deal_field_value.rb +20 -0
  16. data/lib/active_campaign/models/deal.rb +17 -0
  17. data/lib/active_campaign/models/email_activity.rb +7 -0
  18. data/lib/active_campaign/models/field.rb +13 -0
  19. data/lib/active_campaign/models/field_value.rb +9 -0
  20. data/lib/active_campaign/models/list.rb +11 -0
  21. data/lib/active_campaign/models/model.rb +12 -8
  22. data/lib/active_campaign/models/note.rb +7 -0
  23. data/lib/active_campaign/models/pipeline.rb +18 -0
  24. data/lib/active_campaign/models/stage.rb +22 -0
  25. data/lib/active_campaign/models/tag.rb +1 -7
  26. data/lib/active_campaign/models/task.rb +23 -0
  27. data/lib/active_campaign/models/task_outcome.rb +7 -0
  28. data/lib/active_campaign/models/task_type.rb +13 -0
  29. data/lib/active_campaign/models/user.rb +15 -0
  30. data/lib/active_campaign/version.rb +1 -1
  31. data/lib/active_campaign.rb +0 -1
  32. metadata +24 -39
  33. data/lib/active_campaign/api_errors.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6b7944a2753a3db0335c5c172ebeac9dfb33eb9a5f15071036b552bf555592a
4
- data.tar.gz: 80048d41a31fe9286cd7aa78dbe9372909336b06b989d2148e42eb58ea39cf6f
3
+ metadata.gz: ee344bdbd4025f17b5d53a9afbdd28358fc29ac2325b8ff3251add3ce096c816
4
+ data.tar.gz: 9774f6a2973cf153fcf68456eecec137e1d88001d4d0c0412f44cf7b69913df8
5
5
  SHA512:
6
- metadata.gz: 2d4d9640752af2626483f7802d5e9236fe54d30a984d700f004424d459be67bc0f934ecbca0bb56df2c75a028b4be14dbd7a1b11ddc51f2c292ad9a8aa01958a
7
- data.tar.gz: afce1288618683daab865e7dc89799c0a79ddece26a3563d8f3a6847053bbb109e6328deb2d73b995afbad8656bdc717ef477559725140555cc0d7899d212a02
6
+ metadata.gz: '0907098764aaa108e6663ca26db45fa45a61b55ec992da65275399a5825adf7d571efbae76adbe96d623a93c73839e7488000465f2977114351d428eb33d39df'
7
+ data.tar.gz: b2fabe0ef19b4b116ef9eda3bcccc54c9d6cdc3cb4f4e70c72133f1d0584517ae097554e5d97489ff2b98327a3f5ffdecbf8490b5dd3e86380c7488ab70cfe60
data/Gemfile.lock CHANGED
@@ -1,13 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ractive_campaign (0.0.1)
4
+ ractive_campaign (0.1.3)
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
+ Simple 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", require: "active_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
@@ -10,11 +10,17 @@ module ActiveCampaign
10
10
  HTTP_METHODS.each do |method|
11
11
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
12
12
  def #{method}(path, params={})
13
+ root = params.delete(:_root)
14
+
13
15
  send(:'#{method}_raw', path, params) do |parsed_data, response|
14
16
  return {} unless [200, 201].include?(parsed_data[:status_code])
15
17
  return {} unless parsed_data[:data].present?
16
18
 
17
- data = parsed_data[:data].first.last
19
+ data = if root
20
+ parsed_data[:data][root.to_sym]
21
+ else
22
+ parsed_data[:data].first.last
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCampaign
4
+ class List < Model # :nodoc:
5
+ define_attributes :name,
6
+ :stringid,
7
+ :sender_url,
8
+ :sender_reminder,
9
+ :user
10
+ end
11
+ end
@@ -8,23 +8,23 @@ 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)
27
- get "#{endpoint}/#{id}"
27
+ get "#{endpoint}/#{id}", { _root: root_element }
28
28
  end
29
29
 
30
30
  def save(**args)
@@ -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.0.1"
4
+ VERSION = "0.1.3"
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
 
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.0.1
4
+ version: 0.1.3
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-18 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,26 +66,6 @@ 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
69
  description: Active Campaign - API v3
104
70
  email:
105
71
  - wedson.sousa.lima@gmail.com
@@ -121,12 +87,31 @@ 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
105
+ - lib/active_campaign/models/list.rb
128
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
129
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
130
115
  - lib/active_campaign/parser.rb
131
116
  - lib/active_campaign/version.rb
132
117
  homepage: https://github.com/wedsonlima/ractive_campaign
@@ -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