Skip to content

Instantly share code, notes, and snippets.

@thorpj
Created April 1, 2020 03:49
Show Gist options
  • Save thorpj/d602bdd8b93ff9eb9e2fe288244f1d3b to your computer and use it in GitHub Desktop.
Save thorpj/d602bdd8b93ff9eb9e2fe288244f1d3b to your computer and use it in GitHub Desktop.
class BookInPartJob < ActiveJob::Base
queue_as :default
def perform(ticket_number, message, all_parts_received, warranty_reference, vendor, title)
ticket = Api::Autotask::Ticket.find_by_ticket(ticket_number)
api_warranty_reference = ticket.warranty_reference.value
if api_warranty_reference.exclude? warranty_reference
ticket.warranty_reference = "#{ticket.warranty_reference.value} #{warranty_reference}".strip
end
if all_parts_received
ticket.status = ticket.status = 'Parts/Materials Received'
end
ticket_note = Api::Autotask::TicketNote.new
ticket_note.description = "Ref: #{warranty_reference}\n#{message}"
ticket_note.ticket_id = ticket.id.value
ticket_note.title = title
ticket_note.note_type = 'Task Summary'
ticket_note.publish = 'Internal Project Team'
ticket_note.create
ticket.update
ticket
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment