Class: Infobeep::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/infobeep/client.rb

Direct Known Subclasses

SMSClient

Constant Summary collapse

API_BASE_URL =
'https://api.infobip.com/'

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ BaseClient

Returns a new instance of BaseClient.



10
11
12
13
# File 'lib/infobeep/client.rb', line 10

def initialize(username, password)
  @username = username
  @password = password
end

Instance Method Details

#authentication_headersObject



15
16
17
18
# File 'lib/infobeep/client.rb', line 15

def authentication_headers
  auth_string = ::Base64.encode64("#{@username}:#{@password}").strip
  {'Authorization': "Basic #{auth_string}"}
end

#client_headersObject



20
21
22
23
24
25
26
27
28
# File 'lib/infobeep/client.rb', line 20

def client_headers
  hsh = {
      'User-Agent': "Infobeep-#{Infobeep::VERSION}",
      'Content-Type': 'application/json',
      'accept': 'application/json'
  }
  hsh.merge!(authentication_headers)
  hsh
end