Class: Arafa::Wasiliana
Overview
Wasiliana SMS send adapter (§1.4). Unlike Africa's Talking, Wasiliana's
response carries no per-recipient breakdown — just an overall
status/data pair — so success/failure is decided once for the whole
request rather than per number.
Constant Summary
collapse
- CONTRACT =
Contracts::WasilianaContract
Providers::Base::TO_TYPE
Instance Method Summary
collapse
connection, #connection, new, send, #send
Instance Method Details
#build_payload ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/arafa/providers/wasiliana.rb', line 29
def build_payload
payload = {
recipients: to,
from: from,
message: text
}
payload[:linkid] = linkid unless linkid.nil?
payload[:message_uid] = message_uid unless message_uid.nil?
payload[:is_otp] = is_otp unless is_otp.nil?
payload
end
|
#endpoint ⇒ Object
18
19
20
|
# File 'lib/arafa/providers/wasiliana.rb', line 18
def endpoint
"https://api.wasiliana.com/api/v1/send/sms"
end
|
22
23
24
25
26
27
|
# File 'lib/arafa/providers/wasiliana.rb', line 22
def
{
"Content-Type" => "application/json",
"apiKey" => Arafa.config.wasiliana.api_key
}
end
|
#parse_response(response) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/arafa/providers/wasiliana.rb', line 41
def parse_response(response)
body = response.body
if response.status.between?(200, 299) && body.is_a?(Hash) && body["status"] == "success"
build_success(body)
else
build_failure(response)
end
end
|