create.rb 626 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Create < BaseMutation
  4. description 'Create a new ticket.'
  5. argument :input, Gql::Types::Input::Ticket::CreateInputType, description: 'The ticket data'
  6. field :ticket, Gql::Types::TicketType, description: 'The created user.'
  7. def self.authorize(_obj, ctx)
  8. ctx[:current_user].permissions?(['ticket.agent', 'ticket.customer'])
  9. end
  10. def resolve(input:)
  11. { ticket: Service::Ticket::Create.new(current_user: context.current_user).execute(ticket_data: input.to_h) }
  12. end
  13. end
  14. end