cakemail-next-gen 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -2
- data/gemfiles/cakemail-next-gen-1.0.0.gem +0 -0
- data/gemfiles/cakemail-next-gen-1.0.1.gem +0 -0
- data/lib/cakemail/contact.rb +13 -11
- data/lib/cakemail/custom_attribute.rb +31 -0
- data/lib/cakemail/list.rb +4 -0
- data/lib/cakemail/version.rb +1 -1
- data/lib/cakemail.rb +1 -0
- data/vcr_cassettes/attribute_create.yml +45 -0
- data/vcr_cassettes/attribute_create_contact_with_custom_attribute.yml +45 -0
- data/vcr_cassettes/attributes_all_without_error.yml +45 -0
- data/vcr_cassettes/attributes_lists.yml +49 -0
- data/vcr_cassettes/list_attributes.yml +45 -0
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a84b3e883fc694953cd3f7b9ff6d1c0ac7486a63eed02732cd7f7de1b5227b96
|
4
|
+
data.tar.gz: cc6fc412fb7cba8791f2a2dd5df90600417c10c104728753a7c1cb0359f2f7b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97eb11efcd8db2837a5d593b86bac4d1a25dc1811f120a4d21ed487e08e76e1ff760c3fa968deec183e55750e8c22d19f0d53d9d96cc6a715d691bb3f9c7dbed
|
7
|
+
data.tar.gz: 56a4d013d11742d97c413e1b5f3f6f8b34552650df7648f15dc861548090ae5070dfb2b7da21c9eb2ba256f84b82a066fe7a4e1b1bf8eafb88781e5a1b5b191f
|
data/README.md
CHANGED
@@ -68,7 +68,7 @@ Here are some basic usage examples for managing lists:
|
|
68
68
|
|
69
69
|
1. Fetching all lists:
|
70
70
|
```ruby
|
71
|
-
lists = Cakemail::List.
|
71
|
+
lists = Cakemail::List.list
|
72
72
|
lists.each do |list|
|
73
73
|
puts "List ID: #{list.id}"
|
74
74
|
puts "List Name: #{list.name}"
|
@@ -128,7 +128,7 @@ To retrieve all contacts in a given list, you can use the `list` method of the `
|
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
# Get lists
|
131
|
-
lists = Cakemail::List.
|
131
|
+
lists = Cakemail::List.list
|
132
132
|
|
133
133
|
# Retrieve all contacts in a list
|
134
134
|
contacts = Cakemail::Contact.list(parent: lists.first)
|
@@ -192,3 +192,50 @@ contact = list.contacts.last
|
|
192
192
|
contact.unsubscribe
|
193
193
|
puts "Contact unsubscribed successfully."
|
194
194
|
```
|
195
|
+
|
196
|
+
## Custom attributes
|
197
|
+
|
198
|
+
Cakemail allows you to define custom attributes for your contacts. Here's how you can work with custom attributes:
|
199
|
+
|
200
|
+
1. Get list of custom attributes from a list object:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
attributes = @list.custom_attributes
|
204
|
+
|
205
|
+
attributes.each do |attribute|
|
206
|
+
puts "Attribute Name: #{attribute.name}"
|
207
|
+
puts "Attribute Type: #{attribute.type}"
|
208
|
+
# Additional attribute details can be accessed here
|
209
|
+
end
|
210
|
+
```
|
211
|
+
|
212
|
+
2. Create a contact with custom attributes:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
attribute = @list.custom_attributes.first
|
216
|
+
|
217
|
+
params = {
|
218
|
+
email: "nathan.lopez042@gmail.com",
|
219
|
+
custom_attributes: [
|
220
|
+
{
|
221
|
+
name: attribute.name,
|
222
|
+
value: "Nathan"
|
223
|
+
}
|
224
|
+
]
|
225
|
+
}
|
226
|
+
|
227
|
+
contact = @list.create_contact(params)
|
228
|
+
|
229
|
+
puts "Contact created successfully."
|
230
|
+
puts "Email: #{contact.email}"
|
231
|
+
puts "Status: #{contact.status}"
|
232
|
+
puts "Custom Attribute: #{contact.custom_attributes.first['name']}: #{contact.custom_attributes.first['value']}"
|
233
|
+
```
|
234
|
+
|
235
|
+
You can create custom attributes on a list by using the `create` method of the `Cakemail::CustomAttributes` class. To do so, you need to provide the necessary information such as the name and type of the custom attribute. Here's an example code to create a text-type custom attribute with the name "firstname" on a given list:
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
params = { name: "firstname", type: "text" }
|
239
|
+
|
240
|
+
Cakemail::CustomAttributes.create(params, parent: @list)
|
241
|
+
```
|
Binary file
|
Binary file
|
data/lib/cakemail/contact.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Cakemail
|
2
|
-
# @attr [String] email
|
3
|
-
# @attr [String] status
|
4
|
-
# @attr [Integer] subscribed_on
|
5
|
-
# @attr [Integer] bounces_count
|
6
|
-
# @attr [List] list
|
2
|
+
# @attr [String] email Email of the contact
|
3
|
+
# @attr [String] status Status ex. "active"
|
4
|
+
# @attr [Integer] subscribed_on Date of subscription (timestamp)
|
5
|
+
# @attr [Integer] bounces_count Number of bounces
|
6
|
+
# @attr [List] list List of the contact
|
7
|
+
# @attr [Array<Hash>] custom_attributes List of the custom attributes (name: value)
|
7
8
|
class Contact < Base
|
8
|
-
attr_accessor :email, :status, :subscribed_on, :bounces_count
|
9
|
+
attr_accessor :email, :status, :subscribed_on, :bounces_count, :custom_attributes
|
9
10
|
|
10
11
|
# Unsubscribe contact
|
11
12
|
#
|
@@ -47,11 +48,12 @@ module Cakemail
|
|
47
48
|
def initialize(options = {})
|
48
49
|
super(options)
|
49
50
|
|
50
|
-
@email
|
51
|
-
@status
|
52
|
-
@subscribed_on
|
53
|
-
@bounces_count
|
54
|
-
@
|
51
|
+
@email = options["email"]
|
52
|
+
@status = options["status"]
|
53
|
+
@subscribed_on = options["subscribed_on"]
|
54
|
+
@bounces_count = options["bounces_count"]
|
55
|
+
@custom_attributes = options["custom_attributes"]
|
56
|
+
@list = parent
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Cakemail
|
2
|
+
# @attr [String] name Name of the list
|
3
|
+
# @attr [String] type Ex. "text", "integer"
|
4
|
+
class CustomAttributes < Base
|
5
|
+
attr_accessor :name, :type
|
6
|
+
|
7
|
+
def self.parent_required
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.no_parent_exception
|
12
|
+
raise Cakemail::Base::NoParentError,
|
13
|
+
"To request custom attributes, a list is required. Please use the parent option to pass it."
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.object_class
|
17
|
+
Cakemail::CustomAttributes
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.path
|
21
|
+
"custom-attributes"
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
super(options)
|
26
|
+
|
27
|
+
@name = options["name"]
|
28
|
+
@type = options["type"]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/cakemail/list.rb
CHANGED
@@ -19,6 +19,10 @@ module Cakemail
|
|
19
19
|
Cakemail::Contact.list(options.merge(parent: self))
|
20
20
|
end
|
21
21
|
|
22
|
+
def custom_attributes(options = {})
|
23
|
+
Cakemail::CustomAttributes.list(options.merge(parent: self))
|
24
|
+
end
|
25
|
+
|
22
26
|
def create_contact(params, options = {})
|
23
27
|
Cakemail::Contact.create(params, options.merge(parent: self))
|
24
28
|
end
|
data/lib/cakemail/version.rb
CHANGED
data/lib/cakemail.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.cakemail.dev/lists/8944823/custom-attributes
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "<FILTERED>"
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v2.7.10
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer <TOKEN_PLACEHOLDER>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Sat, 15 Jul 2023 04:42:46 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '98'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Vary:
|
36
|
+
- Origin
|
37
|
+
X-Krakend:
|
38
|
+
- Version 1.1.1
|
39
|
+
X-Krakend-Completed:
|
40
|
+
- 'false'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"name":"firstname","object":"attribute","created":true,"data":{"name":"firstname","type":"text"}}'
|
44
|
+
recorded_at: Sat, 15 Jul 2023 04:42:46 GMT
|
45
|
+
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.cakemail.dev/lists/8944823/contacts
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "<FILTERED>"
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v2.7.10
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer <TOKEN_PLACEHOLDER>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Sat, 15 Jul 2023 04:47:58 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '268'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Vary:
|
36
|
+
- Origin
|
37
|
+
X-Krakend:
|
38
|
+
- Version 1.1.1
|
39
|
+
X-Krakend-Completed:
|
40
|
+
- 'false'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"id":5,"object":"contact","created":true,"data":{"id":5,"email":"nathan.lopez042@gmail.com","status":"active","subscribed_on":1689396477,"last_bounce_type":"none","bounces_count":0,"custom_attributes":[{"name":"firstname","value":"Nathan"}],"tags":[],"interests":[]}}'
|
44
|
+
recorded_at: Sat, 15 Jul 2023 04:47:58 GMT
|
45
|
+
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.cakemail.dev/lists/8944823/custom-attributes?page=1&per_page=50
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v2.7.10
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer <TOKEN_PLACEHOLDER>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Sat, 15 Jul 2023 04:42:45 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '62'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Vary:
|
36
|
+
- Origin
|
37
|
+
X-Krakend:
|
38
|
+
- Version 1.1.1
|
39
|
+
X-Krakend-Completed:
|
40
|
+
- 'false'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"pagination":{"count":null,"page":1,"per_page":50},"data":[]}'
|
44
|
+
recorded_at: Sat, 15 Jul 2023 04:42:45 GMT
|
45
|
+
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.cakemail.dev/lists?page=1&per_page=50
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v2.7.10
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer <TOKEN_PLACEHOLDER>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Sat, 15 Jul 2023 04:42:44 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '583'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Vary:
|
36
|
+
- Origin
|
37
|
+
X-Krakend:
|
38
|
+
- Version 1.1.1
|
39
|
+
X-Krakend-Completed:
|
40
|
+
- 'false'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"pagination":{"count":null,"page":1,"per_page":50},"data":[{"id":8944823,"name":"Liste
|
44
|
+
de Nathan Lopez","status":"active","language":"fr_CA","created_on":1688012089,"default_sender":{"name":"Nathan
|
45
|
+
Lopez","email":"nathan.lopez042@gmail.com"}},{"id":8947181,"name":"Test","status":"active","language":"fr_FR","created_on":1688445887,"default_sender":{"name":"Nathan
|
46
|
+
Lopez","email":"nathan.lopez042@gmail.com"}},{"id":8947185,"name":"New name","status":"active","language":"fr_CA","created_on":1688447179,"default_sender":{"name":"Nathan
|
47
|
+
Lopez","email":"nathan.lopez042@gmail.com"}}]}'
|
48
|
+
recorded_at: Sat, 15 Jul 2023 04:42:44 GMT
|
49
|
+
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.cakemail.dev/lists/8944823/custom-attributes?page=1&per_page=50
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v2.7.10
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
Authorization:
|
17
|
+
- Bearer <TOKEN_PLACEHOLDER>
|
18
|
+
Accept-Encoding:
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Date:
|
28
|
+
- Sat, 15 Jul 2023 04:42:46 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '96'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Vary:
|
36
|
+
- Origin
|
37
|
+
X-Krakend:
|
38
|
+
- Version 1.1.1
|
39
|
+
X-Krakend-Completed:
|
40
|
+
- 'false'
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"pagination":{"count":null,"page":1,"per_page":50},"data":[{"name":"firstname","type":"text"}]}'
|
44
|
+
recorded_at: Sat, 15 Jul 2023 04:42:46 GMT
|
45
|
+
recorded_with: VCR 6.2.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cakemail-next-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Lopez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This library allows you to quickly and easily use the Cakemail Next-gen
|
14
14
|
API via Ruby.
|
@@ -25,17 +25,24 @@ files:
|
|
25
25
|
- README.md
|
26
26
|
- Rakefile
|
27
27
|
- cakemail.gemspec
|
28
|
+
- gemfiles/cakemail-next-gen-1.0.0.gem
|
29
|
+
- gemfiles/cakemail-next-gen-1.0.1.gem
|
28
30
|
- images/logo.png
|
29
31
|
- lib/cakemail.rb
|
30
32
|
- lib/cakemail/base.rb
|
31
33
|
- lib/cakemail/configuration.rb
|
32
34
|
- lib/cakemail/connection.rb
|
33
35
|
- lib/cakemail/contact.rb
|
36
|
+
- lib/cakemail/custom_attribute.rb
|
34
37
|
- lib/cakemail/list.rb
|
35
38
|
- lib/cakemail/sender.rb
|
36
39
|
- lib/cakemail/token.rb
|
37
40
|
- lib/cakemail/version.rb
|
38
41
|
- sig/cakemail.rbs
|
42
|
+
- vcr_cassettes/attribute_create.yml
|
43
|
+
- vcr_cassettes/attribute_create_contact_with_custom_attribute.yml
|
44
|
+
- vcr_cassettes/attributes_all_without_error.yml
|
45
|
+
- vcr_cassettes/attributes_lists.yml
|
39
46
|
- vcr_cassettes/contact_create.yml
|
40
47
|
- vcr_cassettes/contact_create_from_list.yml
|
41
48
|
- vcr_cassettes/contact_unsubscribe.yml
|
@@ -50,6 +57,7 @@ files:
|
|
50
57
|
- vcr_cassettes/create_wrong_token.yml
|
51
58
|
- vcr_cassettes/list.yml
|
52
59
|
- vcr_cassettes/list_archive.yml
|
60
|
+
- vcr_cassettes/list_attributes.yml
|
53
61
|
- vcr_cassettes/list_contacts.yml
|
54
62
|
- vcr_cassettes/list_create.yml
|
55
63
|
- vcr_cassettes/list_delete.yml
|
@@ -70,7 +78,7 @@ licenses:
|
|
70
78
|
metadata:
|
71
79
|
homepage_uri: https://github.com/andrewdsilva/cakemail-ruby
|
72
80
|
source_code_uri: https://github.com/andrewdsilva/cakemail-ruby
|
73
|
-
post_install_message:
|
81
|
+
post_install_message:
|
74
82
|
rdoc_options: []
|
75
83
|
require_paths:
|
76
84
|
- lib
|
@@ -85,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
93
|
- !ruby/object:Gem::Version
|
86
94
|
version: '0'
|
87
95
|
requirements: []
|
88
|
-
rubygems_version: 3.1
|
89
|
-
signing_key:
|
96
|
+
rubygems_version: 3.0.3.1
|
97
|
+
signing_key:
|
90
98
|
specification_version: 4
|
91
99
|
summary: This library allows you to quickly and easily use the Cakemail Next-gen API
|
92
100
|
via Ruby.
|