Class: ArchivesSpace::Client
- Inherits:
-
Object
- Object
- ArchivesSpace::Client
- Includes:
- Pagination, Task
- Defined in:
- lib/archivesspace/client/cli.rb,
lib/archivesspace/client/client.rb,
lib/archivesspace/client/version.rb,
lib/archivesspace/client/cli/exec.rb,
lib/archivesspace/client/cli/version.rb
Defined Under Namespace
Modules: CLI
Constant Summary collapse
- NAME =
"ArchivesSpaceClient"- VERSION =
"0.4.2"
Constants included from Pagination
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #backend_version ⇒ Object
- #delete(path) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(config = Configuration.new) ⇒ Client
constructor
A new instance of Client.
- #post(path, payload, params = {}) ⇒ Object
- #put(path, payload, params = {}) ⇒ Object
-
#repository(id) ⇒ Object
Scoping requests.
- #use_global_repository ⇒ Object
Methods included from Task
#group_user_assignment, #login, #password_reset
Methods included from Pagination
Constructor Details
#initialize(config = Configuration.new) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 |
# File 'lib/archivesspace/client/client.rb', line 12 def initialize(config = Configuration.new) raise "Invalid configuration object" unless config.is_a? ArchivesSpace::Configuration @config = config @token = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/archivesspace/client/client.rb', line 8 def config @config end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/archivesspace/client/client.rb', line 7 def token @token end |
Instance Method Details
#backend_version ⇒ Object
19 20 21 |
# File 'lib/archivesspace/client/client.rb', line 19 def backend_version get "version" end |
#delete(path) ⇒ Object
35 36 37 |
# File 'lib/archivesspace/client/client.rb', line 35 def delete(path) request "DELETE", path end |
#get(path, options = {}) ⇒ Object
23 24 25 |
# File 'lib/archivesspace/client/client.rb', line 23 def get(path, = {}) request "GET", path, end |
#post(path, payload, params = {}) ⇒ Object
27 28 29 |
# File 'lib/archivesspace/client/client.rb', line 27 def post(path, payload, params = {}) request "POST", path, {body: payload.to_json, query: params} end |
#put(path, payload, params = {}) ⇒ Object
31 32 33 |
# File 'lib/archivesspace/client/client.rb', line 31 def put(path, payload, params = {}) request "PUT", path, {body: payload.to_json, query: params} end |
#repository(id) ⇒ Object
Scoping requests
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/archivesspace/client/client.rb', line 40 def repository(id) if id.nil? use_global_repository return end begin Integer(id) rescue raise RepositoryIdError, "Invalid Repository id: #{id}" end @config.base_repo = "repositories/#{id}" end |
#use_global_repository ⇒ Object
55 56 57 |
# File 'lib/archivesspace/client/client.rb', line 55 def use_global_repository @config.base_repo = "" end |