class CONTENTdmAPI::Request

Form requests to the ContentDM API

Attributes

base_url[R]
client[R]
service[R]

Public Class Methods

new(base_url: '', client: HTTP, service: Service.new) click to toggle source

@param [String] base_url URL to the CONTENTdm API

"http://CdmServer.com:port/dmwebservices/index.php"

@param [Object] client An HTTP client to make requests of the API @param [Object] service A class to tell the Request class which function,

params and format to request of the CONTENTdm API

@return [Void]

# File lib/contentdm_api/request.rb, line 14
def initialize(base_url: '', client: HTTP, service: Service.new)
  @base_url = base_url
  @client   = client
  @service  = service
end

Public Instance Methods

fetch() click to toggle source

Fetch data from the CONTENTdm API

@return [String] either XML or JSON

# File lib/contentdm_api/request.rb, line 23
def fetch
  client.get(unencoded_url).to_s
end
unencoded_url() click to toggle source

A URL for a given service

@return [String] a url string

# File lib/contentdm_api/request.rb, line 30
def unencoded_url
  "#{base_url}?q=#{service.url_params}"
end