Class: CollectionSpace::Client

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/collectionspace/client/client.rb,
lib/collectionspace/client/version.rb

Overview

CollectionSpace client

Constant Summary collapse

VERSION =
'0.3.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#all, #count, #get_list_types, #prepare_query, #search

Constructor Details

#initialize(config = Configuration.new) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/collectionspace/client/client.rb', line 7

def initialize(config = Configuration.new)
  unless config.is_a? CollectionSpace::Configuration
    raise CollectionSpace::ArgumentError, 'Invalid configuration object'
  end

  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/collectionspace/client/client.rb', line 5

def config
  @config
end

Instance Method Details

#delete(path) ⇒ Object



29
30
31
# File 'lib/collectionspace/client/client.rb', line 29

def delete(path)
  request 'DELETE', path
end

#get(path, options = {}) ⇒ Object



15
16
17
# File 'lib/collectionspace/client/client.rb', line 15

def get(path, options = {})
  request 'GET', path, options
end

#post(path, payload, options = {}) ⇒ Object



19
20
21
22
# File 'lib/collectionspace/client/client.rb', line 19

def post(path, payload, options = {})
  check_payload(payload)
  request 'POST', path, { body: payload }.merge(options)
end

#put(path, payload) ⇒ Object



24
25
26
27
# File 'lib/collectionspace/client/client.rb', line 24

def put(path, payload)
  check_payload(payload)
  request 'PUT', path, body: payload
end