class Alma::FineSet
Attributes
raw_response[R]
results[R]
Public Class Methods
new(raw_response)
click to toggle source
# File lib/alma/fine_set.rb, line 11 def initialize(raw_response) @raw_response = raw_response @response = raw_response.parsed_response validate(raw_response) @results = @response.fetch(key, []) .map { |item| single_record_class.new(item) } end
Public Instance Methods
currency()
click to toggle source
# File lib/alma/fine_set.rb, line 50 def currency fetch("currency", nil) end
each(&block)
click to toggle source
# File lib/alma/fine_set.rb, line 32 def each(&block) @results.each(&block) end
key()
click to toggle source
# File lib/alma/fine_set.rb, line 40 def key "fee" end
loggable()
click to toggle source
# File lib/alma/fine_set.rb, line 19 def loggable { uri: @raw_response&.request&.uri.to_s }.select { |k, v| !(v.nil? || v.empty?) } end
success?()
click to toggle source
# File lib/alma/fine_set.rb, line 36 def success? raw_response.response.code.to_s == "200" end
sum()
click to toggle source
# File lib/alma/fine_set.rb, line 44 def sum fetch("total_sum", 0) end
Also aliased as: total_sum
validate(response)
click to toggle source
# File lib/alma/fine_set.rb, line 24 def validate(response) if response.code != 200 message = "Could not find fines." log = loggable.merge(response.parsed_response) raise ResponseError.new(message, log) end end