Class: CampactUserService::Client
- Inherits:
-
Object
- Object
- CampactUserService::Client
- Defined in:
- lib/campact_user_service/client.rb
Constant Summary collapse
- TIMEOUT =
60.freeze
- OPEN_TIMEOUT =
20.freeze
Instance Attribute Summary collapse
-
#basic_auth ⇒ Object
readonly
Returns the value of attribute basic_auth.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/campact_user_service/client.rb', line 12 def initialize() @host = .fetch(:host) @port = [:port] @basic_auth = [:basic_auth] = .merge(.delete(:faraday) || {}) adapter = .delete(:adapter) || Faraday.default_adapter @connection = Faraday.new(endpoint, ) do |faraday| faraday.adapter adapter faraday.request :json faraday.request :authorization, :basic, basic_auth[:user], basic_auth[:password] if basic_auth end end |
Instance Attribute Details
#basic_auth ⇒ Object (readonly)
Returns the value of attribute basic_auth.
10 11 12 |
# File 'lib/campact_user_service/client.rb', line 10 def basic_auth @basic_auth end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/campact_user_service/client.rb', line 10 def connection @connection end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/campact_user_service/client.rb', line 10 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/campact_user_service/client.rb', line 10 def port @port end |