Module: Legion::Extensions::ServiceNow::CatalogVariable::Runners::CatalogVariable
Instance Method Summary
collapse
#connection, #fetch_oauth2_token, #handle_response
Instance Method Details
#create_catalog_variable(cat_item:, name:, question_text:, type: '6', mandatory: false) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/legion/extensions/service_now/catalog_variable/runners/catalog_variable.rb', line 25
def create_catalog_variable(cat_item:, name:, question_text:,
type: '6', mandatory: false, **)
body = {
cat_item: cat_item,
name: name,
question_text: question_text,
type: type,
mandatory: mandatory
}
resp = connection(**).post('/api/now/table/item_option_new', body)
{ variable: resp.body['result'] }
end
|
#delete_catalog_variable(sys_id:) ⇒ Object
48
49
50
51
|
# File 'lib/legion/extensions/service_now/catalog_variable/runners/catalog_variable.rb', line 48
def delete_catalog_variable(sys_id:, **)
resp = connection(**).delete("/api/now/table/item_option_new/#{sys_id}")
{ deleted: resp.status == 204, sys_id: sys_id }
end
|
#get_catalog_variable(sys_id:) ⇒ Object
20
21
22
23
|
# File 'lib/legion/extensions/service_now/catalog_variable/runners/catalog_variable.rb', line 20
def get_catalog_variable(sys_id:, **)
resp = connection(**).get("/api/now/table/item_option_new/#{sys_id}")
{ variable: resp.body['result'] }
end
|
#list_catalog_variables(cat_item_sys_id:, sysparm_limit: 100) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/legion/extensions/service_now/catalog_variable/runners/catalog_variable.rb', line 11
def list_catalog_variables(cat_item_sys_id:, sysparm_limit: 100, **)
params = {
sysparm_query: "cat_item=#{cat_item_sys_id}",
sysparm_limit: sysparm_limit
}
resp = connection(**).get('/api/now/table/item_option_new', params)
{ variables: resp.body['result'] }
end
|
#update_catalog_variable(sys_id:, question_text: nil, mandatory: nil, active: nil) ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/legion/extensions/service_now/catalog_variable/runners/catalog_variable.rb', line 38
def update_catalog_variable(sys_id:, question_text: nil, mandatory: nil,
active: nil, **)
body = {}
body[:question_text] = question_text if question_text
body[:mandatory] = mandatory unless mandatory.nil?
body[:active] = active unless active.nil?
resp = connection(**).patch("/api/now/table/item_option_new/#{sys_id}", body)
{ variable: resp.body['result'] }
end
|