Sha256: e68ab9c5fea5bfefb76d77b323427b0cfa8a5cea70e495f7c321e88634c14322
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 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 :basic_auth, @username, @password f.options[:open_timeout] = 2 f.options[:timeout] = 5 f.use SetHeader f.use ParseResponse 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] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omcms-ruby-client-1.0.2 | lib/omcms/client.rb |