Class: Dspace::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/dspace/client.rb
Constant Summary
collapse
- DSPACE_API =
'https://demo.dspace.org'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7
8
9
10
11
|
# File 'lib/dspace/client.rb', line 7
def initialize(options = {})
@access_token = options.with_indifferent_access[:access_token]
@dspace_api = options.with_indifferent_access[:dspace_api]
@logger = options.with_indifferent_access[:logger]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33
34
35
|
# File 'lib/dspace/client.rb', line 33
def method_missing(name, *args, &block)
resource(name) || super
end
|
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5
6
7
|
# File 'lib/dspace/client.rb', line 5
def access_token
@access_token
end
|
Instance Method Details
#connection ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/dspace/client.rb', line 13
def connection
Faraday.new(connection_options) do |req|
req.request :multipart
req.request :url_encoded
req.use(Faraday::Response::Logger, @logger) unless @logger.nil?
req.adapter :net_http_persistent
end
end
|
#is_running? ⇒ Boolean
41
42
43
|
# File 'lib/dspace/client.rb', line 41
def is_running?
resource(:status).test
end
|
#login(email, password) ⇒ Object
45
46
47
|
# File 'lib/dspace/client.rb', line 45
def login(email, password)
@access_token = resource(:authentication).login(email, password)
end
|
#logout ⇒ Object
49
50
51
52
|
# File 'lib/dspace/client.rb', line 49
def logout
resource(:authentication).logout
@access_token = nil
end
|
#resources ⇒ Object
37
38
39
|
# File 'lib/dspace/client.rb', line 37
def resources
@resources ||= {}
end
|