Class: Fulcrum::Record

Inherits:
Api
  • Object
show all
Defined in:
lib/fulcrum/record.rb

Constant Summary

Constants inherited from Api

Api::VALID_METHODS

Instance Attribute Summary

Attributes inherited from Api

#configuration, #connection, #response

Class Method Summary collapse

Methods inherited from Api

call, configuration, configure, connection, get_key, key, parse_opts, response, uri

Class Method Details

.all(opts = {}) ⇒ Object



6
7
8
9
# File 'lib/fulcrum/record.rb', line 6

def all(opts = {})
  params = parse_opts([:page, :form_id, :project_id, :bounding_box, :updated_since], opts)
  call(:get, 'records.json', params)
end

.create(record) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fulcrum/record.rb', line 15

def create(record)
  validation = RecordValidator.new(record)
  if validation.valid?
    call(:post, 'records.json', record)
  else
    { error: { validation: validation.errors } }
  end
end

.delete(id) ⇒ Object



33
34
35
# File 'lib/fulcrum/record.rb', line 33

def delete(id)
  call(:delete, "records/#{id}.json")
end

.find(id) ⇒ Object



11
12
13
# File 'lib/fulcrum/record.rb', line 11

def find(id)
  call(:get, "records/#{id}.json")
end

.update(id, record) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/fulcrum/record.rb', line 24

def update(id, record)
  validation = RecordValidator.new(record)
  if validation.valid?
    call(:put, "records/#{id}.json", record)
  else
    { error: { validation: validation.errors } }
  end
end