class Servicenow::Change

This class represents a ServiceNow Change. A Change is a local representation of the state of the remote. For writing operations, the local is updated, and then a request to update the remote is sent

Public Instance Methods

add_work_notes(notes) click to toggle source

@param [String] notes the notes to post

@return [Servicenow::Change] the change

# File lib/servicenow/change.rb, line 15
def add_work_notes(notes)
  url = format('%s/change_request/%s', client.snow_table_url, sys_id)

  query = {
    work_notes: notes
  }

  client.send_request(url, query, :patch)
  change
end
end_change(extra={}) click to toggle source

@param [Hash] extra options to override default query, or non-standard

parameters / columns to send to the Change table

@return [Servicenow::Change] the change

# File lib/servicenow/change.rb, line 48
def end_change(extra={})
  url = format('%s/change_request/%s', client.snow_table_url, sys_id)

  query = {
    state: states['work complete'],
    work_end: Time.now.utc
  }.merge(extra)

  client.send_request(url, query, :patch)
  change
end
reload() click to toggle source

This is a convenience method only. It cannot be used to reload a Change *in place* but only to return a new copy of the same Change from the server

@return [Servicenow::Change] a refreshed copy of this Change

# File lib/servicenow/change.rb, line 66
def reload
  client.get_change(number)
end
start(extra={}) click to toggle source

@param [Hash] extra options to override default query, or non-standard

parameters / columns to send to the Change table

@return [Servicenow::Change] the change

# File lib/servicenow/change.rb, line 31
def start(extra={})
  url = format('%s/change_request/%s', client.snow_table_url, sys_id)

  query = {
    state: states['work in progress'],
    work_start: Time.now.utc
  }.merge(extra)

  client.send_request(url, query, :patch)
  change
end

Private Instance Methods

client() click to toggle source
# File lib/servicenow/change.rb, line 75
def client
  @_client = Servicenow::Client.new if @_client.nil?
  @_client
end
completion_codes() click to toggle source
# File lib/servicenow/change.rb, line 92
def completion_codes
  {
    'success' => 11
  }
end
states() click to toggle source
# File lib/servicenow/change.rb, line 81
def states
  {
    'open' => 1,
    'work in progress' => 2,
    'work complete' => 11,
    'work incomplete' => 4,
    'waiting on user' => -5
  }
end