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.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +52 -9
- data/lib/active_campaign/api_attributes.rb +6 -17
- data/lib/active_campaign/api_http.rb +7 -1
- data/lib/active_campaign/models/account.rb +7 -0
- data/lib/active_campaign/models/account_contact.rb +9 -0
- data/lib/active_campaign/models/address.rb +7 -0
- data/lib/active_campaign/models/campaign.rb +7 -0
- data/lib/active_campaign/models/contact.rb +41 -28
- data/lib/active_campaign/models/contact_automation.rb +7 -0
- data/lib/active_campaign/models/contact_deal.rb +7 -0
- data/lib/active_campaign/models/contact_tag.rb +35 -2
- data/lib/active_campaign/models/custom_deal_field.rb +21 -0
- data/lib/active_campaign/models/custom_deal_field_value.rb +20 -0
- data/lib/active_campaign/models/deal.rb +17 -0
- data/lib/active_campaign/models/email_activity.rb +7 -0
- data/lib/active_campaign/models/field.rb +13 -0
- data/lib/active_campaign/models/field_value.rb +9 -0
- data/lib/active_campaign/models/list.rb +11 -0
- data/lib/active_campaign/models/model.rb +12 -8
- data/lib/active_campaign/models/note.rb +7 -0
- data/lib/active_campaign/models/pipeline.rb +18 -0
- data/lib/active_campaign/models/stage.rb +22 -0
- data/lib/active_campaign/models/tag.rb +1 -7
- data/lib/active_campaign/models/task.rb +23 -0
- data/lib/active_campaign/models/task_outcome.rb +7 -0
- data/lib/active_campaign/models/task_type.rb +13 -0
- data/lib/active_campaign/models/user.rb +15 -0
- data/lib/active_campaign/version.rb +1 -1
- data/lib/active_campaign.rb +0 -1
- metadata +24 -39
- data/lib/active_campaign/api_errors.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee344bdbd4025f17b5d53a9afbdd28358fc29ac2325b8ff3251add3ce096c816
|
|
4
|
+
data.tar.gz: 9774f6a2973cf153fcf68456eecec137e1d88001d4d0c0412f44cf7b69913df8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
4
|
+
ractive_campaign (0.1.3)
|
|
5
5
|
activemodel (~> 6.1.4)
|
|
6
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
1
|
+
[](https://badge.fury.io/rb/ractive_campaign) [](https://codeclimate.com/github/wedsonlima/ractive_campaign/maintainability) [](https://codeclimate.com/github/wedsonlima/ractive_campaign/test_coverage)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# RactiveCampaign
|
|
4
4
|
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
60
|
+
```ruby
|
|
61
|
+
ActiveCampaign::Tag.create tag: "hogwarts"
|
|
62
|
+
```
|
|
28
63
|
|
|
29
|
-
|
|
64
|
+
#### Contact tags
|
|
30
65
|
|
|
31
|
-
|
|
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/
|
|
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 -
|
|
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.
|
|
67
|
+
name.demodulize.camelize(:lower).pluralize
|
|
79
68
|
end
|
|
80
69
|
|
|
81
70
|
def root_element
|
|
82
|
-
name.demodulize.
|
|
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 =
|
|
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
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ActiveCampaign
|
|
4
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ActiveCampaign
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
self
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
def destroy
|
|
@@ -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 :
|
|
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,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
|
data/lib/active_campaign.rb
CHANGED
|
@@ -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.
|
|
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-
|
|
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.
|
|
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.
|
|
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
|