From 97c3da6f93fa65fc211f5d86304873fec2111b4c Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Thu, 15 May 2025 14:49:26 +0700 Subject: [PATCH] update automation rules payload for developer docs --- swagger/definitions/index.yml | 2 + .../definitions/resource/automation_rule.yml | 129 +++++++----- .../resource/contactable_inboxes_response.yml | 7 + .../application/automation_rule/index.yml | 5 +- .../application/contactable_inboxes/get.yml | 2 +- swagger/swagger.json | 187 +++++++++++------- 6 files changed, 209 insertions(+), 123 deletions(-) create mode 100644 swagger/definitions/resource/contactable_inboxes_response.yml diff --git a/swagger/definitions/index.yml b/swagger/definitions/index.yml index 4985014d5..4e26c2c7e 100644 --- a/swagger/definitions/index.yml +++ b/swagger/definitions/index.yml @@ -223,3 +223,5 @@ contact_conversation_message: $ref: ./resource/contact_conversation_message.yml contact_conversations_response: $ref: ./resource/contact_conversations_response.yml +contactable_inboxes_response: + $ref: ./resource/contactable_inboxes_response.yml diff --git a/swagger/definitions/resource/automation_rule.yml b/swagger/definitions/resource/automation_rule.yml index 18c4a67f5..3df291221 100644 --- a/swagger/definitions/resource/automation_rule.yml +++ b/swagger/definitions/resource/automation_rule.yml @@ -1,53 +1,82 @@ type: object properties: payload: - type: array - items: - type: object - properties: - id: - type: integer - description: The ID of the automation rule - event_name: - type: string - description: Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created) - enum: - - conversation_created - - conversation_updated - - message_created - example: message_created - name: - type: string - description: The name of the rule - example: Add label on message create event - description: - type: string - description: Description to give more context about the rule - example: Add label support and sales on message create event if incoming message content contains text help - active: - type: boolean - description: Enable/disable automation rule - actions: - type: array - description: Array of actions which we perform when condition matches - items: - type: object - example: - action_name: add_label - action_params: - - support - - sales - conditions: - type: array - description: Array of conditions on which conversation/message filter would work - items: - type: object - example: - attribute_key: content - filter_operator: contains - values: - - help - query_operator: nil - account_id: - type: integer - description: Account Id + oneOf: + - type: array + items: + $ref: '#/components/schemas/automation_rule_item' + description: Array of automation rules (for listing endpoint) + - $ref: '#/components/schemas/automation_rule_item' + description: Single automation rule (for show/create/update endpoints) + +# Schema for an individual automation rule (used by all automation rule endpoints) +automation_rule_item: + type: object + properties: + id: + type: integer + description: The ID of the automation rule + account_id: + type: integer + description: Account Id + name: + type: string + description: The name of the rule + example: Add label on message create event + description: + type: string + description: Description to give more context about the rule + example: Add label support and sales on message create event if incoming message content contains text help + event_name: + type: string + description: Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created) + enum: + - conversation_created + - conversation_updated + - message_created + example: message_created + conditions: + type: array + description: Array of conditions on which conversation/message filter would work + items: + type: object + properties: + values: + type: array + items: + type: string + attribute_key: + type: string + query_operator: + type: string + filter_operator: + type: string + example: + attribute_key: content + filter_operator: contains + values: + - help + query_operator: nil + actions: + type: array + description: Array of actions which we perform when condition matches + items: + type: object + properties: + action_name: + type: string + action_params: + type: array + items: + type: string + example: + action_name: add_label + action_params: + - support + - sales + created_on: + type: integer + description: The timestamp when the rule was created + active: + type: boolean + description: Enable/disable automation rule diff --git a/swagger/definitions/resource/contactable_inboxes_response.yml b/swagger/definitions/resource/contactable_inboxes_response.yml new file mode 100644 index 000000000..5af3e7dc8 --- /dev/null +++ b/swagger/definitions/resource/contactable_inboxes_response.yml @@ -0,0 +1,7 @@ +type: object +properties: + payload: + type: array + items: + $ref: '#/components/schemas/contact_inbox' + description: List of contactable inboxes for the contact \ No newline at end of file diff --git a/swagger/paths/application/automation_rule/index.yml b/swagger/paths/application/automation_rule/index.yml index e1b78fa37..b5193e1af 100644 --- a/swagger/paths/application/automation_rule/index.yml +++ b/swagger/paths/application/automation_rule/index.yml @@ -14,10 +14,7 @@ responses: content: application/json: schema: - type: array - description: Array of all automation rules - items: - $ref: '#/components/schemas/automation_rule' + $ref: '#/components/schemas/automation_rule' '403': description: Access denied content: diff --git a/swagger/paths/application/contactable_inboxes/get.yml b/swagger/paths/application/contactable_inboxes/get.yml index 3f56f6939..357c84597 100644 --- a/swagger/paths/application/contactable_inboxes/get.yml +++ b/swagger/paths/application/contactable_inboxes/get.yml @@ -20,7 +20,7 @@ get: content: application/json: schema: - $ref: '#/components/schemas/contactable_inboxes' + $ref: '#/components/schemas/contactable_inboxes_response' '401': description: Authentication error content: diff --git a/swagger/swagger.json b/swagger/swagger.json index 00378f206..1b42a52f4 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -3298,7 +3298,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/contactable_inboxes" + "$ref": "#/components/schemas/contactable_inboxes_response" } } } @@ -3360,11 +3360,7 @@ "content": { "application/json": { "schema": { - "type": "array", - "description": "Array of all automation rules", - "items": { - "$ref": "#/components/schemas/automation_rule" - } + "$ref": "#/components/schemas/automation_rule" } } } @@ -7599,72 +7595,115 @@ "type": "object", "properties": { "payload": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "description": "The ID of the automation rule" + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/components/schemas/automation_rule_item" }, - "event_name": { - "type": "string", - "description": "Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created)", - "enum": [ - "conversation_created", - "conversation_updated", - "message_created" + "description": "Array of automation rules (for listing endpoint)" + }, + { + "$ref": "#/components/schemas/automation_rule_item" + } + ] + } + }, + "automation_rule_item": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The ID of the automation rule" + }, + "account_id": { + "type": "integer", + "description": "Account Id" + }, + "name": { + "type": "string", + "description": "The name of the rule", + "example": "Add label on message create event" + }, + "description": { + "type": "string", + "description": "Description to give more context about the rule", + "example": "Add label support and sales on message create event if incoming message content contains text help" + }, + "event_name": { + "type": "string", + "description": "Automation Rule event, on which we call the actions(conversation_created, conversation_updated, message_created)", + "enum": [ + "conversation_created", + "conversation_updated", + "message_created" + ], + "example": "message_created" + }, + "conditions": { + "type": "array", + "description": "Array of conditions on which conversation/message filter would work", + "items": { + "type": "object", + "properties": { + "values": { + "type": "array", + "items": { + "type": "string" + } + }, + "attribute_key": { + "type": "string" + }, + "query_operator": { + "type": "string" + }, + "filter_operator": { + "type": "string" + } + }, + "example": { + "attribute_key": "content", + "filter_operator": "contains", + "values": [ + "help" ], - "example": "message_created" - }, - "name": { - "type": "string", - "description": "The name of the rule", - "example": "Add label on message create event" - }, - "description": { - "type": "string", - "description": "Description to give more context about the rule", - "example": "Add label support and sales on message create event if incoming message content contains text help" - }, - "active": { - "type": "boolean", - "description": "Enable/disable automation rule" - }, - "actions": { - "type": "array", - "description": "Array of actions which we perform when condition matches", - "items": { - "type": "object", - "example": { - "action_name": "add_label", - "action_params": [ - "support", - "sales" - ] - } - } - }, - "conditions": { - "type": "array", - "description": "Array of conditions on which conversation/message filter would work", - "items": { - "type": "object", - "example": { - "attribute_key": "content", - "filter_operator": "contains", - "values": [ - "help" - ], - "query_operator": "nil" - } - } - }, - "account_id": { - "type": "integer", - "description": "Account Id" + "query_operator": "nil" } } + }, + "actions": { + "type": "array", + "description": "Array of actions which we perform when condition matches", + "items": { + "type": "object", + "properties": { + "action_name": { + "type": "string" + }, + "action_params": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "example": { + "action_name": "add_label", + "action_params": [ + "support", + "sales" + ] + } + } + }, + "created_on": { + "type": "integer", + "description": "The timestamp when the rule was created" + }, + "active": { + "type": "boolean", + "description": "Enable/disable automation rule" } } } @@ -11250,6 +11289,18 @@ "description": "List of conversations for the contact" } } + }, + "contactable_inboxes_response": { + "type": "object", + "properties": { + "payload": { + "type": "array", + "items": { + "$ref": "#/components/schemas/contact_inbox" + }, + "description": "List of contactable inboxes for the contact" + } + } } }, "parameters": {