mailosaur 7.3.1 → 7.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e326500621113c758df3e3d9fbc06778a9799a73e9d825de967c85c4f905d5d
4
- data.tar.gz: f3110a0807155e33a531c655eeaeb1f05397ab501ae8a273ec6cbeff40c4adc7
3
+ metadata.gz: c7fada04554f5062be36d26e90696358362e477f02a4342e3e41c4296a37cd05
4
+ data.tar.gz: b9d768ae07fd46bc9e0456b88963c473434f92772d3aed6d4d805f01d1b956fe
5
5
  SHA512:
6
- metadata.gz: ff7ee803eb0cc60fa0bcf7ad2f94f0103f2ebd94a056512fdb093e84f28db9cf6a00d2d6f8640fd4d439e1c120b314a05af7f37b7efda3c9ccf8b3281652caab
7
- data.tar.gz: e807b3f423236e619b15e8cf3a4d95399531648b18f99595d31e381bc20862a7aa13286ccb686a82df99a49ff3e6934026a91d95315e1d80fba62829e7ccb5a6
6
+ metadata.gz: f9e635870cc5e3102dcdeb1e247841ea2341cd8593cfe1f3fa0f084741dd73599c7c856f2f8756601389c83ba53eadbfe0efee60c43c90ae60fe6be97c521631
7
+ data.tar.gz: d71f6b94a70a7532e4727a6047a2d8f93b630b637d73f0a47664b3544edbbb9f736e9b37d8122ae41c156e510b87099c4da61cca3e8e9eb55e849a124a94bfb2
@@ -22,7 +22,7 @@ module Mailosaur
22
22
  # @return [SpamAnalysisResult] operation results.
23
23
  #
24
24
  def spam(email)
25
- response = conn.get 'api/analysis/spam/' + email
25
+ response = conn.get "api/analysis/spam/#{email}"
26
26
  @handle_http_error.call(response) unless response.status == 200
27
27
  model = JSON.load(response.body)
28
28
  Mailosaur::Models::SpamAnalysisResult.new(model)
@@ -23,7 +23,7 @@ module Mailosaur
23
23
  # @return [NOT_IMPLEMENTED] operation results.
24
24
  #
25
25
  def get_attachment(id)
26
- response = conn.get 'api/files/attachments/' + id
26
+ response = conn.get "api/files/attachments/#{id}"
27
27
  @handle_http_error.call(response) unless response.status == 200
28
28
  response.body
29
29
  end
@@ -39,7 +39,7 @@ module Mailosaur
39
39
  # @return [NOT_IMPLEMENTED] operation results.
40
40
  #
41
41
  def get_email(id)
42
- response = conn.get 'api/files/email/' + id
42
+ response = conn.get "api/files/email/#{id}"
43
43
  @handle_http_error.call(response) unless response.status == 200
44
44
  response.body
45
45
  end
@@ -1,8 +1,6 @@
1
1
  module Mailosaur
2
2
  class MailosaurError < StandardError
3
- attr_reader :error_type
4
- attr_reader :http_status_code
5
- attr_reader :http_response_body
3
+ attr_reader :error_type, :http_status_code, :http_response_body
6
4
 
7
5
  def initialize(message = '', error_type = '', http_status_code = nil, http_response_body = nil)
8
6
  super(message)
@@ -49,7 +49,7 @@ module Mailosaur
49
49
  # @return [Message] operation results.
50
50
  #
51
51
  def get_by_id(id)
52
- response = conn.get 'api/messages/' + id
52
+ response = conn.get "api/messages/#{id}"
53
53
  @handle_http_error.call(response) unless response.status == 200
54
54
  model = JSON.load(response.body)
55
55
  Mailosaur::Models::Message.new(model)
@@ -64,7 +64,7 @@ module Mailosaur
64
64
  # @param id The identifier of the message to be deleted.
65
65
  #
66
66
  def delete(id)
67
- response = conn.delete 'api/messages/' + id
67
+ response = conn.delete "api/messages/#{id}"
68
68
  @handle_http_error.call(response) unless response.status == 204
69
69
  nil
70
70
  end
@@ -87,10 +87,10 @@ module Mailosaur
87
87
  # @return [MessageListResult] operation results.
