Method: Vng::WorkOrder.create

Defined in:
lib/vng/work_order.rb

.create(lock_id:, client_id:, contact_id:, location_id:, duration:, summary:, line_items:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vng/work_order.rb', line 22

def self.create(lock_id:, client_id:, contact_id:, location_id:, duration:, summary:, line_items:)
  body = {
    method: '3',
    serviceTypeID: '14', # only return items of serviceType 'Pet Grooming'
    lockID: lock_id,
    clientID: client_id,
    contactID: contact_id,
    locationID: location_id,
    Fields: [
      { fieldID: 200, fieldValue: summary },
      { fieldID: 186, fieldValue: duration.to_i },
      { fieldID: 201, optionID: '9537' } # label: Online Tentative
    ],
    Charges: charges_for(line_items)
  }

  data = request path: PATH, body: body

  new id: data['WorkOrder']['objectID']
end