Class: Mailosaur::Usage
- Inherits:
-
Object
- Object
- Mailosaur::Usage
- Defined in:
- lib/Mailosaur/usage.rb
Overview
Operations for inspecting your account’s usage limits and recent transactional usage. These endpoints require authentication with an account-level API key. Accessed via client.usage.
Instance Attribute Summary collapse
-
#conn ⇒ Connection
readonly
The client connection.
Instance Method Summary collapse
-
#initialize(conn, handle_http_error) ⇒ Usage
constructor
Creates and initializes a new instance of the Usage class.
-
#limits ⇒ Mailosaur::Models::UsageAccountLimits
Retrieve account usage limits.
-
#transactions ⇒ Mailosaur::Models::UsageTransactionListResult
Retrieves the last 31 days of transactional usage.
Constructor Details
#initialize(conn, handle_http_error) ⇒ Usage
Creates and initializes a new instance of the Usage class.
10 11 12 13 |
# File 'lib/Mailosaur/usage.rb', line 10 def initialize(conn, handle_http_error) @conn = conn @handle_http_error = handle_http_error end |
Instance Attribute Details
#conn ⇒ Connection (readonly)
Returns the client connection.
16 17 18 |
# File 'lib/Mailosaur/usage.rb', line 16 def conn @conn end |
Instance Method Details
#limits ⇒ Mailosaur::Models::UsageAccountLimits
Retrieve account usage limits. Details the current limits and usage for your account. This endpoint requires authentication with an account-level API key.
24 25 26 27 28 29 |
# File 'lib/Mailosaur/usage.rb', line 24 def limits response = conn.get 'api/usage/limits' @handle_http_error.call(response) unless response.status == 200 model = JSON.parse(response.body) Mailosaur::Models::UsageAccountLimits.new(model) end |
#transactions ⇒ Mailosaur::Models::UsageTransactionListResult
Retrieves the last 31 days of transactional usage. This endpoint requires authentication with an account-level API key.
37 38 39 40 41 42 |
# File 'lib/Mailosaur/usage.rb', line 37 def transactions response = conn.get 'api/usage/transactions' @handle_http_error.call(response) unless response.status == 200 model = JSON.parse(response.body) Mailosaur::Models::UsageTransactionListResult.new(model) end |