mailersend-ruby 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/mailersend-ruby.rb +1 -1
- data/lib/mailersend.rb +10 -10
- data/lib/mailersend/analytics/analytics.rb +19 -19
- data/lib/mailersend/client.rb +8 -8
- data/lib/mailersend/domains/domains.rb +18 -18
- data/lib/mailersend/email/email.rb +18 -17
- data/lib/mailersend/messages/messages.rb +3 -3
- data/lib/mailersend/recipients/recipients.rb +3 -3
- data/lib/mailersend/templates/templates.rb +4 -4
- data/lib/mailersend/tokens/tokens.rb +3 -3
- data/lib/mailersend/version.rb +1 -1
- data/lib/mailersend/webhooks/webhooks.rb +11 -11
- data/mailersend-ruby.gemspec +20 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98b4051caac7b675422e4a75cbd0c80009568212ce7164bc21df55b91960b79f
|
4
|
+
data.tar.gz: 97534d566796c7a78be2345c710e555b71a8e31140e7f7c09c500c46674eef4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07160b40cc910448207d48f6796a6cea6e581ea985611be55e4e8dc11784279f876270be132922d24ef6e20e1a9093a99f6d1b6098344d8f5bec9d843efb016
|
7
|
+
data.tar.gz: f8cbbb7f0dbc1c20073ba13389bb0cf1d190083f2ee89931421d8e9cd8009d4ed9bfcbb1b15bbd865ba8e38806a93f44607f4584216c3f8a88a689c4a37bb406
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Released]
|
2
2
|
|
3
|
+
## [0.2.0] - 2021-08-04
|
4
|
+
|
5
|
+
- Fixed email class so that it omits empty values
|
6
|
+
|
7
|
+
## [0.2.0] - 2021-07-01
|
8
|
+
|
9
|
+
- Added Templates endpoint
|
10
|
+
|
11
|
+
## [0.1.9] - 2021-06-30
|
12
|
+
|
13
|
+
- Fixed docs
|
14
|
+
|
3
15
|
## [0.1.8] - 2021-06-15
|
4
16
|
|
5
17
|
- Fixed unused parameter
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require_relative
|
4
|
+
require 'bundler/setup'
|
5
|
+
require_relative '../lib/mailersend/version'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require_relative "../lib/mailersend/version"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require 'irb'
|
15
15
|
IRB.start(__FILE__)
|
data/lib/mailersend-ruby.rb
CHANGED
data/lib/mailersend.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
3
|
+
require 'mailersend/client'
|
4
|
+
require 'mailersend/activity/activity'
|
5
|
+
require 'mailersend/analytics/analytics'
|
6
|
+
require 'mailersend/domains/domains'
|
7
|
+
require 'mailersend/email/email'
|
8
|
+
require 'mailersend/messages/messages'
|
9
|
+
require 'mailersend/recipients/recipients'
|
10
|
+
require 'mailersend/templates/templates'
|
11
|
+
require 'mailersend/tokens/tokens'
|
12
|
+
require 'mailersend/webhooks/webhooks'
|
@@ -14,27 +14,27 @@ module Mailersend
|
|
14
14
|
|
15
15
|
def initialize(client = Mailersend::Client.new)
|
16
16
|
@client = client
|
17
|
-
@date_from =
|
18
|
-
@date_to =
|
17
|
+
@date_from = ''
|
18
|
+
@date_to = ''
|
19
19
|
@events = []
|
20
|
-
@domain_id =
|
21
|
-
@recipient_id =
|
22
|
-
@group_by =
|
20
|
+
@domain_id = ''
|
21
|
+
@recipient_id = ''
|
22
|
+
@group_by = ''
|
23
23
|
@tags = []
|
24
24
|
end
|
25
25
|
|
26
26
|
def date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group_by: nil, tags: nil)
|
27
27
|
hash = {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
'date_from' => date_from,
|
29
|
+
'date_to' => date_to,
|
30
|
+
'event[]' => events,
|
31
|
+
'domain_id' => domain_id,
|
32
|
+
'recipient_id' => recipient_id,
|
33
|
+
'group_by' => group_by,
|
34
|
+
'tags[]' => tags
|
35
35
|
}
|
36
36
|
|
37
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
37
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/date',
|
38
38
|
query: URI.encode_www_form(hash.compact)))
|
39
39
|
puts response
|
40
40
|
end
|
@@ -45,10 +45,10 @@ module Mailersend
|
|
45
45
|
recipient_id: recipient_id,
|
46
46
|
date_from: date_from,
|
47
47
|
date_to: date_to,
|
48
|
-
|
48
|
+
'tags[]': tags
|
49
49
|
}
|
50
50
|
|
51
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
51
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/country',
|
52
52
|
query: URI.encode_www_form(hash.compact)))
|
53
53
|
puts response
|
54
54
|
end
|
@@ -59,10 +59,10 @@ module Mailersend
|
|
59
59
|
recipient_id: recipient_id,
|
60
60
|
date_from: date_from,
|
61
61
|
date_to: date_to,
|
62
|
-
|
62
|
+
'tags[]': tags
|
63
63
|
}
|
64
64
|
|
65
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
65
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-name',
|
66
66
|
query: URI.encode_www_form(hash.compact)))
|
67
67
|
puts response
|
68
68
|
end
|
@@ -73,10 +73,10 @@ module Mailersend
|
|
73
73
|
recipient_id: recipient_id,
|
74
74
|
date_from: date_from,
|
75
75
|
date_to: date_to,
|
76
|
-
|
76
|
+
'tags[]': tags
|
77
77
|
}
|
78
78
|
|
79
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
79
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/analytics/ua-type',
|
80
80
|
query: URI.encode_www_form(hash.compact)))
|
81
81
|
puts response
|
82
82
|
end
|
data/lib/mailersend/client.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'http'
|
4
|
+
require 'dotenv/load'
|
5
5
|
|
6
|
-
API_URL =
|
7
|
-
API_BASE_HOST =
|
6
|
+
API_URL = 'https://api.mailersend.com/v1'
|
7
|
+
API_BASE_HOST = 'api.mailersend.com'
|
8
8
|
|
9
|
-
Dotenv.require_keys(
|
9
|
+
Dotenv.require_keys('API_TOKEN')
|
10
10
|
|
11
11
|
# mailersend-ruby is a gem that integrates all endpoints from MailerSend API
|
12
12
|
module Mailersend
|
@@ -14,7 +14,7 @@ module Mailersend
|
|
14
14
|
|
15
15
|
# Inits the client.
|
16
16
|
class Client
|
17
|
-
|
17
|
+
def initialize(api_token = ENV['API_TOKEN'])
|
18
18
|
@api_token = api_token
|
19
19
|
end
|
20
20
|
|
@@ -22,8 +22,8 @@ module Mailersend
|
|
22
22
|
HTTP
|
23
23
|
.timeout(connect: 15, read: 30)
|
24
24
|
.auth("Bearer #{@api_token}")
|
25
|
-
.headers(
|
26
|
-
|
25
|
+
.headers('User-Agent' => 'MailerSend-client-ruby/1.0.0',
|
26
|
+
'Accept' => 'application/json')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -19,20 +19,20 @@ module Mailersend
|
|
19
19
|
|
20
20
|
def list(page: nil, limit: nil, verified: nil)
|
21
21
|
hash = {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
'page' => page,
|
23
|
+
'limit' => limit,
|
24
|
+
'verified' => verified
|
25
25
|
}
|
26
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
26
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/domains',
|
27
27
|
query: URI.encode_www_form(hash.compact)))
|
28
28
|
puts response
|
29
29
|
end
|
30
30
|
|
31
31
|
def single(domain_id:, page: nil, limit: nil, verified: nil)
|
32
32
|
hash = {
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
'page' => page,
|
34
|
+
'limit' => limit,
|
35
|
+
'verified' => verified
|
36
36
|
}
|
37
37
|
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}",
|
38
38
|
query: URI.encode_www_form(hash.compact)))
|
@@ -46,8 +46,8 @@ module Mailersend
|
|
46
46
|
|
47
47
|
def recipients(domain_id:)
|
48
48
|
hash = {
|
49
|
-
|
50
|
-
|
49
|
+
'page' => page,
|
50
|
+
'limit' => limit
|
51
51
|
}
|
52
52
|
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains/#{domain_id}/recipients",
|
53
53
|
query: URI.encode_www_form(hash.compact)))
|
@@ -56,15 +56,15 @@ module Mailersend
|
|
56
56
|
|
57
57
|
def settings(domain_id:, send_paused: nil, track_clicks: nil, track_opens: nil, track_unsubscribe: nil, track_unsubscribe_html: nil, track_unsubscribe_plain: nil, track_content: nil, custom_tracking_enabled: nil, custom_tracking_subdomain: nil)
|
58
58
|
hash = {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
'send_paused' => send_paused,
|
60
|
+
'track_clicks' => track_clicks,
|
61
|
+
'track_opens' => track_opens,
|
62
|
+
'track_unsubscribe' => track_unsubscribe,
|
63
|
+
'track_unsubscribe_html' => track_unsubscribe_html,
|
64
|
+
'track_unsubscribe_plain' => track_unsubscribe_plain,
|
65
|
+
'track_content' => track_content,
|
66
|
+
'custom_tracking_enabled' => custom_tracking_enabled,
|
67
|
+
'custom_tracking_subdomain' => custom_tracking_subdomain
|
68
68
|
}
|
69
69
|
response = client.http.put("#{API_URL}/domains/#{domain_id}/settings", json: hash.compact)
|
70
70
|
puts response
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'base64'
|
4
4
|
|
5
5
|
module Mailersend
|
6
6
|
# Send an email through MailerSend API
|
@@ -87,30 +87,31 @@ module Mailersend
|
|
87
87
|
def add_attachment(content:, filename:)
|
88
88
|
data = File.open(content.to_s).read
|
89
89
|
encoded = Base64.strict_encode64(data)
|
90
|
-
attachments << {
|
91
|
-
|
92
|
-
|
90
|
+
@attachments << {
|
91
|
+
'content' => encoded,
|
92
|
+
'filename' => filename
|
93
93
|
}
|
94
94
|
end
|
95
95
|
|
96
96
|
def send
|
97
97
|
message = {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
'from' => @from,
|
99
|
+
'to' => @recipients,
|
100
|
+
'cc' => @ccs,
|
101
|
+
'bcc' => @bcc,
|
102
|
+
'reply_to' => @reply_to,
|
103
|
+
'subject' => @subject,
|
104
|
+
'text' => @text,
|
105
|
+
'html' => @html,
|
106
|
+
'variables' => @variables,
|
107
|
+
'personalization' => @personalization,
|
108
|
+
'template_id' => @template_id,
|
109
|
+
'attachments' => @attachments
|
110
110
|
}
|
111
111
|
|
112
|
-
response = client.http.post("#{API_URL}/email", json: message.
|
112
|
+
response = client.http.post("#{API_URL}/email", json: message.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} })
|
113
113
|
puts response
|
114
|
+
puts message
|
114
115
|
puts response.status.code
|
115
116
|
end
|
116
117
|
end
|
@@ -17,11 +17,11 @@ module Mailersend
|
|
17
17
|
|
18
18
|
def list(page: nil, limit: nil)
|
19
19
|
hash = {
|
20
|
-
|
21
|
-
|
20
|
+
'page' => page,
|
21
|
+
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
24
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/messages',
|
25
25
|
query: URI.encode_www_form(hash)))
|
26
26
|
puts response
|
27
27
|
end
|
@@ -17,11 +17,11 @@ module Mailersend
|
|
17
17
|
|
18
18
|
def list(page: nil, limit: nil)
|
19
19
|
hash = {
|
20
|
-
|
21
|
-
|
20
|
+
'page' => page,
|
21
|
+
'limit' => limit
|
22
22
|
}
|
23
23
|
|
24
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
24
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/recipients',
|
25
25
|
query: URI.encode_www_form(hash)))
|
26
26
|
puts response
|
27
27
|
end
|
@@ -17,12 +17,12 @@ module Mailersend
|
|
17
17
|
|
18
18
|
def list(domain_id: nil, page: nil, limit: nil)
|
19
19
|
hash = {
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
'domain_id' => domain_id,
|
21
|
+
'page' => page,
|
22
|
+
'limit' => limit
|
23
23
|
}
|
24
24
|
|
25
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
25
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/templates',
|
26
26
|
query: URI.encode_www_form(hash)))
|
27
27
|
puts response
|
28
28
|
end
|
@@ -19,9 +19,9 @@ module Mailersend
|
|
19
19
|
|
20
20
|
def create(name:, scopes:, domain_id:)
|
21
21
|
json = {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
'name' => name,
|
23
|
+
'scopes' => scopes,
|
24
|
+
'domain_id' => domain_id
|
25
25
|
}
|
26
26
|
response = client.http.post("#{API_URL}/token", json: json)
|
27
27
|
puts response
|
data/lib/mailersend/version.rb
CHANGED
@@ -22,9 +22,9 @@ module Mailersend
|
|
22
22
|
|
23
23
|
def list(domain_id:)
|
24
24
|
hash = {
|
25
|
-
|
25
|
+
'domain_id' => domain_id
|
26
26
|
}
|
27
|
-
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path:
|
27
|
+
response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/webhooks',
|
28
28
|
query: URI.encode_www_form(hash)))
|
29
29
|
puts response
|
30
30
|
end
|
@@ -36,11 +36,11 @@ module Mailersend
|
|
36
36
|
|
37
37
|
def create(url:, name:, events:, domain_id:, enabled: nil)
|
38
38
|
hash = {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
'url' => url,
|
40
|
+
'name' => name,
|
41
|
+
'events' => events,
|
42
|
+
'domain_id' => domain_id,
|
43
|
+
'enabled' => enabled.to_s == 'true'
|
44
44
|
}
|
45
45
|
|
46
46
|
response = client.http.post("#{API_URL}/webhooks", json: hash.compact)
|
@@ -49,10 +49,10 @@ module Mailersend
|
|
49
49
|
|
50
50
|
def update(webhook_id:, url: nil, name: nil, events: nil, enabled: nil)
|
51
51
|
hash = {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
'url' => url,
|
53
|
+
'name' => name,
|
54
|
+
'events' => events,
|
55
|
+
'enabled' => enabled.to_s == 'true'
|
56
56
|
}
|
57
57
|
response = client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: hash.compact)
|
58
58
|
puts response
|
data/mailersend-ruby.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require 'mailersend/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = 'mailersend-ruby'
|
9
9
|
spec.version = Mailersend::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ['Nikola Milojević']
|
11
|
+
spec.email = ['info@mailersend.com']
|
12
12
|
|
13
13
|
spec.summary = "MailerSend's official Ruby SDK"
|
14
14
|
spec.description = "MailerSend's official Ruby SDK. Interacts with all endpoints at MailerSend API."
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
17
|
-
spec.required_ruby_version =
|
15
|
+
spec.homepage = 'https://www.mailersend.com'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.required_ruby_version = '>= 2.5.0'
|
18
18
|
|
19
|
-
spec.metadata[
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
20
|
|
21
|
-
spec.metadata[
|
22
|
-
spec.metadata[
|
23
|
-
spec.metadata[
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/mailersend/mailersend-ruby'
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/mailersend/mailersend-ruby/blob/main/CHANGELOG.md'
|
24
24
|
|
25
25
|
spec.files = `git ls-files -z`.split("\x0")
|
26
26
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
27
|
+
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_dependency
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.2.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 1.7'
|
32
|
+
spec.add_dependency 'dotenv', '~> 2.7'
|
33
|
+
spec.add_dependency 'http', '~> 5.0'
|
34
|
+
spec.add_dependency 'json', '~> 2.5'
|
35
|
+
spec.add_dependency 'uri', '~> 0.10.1'
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailersend-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojević
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.2.
|
169
|
+
rubygems_version: 3.2.22
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: MailerSend's official Ruby SDK
|