mailosaur 7.2.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: 27d013e44169ed1c8b0881334b94ce03d76177c35b48202058683a271a7920a8
4
- data.tar.gz: 3fd514240ac76ddfe02296e7a67b97f10b9d5fc711e1c7d321a1222cc1caef0a
3
+ metadata.gz: 433da61cccbbf2683597e2dca5da83d0db8d127189e1a780cb0d620994f8d625
4
+ data.tar.gz: 3a3d1d058f2d5a62bd728228e32d0a7c78f07e11cc755f29f295ae544ac26ca1
5
5
  SHA512:
6
- metadata.gz: 173665bfe6e3ac1b5eacc99f8e4e3b8bf6e7e9487e4852be057473468b56c00c9f53d38ac95218587fd07d86301efcf98b7ce04f234c93dff5df66aa6c8db402
7
- data.tar.gz: 81b04fd97abcfaf0784973d7cf9e1b627d6f28664b1c38a43133f47a001f743a128102520d764d52fba0e7ca825625219b41121feb207b5f489eff569c1dac25
6
+ metadata.gz: afa9cc3cdd1b0c37b5364673824ce6695c662036595c3eaca91dbc2a76c99622f729b28fa6cf3d796e834f98a908074aeb2c5c498de79ebf3669ec3b4e79d67e
7
+ data.tar.gz: 9a5f5e6a88e53c754032b4ef79ff59b61a859c9413f79da4b9992f6c5e7917ce56eeb8ffb3c09252a0c35775314f648fc1d8d5ffb0a9e29232c5285fbbff9bbc
@@ -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
@@ -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.2.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
@@ -33,6 +34,10 @@ module Mailosaur
33
34
  autoload :ServerListResult, 'Mailosaur/models/server_list_result.rb'
34
35
  autoload :SpamFilterResults, 'Mailosaur/models/spam_filter_results.rb'
35
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'
36
41
  autoload :BaseModel, 'Mailosaur/models/base_model.rb'
37
42
  end
38
43
 
@@ -67,6 +72,11 @@ module Mailosaur
67
72
  @servers ||= Servers.new(connection, method(:handle_http_error))
68
73
  end
69
74
 
75
+ # @return [Usage] usage
76
+ def usage
77
+ @usage ||= Usage.new(connection, method(:handle_http_error))
78
+ end
79
+
70
80
  private
71
81
 
72
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.2.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: 2021-04-21 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
@@ -175,8 +175,13 @@ files:
175
175
  - lib/Mailosaur/models/spam_analysis_result.rb
176
176
  - lib/Mailosaur/models/spam_assassin_rule.rb
177
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
178
182
  - lib/Mailosaur/module_definition.rb
179
183
  - lib/Mailosaur/servers.rb
184
+ - lib/Mailosaur/usage.rb
180
185
  - lib/Mailosaur/version.rb
181
186
  - lib/mailosaur.rb
182
187
  homepage: https://mailosaur.com/