active_campaign_crm 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/active_campaign_crm.rb +1 -1
- data/lib/active_campaign_crm/client.rb +1 -1
- data/lib/active_campaign_crm/client/contact_fields.rb +17 -0
- data/lib/active_campaign_crm/client/organizations.rb +10 -1
- data/lib/active_campaign_crm/client/tags.rb +11 -1
- data/lib/active_campaign_crm/connection.rb +1 -2
- data/lib/active_campaign_crm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f200b7283f94c48f1480fcb49042a340242d6621fa5109df1e29f4135dfe2f
|
4
|
+
data.tar.gz: 2e101a3c5dffff3bd12dbc41df7b973942836661837aef3fe09219d7a69801c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4fc77022772a99cef0e96064dae022ab901d9c255cd9ed5aa13476ffcfa864e2d33cff954a240cb8882942d5abbd25910909145e00a424b39539c947c45fae
|
7
|
+
data.tar.gz: 5a17dc649db72c3b8a834cf1950542f3cd876e1a65098efa48468c8554d923e255f4cdbbead6b6968f17b86911a975292a040ca3880415aa873f533c4bdd9347
|
data/Gemfile.lock
CHANGED
data/lib/active_campaign_crm.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveCampaignCrm
|
|
2
2
|
class Client
|
3
3
|
require 'active_campaign_crm/connection'
|
4
4
|
|
5
|
-
Dir[File.expand_path('../client/*.rb', __FILE__)].each{ |f| require f }
|
5
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@connection = ActiveCampaignCrm::Connection.new
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module ActiveCampaignCrm
|
2
2
|
class Client
|
3
|
+
#Contact Fields Interface
|
3
4
|
module ContactFields
|
4
5
|
def contact_fields(params = {})
|
5
6
|
response = @connection.get('fields', params)
|
@@ -16,6 +17,22 @@ module ActiveCampaignCrm
|
|
16
17
|
response['field']
|
17
18
|
end
|
18
19
|
|
20
|
+
def find_or_create_contact_field(perstag, properties)
|
21
|
+
fields = contact_fields("filters[perstag]": perstag)
|
22
|
+
return fields[0] if fields.any?
|
23
|
+
|
24
|
+
create_contact_field(properties)
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_or_create_field_with_relationship(perstag, properties, rel)
|
28
|
+
fields = contact_fields("filters[perstag]": perstag)
|
29
|
+
return fields[0] if fields.any?
|
30
|
+
|
31
|
+
field = create_contact_field(properties)
|
32
|
+
add_relationship_to_field(field['id'], rel)
|
33
|
+
field
|
34
|
+
end
|
35
|
+
|
19
36
|
def add_relationship_to_field(field, rel)
|
20
37
|
response = @connection.post('fieldRels', custom_rel_body(field, rel))
|
21
38
|
response['fieldRel']
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module ActiveCampaignCrm
|
2
2
|
class Client
|
3
|
+
# Organization Interface
|
3
4
|
module Organization
|
4
5
|
def organizations(params = {})
|
5
6
|
response = @connection.get('organizations', params)
|
@@ -16,8 +17,16 @@ module ActiveCampaignCrm
|
|
16
17
|
response['organization']
|
17
18
|
end
|
18
19
|
|
20
|
+
def find_or_create_organization(name)
|
21
|
+
organizations = organizations("filters[name]": name)
|
22
|
+
return organization[0] if organizations.any?
|
23
|
+
|
24
|
+
create_organization(name: name)
|
25
|
+
end
|
26
|
+
|
19
27
|
def update_organization(id, fields)
|
20
|
-
response = @connection.put("organizations/#{id}",
|
28
|
+
response = @connection.put("organizations/#{id}",
|
29
|
+
organization_body(fields))
|
21
30
|
response['organization']
|
22
31
|
end
|
23
32
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module ActiveCampaignCrm
|
2
2
|
class Client
|
3
|
+
# Tag Interface
|
3
4
|
module Tags
|
4
5
|
def tags(params = {})
|
5
6
|
response = @connection.get('tags', params)
|
@@ -16,8 +17,17 @@ module ActiveCampaignCrm
|
|
16
17
|
response['tag']
|
17
18
|
end
|
18
19
|
|
20
|
+
def sync_tag(tag, type, description)
|
21
|
+
query = { 'filters[tag]': tag }
|
22
|
+
tags = tags(query)
|
23
|
+
return tags[0] if tags.any?
|
24
|
+
|
25
|
+
create_tag(tag: tag, tagType: type, description: description)
|
26
|
+
end
|
27
|
+
|
19
28
|
def add_tag_to_contact(contact, tag)
|
20
|
-
response = @connection.post('contactTags',
|
29
|
+
response = @connection.post('contactTags',
|
30
|
+
contact_link_tag_body(contact, tag))
|
21
31
|
response['contactTag']
|
22
32
|
end
|
23
33
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module ActiveCampaignCrm
|
2
|
+
# Handles all connections with active campaign
|
2
3
|
class Connection
|
3
4
|
require 'faraday'
|
4
5
|
require 'json'
|
5
6
|
require 'active_campaign_crm/error'
|
6
7
|
def initialize
|
7
|
-
# TODO: raise exception if account_url is not defined
|
8
|
-
# TODO: raise exception if api_key is not defined
|
9
8
|
@connection = Faraday.new(
|
10
9
|
url: "#{ActiveCampaignCrm.configuration.account_url}/api/3"
|
11
10
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_campaign_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nuno Correia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|