Class: Busibe::Client
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Request
#get, #post
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args, &_block) ⇒ Object
50
51
52
53
54
|
# 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
|
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
11
12
13
|
# File 'lib/busibe/client.rb', line 11
def response
@response
end
|
Instance Method Details
#check_available_credits ⇒ Object
30
31
32
33
|
# File 'lib/busibe/client.rb', line 30
def check_available_credits
get("/smsapi/get_credits")
self
end
|
#check_delivery_status(message_id = nil) ⇒ Object
35
36
37
38
39
40
41
42
|
# 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 ⇒ Object
44
45
46
|
# File 'lib/busibe/client.rb', line 44
def get_response
JSON.load @response.body
end
|
#send_sms(payload = {}) ⇒ Object
21
22
23
24
25
26
27
28
|
# 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
|