88
88
  #
89
89
  def list(server, page: nil, items_per_page: nil, received_after: nil)
90
- url = 'api/messages?server=' + server
91
- url += page ? '&page=' + page.to_s : ''
92
- url += items_per_page ? '&itemsPerPage=' + items_per_page.to_s : ''
93
- url += received_after ? '&receivedAfter=' + CGI.escape(received_after.iso8601) : ''
90
+ url = "api/messages?server=#{server}"
91
+ url += page ? "&page=#{page}" : ''
92
+ url += items_per_page ? "&itemsPerPage=#{items_per_page}" : ''
93
+ url += received_after ? "&receivedAfter=#{CGI.escape(received_after.iso8601)}" : ''
94
94
 
95
95
  response = conn.get url
96
96
 
@@ -109,7 +109,7 @@ module Mailosaur
109
109
  # @param server [String] The identifier of the server to be emptied.
110
110
  #
111
111
  def delete_all(server)
112
- response = conn.delete 'api/messages?server=' + server
112
+ response = conn.delete "api/messages?server=#{server}"
113
113
  @handle_http_error.call(response) unless response.status == 204
114
114
  nil
115
115
  end
@@ -138,10 +138,10 @@ module Mailosaur
138
138
  # @return [MessageListResult] operation results.
139
139
  #
140
140
  def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil, error_on_timeout: true) # rubocop:disable all
141
- url = 'api/messages/search?server=' + server
142
- url += page ? '&page=' + page.to_s : ''
143
- url += items_per_page ? '&itemsPerPage=' + items_per_page.to_s : ''
144
- url += received_after ? '&receivedAfter=' + CGI.escape(received_after.iso8601) : ''
141
+ url = "api/messages/search?server=#{server}"
142
+ url += page ? "&page=#{page}" : ''
143
+ url += items_per_page ? "&itemsPerPage=#{items_per_page}" : ''
144
+ url += received_after ? "&receivedAfter=#{CGI.escape(received_after.iso8601)}" : ''
145
145
 
146
146
  poll_count = 0
147
147
  start_time = Time.now.to_f
@@ -170,5 +170,61 @@ module Mailosaur
170
170
  sleep(delay / 1000)
171
171
  end
172
172
  end
173
+
174
+ #
175
+ # Create a message.
176
+ #
177
+ # Creates a new message that can be sent to a verified email address. This is
178
+ # useful in scenarios where you want an email to trigger a workflow in your
179
+ # product
180
+ #
181
+ # @param server [String] The identifier of the server to create the message in.
182
+ # @param options [MessageCreateOptions] The options with which to create the message.
183
+ #
184
+ # @return [Message] operation result.
185
+ #
186
+ def create(server, message_create_options)
187
+ response = conn.post "api/messages?server=#{server}", message_create_options.to_json
188
+ @handle_http_error.call(response) unless response.status == 200
189
+ model = JSON.load(response.body)
190
+ Mailosaur::Models::Message.new(model)
191
+ end
192
+
193
+ #
194
+ # Forward an email.
195
+ #
196
+ # Forwards the specified email to a verified email address.
197
+ #
198
+ # @param id [String] The identifier of the email to forward.
199
+ # @param options [MessageForwardOptions] The options with which to forward the email.
200
+ # against.
201
+ #
202
+ # @return [Message] operation result.
203
+ #
204
+ def forward(id, message_forward_options)
205
+ response = conn.post "api/messages/#{id}/forward", message_forward_options.to_json
206
+ @handle_http_error.call(response) unless response.status == 200
207
+ model = JSON.load(response.body)
208
+ Mailosaur::Models::Message.new(model)
209
+ end
210
+
211
+ #
212
+ # Reply to an email.
213
+ #
214
+ # Sends a reply to the specified email. This is useful for when simulating a user
215
+ # replying to one of your emails.
216
+ #
217
+ # @param id [String] The identifier of the email to reply to.
218
+ # @param options [MessageReplyOptions] The options with which to reply to the email.
219
+ # against.
220
+ #
221
+ # @return [Message] operation result.
222
+ #
223
+ def reply(id, message_reply_options)
224
+ response = conn.post "api/messages/#{id}/reply", message_reply_options.to_json
225
+ @handle_http_error.call(response) unless response.status == 200
226
+ model = JSON.load(response.body)
227
+ Mailosaur::Models::Message.new(model)
228
+ end
173
229
  end
174
230
  end
@@ -5,6 +5,7 @@ module Mailosaur
5
5
  @id = data['id']
6
6
  @content_type = data['contentType']
7
7
  @file_name = data['fileName']
8
+ @content = data['content']
8
9
  @content_id = data['contentId']
9
10
  @length = data['length']
10
11
  @url = data['url']
@@ -19,6 +20,9 @@ module Mailosaur
19
20
  # @return [String]
20
21
  attr_accessor :file_name
21
22
 
23
+ # @return [String]
24
+ attr_accessor :content
25
+
22
26
  # @return [String]
23
27
  attr_accessor :content_id
24
28
 
@@ -0,0 +1,35 @@
1
+ module Mailosaur
2
+ module Models
3
+ class MessageCreateOptions < BaseModel
4
+ def initialize(data = {})
5
+ @to = data['to']
6
+ @send = data['send']
7
+ @subject = data['subject']
8
+ @text = data['text']
9
+ @html = data['html']
10
+ @attachments = data['attachments']
11
+ end
12
+
13
+ # @return [String] The email address to which the email will be sent.
14
+ # Must be a verified email address.
15
+ attr_accessor :to
16
+
17
+ # @return [Boolean] If true, email will be sent upon creation.
18
+ attr_accessor :send
19
+
20
+ # @return [String] The email subject line.
21
+ attr_accessor :subject
22
+
23
+ # @return [String] The plain text body of the email. Note that only
24
+ # text or html can be supplied, not both.
25
+ attr_accessor :text
26
+
27
+ # @return [String] The HTML body of the email. Note that only text
28
+ # or html can be supplied, not both.
29
+ attr_accessor :html
30
+
31
+ # @return [Array<Attachment>] Any message attachments.
32
+ attr_accessor :attachments
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ module Mailosaur
2
+ module Models
3
+ class MessageForwardOptions < BaseModel
4
+ def initialize(data = {})
5
+ @to = data['to']
6
+ @text = data['text']
7
+ @html = data['html']
8
+ end
9
+
10
+ # @return [String] The email address to which the email will be sent.
11
+ # Must be a verified email address.
12
+ attr_accessor :to
13
+
14
+ # @return [String] Any additional plain text content to forward the
15
+ # email with. Note that only text or html can be supplied, not both.
16
+ attr_accessor :text
17
+
18
+ # @return [String] Any additional HTML content to forward the email
19
+ # with. Note that only html or text can be supplied, not both.
20
+ attr_accessor :html
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module Mailosaur
2
+ module Models
3
+ class MessageReplyOptions < BaseModel
4
+ def initialize(data = {})
5
+ @text = data['text']
6
+ @html = data['html']
7
+ @attachments = data['attachments']
8
+ end
9
+
10
+ # @return [String] Any additional plain text content to include in
11
+ # the reply. Note that only text or html can be supplied, not both.
12
+ attr_accessor :text
13
+
14
+ # @return [String] Any additional HTML content to include in the
15
+ # reply. Note that only html or text can be supplied, not both.
16
+ attr_accessor :html
17
+
18
+ # @return [Array<Attachment>] Any message attachments.
19
+ attr_accessor :attachments
20
+ end
21
+ end
22
+ end
@@ -4,8 +4,6 @@ module Mailosaur
4
4
  def initialize(data = {})
5
5
  @id = data['id']
6
6
  @server = data['server']
7
- @rcpt = []
8
- (data['rcpt'] || []).each do |i| @rcpt << Mailosaur::Models::MessageAddress.new(i) end
9
7
  @from = []
10
8
  (data['from'] || []).each do |i| @from << Mailosaur::Models::MessageAddress.new(i) end
11
9
  @to = []
@@ -26,9 +24,6 @@ module Mailosaur
26
24
  # @return [String]
27
25
  attr_accessor :server
28
26
 
29
- # @return [Array<MessageAddress>]
30
- attr_accessor :rcpt
31
-
32
27
  # @return [Array<MessageAddress>]
33
28
  attr_accessor :from
34
29
 
@@ -4,10 +4,33 @@ module Mailosaur
4
4
  def initialize(data = {})
5
5
  @headers = []
6
6
  (data['headers'] || []).each do |i| @headers << Mailosaur::Models::MessageHeader.new(i) end
7
+
8
+ @ehlo = data['ehlo']
9
+
10
+ @mail_from = data['mailFrom']
11
+
12
+ @rcpt_to = []
13
+ (data['rcptTo'] || []).each do |i| @rcpt_to << Mailosaur::Models::MessageAddress.new(i) end
7
14
  end
8
15
 
9
16
  # @return [Array<MessageHeader>] Email headers.
10
17
  attr_accessor :headers
18
+
19
+ # @return [String] The fully-qualified domain name or IP address that was provided with the
20
+ # Extended HELLO (EHLO) or HELLO (HELO) command. This value is generally
21
+ # used to identify the SMTP client.
22
+ # https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.1
23
+ attr_accessor :ehlo
24
+
25
+ # @return [String] The source mailbox/email address, referred to as the 'reverse-path',
26
+ # provided via the MAIL command during the SMTP transaction.
27
+ # https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.2
28
+ attr_accessor :mail_from
29
+
30
+ # @return [Array<MessageAddress>] The recipient email addresses, each referred to as a 'forward-path',
31
+ # provided via the RCPT command during the SMTP transaction.
32
+ # https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.1.3
33
+ attr_accessor :rcpt_to
11
34
  end
12
35
  end
13
36
  end
@@ -54,7 +54,7 @@ module Mailosaur
54
54
  # @return [Server] operation results.
55
55
  #
56
56
  def get(id)
57
- response = conn.get 'api/servers/' + id
57
+ response = conn.get "api/servers/#{id}"
58
58
  @handle_http_error.call(response) unless response.status == 200
59
59
  model = JSON.load(response.body)
60
60
  Mailosaur::Models::Server.new(model)
@@ -71,7 +71,7 @@ module Mailosaur
71
71
  # @return [String] Server password.
72
72
  #
73
73
  def get_password(id)
74
- response = conn.get 'api/servers/' + id + '/password'
74
+ response = conn.get "api/servers/#{id}/password"
75
75
  @handle_http_error.call(response) unless response.status == 200
76
76
  model = JSON.load(response.body)
77
77
  model['value']
@@ -88,7 +88,7 @@ module Mailosaur
88
88
  # @return [Server] operation results.
89
89
  #
90
90
  def update(id, server)
91
- response = conn.put 'api/servers/' + id, server.to_json
91
+ response = conn.put "api/servers/#{id}", server.to_json
92
92
  @handle_http_error.call(response) unless response.status == 200
93
93
  model = JSON.load(response.body)
94
94
  Mailosaur::Models::Server.new(model)
@@ -103,7 +103,7 @@ module Mailosaur
103
103
  # @param id [String] The identifier of the server to be deleted.
104
104
  #
105
105
  def delete(id)
106
- response = conn.delete 'api/servers/' + id
106
+ response = conn.delete "api/servers/#{id}"
107
107
  @handle_http_error.call(response) unless response.status == 204
108
108
  nil
109
109
  end
@@ -1,3 +1,3 @@
1
1
  module Mailosaur
2
- VERSION = '7.3.1'.freeze
2
+ VERSION = '7.6.0'.freeze
3
3
  end
data/lib/mailosaur.rb CHANGED
@@ -26,6 +26,9 @@ module Mailosaur
26
26
  autoload :MessageSummary, 'Mailosaur/models/message_summary.rb'
27
27
  autoload :Image, 'Mailosaur/models/image.rb'
28
28
  autoload :MessageListResult, 'Mailosaur/models/message_list_result.rb'
29
+ autoload :MessageCreateOptions, 'Mailosaur/models/message_create_options.rb'
30
+ autoload :MessageForwardOptions, 'Mailosaur/models/message_forward_options.rb'
31
+ autoload :MessageReplyOptions, 'Mailosaur/models/message_reply_options.rb'
29
32
  autoload :Attachment, 'Mailosaur/models/attachment.rb'
30
33
  autoload :SearchCriteria, 'Mailosaur/models/search_criteria.rb'
31
34
  autoload :MessageContent, 'Mailosaur/models/message_content.rb'
@@ -83,9 +86,9 @@ module Mailosaur
83
86
  Faraday.new(@base_url, {
84
87
  headers: {
85
88
  content_type: 'application/json; charset=utf-8',
86
- user_agent: 'mailosaur-ruby/' + Mailosaur::VERSION
89
+ user_agent: "mailosaur-ruby/#{Mailosaur::VERSION}"
87
90
  }
88
- }).tap { |conn| conn.basic_auth(@api_key, '') }
91
+ }).tap { |conn| conn.request(:basic_auth, @api_key, '') }
89
92
  end
90
93
 
91
94
  def handle_http_error(response)
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailosaur
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.1
4
+ version: 7.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailosaur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-15 00:00:00.000000000 Z
11
+ date: 2021-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<="
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 0.9.0
19
+ version: '0.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "<="
28
- - !ruby/object:Gem::Version
29
- version: '1.0'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 0.9.0
29
+ version: '0.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "<="
38
- - !ruby/object:Gem::Version
39
- version: '3.0'
40
37
  - - ">="
41
38
  - !ruby/object:Gem::Version
42
39
  version: 1.7.5
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "<="
48
- - !ruby/object:Gem::Version
49
- version: '3.0'
50
47
  - - ">="
51
48
  - !ruby/object:Gem::Version
52
49
  version: 1.7.5
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: mail
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -76,34 +76,28 @@ dependencies:
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: '12.3'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 12.3.0
79
+ version: '13.0'
83
80
  type: :development
84
81
  prerelease: false
85
82
  version_requirements: !ruby/object:Gem::Requirement
86
83
  requirements:
87
84
  - - "~>"
88
85
  - !ruby/object:Gem::Version
89
- version: '12.3'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 12.3.0
86
+ version: '13.0'
93
87
  - !ruby/object:Gem::Dependency
94
88
  name: rubocop
95
89
  requirement: !ruby/object:Gem::Requirement
96
90
  requirements:
97
91
  - - "~>"
98
92
  - !ruby/object:Gem::Version
99
- version: 0.68.0
93
+ version: 1.19.0
100
94
  type: :development
101
95
  prerelease: false
102
96
  version_requirements: !ruby/object:Gem::Requirement
103
97
  requirements:
104
98
  - - "~>"
105
99
  - !ruby/object:Gem::Version
106
- version: 0.68.0
100
+ version: 1.19.0
107
101
  - !ruby/object:Gem::Dependency
108
102
  name: shoulda-context
109
103
  requirement: !ruby/object:Gem::Requirement
@@ -164,8 +158,11 @@ files:
164
158
  - lib/Mailosaur/models/message.rb
165
159
  - lib/Mailosaur/models/message_address.rb
166
160
  - lib/Mailosaur/models/message_content.rb
161
+ - lib/Mailosaur/models/message_create_options.rb
162
+ - lib/Mailosaur/models/message_forward_options.rb
167
163
  - lib/Mailosaur/models/message_header.rb
168
164
  - lib/Mailosaur/models/message_list_result.rb
165
+ - lib/Mailosaur/models/message_reply_options.rb
169
166
  - lib/Mailosaur/models/message_summary.rb
170
167
  - lib/Mailosaur/models/metadata.rb
171
168
  - lib/Mailosaur/models/search_criteria.rb
@@ -201,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
198
  requirements:
202
199
  - - ">="
203
200
  - !ruby/object:Gem::Version
204
- version: '2.2'
201
+ version: '2.5'
205
202
  required_rubygems_version: !ruby/object:Gem::Requirement
206
203
  requirements:
207
204
  - - ">="
208
205
  - !ruby/object:Gem::Version
209
206
  version: '0'
210
207
  requirements: []
211
- rubygems_version: 3.2.15
208
+ rubygems_version: 3.2.32
212
209
  signing_key:
213
210
  specification_version: 4
214
211
  summary: The Mailosaur Ruby library