active_campaign_crm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +39 -0
- data/LICENSE +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/active_campaign_crm.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/active_campaign_crm/client/contact_fields.rb +31 -0
- data/lib/active_campaign_crm/client/contacts.rb +35 -0
- data/lib/active_campaign_crm/client/custom_field_values.rb +31 -0
- data/lib/active_campaign_crm/client/organizations.rb +31 -0
- data/lib/active_campaign_crm/client/tags.rb +44 -0
- data/lib/active_campaign_crm/client.rb +17 -0
- data/lib/active_campaign_crm/configuration.rb +20 -0
- data/lib/active_campaign_crm/connection.rb +76 -0
- data/lib/active_campaign_crm/error.rb +25 -0
- data/lib/active_campaign_crm/version.rb +3 -0
- data/lib/active_campaign_crm.rb +10 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3669481809ba5f04d81fc3964c2e92eb8fdc58d9f399534fc4a92bbbf8181d7c
|
4
|
+
data.tar.gz: 51af60ef17e611896ac61a96fbe741e54b6d1ce639c1968fe1a78fa974c61ba1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5d81a854e9d01cc402242165c1767d5f333870ca89650a1e9305dad6638754a6bbca667df4a55d45ccff10e097ad73f727303e1f3dd3c7cd2107e130363cc23
|
7
|
+
data.tar.gz: 67dba6d05a8db13c5ef08149f83ea5f173c0b4e3feed741fc3976b1ef4caea57b4b5a98b40b17b651a0a891260bd9dd2f7682e88446f8a1ca25f5ae7d525cd8c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nunolopesrb@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_campaign_crm (0.1.0)
|
5
|
+
faraday (~> 0.15)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
faraday (0.15.4)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
multipart-post (2.0.0)
|
14
|
+
rake (10.5.0)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.0)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
active_campaign_crm!
|
34
|
+
bundler (~> 1.16)
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec (~> 3.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.16.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Whitesmith
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# ActiveCampaignCrm
|
2
|
+
A basic wrapper for active campaign
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'active_campaign_crm'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install active_campaign_crm
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/whitesmith/active_campaign_crm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
37
|
+
|
38
|
+
## Code of Conduct
|
39
|
+
|
40
|
+
Everyone interacting in the ActiveCampaignCrm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_campaign_crm/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "active_campaign_crm/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "active_campaign_crm"
|
8
|
+
spec.version = ActiveCampaignCrm::VERSION
|
9
|
+
spec.authors = ["Nuno Correia"]
|
10
|
+
spec.email = ["nuno_lopes@whitesmith.co"]
|
11
|
+
|
12
|
+
spec.summary = "A basic API wrapper for active campaign "
|
13
|
+
spec.description = "A basic API wrapper for active campaign "
|
14
|
+
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "faraday", "~> 0.15"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "active_campaign_crm"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
module ContactFields
|
4
|
+
def contact_fields(params = {})
|
5
|
+
response = @connection.get('fields', params)
|
6
|
+
response['fields']
|
7
|
+
end
|
8
|
+
|
9
|
+
def contact_field(id)
|
10
|
+
response = @connection.get("fields/#{id}")
|
11
|
+
response['field']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_contact_field(properties)
|
15
|
+
@connection.post('fields', contact_field_body(properties))
|
16
|
+
end
|
17
|
+
|
18
|
+
def contact_field_body(properties)
|
19
|
+
{ 'field': properties }.to_json
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_contact_field(id, properties)
|
23
|
+
@connection.put("fields/#{id}", contact_field_body(properties))
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_contact_field(id)
|
27
|
+
@connection.delete("fields/#{id}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
module Contacts
|
4
|
+
def contacts(params = {})
|
5
|
+
response = @connection.get('contacts', params)
|
6
|
+
response['contacts']
|
7
|
+
end
|
8
|
+
|
9
|
+
def contact(id)
|
10
|
+
response = @connection.get("contacts/#{id}")
|
11
|
+
response['contact']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_contact(fields)
|
15
|
+
@connection.post('contacts', contact_body(fields))
|
16
|
+
end
|
17
|
+
|
18
|
+
def sync_contact(fields)
|
19
|
+
@connection.post('contact/sync', contact_body(fields))
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_contact(id, fields)
|
23
|
+
@connection.put("contacts/#{id}", contact_body(fields))
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_contact(id)
|
27
|
+
@connection.delete("contacts/#{id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def contact_body(fields)
|
31
|
+
{ 'contact': fields }.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
module CustomFieldValues
|
4
|
+
def custom_field_values(params = {})
|
5
|
+
response = @connection.get('fieldValues', params)
|
6
|
+
response['fieldValues']
|
7
|
+
end
|
8
|
+
|
9
|
+
def custom_field_value(id)
|
10
|
+
response = @connection.get("fieldValues/#{id}")
|
11
|
+
response['fieldValue']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_custom_field_value(properties)
|
15
|
+
@connection.post('fieldValues', custom_field_value_body(properties))
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_custom_field_value(id, properties)
|
19
|
+
@connection.put("fieldValues/#{id}", custom_field_value_body(properties))
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete_custom_field_value(id)
|
23
|
+
@connection.delete("fieldValues/#{id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def custom_field_value_body(properties)
|
27
|
+
{ 'fieldValue': properties }.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
module Organization
|
4
|
+
def organizations(params = {})
|
5
|
+
response = @connection.get('organizations', params)
|
6
|
+
response['organizations']
|
7
|
+
end
|
8
|
+
|
9
|
+
def organization(id)
|
10
|
+
response = @connection.get("organizations/#{id}")
|
11
|
+
response['organization']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_organization(fields)
|
15
|
+
@connection.post('organizations', organization_body(fields))
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_organization(id, fields)
|
19
|
+
@connection.put("organizations/#{id}", organization_body(fields))
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete_organization(id)
|
23
|
+
@connection.delete("organizations/#{id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def organization_body(fields)
|
27
|
+
{ 'organization': fields }.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
module Tags
|
4
|
+
def tags(params = {})
|
5
|
+
response = @connection.get('tags', params)
|
6
|
+
response['tags']
|
7
|
+
end
|
8
|
+
|
9
|
+
def tag(id)
|
10
|
+
response = @connection.get("tags/#{id}")
|
11
|
+
response['tag']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_tag(fields)
|
15
|
+
@connection.post('tags', tag_body(fields))
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_tag_to_contact(contact, tag)
|
19
|
+
@connection.post('contactTags', contact_link_tag_body(contact, tag))
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_tag(id, fields)
|
23
|
+
@connection.put("tags/#{id}", tag_body(fields))
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_tag(id)
|
27
|
+
@connection.delete("tags/#{id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def contact_link_tag_body(contact, tag)
|
31
|
+
{
|
32
|
+
'contactTag': {
|
33
|
+
'contact': contact,
|
34
|
+
'tag': tag
|
35
|
+
}
|
36
|
+
}.to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
def tag_body(fields)
|
40
|
+
{ 'tag': fields }.to_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Client
|
3
|
+
require 'active_campaign_crm/connection'
|
4
|
+
|
5
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each{ |f| require f }
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@connection = ActiveCampaignCrm::Connection.new
|
9
|
+
end
|
10
|
+
|
11
|
+
include ActiveCampaignCrm::Client::Contacts
|
12
|
+
include ActiveCampaignCrm::Client::ContactFields
|
13
|
+
include ActiveCampaignCrm::Client::CustomFieldValues
|
14
|
+
include ActiveCampaignCrm::Client::Tags
|
15
|
+
include ActiveCampaignCrm::Client::Organization
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
self.configuration ||= Configuration.new
|
8
|
+
yield(configuration)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Configuration
|
12
|
+
attr_accessor :account_url
|
13
|
+
attr_accessor :api_key
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@account_url = nil
|
17
|
+
@api_key = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
class Connection
|
3
|
+
require 'faraday'
|
4
|
+
require 'json'
|
5
|
+
require 'active_campaign_crm/error'
|
6
|
+
def initialize
|
7
|
+
# TODO: raise exception if account_url is not defined
|
8
|
+
# TODO: raise exception if api_key is not defined
|
9
|
+
@connection = Faraday.new(
|
10
|
+
url: "#{ActiveCampaignCrm.configuration.account_url}/api/3"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(url, params = {})
|
15
|
+
response = @connection.get do |req|
|
16
|
+
req.url url
|
17
|
+
req.headers['Api-Token'] = ActiveCampaignCrm.configuration.api_key
|
18
|
+
req.params = params
|
19
|
+
end
|
20
|
+
handle_response(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
def post(url, body)
|
24
|
+
response = @connection.post do |req|
|
25
|
+
req.url url
|
26
|
+
req.headers['Api-Token'] = ActiveCampaignCrm.configuration.api_key
|
27
|
+
req.body = body
|
28
|
+
end
|
29
|
+
handle_response(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def put(url, body)
|
33
|
+
response = @connection.put do |req|
|
34
|
+
req.url url
|
35
|
+
req.headers['Api-Token'] = ActiveCampaignCrm.configuration.api_key
|
36
|
+
req.body = body
|
37
|
+
end
|
38
|
+
handle_response(response)
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete(url)
|
42
|
+
response = @connection.delete do |req|
|
43
|
+
req.url url
|
44
|
+
req.headers['Api-Token'] = ActiveCampaignCrm.configuration.api_key
|
45
|
+
end
|
46
|
+
handle_response(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_response(response)
|
50
|
+
return JSON.parse response.body if response.success?
|
51
|
+
|
52
|
+
errors = JSON.parse(response.body)['errors']
|
53
|
+
error_messages = errors.map { |error| error['title'] } unless errors.nil?
|
54
|
+
error_message = error_messages.join('-') unless error_messages.nil?
|
55
|
+
|
56
|
+
case response.status
|
57
|
+
when 400
|
58
|
+
raise ActiveCampaignCrm::BadRequest, error_message
|
59
|
+
when 404
|
60
|
+
raise ActiveCampaignCrm::NotFound, error_message
|
61
|
+
when 429
|
62
|
+
raise ActiveCampaignCrm::TooManyRequests, error_message
|
63
|
+
when 500
|
64
|
+
raise ActiveCampaignCrm::InternalServerError, error_message
|
65
|
+
when 502
|
66
|
+
raise ActiveCampaignCrm::BadGateway, error_message
|
67
|
+
when 503
|
68
|
+
raise ActiveCampaignCrm::ServiceUnavailable, error_message
|
69
|
+
when 504
|
70
|
+
raise ActiveCampaignCrm::GatewayTimeout, error_message
|
71
|
+
else
|
72
|
+
raise StandardError, error_message
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ActiveCampaignCrm
|
2
|
+
# Custom error class for rescuing from all errors
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
# Raised when Active Campaign returns the HTTP status code 400
|
6
|
+
class BadRequest < Error; end
|
7
|
+
|
8
|
+
# Raised when Active Campaign returns the HTTP status code 404
|
9
|
+
class NotFound < Error; end
|
10
|
+
|
11
|
+
# Raised when Active Campaign returns the HTTP status code 429
|
12
|
+
class TooManyRequests < Error; end
|
13
|
+
|
14
|
+
# Raised when Active Campaign returns the HTTP status code 500
|
15
|
+
class InternalServerError < Error; end
|
16
|
+
|
17
|
+
# Raised when Active Campaign returns the HTTP status code 502
|
18
|
+
class BadGateway < Error; end
|
19
|
+
|
20
|
+
# Raised when Active Campaign returns the HTTP status code 503
|
21
|
+
class ServiceUnavailable < Error; end
|
22
|
+
|
23
|
+
# Raised when Active Campaign returns the HTTP status code 504
|
24
|
+
class GatewayTimeout < Error; end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_campaign_crm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nuno Correia
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: 'A basic API wrapper for active campaign '
|
70
|
+
email:
|
71
|
+
- nuno_lopes@whitesmith.co
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- active_campaign_crm.gemspec
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/active_campaign_crm.rb
|
89
|
+
- lib/active_campaign_crm/client.rb
|
90
|
+
- lib/active_campaign_crm/client/contact_fields.rb
|
91
|
+
- lib/active_campaign_crm/client/contacts.rb
|
92
|
+
- lib/active_campaign_crm/client/custom_field_values.rb
|
93
|
+
- lib/active_campaign_crm/client/organizations.rb
|
94
|
+
- lib/active_campaign_crm/client/tags.rb
|
95
|
+
- lib/active_campaign_crm/configuration.rb
|
96
|
+
- lib/active_campaign_crm/connection.rb
|
97
|
+
- lib/active_campaign_crm/error.rb
|
98
|
+
- lib/active_campaign_crm/version.rb
|
99
|
+
homepage:
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.7.3
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: A basic API wrapper for active campaign
|
123
|
+
test_files: []
|