Sha256: 09c0de9379d54481ac840ebeb57e089121d31a831ce87a2b83e66e4b63b0244f
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module OMCMS class Client attr_reader :client def initialize(opts) configure_credentials(opts) configure_client end def faraday &block @faraday = block if block @faraday end def configure_client @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$/ faraday.call(f) if faraday f.adapter Faraday.default_adapter unless faraday end end def offerings OMCMS::Offering.new(@client, @response, @host) end private def configure_credentials(opts) raise ArgumentError.new "Public Key is missing for the OMCMS client" if opts[:public_key].to_s.empty? raise ArgumentError.new "Private Key is missing for the OMCMS client" if opts[:private_key].to_s.empty? raise ArgumentError.new "Host is missing for the OMCMS client" if opts[:host].to_s.empty? @username = opts[:public_key] @password = opts[:private_key] @host = opts[:host] @open_timeout = opts[:open_timeout] || 10 @timeout = opts[:timeout] || 20 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omcms-ruby-client-1.2.0 | lib/omcms/client.rb |