active-campaign-simple 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -21
- data/lib/active-campaign-simple/event.rb +25 -0
- data/lib/active-campaign-simple/request.rb +7 -1
- data/lib/active-campaign-simple/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a683730c14f52f5159cc744229637c557389f1ffb79dbde5a703864dd2dff90e
|
4
|
+
data.tar.gz: b0981016a9d3423546aff9534070a2788d0c99481dbda2fbe33e771c345441d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a328b8e85c53228c4a51df55dab6aed6a59f24f9e06da45bc81fd126da20f3bfabaa417a42e6e8bc94aa460c8ea2851218530d503c5c3f93085cbe7647f205c8
|
7
|
+
data.tar.gz: 5b3a82742fb362b2e0eac9524858bf6eecd81188874d129a0ea8f12a5d1a08f08c33cc67104893f42727eb536929f5d1221631fe3157dd385b958bf6a580fb2b
|
data/README.md
CHANGED
@@ -33,44 +33,40 @@ ActiveCampaign.get('/contacts')
|
|
33
33
|
# Get a contact
|
34
34
|
ActiveCampaign.get('/contacts/' + id)
|
35
35
|
|
36
|
-
# Create a new contact
|
36
|
+
# Create (post) a new contact
|
37
37
|
# https://developers.activecampaign.com/reference#create-a-contact-new
|
38
|
-
payload
|
38
|
+
ActiveCampaign.post('/contacts', payload: {
|
39
39
|
contact: {
|
40
40
|
email: 'nate@test.com',
|
41
41
|
firstName: 'Nate',
|
42
42
|
lastName: 'Test',
|
43
43
|
phone: '1231231234'
|
44
44
|
},
|
45
|
-
fieldValues:
|
45
|
+
fieldValues: [
|
46
46
|
{
|
47
47
|
field: '1',
|
48
48
|
value: 'The Value for First Field'
|
49
|
-
},
|
50
|
-
{
|
51
|
-
field: '6',
|
52
|
-
value: '2008-01-20'
|
53
49
|
}
|
54
|
-
|
55
|
-
}
|
56
|
-
ActiveCampaign.post('/contacts', payload: payload)
|
50
|
+
]
|
51
|
+
})
|
57
52
|
|
58
|
-
# Update a contact
|
59
|
-
payload
|
53
|
+
# Update (put) a contact
|
54
|
+
ActiveCampaign.put('/contacts/' + id, payload: {
|
60
55
|
contact: {
|
61
|
-
email: 'nate@test.com'
|
62
|
-
},
|
63
|
-
fieldValues: {
|
64
|
-
{
|
65
|
-
field: '1',
|
66
|
-
value: 'The Value for First Field'
|
67
|
-
},
|
56
|
+
email: 'nate@test.com'
|
68
57
|
}
|
69
|
-
}
|
70
|
-
ActiveCampaign.post('/contacts/' + id, payload: payload)
|
58
|
+
})
|
71
59
|
|
72
60
|
# Delete a contact
|
73
61
|
ActiveCampaign.delete('/contacts/' + id)
|
62
|
+
|
63
|
+
# Event Tracking
|
64
|
+
# See: https://developers.activecampaign.com/reference#track-event
|
65
|
+
# NOTE - The tracking API is different from all other calls as it changes the arguments a little to simplify.
|
66
|
+
ActiveCampaign.track_event('event-key', 'actid', 'event-name', 'email')
|
67
|
+
|
68
|
+
# or with optional eventdata
|
69
|
+
ActiveCampaign.track_event('event-key', 'actid', 'event-name', 'email', 'eventdata')
|
74
70
|
```
|
75
71
|
|
76
72
|
## <a name="contributing">Contributing</a>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ActiveCampaign
|
2
|
+
class Event
|
3
|
+
|
4
|
+
class << self
|
5
|
+
# Post event
|
6
|
+
def post_event(key, actid, event, email, eventdata=nil)
|
7
|
+
# header = { content_type: 'application/x-www-form-urlencoded' }
|
8
|
+
form = {
|
9
|
+
key: key,
|
10
|
+
actid: actid,
|
11
|
+
event: event,
|
12
|
+
# visit: URI.encode_www_form_component{ email: email },
|
13
|
+
visit: { email: email }
|
14
|
+
}
|
15
|
+
form.merge!({ eventdata: eventdata }) if eventdata
|
16
|
+
|
17
|
+
resp = RestClient.post("https://trackcmp.net/event", form)
|
18
|
+
rescue RestClient::ExceptionWithResponse => err
|
19
|
+
raise APIError, err
|
20
|
+
else
|
21
|
+
return resp.body if resp.body # Some calls respond w nothing
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'active-campaign-simple/api_error'
|
3
|
+
require 'active-campaign-simple/event'
|
3
4
|
|
4
5
|
module ActiveCampaign
|
5
6
|
module Request
|
@@ -28,6 +29,11 @@ module ActiveCampaign
|
|
28
29
|
request(:delete, path)
|
29
30
|
end
|
30
31
|
|
32
|
+
# used for tracking events
|
33
|
+
def track_event(key, actid, event, email, eventdata=nil)
|
34
|
+
Event.post_event(key, actid, event, email, eventdata)
|
35
|
+
end
|
36
|
+
|
31
37
|
private
|
32
38
|
|
33
39
|
# Perform request
|
@@ -46,10 +52,10 @@ module ActiveCampaign
|
|
46
52
|
opts.merge!( { payload: payload.to_json }) unless payload.empty?
|
47
53
|
resp = RestClient::Request.execute(opts)
|
48
54
|
rescue RestClient::ExceptionWithResponse => err
|
49
|
-
# log error?
|
50
55
|
raise APIError, err
|
51
56
|
else
|
52
57
|
return JSON.parse(resp.body) if resp.body # Some calls respond w nothing
|
53
58
|
end
|
59
|
+
|
54
60
|
end
|
55
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-campaign-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Leavitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/active-campaign-simple/api_error.rb
|
55
55
|
- lib/active-campaign-simple/client.rb
|
56
56
|
- lib/active-campaign-simple/config.rb
|
57
|
+
- lib/active-campaign-simple/event.rb
|
57
58
|
- lib/active-campaign-simple/logger.rb
|
58
59
|
- lib/active-campaign-simple/request.rb
|
59
60
|
- lib/active-campaign-simple/version.rb
|