mailersend-ruby 0.2.0 → 0.2.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: c4e0823bdc82739f6623c90f41582065cb9ef11abeafb918f19464004c8f771b
4
- data.tar.gz: 617c135a9ccfeacbc578cd51335fa14ee78b07ed6c9222924e8fda0977ec9df3
3
+ metadata.gz: 98b4051caac7b675422e4a75cbd0c80009568212ce7164bc21df55b91960b79f
4
+ data.tar.gz: 97534d566796c7a78be2345c710e555b71a8e31140e7f7c09c500c46674eef4b
5
5
  SHA512:
6
- metadata.gz: 7b0cd7c1327c248a64229318d292ea6a410b926dad0892b8d06fa02e8959a6456605ef459962e303cf50f0ba4648b1d09f060a7b0d22e8cc5448cb39d1cd8843
7
- data.tar.gz: 10d4ef77fb271eef8eef32025a4eba43e7096fb1501d5aa00a8d9cc831c3331bc425f20776366d17cb1c99c421759b103d71410019f4967ba54b626052fe7c34
6
+ metadata.gz: c07160b40cc910448207d48f6796a6cea6e581ea985611be55e4e8dc11784279f876270be132922d24ef6e20e1a9093a99f6d1b6098344d8f5bec9d843efb016
7
+ data.tar.gz: f8cbbb7f0dbc1c20073ba13389bb0cf1d190083f2ee89931421d8e9cd8009d4ed9bfcbb1b15bbd865ba8e38806a93f44607f4584216c3f8a88a689c4a37bb406
data/.rubocop.yml CHANGED
@@ -5,7 +5,6 @@ AllCops:
5
5
 
6
6
  Style/StringLiterals:
7
7
  Enabled: true
8
- EnforcedStyle: double_quotes
9
8
 
10
9
  Style/StringLiteralsInInterpolation:
11
10
  Enabled: true
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
5
 
6
6
  RuboCop::RakeTask.new
7
7
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
- require_relative "../lib/mailersend/version"
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 "irb"
14
+ require 'irb'
15
15
  IRB.start(__FILE__)
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "mailersend"
3
+ require 'mailersend'
data/lib/mailersend.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
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"
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
- "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
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: "/v1/analytics/date",
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
- "tags[]": tags
48
+ 'tags[]': tags
49
49
  }
50
50
 
51
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/analytics/country",
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
- "tags[]": tags
62
+ 'tags[]': tags
63
63
  }
64
64
 
65
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/analytics/ua-name",
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
- "tags[]": tags
76
+ 'tags[]': tags
77
77
  }
78
78
 
79
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/analytics/ua-type",
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
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "http"
4
- require "dotenv/load"
3
+ require 'http'
4
+ require 'dotenv/load'
5
5
 
6
- API_URL = "https://api.mailersend.com/v1"
7
- API_BASE_HOST = "api.mailersend.com"
6
+ API_URL = 'https://api.mailersend.com/v1'
7
+ API_BASE_HOST = 'api.mailersend.com'
8
8
 
9
- Dotenv.require_keys("API_TOKEN")
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
- def initialize(api_token = ENV["API_TOKEN"])
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("User-Agent" => "MailerSend-client-ruby/1.0.0",
26
- "Accept" => "application/json")
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
- "page" => page,
23
- "limit" => limit,
24
- "verified" => verified
22
+ 'page' => page,
23
+ 'limit' => limit,
24
+ 'verified' => verified
25
25
  }
26
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/domains",
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
- "page" => page,
34
- "limit" => limit,
35
- "verified" => verified
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
- "page" => page,
50
- "limit" => limit
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
- "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
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 "base64"
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
- "content" => encoded,
92
- "filename" => filename
90
+ @attachments << {
91
+ 'content' => encoded,
92
+ 'filename' => filename
93
93
  }
94
94
  end
95
95
 
96
96
  def send
97
97
  message = {
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
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.compact)
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
- "page" => page,
21
- "limit" => limit
20
+ 'page' => page,
21
+ 'limit' => limit
22
22
  }
23
23
 
24
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/messages",
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
- "page" => page,
21
- "limit" => limit
20
+ 'page' => page,
21
+ 'limit' => limit
22
22
  }
23
23
 
24
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/recipients",
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
- "domain_id" => domain_id,
21
- "page" => page,
22
- "limit" => limit
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: "/v1/templates",
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
- "name" => name,
23
- "scopes" => scopes,
24
- "domain_id" => domain_id
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailersend
4
- VERSION = "0.2.0"
4
+ VERSION = '0.2.1'
5
5
  end
@@ -22,9 +22,9 @@ module Mailersend
22
22
 
23
23
  def list(domain_id:)
24
24
  hash = {
25
- "domain_id" => domain_id
25
+ 'domain_id' => domain_id
26
26
  }
27
- response = client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: "/v1/webhooks",
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
- "url" => url,
40
- "name" => name,
41
- "events" => events,
42
- "domain_id" => domain_id,
43
- "enabled" => enabled.to_s == "true"
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
- "url" => url,
53
- "name" => name,
54
- "events" => events,
55
- "enabled" => enabled.to_s == "true"
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
@@ -1,36 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path("lib", __dir__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "mailersend/version"
5
+ require 'mailersend/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = "mailersend-ruby"
8
+ spec.name = 'mailersend-ruby'
9
9
  spec.version = Mailersend::VERSION
10
- spec.authors = ["Nikola Milojević"]
11
- spec.email = ["info@mailersend.com"]
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 = "https://www.mailersend.com"
16
- spec.license = "MIT"
17
- spec.required_ruby_version = ">= 2.5.0"
15
+ spec.homepage = 'https://www.mailersend.com'
16
+ spec.license = 'MIT'
17
+ spec.required_ruby_version = '>= 2.5.0'
18
18
 
19
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
20
 
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"
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 = ["lib"]
27
+ spec.require_paths = ['lib']
28
28
 
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"
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.0
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-07-01 00:00:00.000000000 Z
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.15
169
+ rubygems_version: 3.2.22
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: MailerSend's official Ruby SDK