Class: OkComputer::NexmoCheck
- Inherits:
-
Check
- Object
- Check
- OkComputer::NexmoCheck
- Defined in:
- lib/ok_computer/checks/nexmo_check.rb
Constant Summary collapse
- AccountError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#check ⇒ Object
Public: Return the status of the Account Balance check.
-
#initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil) ⇒ NexmoCheck
constructor
rubocop:disable Lint/MissingSuper.
- #perform_request ⇒ Object
Constructor Details
#initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil) ⇒ NexmoCheck
rubocop:disable Lint/MissingSuper
11 12 13 14 15 16 17 18 19 |
# File 'lib/ok_computer/checks/nexmo_check.rb', line 11 def initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil) # rubocop:disable Lint/MissingSuper client ||= Nexmo::Client.new( api_key: api_key, api_secret: api_secret, signature_secret: signature_secret, ) self.client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/ok_computer/checks/nexmo_check.rb', line 9 def client @client end |
Instance Method Details
#check ⇒ Object
Public: Return the status of the Account Balance check
22 23 24 25 26 27 28 29 30 |
# File 'lib/ok_computer/checks/nexmo_check.rb', line 22 def check response = perform_request return mark_failure unless response.http_response.code.to_i == 200 ("Balance #{response.value} check successful") rescue StandardError => e ("Error: '#{e}'") mark_failure end |
#perform_request ⇒ Object
32 33 34 35 36 |
# File 'lib/ok_computer/checks/nexmo_check.rb', line 32 def perform_request client.account.balance rescue StandardError => e raise(AccountError, e) end |