Class: Infobip::SmsApi::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/infobip/sms_api/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
# File 'lib/infobip/sms_api/configuration.rb', line 6

def initialize
  @endpoint = 'https://api.infobip.com'
  @debug = false
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/infobip/sms_api/configuration.rb', line 4

def connection
  @connection
end

#debugObject

Returns the value of attribute debug.



4
5
6
# File 'lib/infobip/sms_api/configuration.rb', line 4

def debug
  @debug
end

#endpointObject

Returns the value of attribute endpoint.



4
5
6
# File 'lib/infobip/sms_api/configuration.rb', line 4

def endpoint
  @endpoint
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/infobip/sms_api/configuration.rb', line 4

def password
  @password
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/infobip/sms_api/configuration.rb', line 4

def username
  @username
end

Instance Method Details

#connectObject



11
12
13
14
15
16
17
18
# File 'lib/infobip/sms_api/configuration.rb', line 11

def connect
  raise 'Username and/or password are not configured' unless @username && @password
  @connection = Faraday.new(url: @endpoint) do |faraday|
    faraday.adapter :net_http
    faraday.response :logger if @debug
  end
  @connection.basic_auth @username, @password
end