Class: TicketAbstractorClient::ServiceNow::Client
Constant Summary
collapse
- SYS_ID_LENGTH =
32
- TICKET_NOT_FOUND =
'Ticket not found or incorrect ID given'.freeze
Constants inherited
from Base::Client
Base::Client::TA_RESPONSE_TIME_HEADERS_LIST
Instance Attribute Summary
Attributes inherited from Base::Client
#communications_stack, #trace_communications
Instance Method Summary
collapse
#build_all_tickets_params, #build_attachment_params, #build_comment_params, #build_status_params, #build_sysparm_query, #build_ticket_params
#with_response_handling
Constructor Details
#initialize(endpoint = 'default') ⇒ Client
Returns a new instance of Client.
9
10
11
12
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 9
def initialize(endpoint = 'default')
super()
@service_now_endpoint = endpoint
end
|
Instance Method Details
#create_attachment(attachment) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 55
def create_attachment(attachment)
attachment.ticket_id = get_ticket_sys_id(ticket_id: attachment.ticket_id, table_name: attachment.project)
args, params = build_attachment_params(attachment)
post(__method__, args, params)
end
|
62
63
64
65
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 62
def ()
.ticket_id = get_ticket_sys_id(ticket_id: .ticket_id, table_name: .project)
post(__method__, ())
end
|
#create_ticket(ticket) ⇒ Object
67
68
69
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 67
def create_ticket(ticket)
post(__method__, build_ticket_params(ticket))
end
|
#endpoints ⇒ Object
34
35
36
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 34
def endpoints
get(__method__)
end
|
#get_all_tickets(opts) ⇒ Object
14
15
16
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 14
def get_all_tickets(opts)
get_tickets_by_query(build_all_tickets_params(opts))
end
|
#get_attachment_file(opts) ⇒ Object
23
24
25
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 23
def get_attachment_file(opts)
get(__method__, opts)
end
|
#get_attachments(opts) ⇒ Object
18
19
20
21
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 18
def get_attachments(opts)
opts[:ticket_id] = get_ticket_sys_id(opts)
get(__method__, opts)
end
|
27
28
29
30
31
32
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 27
def (opts)
opts[:table_name] = opts[:project]
opts[:sys_id] = get_ticket_sys_id(opts)
opts[:display_value] = TicketAbstractorClient.configuration.snow_display_value if opts[:display_value].nil?
get(__method__, opts)
end
|
#get_ticket_by_id(opts) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 38
def get_ticket_by_id(opts)
opts[:table_name] = opts[:project]
opts[:sys_id] = get_ticket_sys_id(opts)
opts[:display_value] = TicketAbstractorClient.configuration.snow_display_value if opts[:display_value].nil?
get(__method__, opts)
end
|
#get_tickets_by_query(opts) ⇒ Object
45
46
47
48
49
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 45
def get_tickets_by_query(opts)
opts[:table_name] = opts[:project]
opts[:display_value] = TicketAbstractorClient.configuration.snow_display_value if opts[:display_value].nil?
get(__method__, opts)
end
|
#get_users(opts) ⇒ Object
51
52
53
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 51
def get_users(opts)
get(__method__, opts)
end
|
#update_ticket(ticket) ⇒ Object
71
72
73
74
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 71
def update_ticket(ticket)
ticket.sys_id = get_ticket_sys_id(ticket_id: ticket.ticket_id, table_name: ticket.project)
post(__method__, build_ticket_params(ticket))
end
|
#update_ticket_status(ticket) ⇒ Object
76
77
78
79
|
# File 'lib/ticket_abstractor_client/service_now/client.rb', line 76
def update_ticket_status(ticket)
ticket.sys_id = get_ticket_sys_id(ticket_id: ticket.ticket.id, table_name: ticket.project)
post(:update_ticket, build_status_params(ticket))
end
|