Class: R4DigitalNZ::DigitalNZ
- Inherits:
-
Object
- Object
- R4DigitalNZ::DigitalNZ
- Defined in:
- lib/r4digitalnz.rb
Instance Method Summary collapse
- #content_partners ⇒ Object
-
#initialize(api_key, debug = false) ⇒ DigitalNZ
constructor
A new instance of DigitalNZ.
- #meta_data(id) ⇒ Object
- #search(query, options = {}) ⇒ Object
Constructor Details
#initialize(api_key, debug = false) ⇒ DigitalNZ
Returns a new instance of DigitalNZ.
12 13 14 15 |
# File 'lib/r4digitalnz.rb', line 12 def initialize api_key, debug = false @api_key = api_key @debug = debug end |
Instance Method Details
#content_partners ⇒ Object
35 36 37 38 |
# File 'lib/r4digitalnz.rb', line 35 def content_partners command = "/content_partners/v1.json/?api_key=#{@api_key}" send command end |
#meta_data(id) ⇒ Object
29 30 31 32 33 |
# File 'lib/r4digitalnz.rb', line 29 def id command = "/records/v1/#{id}.xml/?api_key=#{@api_key}" res = send(command) MetaData.new(Hash.from_xml(res)) end |
#search(query, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/r4digitalnz.rb', line 17 def search query, = {} command = "/records/v1.json/?api_key=#{@api_key}&search_text=#{CGI.escape query}" unless .nil? o = .collect do |k,v| "&#{k.to_s}=#{v}" end command += o.to_s end SearchResult.new JSON.parse(send(command)) end |