Module: Legion::Extensions::ServiceNow::Csm::Runners::Csm
Constant Summary
Helpers::Client::OAUTH_TOKEN_BUFFER_SECONDS
Instance Method Summary
collapse
-
#create_csm_case(subject:, account: nil, contact: nil, priority: '4', description: nil) ⇒ Object
-
#get_contact(sys_id:) ⇒ Object
-
#get_csm_case(sys_id:) ⇒ Object
-
#list_contacts(sysparm_limit: 100, sysparm_offset: 0, account: nil) ⇒ Object
-
#list_csm_cases(sysparm_limit: 100, sysparm_offset: 0, sysparm_query: nil) ⇒ Object
-
#update_csm_case(sys_id:, state: nil, assigned_to: nil, resolution_notes: nil) ⇒ Object
#connection, #fetch_oauth2_token, #handle_response
Instance Method Details
#create_csm_case(subject:, account: nil, contact: nil, priority: '4', description: nil) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 24
def create_csm_case(subject:, account: nil, contact: nil,
priority: '4', description: nil, **)
body = { subject: subject, priority: priority }
body[:account] = account if account
body[:contact] = contact if contact
body[:description] = description if description
resp = post('/api/now/table/sn_customerservice_case', body, **)
{ csm_case: resp.body['result'] }
end
|
52
53
54
55
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 52
def get_contact(sys_id:, **)
resp = get("/api/now/table/customer_contact/#{sys_id}", {}, **)
{ contact: resp.body['result'] }
end
|
#get_csm_case(sys_id:) ⇒ Object
19
20
21
22
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 19
def get_csm_case(sys_id:, **)
resp = get("/api/now/table/sn_customerservice_case/#{sys_id}", {}, **)
{ csm_case: resp.body['result'] }
end
|
44
45
46
47
48
49
50
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 44
def list_contacts(sysparm_limit: 100, sysparm_offset: 0,
account: nil, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
params[:sysparm_query] = "account=#{account}" if account
resp = get('/api/now/table/customer_contact', params, **)
{ contacts: resp.body['result'] }
end
|
#list_csm_cases(sysparm_limit: 100, sysparm_offset: 0, sysparm_query: nil) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 11
def list_csm_cases(sysparm_limit: 100, sysparm_offset: 0,
sysparm_query: nil, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
params[:sysparm_query] = sysparm_query if sysparm_query
resp = get('/api/now/table/sn_customerservice_case', params, **)
{ cases: resp.body['result'] }
end
|
#update_csm_case(sys_id:, state: nil, assigned_to: nil, resolution_notes: nil) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/legion/extensions/service_now/csm/runners/csm.rb', line 34
def update_csm_case(sys_id:, state: nil, assigned_to: nil,
resolution_notes: nil, **)
body = {}
body[:state] = state if state
body[:assigned_to] = assigned_to if assigned_to
body[:resolution_notes] = resolution_notes if resolution_notes
resp = patch("/api/now/table/sn_customerservice_case/#{sys_id}", body, **)
{ csm_case: resp.body['result'] }
end
|