class OkComputer::NexmoCheck

Constants

AccountError

Attributes

client[RW]

Public Class Methods

new(client: nil, api_key: nil, api_secret: nil, signature_secret: nil) click to toggle source
# File lib/ok_computer/checks/nexmo_check.rb, line 11
def initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil)
  client ||= Nexmo::Client.new(
    api_key: api_key,
    api_secret: api_secret,
    signature_secret: signature_secret
  )

  self.client = client
end

Public Instance Methods

check() click to toggle source

Public: Return the status of the Account Balance check

# 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

  mark_message("Balance #{response.value} check successful")
rescue StandardError => e
  mark_message("Error: '#{e}'")
  mark_failure
end
perform_request() click to toggle source
# File lib/ok_computer/checks/nexmo_check.rb, line 32
def perform_request
  client.account.balance
rescue StandardError => e
  raise(AccountError, e)
end