Class: CMIS::Connection
- Inherits:
-
Object
- Object
- CMIS::Connection
- Defined in:
- lib/cmis/connection.rb,
lib/cmis/connection/url_resolver.rb,
lib/cmis/connection/response_parser.rb,
lib/cmis/connection/request_modifier.rb
Direct Known Subclasses
Defined Under Namespace
Classes: RequestModifier, ResponseParser, URLResolver
Instance Method Summary collapse
- #execute!(params = {}, options = {}) ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cmis/connection.rb', line 11 def initialize() .symbolize_keys! = "option `service_url` must be set" service_url = [:service_url] or raise adapter = ([:adapter] || :net_http).to_sym headers = { user_agent: "cmis-ruby/#{VERSION} [#{adapter}]" }.merge([:headers] || {}) conn_opts = { headers: headers, ssl: [:ssl] }.compact @http = Faraday.new(conn_opts) do |builder| builder.use RequestModifier builder.request :multipart builder.request :url_encoded if [:username] builder.basic_auth([:username], [:password]) end builder.adapter adapter builder.response :logger if [:log_requests] builder.use ResponseParser end @url_resolver = URLResolver.new(@http, service_url) end |
Instance Method Details
#execute!(params = {}, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cmis/connection.rb', line 41 def execute!(params = {}, = {}) params.symbolize_keys! .symbolize_keys! query = [:query] || {} headers = [:headers] || {} url = @url_resolver.url(params.delete(:repositoryId), params[:objectId]) response = if params[:cmisaction] @http.post(url, params, headers) else @http.get(url, params.merge(query), headers) end response.body end |