Sha256: 11672a137e0a161e3dc8272b83190ed27647142d9a78ad059b9ea8f43424c219

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require "alma_api/collection"
require "json"
require_relative "../users"

class AlmaApi::Client::Users::Fees
  def initialize(client, user_id, fee_id = nil)
    @client = client
    @fee_id = fee_id
    @user_id = user_id
  end

  def get(options = {})
    if @fee_id
      (options = options.deep_dup).symbolize_keys!.reverse_merge!({
        user_id_type: :all_unique
      })

      @client.http(:get, "/v1/users/#{@user_id}/fees/#{@fee_id}", options).try do |_response|
        if _response.status == 200
          AlmaApi::Object.new(JSON.parse(_response.body))
        end
      end

    else
      (options = options.deep_dup).symbolize_keys!.reverse_merge!({
        user_id_type: :all_unique,
        status: :ACTIVE
      })

      # sanitize api quirks
      options[:status] = options[:status].to_s.upcase.to_sym

      @client.http(:get, "/v1/users/#{@user_id}/fees", options).try do |_response|
        if _response.status == 200
          AlmaApi::Collection.new(JSON.parse(_response.body), "fee")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alma_api-0.1.0 lib/alma_api/client/users/fees.rb