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
- VERSION =
'0.1.10'
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.
10 11 12 13 14 15 |
# File 'lib/archivesspace/client/client.rb', line 10 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
17 18 19 |
# File 'lib/archivesspace/client/client.rb', line 17 def backend_version get 'version' end |
#delete(path) ⇒ Object
33 34 35 |
# File 'lib/archivesspace/client/client.rb', line 33 def delete(path) request 'DELETE', path end |
#get(path, options = {}) ⇒ Object
21 22 23 |
# File 'lib/archivesspace/client/client.rb', line 21 def get(path, = {}) request 'GET', path, end |
#post(path, payload, params = {}) ⇒ Object
25 26 27 |
# File 'lib/archivesspace/client/client.rb', line 25 def post(path, payload, params = {}) request 'POST', path, { body: payload, query: params } end |
#put(path, payload, params = {}) ⇒ Object
29 30 31 |
# File 'lib/archivesspace/client/client.rb', line 29 def put(path, payload, params = {}) request 'PUT', path, { body: payload, query: params } end |
#repository(id) ⇒ Object
Scoping requests
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/archivesspace/client/client.rb', line 38 def repository(id) if id.nil? use_global_repository return end begin Integer(id) rescue StandardError raise RepositoryIdError, "Invalid Repository id: #{id}" end @config.base_repo = "repositories/#{id}" end |
#use_global_repository ⇒ Object
53 54 55 |
# File 'lib/archivesspace/client/client.rb', line 53 def use_global_repository @config.base_repo = '' end |