infobeep 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/infobeep/client.rb +17 -23
- data/lib/infobeep/models.rb +5 -0
- data/lib/infobeep/requests/account_balance_request.rb +18 -0
- data/lib/infobeep/requests/bulk_sms_request.rb +1 -1
- data/lib/infobeep/requests/sms_log_request.rb +1 -1
- data/lib/infobeep/requests/sms_report_request.rb +1 -1
- data/lib/infobeep/requests/sms_request.rb +1 -1
- data/lib/infobeep/requests.rb +2 -1
- data/lib/infobeep/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1587ca94de8b7d9a015391b3018d379842b66a31
|
4
|
+
data.tar.gz: f9888c6361093ca34e1f36b05be7e930a67d36b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035a669989722c7dae9479dca0e90fdb8bcdce5a859b155ee4e8a0883f2a27e554f1fd56e5aae1ed00ae4e651c0edc7509b88de689a2a9ff77077a138bc8073a
|
7
|
+
data.tar.gz: 0a5fd0ba388609a7ba4d263bb4d5fe6898c6f1188b8582729e5639a381a79859c4f04282530faa3c639a78021d89b1e04d58595e19b5422a6ba2c56492c45fd3
|
data/lib/infobeep/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rest-client'
|
|
4
4
|
|
5
5
|
module Infobeep
|
6
6
|
|
7
|
-
class
|
7
|
+
class Client
|
8
8
|
API_BASE_URL = 'https://api.infobip.com/'
|
9
9
|
|
10
10
|
def initialize(username, password)
|
@@ -12,29 +12,8 @@ module Infobeep
|
|
12
12
|
@password = password
|
13
13
|
end
|
14
14
|
|
15
|
-
def authentication_headers
|
16
|
-
auth_string = ::Base64.encode64("#{@username}:#{@password}").strip
|
17
|
-
{'Authorization': "Basic #{auth_string}"}
|
18
|
-
end
|
19
|
-
|
20
|
-
def client_headers
|
21
|
-
hsh = {
|
22
|
-
'User-Agent': "Infobeep-#{Infobeep::VERSION}",
|
23
|
-
'Content-Type': 'application/json',
|
24
|
-
'accept': 'application/json'
|
25
|
-
}
|
26
|
-
hsh.merge!(authentication_headers)
|
27
|
-
hsh
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
class SMSClient < BaseClient
|
34
|
-
SMS_API_BASE_URL = "#{API_BASE_URL}sms/1/"
|
35
|
-
|
36
15
|
def send_request(sms_request)
|
37
|
-
url =
|
16
|
+
url = API_BASE_URL + sms_request.route
|
38
17
|
method = sms_request.http_method
|
39
18
|
headers = client_headers.merge(sms_request.headers)
|
40
19
|
payload = sms_request.payload
|
@@ -49,6 +28,21 @@ module Infobeep
|
|
49
28
|
sms_request.response_class.new(response_hash)
|
50
29
|
end
|
51
30
|
|
31
|
+
def authentication_headers
|
32
|
+
auth_string = ::Base64.encode64("#{@username}:#{@password}").strip
|
33
|
+
{'Authorization': "Basic #{auth_string}"}
|
34
|
+
end
|
35
|
+
|
36
|
+
def client_headers
|
37
|
+
hsh = {
|
38
|
+
'User-Agent': "Infobeep-#{Infobeep::VERSION}",
|
39
|
+
'Content-Type': 'application/json',
|
40
|
+
'accept': 'application/json'
|
41
|
+
}
|
42
|
+
hsh.merge!(authentication_headers)
|
43
|
+
hsh
|
44
|
+
end
|
45
|
+
|
52
46
|
end
|
53
47
|
|
54
48
|
end
|
data/lib/infobeep/models.rb
CHANGED
data/lib/infobeep/requests.rb
CHANGED
@@ -2,4 +2,5 @@ require "infobeep/requests/base_request_model"
|
|
2
2
|
require "infobeep/requests/sms_request"
|
3
3
|
require "infobeep/requests/bulk_sms_request"
|
4
4
|
require "infobeep/requests/sms_log_request"
|
5
|
-
require "infobeep/requests/sms_report_request"
|
5
|
+
require "infobeep/requests/sms_report_request"
|
6
|
+
require "infobeep/requests/account_balance_request"
|
data/lib/infobeep/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infobeep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Favourite Onwuemene
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/infobeep/client.rb
|
87
87
|
- lib/infobeep/models.rb
|
88
88
|
- lib/infobeep/requests.rb
|
89
|
+
- lib/infobeep/requests/account_balance_request.rb
|
89
90
|
- lib/infobeep/requests/base_request_model.rb
|
90
91
|
- lib/infobeep/requests/bulk_sms_request.rb
|
91
92
|
- lib/infobeep/requests/sms_log_request.rb
|