Class: CONTENTdmAPI::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/contentdm_api/service.rb

Overview

A class to tell the Request class which function, params and format to request of the CONTENTdm API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function: 'wsAPIDescribe', params: [], format: 'json') ⇒ Void

Parameters:

  • function (String) (defaults to: 'wsAPIDescribe')

    function A CONTENTdm function

  • params (Array) (defaults to: [])

    A set of params for a given function. Parameters must be passed as an array in the order specified in the CONTENTdm API documentation.

  • format (String) (defaults to: 'json')

    Either XML or JSON. Defaults to JSON.


15
16
17
18
19
# File 'lib/contentdm_api/service.rb', line 15

def initialize(function: 'wsAPIDescribe', params: [], format: 'json')
  @format   = format
  @function = function
  @params   = params
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format


5
6
7
# File 'lib/contentdm_api/service.rb', line 5

def format
  @format
end

#functionObject (readonly)

Returns the value of attribute function


5
6
7
# File 'lib/contentdm_api/service.rb', line 5

def function
  @function
end

#paramsObject (readonly)

Returns the value of attribute params


5
6
7
# File 'lib/contentdm_api/service.rb', line 5

def params
  @params
end

Instance Method Details

#url_paramsString

URL params for a given service

Returns:

  • (String)

    A CONTENTdm formatted url parameter string


24
25
26
# File 'lib/contentdm_api/service.rb', line 24

def url_params
  "#{function}/#{all_params.join('/')}"
end