class MediTAF::Services::Clients::MauthClient
A MauthClient
object set to a specific base_url and uses the common MAuth::Client object @note only MauthAdapter
object instantiate objects of this type
Public Class Methods
@param connection [Faraday] defines the MAuth::Faraday parameters/handlers/response formats @param base_url [String] the base url for all paths @raise [MauthClientBaseURLMissing] when the no base url is given
# File lib/MediTAF/services/clients/mauth_adapter.rb, line 86 def initialize(connection, base_url) @connection, @base_url = connection, base_url end
Public Instance Methods
@note not implemented check if the resource is consumable @param resource [Symbol] the resource to check
# File lib/MediTAF/services/clients/mauth_adapter.rb, line 118 def connected?(resource) end
@note not implemented checks if the resource is deployed within eureka @param resource [Symbol] the resource to check
# File lib/MediTAF/services/clients/mauth_adapter.rb, line 112 def deployed?(resource) end
@param [Hash] opts the arguments to do an HTTP request @option opts [Symbol] :verb :get, :post, :put, or :delete @option opts [Symbol] :resource @option opts [Symbol] :body @option opts [Symbol] :content_type @return [Faraday::Response] @raise [ResourceAdapterRequestError]
# File lib/MediTAF/services/clients/mauth_adapter.rb, line 97 def request(opts) headers = {} headers['Content-Type'] = opts[:content_type] if opts[:content_type] headers['Content-Type'] = 'application/json' if opts[:content_type].nil? && opts[:body] headers['Accept'] = opts[:accept] || 'text/html,application/xhtml+xml,application/xml,application/json' @connection.run_request(opts[:verb], @base_url + '/' + opts[:resource], opts[:body], headers) rescue MAuth::InauthenticError, MAuth::UnableToAuthenticateError => e raise ResourceAdapterRequestError, "Failed to #{opts[:verb]} #{opts[:resource]}. Inner Exception: #{e.to_s}" rescue => e raise ResourceAdapterRequestError, "#{opts}. Inner Exception: #{e.to_s}" end