Class: CampactUserService::Client

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

Constant Summary collapse

TIMEOUT =
5.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/campact_user_service/client.rb', line 13

def initialize(options)
  @scheme = options.fetch(:scheme, 'https')
  @host = options.fetch(:host)
  @port = options[:port]
  faraday_options = default_faraday_options.merge(options.delete(:faraday) || {})
  adapter = faraday_options.delete(:adapter) || Faraday.default_adapter

  @connection = Faraday.new(endpoint, faraday_options) do |faraday|
    if options.has_key?(:enable_auth)
      faraday.basic_auth options[:username], options[:password]
    end
    faraday.adapter adapter
  end
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#schemeObject (readonly)

Returns the value of attribute scheme.



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

def scheme
  @scheme
end