Class: HotelBeds::Configuration

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint: :test, username:, password:, proxy: nil, request_timeout: 5, response_timeout: 30, enable_logging: false) ⇒ Configuration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
21
22
23
# File 'lib/hotel_beds/configuration.rb', line 14

def initialize(endpoint: :test, username:, password:, proxy: nil, request_timeout: 5, response_timeout: 30, enable_logging: false)
  self.endpoint = self.class.endpoints.fetch(endpoint, endpoint)
  self.username = username
  self.password = password
  self.proxy = proxy
  self.request_timeout = Integer(request_timeout)
  self.response_timeout = Integer(response_timeout)
  self.enable_logging = enable_logging
  freeze
end

Instance Attribute Details

#enable_loggingObject

Returns the value of attribute enable_logging.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def enable_logging
  @enable_logging
end

#endpointObject

Returns the value of attribute endpoint.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def endpoint
  @endpoint
end

#passwordObject

Returns the value of attribute password.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def password
  @password
end

#proxyObject

Returns the value of attribute proxy.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def proxy
  @proxy
end

#request_timeoutObject

Returns the value of attribute request_timeout.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def request_timeout
  @request_timeout
end

#response_timeoutObject

Returns the value of attribute response_timeout.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def response_timeout
  @response_timeout
end

#usernameObject

Returns the value of attribute username.



11
12
13
# File 'lib/hotel_beds/configuration.rb', line 11

def username
  @username
end

Class Method Details

.endpointsObject



3
4
5
6
7
8
9
# File 'lib/hotel_beds/configuration.rb', line 3

def self.endpoints
  path = "appservices/ws/FrontendService"
  {
    test: "http://testapi.interface-xml.com/#{path}".freeze,
    live: "http://api.interface-xml.com/#{path}".freeze,
  }
end

Instance Method Details

#enable_logging?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/hotel_beds/configuration.rb', line 25

def enable_logging?
  !!enable_logging
end

#proxy?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/hotel_beds/configuration.rb', line 29

def proxy?
  !!(proxy && !proxy.empty?)
end