Class: ArchivesSpace::Request
- Inherits:
-
Object
- Object
- ArchivesSpace::Request
- Includes:
- HTTParty
- Defined in:
- lib/archivesspace/client/request.rb
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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/archivesspace/client/request.rb', line 24 def initialize(config, method = 'GET', path = '', = {}) @config = config @method = method.downcase.to_sym @path = path.gsub(%r{^/+}, '') @options = @options[:headers] = [:headers] ? default_headers(@method).merge([:headers]) : default_headers(@method) @options[:verify] = config.verify_ssl @options[:query] = {} unless .key? :query self.class.debug_output($stdout) if @config.debug base_uri = config.base_repo&.length&.positive? ? File.join(config.base_uri, config.base_repo) : config.base_uri self.class.base_uri base_uri end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/archivesspace/client/request.rb', line 6 def config @config end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/archivesspace/client/request.rb', line 6 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/archivesspace/client/request.rb', line 6 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/archivesspace/client/request.rb', line 6 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/archivesspace/client/request.rb', line 6 def path @path end |
Instance Method Details
#default_headers(method = :get) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/archivesspace/client/request.rb', line 8 def default_headers(method = :get) headers = { delete: {}, get: {}, post: { 'Content-Type' => 'application/json', 'Content-Length' => 'nnnn' }, put: { 'Content-Type' => 'application/json', 'Content-Length' => 'nnnn' } } headers[method] end |
#execute ⇒ Object
39 40 41 |
# File 'lib/archivesspace/client/request.rb', line 39 def execute self.class.send method, "/#{path}", end |