cakemail-next-gen 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95edcd5ef79bdd5c936ed0e1796dea3e69a2c0b9c91b7e8c22d4a96a35bdc022
4
- data.tar.gz: 6c9771c0061bd3268833293db53f3b5caecadbf09389303333fa4056674cef11
3
+ metadata.gz: c93703fecdffbf27033542781c2c831f09b21b600f23b4ffaaa70f8e215f93e8
4
+ data.tar.gz: 84aaa4a0853645e060ec6701743138fde65b4fd416d28cf959f2ae76c47504a7
5
5
  SHA512:
6
- metadata.gz: b7cfcf78af7aed0e39e83d6a507035631046aeeb7eec499b4cf23bbcadcf336ad76083bb5d64c73f65c6a98208a8667c83c421685c6b7785cdb5950a6d3a85cd
7
- data.tar.gz: 06db8e184b081f991a2f35bc0ed76affd657a03b91a1545080d627b4a9f576ed261bdf58e02e13c13129e23c9443cbe2667cb681cd91972ba278e18767d7fc6a
6
+ metadata.gz: c16215bf239df9d1a494b2556bf211b61eadc8b3918b02b8281691c661afa65596809aac4721e6106152bef877e9a027d6fb25f4da0f373895693e7812e43cc7
7
+ data.tar.gz: d61aa75c0d3f929281445ff56c12f02992b55f128bae248f0f10915b7765eb61000287b90b526657fdda170b4d20c839110949d5cf3144cae3a54f2a9cf268d2
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.all
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.all
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
+ ```
@@ -1,11 +1,12 @@
1
1
  module Cakemail
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
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 = options["email"]
51
- @status = options["status"]
52
- @subscribed_on = options["subscribed_on"]
53
- @bounces_count = options["bounces_count"]
54
- @list = parent
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cakemail
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
data/lib/cakemail.rb CHANGED
@@ -18,4 +18,5 @@ module Cakemail
18
18
  autoload :Sender, "cakemail/sender"
19
19
  autoload :List, "cakemail/list"
20
20
  autoload :Contact, "cakemail/contact"
21
+ autoload :CustomAttributes, "cakemail/custom_attribute"
21
22
  end
@@ -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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lopez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-08 00:00:00.000000000 Z
11
+ date: 2023-07-15 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,23 @@ files:
25
25
  - README.md
26
26
  - Rakefile
27
27
  - cakemail.gemspec
28
+ - gemfiles/cakemail-next-gen-1.0.0.gem
28
29
  - images/logo.png
29
30
  - lib/cakemail.rb
30
31
  - lib/cakemail/base.rb
31
32
  - lib/cakemail/configuration.rb
32
33
  - lib/cakemail/connection.rb
33
34
  - lib/cakemail/contact.rb
35
+ - lib/cakemail/custom_attribute.rb
34
36
  - lib/cakemail/list.rb
35
37
  - lib/cakemail/sender.rb
36
38
  - lib/cakemail/token.rb
37
39
  - lib/cakemail/version.rb
38
40
  - sig/cakemail.rbs
41
+ - vcr_cassettes/attribute_create.yml
42
+ - vcr_cassettes/attribute_create_contact_with_custom_attribute.yml
43
+ - vcr_cassettes/attributes_all_without_error.yml
44
+ - vcr_cassettes/attributes_lists.yml
39
45
  - vcr_cassettes/contact_create.yml
40
46
  - vcr_cassettes/contact_create_from_list.yml
41
47
  - vcr_cassettes/contact_unsubscribe.yml
@@ -50,6 +56,7 @@ files:
50
56
  - vcr_cassettes/create_wrong_token.yml
51
57
  - vcr_cassettes/list.yml
52
58
  - vcr_cassettes/list_archive.yml
59
+ - vcr_cassettes/list_attributes.yml
53
60
  - vcr_cassettes/list_contacts.yml
54
61
  - vcr_cassettes/list_create.yml
55
62
  - vcr_cassettes/list_delete.yml