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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/archivesspace/client/request.rb', line 23 def initialize(config, method = "GET", path = "", = {}) @config = config @method = method.downcase.to_sym @path = path = [:headers] = [:headers] ? default_headers(@method).merge([:headers]) : default_headers [:verify] = config.verify_ssl [:query] = {} unless .has_key? :query base_uri = (config.base_repo.nil? or config.base_repo.empty?) ? config.base_uri : "#{config.base_uri}/#{config.base_repo}" self.class.base_uri base_uri # self.class.default_params abc: 123 end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/archivesspace/client/request.rb', line 5 def config @config end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/archivesspace/client/request.rb', line 5 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/archivesspace/client/request.rb', line 5 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/archivesspace/client/request.rb', line 5 def end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/archivesspace/client/request.rb', line 5 def path @path end |
Instance Method Details
#default_headers(method = :get) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/archivesspace/client/request.rb', line 7 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
38 39 40 |
# File 'lib/archivesspace/client/request.rb', line 38 def execute self.class.send method, "/#{path}", end |