Class: SmsKit::CentralICT
Constant Summary
collapse
- HTTP_ENDPOINT =
'https://api.de.centralict.net/controller/cgi/'
Constants included
from HTTP
HTTP::USER_AGENT
Instance Attribute Summary
Attributes inherited from Provider
#data, #error_code, #error_message
Instance Method Summary
collapse
Methods inherited from Provider
deliver, #initialize
Methods included from HTTP
#connection, #post, #uri
Methods included from Config
included
Instance Method Details
#deliver ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/sms_kit/providers/central_ict.rb', line 8
def deliver
response = get params
parsed_response = parse response.body
status = parsed_response['sent']
if 1 != status.to_i
raise DeliveryError, "Delivery failed (#{status})"
else
true
end
end
|
#get(payload) ⇒ Object
33
34
35
36
|
# File 'lib/sms_kit/providers/central_ict.rb', line 33
def get payload
connection.basic_auth config.username, config.password
super
end
|
#params ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/sms_kit/providers/central_ict.rb', line 20
def params
{
type: 'SMS',
src: data[:from] || config.sender,
dst: data[:to],
body: data[:text],
uid: data[:uid] || '',
pin: data[:pin] || '',
subject: data[:subject] || '',
call: data[:call] || 'message_sender'
}
end
|
#parse(string) ⇒ Object
38
39
40
|
# File 'lib/sms_kit/providers/central_ict.rb', line 38
def parse string
Hash[string.scan %r{(\w+)=(.*)}]
end
|