Class: Alma::RequestOptions

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/alma/request_options.rb

Constant Summary collapse

REQUEST_OPTIONS_PERMITTED_ARGS =
[:user_id]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ RequestOptions

Returns a new instance of RequestOptions.



10
11
12
13
# File 'lib/alma/request_options.rb', line 10

def initialize(response)
  @raw_response = response
  @request_options = JSON.parse(response.body)["request_option"]
end

Instance Attribute Details

#raw_responseObject

Returns the value of attribute raw_response.



5
6
7
# File 'lib/alma/request_options.rb', line 5

def raw_response
  @raw_response
end

#request_optionsObject

Returns the value of attribute request_options.



5
6
7
# File 'lib/alma/request_options.rb', line 5

def request_options
  @request_options
end

Class Method Details

.get(mms_id, options = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/alma/request_options.rb', line 15

def self.get(mms_id, options={})
  url = "#{bibs_base_path}/#{mms_id}/request-options"
  options.select! {|k,_|  REQUEST_OPTIONS_PERMITTED_ARGS.include? k }
  response = HTTParty.get(url, headers: headers, query: options)
  new(response)
end

Instance Method Details

#digitization_allowed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/alma/request_options.rb', line 26

def digitization_allowed?
  !request_options.select {|option| option["type"]["value"] == "DIGITIZATION" }.empty?
end

#hold_allowed?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/alma/request_options.rb', line 22

def hold_allowed?
  !request_options.select {|option| option["type"]["value"] == "HOLD" }.empty?
end