Skip to content

Instantly share code, notes, and snippets.

@syastrebov
Last active February 18, 2016 16:38
Show Gist options
  • Save syastrebov/a6450ce34e511a892761 to your computer and use it in GitHub Desktop.
Save syastrebov/a6450ce34e511a892761 to your computer and use it in GitHub Desktop.
New ticket form simple docs
{
"attachments": [
{"blob_auth": "AAAAAAAAAAAAAAAAAA"},
{"blob_auth": "BBBBBBBBBBBBBBBBBB", "is_inline": true}
]
}
{
"person": {
"name": "Changed Name"
},
"subject": "Modified subject",
"department": 2,
"product": 2,
"priority": 3,
"cc": ["agent@deskpro.dev", "user@deskpro.dev"],
"labels": ["ticket label 1", "ticket label 2"],
"fields": {
"1": "2",
"5": "2016-02-09 17:28:00",
"6": "inline text",
"7": "textarea text",
"8": ["10", "11"]
},
"user_fields": {
"1": "2",
"5": "2016-02-09 17:28:00",
"6": "inline text",
"7": "textarea text"
},
"organization_fields": {
"1": "2",
"5": "2016-02-09 17:28:00",
"6": "inline text",
"7": "textarea text"
},
"message": {
"message": "my text message",
"format": "text"
},
"attachments": [
{"blob_auth": "AAAAAAAAAAAAAAAAAA"},
{"blob_auth": "BBBBBBBBBBBBBBBBBB", "is_inline": true}
]
}
{
"data": {
"id": 5,
"ref": "TPDI-0173-OXYX",
"auth": "8HRKHZRAD5SR4TP",
"parent_ticket": null,
"language": null,
"department": 2,
"category": null,
"priority": 3,
"workflow": null,
"product": 2,
"person": 1,
"person_email": "admin@deskpro.dev",
"agent": null,
"agent_team": null,
"organization": 1,
"linked_chat": null,
"email_account": null,
"email_account_address": "",
"creation_system": "unknown",
"creation_system_option": "",
"ticket_hash": "none",
"status": "awaiting_agent",
"hidden_status": null,
"is_hold": false,
"urgency": 1,
"feedback_rating": null,
"date_feedback_rating": null,
"date_created": "2016-02-08T13:42:22+0000",
"date_resolved": null,
"date_archived": null,
"date_first_agent_assign": null,
"date_first_agent_reply": "2016-02-08T13:42:23+0000",
"date_last_agent_reply": "2016-02-08T13:42:23+0000",
"date_last_user_reply": "2016-02-08T13:42:22+0000",
"date_agent_waiting": null,
"date_user_waiting": null,
"date_status": "2016-02-08T13:42:22+0000",
"total_user_waiting": 0,
"total_to_first_reply": 1,
"locked_by_agent": null,
"date_locked": null,
"has_attachments": true,
"subject": "Modified subject",
"original_subject": "Sample Ticket",
"properties": null,
"problems": [],
"count_agent_replies": 1,
"count_user_replies": 0,
"worst_sla_status": null,
"waiting_times": null,
"ticket_slas": [],
"sent_to_address": [],
"fields": {
"1": {
"value": [
2
],
"detail": {
"1": {
"id": 1,
"title": "Desired Sizes"
}
}
},
"5": {
"value": "2016-02-09T17:28:00+0000"
},
"6": {
"value": "inline text"
},
"7": {
"value": "textarea text"
}
},
"labels": [
"ticket label 1",
"ticket label 2"
],
"participants": [
3
],
"followers": [
2
],
"child_tickets": [],
"sibling_tickets": []
},
"meta": [],
"linked": []
}
{
"message": {
"message": "<p>my html message</p>",
"format": "html"
}
}
{
"person": "unknown-email@deskpro.dev"
}
{
"person": 2
}
{
"person": {
"email": "new-user@deskpro.dev",
"name": "Some NewUser"
}
}
{
"message": {
"message": "my text message",
"format": "text"
}
}
{
"status": 400,
"code": "invalid_input",
"message": "Request input is invalid.",
"errors": {
"fields": {
"subject": {
"errors": [
{
"code": "This value should not be null.",
"message": "This value should not be null."
}
]
}
}
}
}
@syastrebov
Copy link
Author

The new ticket form has custom department layouts and number of field types that you can customize in the admin interface. So POST /api/v2/ticket_forms/{context} endpoint params depend on which department you will pass in the request. I reused the existing ticket form type class from the portal (/new-ticket) so the api works the same way as in the portal with the same form structure for now. It has some odd parts which i think should be discussed and improved in future.

  1. Use POST /api/v2/ticket_forms/{context} to create a new ticket and PUT /api/v2/ticket_forms/{context}/{id} to modify an existing one. Context could be "user" or "agent".
  2. If ticket layout doesn't have such field that you have in the request it will be just skipped (no validation errors) for now.
  3. To set ticket message use message.message and message.format ("html" or "text") fields.
  4. To set ticket attachments you should pass blob auth code and you additional "is_inline" param for images inside html message.
  5. CC - array of emails (they will be added as participants or followers).
  6. Labels - array of label names.
  7. You can set ticket person via person field. It can accept id (int), email (string) or {"email": "xxx", "name": "xxx"} (object).
    • You can pass email or name optionally for object type.
    • If no person info is provided then person entity will be get from the session.
    • If you pass unknown email then a new user will be created.
  8. Custom fields have name pattern fields: {{id}: "value"}, user_fields: {{id}: "value"} or organization_fields: {{id}: "value"} where id is custom_def_ticket row id. Types of fields:
    • Choice type (select, multi select, checkbox and radio):
      {fields: {"1": "2"}}
      or if multiple values:
      {fields: {"2": ["2", "3"]}}
    • Date/DateTime type:
      {fields: {"3": "2016-02-09 17:28:00"}
    • Text/Textarea type:
      {fields: {"4": "inline text"}
  9. Validation errors have the same structure as all DeskPRO api endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment