mailosaur 7.0.1 → 7.3.0

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: b6e3bc63d01ecbecc505562a188a9b7c122b812d12a9b1e3437ace3b5348f6f5
4
- data.tar.gz: be81cb74fddd57bbc539d4fb9c3723436e2b5af60d695413785d2f7c7ea6892e
3
+ metadata.gz: 433da61cccbbf2683597e2dca5da83d0db8d127189e1a780cb0d620994f8d625
4
+ data.tar.gz: 3a3d1d058f2d5a62bd728228e32d0a7c78f07e11cc755f29f295ae544ac26ca1
5
5
  SHA512:
6
- metadata.gz: '058e76420f70a2525437f99b37e2ee0c9ebbb67330b1c3a9be36f5d650fb51e1839929be54f765719b7df71e002624b4223f949c5762452429ceb5f968f96dc3'
7
- data.tar.gz: a176041bec46bec551bcaff33d9b01213aa5652d223629fa7028d9f73807c132d8770bba10b3b6a34af78600e4db9a34f7a6df8964a08f59b5690bf0834d00f6
6
+ metadata.gz: afa9cc3cdd1b0c37b5364673824ce6695c662036595c3eaca91dbc2a76c99622f729b28fa6cf3d796e834f98a908074aeb2c5c498de79ebf3669ec3b4e79d67e
7
+ data.tar.gz: 9a5f5e6a88e53c754032b4ef79ff59b61a859c9413f79da4b9992f6c5e7917ce56eeb8ffb3c09252a0c35775314f648fc1d8d5ffb0a9e29232c5285fbbff9bbc
@@ -132,10 +132,12 @@ module Mailosaur
132
132
  # (in milliseconds).
133
133
  # @param received_after [DateTime] Limits results to only messages received
134
134
  # after this date/time.
135
+ # @param error_on_timeout [Boolean] When set to false, an error will not be
136
+ # throw if timeout is reached (default: true).
135
137
  #
136
138
  # @return [MessageListResult] operation results.
137
139
  #
138
- def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil) # rubocop:disable all
140
+ def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, received_after: nil, error_on_timeout: true) # rubocop:disable all
139
141
  url = 'api/messages/search?server=' + server
140
142
  url += page ? '&page=' + page.to_s : ''
141
143
  url += items_per_page ? '&itemsPerPage=' + items_per_page.to_s : ''
@@ -160,6 +162,8 @@ module Mailosaur
160
162
 
161
163
  ## Stop if timeout will be exceeded
162
164
  if ((1000 * (Time.now.to_f - start_time).to_i) + delay) > timeout
165
+ return Mailosaur::Models::MessageListResult.new(model) unless error_on_timeout
166
+
163
167
  raise Mailosaur::MailosaurError.new('No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this).', 'search_timeout')
164
168
  end
165
169
 
@@ -3,21 +3,15 @@ module Mailosaur
3
3
  class Server < BaseModel
4
4
  def initialize(data = {})
5
5
  @id = data['id']
6
- @password = data['password']
7
6
  @name = data['name']
8
7
  @users = data['users']
9
8
  @messages = data['messages']
10
- @forwarding_rules = []
11
- (data['forwardingRules'] || []).each do |i| @forwarding_rules << Mailosaur::Models::ForwardingRule.new(i) end
12
9
  end
13
10
 
14
11
  # @return [String] Unique identifier for the server. Used as username for
15
12
  # SMTP/POP3 authentication.
16
13
  attr_accessor :id
17
14
 
18
- # @return [String] SMTP/POP3 password.
19
- attr_accessor :password
20
-
21
15
  # @return [String] A name used to identify the server.
22
16
  attr_accessor :name
23
17
 
@@ -26,10 +20,6 @@ module Mailosaur
26
20
 
27
21
  # @return [Integer] The number of messages currently in the server.
28
22
  attr_accessor :messages
29
-
30
- # @return [Array<ForwardingRule>] The rules used to manage email
31
- # forwarding for this server.
32
- attr_accessor :forwarding_rules
33
23
  end
34
24
  end
35
25
  end
@@ -0,0 +1,16 @@
1
+ module Mailosaur
2
+ module Models
3
+ class UsageAccountLimit < BaseModel
4
+ def initialize(data = {})
5
+ @limit = data['limit']
6
+ @current = data['current']
7
+ end
8
+
9
+ # @return [Integer] The limit.
10
+ attr_accessor :limit
11
+
12
+ # @return [Integer] The current usage.
13
+ attr_accessor :current
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ module Mailosaur
2
+ module Models
3
+ class UsageAccountLimits < BaseModel
4
+ def initialize(data = {})
5
+ @servers = Mailosaur::Models::UsageAccountLimit.new(data['servers'])
6
+ @users = Mailosaur::Models::UsageAccountLimit.new(data['users'])
7
+ @email = Mailosaur::Models::UsageAccountLimit.new(data['email'])
8
+ @sms = Mailosaur::Models::UsageAccountLimit.new(data['sms'])
9
+ end
10
+
11
+ # @return [UsageAccountLimit]
12
+ attr_accessor :servers
13
+
14
+ # @return [UsageAccountLimit]
15
+ attr_accessor :users
16
+
17
+ # @return [UsageAccountLimit]
18
+ attr_accessor :email
19
+
20
+ # @return [UsageAccountLimit]
21
+ attr_accessor :sms
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ module Mailosaur
2
+ module Models
3
+ class UsageTransaction < BaseModel
4
+ def initialize(data = {})
5
+ @timestamp = DateTime.parse(data['timestamp'])
6
+ @email = data['email']
7
+ @sms = data['sms']
8
+ end
9
+
10
+ # @return [DateTime] The datetime that this transaction occurred.
11
+ attr_accessor :timestamp
12
+
13
+ # @return [Integer] The count of emails.
14
+ attr_accessor :email
15
+
16
+ # @return [Integer] The count of SMS messages.
17
+ attr_accessor :sms
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ module Mailosaur
2
+ module Models
3
+ class UsageTransactionListResult < BaseModel
4
+ def initialize(data = {})
5
+ @items = []
6
+ (data['items'] || []).each do |i| @items << Mailosaur::Models::UsageTransaction.new(i) end
7
+ end
8
+
9
+ # @return [Array<UsageTransaction>] The individual transactions the result.
10
+ attr_accessor :items
11
+ end
12
+ end
13
+ end
@@ -60,6 +60,23 @@ module Mailosaur
60
60
  Mailosaur::Models::Server.new(model)
61
61
  end
62
62
 
63
+ #
64
+ # Retrieve server password
65
+ #
66
+ # Retrieves the password for use with SMTP and POP3 for a single server.
67
+ # Simply supply the unique identifier for the required server.
68
+ #
69
+ # @param id [String] The identifier of the server.
70
+ #
71
+ # @return [String] Server password.
72
+ #
73
+ def get_password(id)
74
+ response = conn.get 'api/servers/' + id + '/password'
75
+ @handle_http_error.call(response) unless response.status == 200
76
+ model = JSON.load(response.body)
77
+ model['value']
78
+ end
79
+
63
80
  #
64
81
  # Update a server
65
82
  #
@@ -92,8 +109,8 @@ module Mailosaur
92
109
  end
93
110
 
94
111
  def generate_email_address(server)
95
- host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.io'
96
- '%s.%s@%s' % [SecureRandom.hex(3), server, host]
112
+ host = ENV['MAILOSAUR_SMTP_HOST'] || 'mailosaur.net'
113
+ '%s@%s.%s' % [SecureRandom.hex(3), server, host]
97
114
  end
98
115
  end
99
116
  end
@@ -0,0 +1,41 @@
1
+ module Mailosaur
2
+ class Usage
3
+ #
4
+ # Creates and initializes a new instance of the Usage class.
5
+ # @param client connection.
6
+ #
7
+ def initialize(conn, handle_http_error)
8
+ @conn = conn
9
+ @handle_http_error = handle_http_error
10
+ end
11
+
12
+ # @return [Connection] the client connection.
13
+ attr_reader :conn
14
+
15
+ #
16
+ # Retrieve account usage limits.
17
+ #
18
+ # Details the current limits and usage for your account.
19
+ #
20
+ # @return [UsageAccountLimits] operation results.
21
+ #
22
+ def limits
23
+ response = conn.get 'api/usage/limits'
24
+ @handle_http_error.call(response) unless response.status == 200
25
+ model = JSON.load(response.body)
26
+ Mailosaur::Models::UsageAccountLimits.new(model)
27
+ end
28
+
29
+ #
30
+ # List account transactions. Retrieves the last 31 days of transactional usage.
31
+ #
32
+ # @return [UsageTransactionListResult] operation results.
33
+ #
34
+ def transactions
35
+ response = conn.get 'api/usage/transactions'
36
+ @handle_http_error.call(response) unless response.status == 200
37
+ model = JSON.load(response.body)
38
+ Mailosaur::Models::UsageTransactionListResult.new(model)
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Mailosaur
2
- VERSION = '7.0.1'.freeze
2
+ VERSION = '7.3.0'.freeze
3
3
  end
data/lib/mailosaur.rb CHANGED
@@ -13,6 +13,7 @@ module Mailosaur
13
13
  autoload :Files, 'Mailosaur/files.rb'
14
14
  autoload :Messages, 'Mailosaur/messages.rb'
15
15
  autoload :Servers, 'Mailosaur/servers.rb'
16
+ autoload :Usage, 'Mailosaur/usage.rb'
16
17
  autoload :MailosaurError, 'Mailosaur/mailosaur_error.rb'
17
18
 
18
19
  module Models
@@ -27,13 +28,16 @@ module Mailosaur
27
28
  autoload :MessageListResult, 'Mailosaur/models/message_list_result.rb'
28
29
  autoload :Attachment, 'Mailosaur/models/attachment.rb'
29
30
  autoload :SearchCriteria, 'Mailosaur/models/search_criteria.rb'
30
- autoload :ForwardingRule, 'Mailosaur/models/forwarding_rule.rb'
31
31
  autoload :MessageContent, 'Mailosaur/models/message_content.rb'
32
32
  autoload :Server, 'Mailosaur/models/server.rb'
33
33
  autoload :Link, 'Mailosaur/models/link.rb'
34
34
  autoload :ServerListResult, 'Mailosaur/models/server_list_result.rb'
35
35
  autoload :SpamFilterResults, 'Mailosaur/models/spam_filter_results.rb'
36
36
  autoload :ServerCreateOptions, 'Mailosaur/models/server_create_options.rb'
37
+ autoload :UsageAccountLimits, 'Mailosaur/models/usage_account_limits.rb'
38
+ autoload :UsageAccountLimit, 'Mailosaur/models/usage_account_limit.rb'
39
+ autoload :UsageTransactionListResult, 'Mailosaur/models/usage_transaction_list_result.rb'
40
+ autoload :UsageTransaction, 'Mailosaur/models/usage_transaction.rb'
37
41
  autoload :BaseModel, 'Mailosaur/models/base_model.rb'
38
42
  end
39
43
 
@@ -68,6 +72,11 @@ module Mailosaur
68
72
  @servers ||= Servers.new(connection, method(:handle_http_error))
69
73
  end
70
74
 
75
+ # @return [Usage] usage
76
+ def usage
77
+ @usage ||= Usage.new(connection, method(:handle_http_error))
78
+ end
79
+
71
80
  private
72
81
 
73
82
  def connection
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailosaur
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailosaur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-19 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -159,7 +159,6 @@ files:
159
159
  - lib/Mailosaur/messages.rb
160
160
  - lib/Mailosaur/models/attachment.rb
161
161
  - lib/Mailosaur/models/base_model.rb
162
- - lib/Mailosaur/models/forwarding_rule.rb
163
162
  - lib/Mailosaur/models/image.rb
164
163
  - lib/Mailosaur/models/link.rb
165
164
  - lib/Mailosaur/models/message.rb
@@ -176,8 +175,13 @@ files:
176
175
  - lib/Mailosaur/models/spam_analysis_result.rb
177
176
  - lib/Mailosaur/models/spam_assassin_rule.rb
178
177
  - lib/Mailosaur/models/spam_filter_results.rb
178
+ - lib/Mailosaur/models/usage_account_limit.rb
179
+ - lib/Mailosaur/models/usage_account_limits.rb
180
+ - lib/Mailosaur/models/usage_transaction.rb
181
+ - lib/Mailosaur/models/usage_transaction_list_result.rb
179
182
  - lib/Mailosaur/module_definition.rb
180
183
  - lib/Mailosaur/servers.rb
184
+ - lib/Mailosaur/usage.rb
181
185
  - lib/Mailosaur/version.rb
182
186
  - lib/mailosaur.rb
183
187
  homepage: https://mailosaur.com/
@@ -204,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
208
  - !ruby/object:Gem::Version
205
209
  version: '0'
206
210
  requirements: []
207
- rubygems_version: 3.1.2
211
+ rubygems_version: 3.2.15
208
212
  signing_key:
209
213
  specification_version: 4
210
214
  summary: The Mailosaur Ruby library
@@ -1,25 +0,0 @@
1
- module Mailosaur
2
- module Models
3
- class ForwardingRule < BaseModel
4
- def initialize(data = {})
5
- @field = data['field']
6
- @operator = data['operator']
7
- @value = data['value']
8
- @forward_to = data['forwardTo']
9
- end
10
-
11
- # @return [Enum] Possible values include: 'from', 'to', 'subject'
12
- attr_accessor :field
13
-
14
- # @return [Enum] Possible values include: 'endsWith', 'startsWith',
15
- # 'contains'
16
- attr_accessor :operator
17
-
18
- # @return [String]
19
- attr_accessor :value
20
-
21
- # @return [String]
22
- attr_accessor :forward_to
23
- end
24
- end
25
- end