Class: Vng::Case

Inherits:
Resource show all
Defined in:
lib/vng/case.rb

Overview

Provides methods to interact with Vonigo cases.

Constant Summary collapse

PATH =
'/api/v1/data/Cases/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:) ⇒ Case

Returns a new instance of Case.



10
11
12
# File 'lib/vng/case.rb', line 10

def initialize(id:)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/case.rb', line 8

def id
  @id
end

Class Method Details

.create(client_id:, summary:, comments:, phone:, email:, zip:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vng/case.rb', line 14

def self.create(client_id:, summary:, comments:, phone:, email:, zip:)
  body = {
    method: '3',
    clientID: client_id,
    Fields: [
       {fieldID: 219, optionID: 239}, # Status: open
       {fieldID: 220, fieldValue: summary}, # Summary:
       {fieldID: 230, fieldValue: comments}, # Comments:
       {fieldID: 226, optionID: 227}, # Type: 'General request'
       {fieldID: 227, optionID: 232}, # Preferred Contact Method: 'Phone'
       {fieldID: 228, fieldValue: phone}, # Phone Me Back at:
       {fieldID: 229, fieldValue: email}, # Email:
       {fieldID: 1023, fieldValue: zip}, # Zip Code:
    ]
  }

  data = request path: PATH, body: body

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

Instance Method Details

#destroyObject



35
36
37
38
39
40
41
42
# File 'lib/vng/case.rb', line 35

def destroy
  body = {
    method: '4',
    objectID: id,
  }

  self.class.request path: PATH, body: body
end