Sha256: 5bab6e777812fce1daf7ae62eae36c9676d0c17da1fde994d5218a1ec827b6a0

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

class FolioClient
  # Query organization records in Folio; see
  # https://s3.amazonaws.com/foliodocs/api/mod-organizations/p/organizations.html
  # https://s3.amazonaws.com/foliodocs/api/mod-organizations-storage/p/interface.html
  class Organizations
    # @param query [String] an optional query to limit the number of organizations returned
    # @param limit [Integer] the number of results to return (defaults to 10,000)
    # @param offset [Integer] the offset for results returned (defaults to 0)
    # @param lang [String] language code for returned results (defaults to 'en')
    def fetch_list(query: nil, limit: 10_000, offset: 0, lang: 'en')
      params = { limit: limit, offset: offset, lang: lang }
      params[:query] = query if query
      client.get('/organizations/organizations', params)
    end

    # @param query [String] an optional query to limit the number of organization interfaces returned
    # @param limit [Integer] the number of results to return (defaults to 10,000)
    # @param offset [Integer] the offset for results returned (defaults to 0)
    # @param lang [String] language code for returned results (defaults to 'en')
    def fetch_interface_list(query: nil, limit: 10_000, offset: 0, lang: 'en')
      params = { limit: limit, offset: offset, lang: lang }
      params[:query] = query if query
      client.get('/organizations-storage/interfaces', params)
    end

    # @param id [String] id for requested storage interface
    # @param lang [String] language code for returned result (defaults to 'en')
    def fetch_interface_details(id:, lang: 'en')
      client.get("/organizations-storage/interfaces/#{id}", {
                   lang: lang
                 })
    end

    private

    def client
      FolioClient.instance
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
folio_client-0.17.0 lib/folio_client/organizations.rb
folio_client-0.16.0 lib/folio_client/organizations.rb