parallel588-klaviyo 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/klaviyo/lists/api_operations.rb +116 -0
- data/lib/klaviyo/lists/collection.rb +21 -0
- data/lib/klaviyo/lists/entry.rb +12 -0
- data/lib/klaviyo/lists.rb +8 -0
- data/lib/klaviyo/people.rb +22 -0
- data/lib/klaviyo/version.rb +1 -1
- data/lib/klaviyo.rb +1 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c48e98339ae3627124429dce0eccb27092ed6643
|
4
|
+
data.tar.gz: b10d9a87e4d3bf4de4bc28e952b5cb59cc8680d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8f5f95e511b87f2639b33cd21b09ebb71711ff2f6554e7e08d0757fa9402d1f143f8773654faf7fd3ce40f959e8836a22fa280d61f60938d78fb33d46869047
|
7
|
+
data.tar.gz: c74da73b0beea64f332d37922e6b233722ff26e45b354f89eacd7bd8e8a672821ec46006e785175fc095c5a6131c7fcc9385b2675a734950329d9dc8b546b2e7
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative 'collection'
|
2
|
+
require_relative 'entry'
|
3
|
+
module Klaviyo
|
4
|
+
module Lists
|
5
|
+
# https://www.klaviyo.com/docs/api/lists
|
6
|
+
#
|
7
|
+
module ApiOperations
|
8
|
+
|
9
|
+
def all(client:, page: 0, per: 50)
|
10
|
+
Collection.new(
|
11
|
+
client.conn.get(
|
12
|
+
'/api/v1/lists',
|
13
|
+
api_key: client.api_key,
|
14
|
+
page: page, count: per
|
15
|
+
).body)
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(client:, id:)
|
19
|
+
Entry.new(
|
20
|
+
client.conn.get(
|
21
|
+
"/api/v1/list/#{id}", api_key: client.api_key
|
22
|
+
).body)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(client:, name:, list_type: 'standart')
|
26
|
+
res = client.conn.post(
|
27
|
+
'/api/v1/lists',
|
28
|
+
api_key: client.api_key,
|
29
|
+
name: name,
|
30
|
+
list_type: list_type
|
31
|
+
)
|
32
|
+
Entry(res.body)
|
33
|
+
end
|
34
|
+
|
35
|
+
def update(client:, id:, name:)
|
36
|
+
res = client.conn.put(
|
37
|
+
"/api/v1/list/#{id}",
|
38
|
+
api_key: client.api_key,
|
39
|
+
name: name
|
40
|
+
)
|
41
|
+
Entry.new(res.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete(client:, id:)
|
45
|
+
res = client.conn.delete(
|
46
|
+
"/api/v1/list/#{id}",
|
47
|
+
api_key: client.api_key
|
48
|
+
)
|
49
|
+
Entry.new(res.body)
|
50
|
+
end
|
51
|
+
|
52
|
+
def include_member_in_list?(client:, id:, email:)
|
53
|
+
client.conn.get(
|
54
|
+
"/api/v1/list/#{id}/members",
|
55
|
+
api_key: client.api_key,
|
56
|
+
email: email
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def include_member_in_segment?(client:, segment_id:, email:)
|
61
|
+
client.conn.get(
|
62
|
+
"/api/v1/segment/#{segment_id}/members",
|
63
|
+
api_key: client.api_key,
|
64
|
+
email: email
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# @id - list id
|
70
|
+
#
|
71
|
+
def subscribe(client:, id:, email:, properties: {}, confirm_optin: true)
|
72
|
+
client.conn.post(
|
73
|
+
"/api/v1/list/#{id}/members",
|
74
|
+
api_key: client.api_key,
|
75
|
+
email: email,
|
76
|
+
properties: properties,
|
77
|
+
confirm_optin: confirm_optin
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def unsubscribe(client:, id:, email:, ts: Time.now.to_i)
|
82
|
+
client.conn.post(
|
83
|
+
"/api/v1/list/#{id}/members/exclude",
|
84
|
+
api_key: client.api_key,
|
85
|
+
email: email,
|
86
|
+
timestamp: ts
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# @id - list id
|
92
|
+
#
|
93
|
+
def batch_subscribe(client:, id:, batch:, confirm_optin: true)
|
94
|
+
client.conn.post(
|
95
|
+
"/api/v1/list/#{id}/members/batch",
|
96
|
+
api_key: client.api_key,
|
97
|
+
batch: batch,
|
98
|
+
confirm_optin: confirm_optin
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# @reason - unsubscribed, bounced, invalid_email, reported_spam and manually_excluded.
|
104
|
+
# @sort - asc\desc
|
105
|
+
#
|
106
|
+
def unsubscribes(client:, id:, reason: 'unsubscribed', sort: 'asc')
|
107
|
+
client.conn.post(
|
108
|
+
"/api/v1/list/#{id}/exclusions",
|
109
|
+
api_key: client.api_key,
|
110
|
+
reason: reason,
|
111
|
+
sort: sort
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'entry'
|
2
|
+
module Klaviyo
|
3
|
+
module Lists
|
4
|
+
|
5
|
+
class Collection
|
6
|
+
attr_reader :data
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@data = data
|
10
|
+
end
|
11
|
+
|
12
|
+
def items
|
13
|
+
@items ||= data.fetch('data') { [] }.map { |j| Entry.new(j) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def meta
|
17
|
+
@meta ||= data.except('data')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/klaviyo/people.rb
CHANGED
@@ -17,6 +17,28 @@ module Klaviyo
|
|
17
17
|
)
|
18
18
|
Result.new(res.body)
|
19
19
|
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# @reason - unsubscribed, bounced, invalid_email, reported_spam, manually_excluded
|
23
|
+
# @sort - asc|desc
|
24
|
+
#
|
25
|
+
def exclusions(client:, reason: 'unsubscribed', sort: 'asc')
|
26
|
+
client.conn.get(
|
27
|
+
'/api/v1/people/exclusions',
|
28
|
+
api_key: client.api_key,
|
29
|
+
reason: reason,
|
30
|
+
sort: sort
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def exclude(client:, email:, ts: Time.now.to_i)
|
35
|
+
client.conn.post(
|
36
|
+
'/api/v1/people/exclusions',
|
37
|
+
api_key: client.api_key,
|
38
|
+
email: email,
|
39
|
+
timestamp: ts
|
40
|
+
)
|
41
|
+
end
|
20
42
|
end
|
21
43
|
|
22
44
|
extend ApiOperations
|
data/lib/klaviyo/version.rb
CHANGED
data/lib/klaviyo.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel588-klaviyo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Pechnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -169,6 +169,10 @@ files:
|
|
169
169
|
- lib/klaviyo.rb
|
170
170
|
- lib/klaviyo/client.rb
|
171
171
|
- lib/klaviyo/event.rb
|
172
|
+
- lib/klaviyo/lists.rb
|
173
|
+
- lib/klaviyo/lists/api_operations.rb
|
174
|
+
- lib/klaviyo/lists/collection.rb
|
175
|
+
- lib/klaviyo/lists/entry.rb
|
172
176
|
- lib/klaviyo/people.rb
|
173
177
|
- lib/klaviyo/templates.rb
|
174
178
|
- lib/klaviyo/templates/api_operations.rb
|