create.rb 766 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 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 ticket. If this is present but empty, the mutation was successful but the user has no rights to view the new ticket.'
  7. def self.authorize(_obj, ctx)
  8. ctx.current_user.permissions?(['ticket.agent', 'ticket.customer'])
  9. end
  10. def resolve(input:)
  11. {
  12. ticket: Service::Ticket::Create
  13. .new(current_user: context.current_user)
  14. .execute(ticket_data: input)
  15. }
  16. end
  17. end
  18. end