class Busibe::Client

Attributes

response[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/busibe/client.rb, line 13
def initialize(options = {})
  merged_options = Busibe::Jusibe.options.merge(options)

  Configuration::VALID_CONFIG_KEYS.each do |key|
    send("#{key}=", merged_options[key])
  end
end

Public Instance Methods

check_available_credits() click to toggle source
# File lib/busibe/client.rb, line 30
def check_available_credits
  get("/smsapi/get_credits")
  self
end
check_delivery_status(message_id = nil) click to toggle source
# File lib/busibe/client.rb, line 35
def check_delivery_status(message_id = nil)
  if message_id.nil?
    raise ArgumentError.new("A message ID is required")
  end

  post("/smsapi/delivery_status?message_id=#{message_id}")
  self
end
get_response() click to toggle source
# File lib/busibe/client.rb, line 44
def get_response
  JSON.load @response.body
end
send_sms(payload = {}) click to toggle source
# File lib/busibe/client.rb, line 21
def send_sms(payload = {})
  if payload.empty?
    raise ArgumentError.new("A payload is required in order to send an sms")
  end

  post("/smsapi/send_sms", payload)
  self
end

Private Instance Methods

method_missing(method_sym, *args, &_block) click to toggle source
Calls superclass method
# File lib/busibe/client.rb, line 50
def method_missing(method_sym, *args, &_block)
  result = method_sym.to_s =~ /^(.*)_with_response$/
  super unless result
  send($1, *args).get_response
end
respond_to_missing?(method_sym, include_private = false) click to toggle source
Calls superclass method
# File lib/busibe/client.rb, line 56
def respond_to_missing?(method_sym, include_private = false)
  method_sym.to_s =~ /^(.*)_with_response$/
  super unless respond_to? $1.to_sym
  true
end