class ArchivesSpace::Request
Attributes
config[R]
headers[R]
method[R]
options[R]
path[R]
Public Class Methods
new(config, method = 'GET', path = '', options = {})
click to toggle source
# File lib/archivesspace/client/request.rb, line 24 def initialize(config, method = 'GET', path = '', options = {}) @config = config @method = method.downcase.to_sym @path = path.gsub(%r{^/+}, '') @options = options @options[:headers] = options[:headers] ? default_headers(@method).merge(options[:headers]) : default_headers(@method) @options[:verify] = config.verify_ssl @options[:query] = {} unless options.key? :query 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
Public Instance Methods
default_headers(method = :get)
click to toggle source
# 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()
click to toggle source
# File lib/archivesspace/client/request.rb, line 38 def execute self.class.send method, "/#{path}", options end