Class: OMCMS::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/omcms/client.rb', line 7

def initialize(opts)
  configure_credentials(opts)
  @client = configure_client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/omcms/client.rb', line 5

def client
  @client
end

Instance Method Details

#configure_clientObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/omcms/client.rb', line 12

def configure_client
  @configure_client ||= Faraday.new do |f|
    f.request :authorization, :basic, @username, @password
    f.options[:open_timeout] = @open_timeout
    f.options[:timeout] = @timeout
    f.request :omcms_set_header
    f.response :omcms_parse_response
    f.response :json, content_type: /\bjson$/
    f.adapter :httpclient
  end
end

#offeringsObject



24
25
26
# File 'lib/omcms/client.rb', line 24

def offerings
  OMCMS::Offering.new(@client, @host, @response)
end