Class: CollectionSpace::Request
- Inherits:
-
Object
- Object
- CollectionSpace::Request
- Includes:
- HTTParty
- Defined in:
- lib/collectionspace/client/request.rb
Overview
CollectionSpace request
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #default_headers(method = :get) ⇒ Object
- #execute ⇒ Object
-
#initialize(config, method = "GET", path = "", options = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(config, method = "GET", path = "", options = {}) ⇒ Request
Returns a new instance of Request.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/collectionspace/client/request.rb', line 25 def initialize(config, method = "GET", path = "", = {}) @config = config @method = method.downcase.to_sym @path = path.gsub(%r{^/}, "") @auth = { username: config.username, password: config.password } headers = default_headers(@method).merge(.fetch(:headers, {})) @options = @options[:basic_auth] = @auth @options[:headers] = headers @options[:verify] = config.verify_ssl @options[:query] = .fetch(:query, {}) self.class.base_uri config.base_uri self.class.debug_output $stdout if config.verbose self.class.default_params( wf_deleted: config.include_deleted, pgSz: config.page_size ) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/collectionspace/client/request.rb', line 7 def config @config end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/collectionspace/client/request.rb', line 7 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/collectionspace/client/request.rb', line 7 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/collectionspace/client/request.rb', line 7 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/collectionspace/client/request.rb', line 7 def path @path end |
Instance Method Details
#default_headers(method = :get) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/collectionspace/client/request.rb', line 9 def default_headers(method = :get) headers = { delete: {}, get: {}, post: { "Content-Type" => "application/xml", "Content-Length" => "nnnn" }, put: { "Content-Type" => "application/xml", "Content-Length" => "nnnn" } } headers[method] end |
#execute ⇒ Object
50 51 52 |
# File 'lib/collectionspace/client/request.rb', line 50 def execute self.class.send method, "/#{path}", end |