infobeep 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 579c6166aa3d343621867ac8f318194689360665
4
- data.tar.gz: 7d1d88e6da3830dcf223076381f4f0fc66f073f8
3
+ metadata.gz: 1587ca94de8b7d9a015391b3018d379842b66a31
4
+ data.tar.gz: f9888c6361093ca34e1f36b05be7e930a67d36b5
5
5
  SHA512:
6
- metadata.gz: 464f148aad810295414e9e0e440f2ffadee2f41f6bf734dc266c00784fe7294b260483201701fedfafcbbc7f887ccea2f7fe73b37345fb1a21234600732e49b6
7
- data.tar.gz: 7f954f622cf01d56d1449a3122cb477f828357c30e9c7be1c63e0d7d601f14ec1190df32499a6299609d67a589694c98e19e35c896cc5f72f876f22ba7451109
6
+ metadata.gz: 035a669989722c7dae9479dca0e90fdb8bcdce5a859b155ee4e8a0883f2a27e554f1fd56e5aae1ed00ae4e651c0edc7509b88de689a2a9ff77077a138bc8073a
7
+ data.tar.gz: 0a5fd0ba388609a7ba4d263bb4d5fe6898c6f1188b8582729e5639a381a79859c4f04282530faa3c639a78021d89b1e04d58595e19b5422a6ba2c56492c45fd3
@@ -4,7 +4,7 @@ require 'rest-client'
4
4
 
5
5
  module Infobeep
6
6
 
7
- class BaseClient
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 = SMS_API_BASE_URL + sms_request.route
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
@@ -37,6 +37,11 @@ module Infobeep
37
37
  attribute :currency, String
38
38
  end
39
39
 
40
+ class AccountBalance < Model
41
+ attribute :balance, BigDecimal
42
+ attribute :currency, String
43
+ end
44
+
40
45
  class SMSResponseDetail < Model
41
46
  attribute :to, String
42
47
  attribute :status, Status
@@ -0,0 +1,18 @@
1
+ require 'json'
2
+
3
+ module Infobeep
4
+ class AccountBalanceRequest < BaseRequestModel
5
+
6
+ def http_method
7
+ :get
8
+ end
9
+
10
+ def route
11
+ 'account/1/balance'
12
+ end
13
+
14
+ def response_class
15
+ AccountBalance
16
+ end
17
+ end
18
+ end
@@ -16,7 +16,7 @@ module Infobeep
16
16
  end
17
17
 
18
18
  def route
19
- 'text/advanced'
19
+ 'sms/1/text/advanced'
20
20
  end
21
21
 
22
22
  def response_class
@@ -18,7 +18,7 @@ module Infobeep
18
18
  end
19
19
 
20
20
  def route
21
- 'logs'
21
+ 'sms/1/logs'
22
22
  end
23
23
 
24
24
  def response_class
@@ -11,7 +11,7 @@ module Infobeep
11
11
  end
12
12
 
13
13
  def route
14
- 'reports'
14
+ 'sms/1/reports'
15
15
  end
16
16
 
17
17
  def response_class
@@ -24,7 +24,7 @@ module Infobeep
24
24
  end
25
25
 
26
26
  def route
27
- 'text/advanced'
27
+ 'sms/1/text/advanced'
28
28
  end
29
29
 
30
30
  def http_method
@@ -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"
@@ -1,3 +1,3 @@
1
1
  module Infobeep
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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