{
    "openapi": "3.1.0",
    "info": {
        "title": "Pippasync Notification Service",
        "version": "0.0.1"
    },
    "servers": [
        {
            "url": "https://pippasync-notification-service.test/api",
            "description": "Local"
        }
    ],
    "paths": {
        "/v1/notification/send": {
            "post": {
                "operationId": "notification.sendNotification",
                "description": "template_name decides payload structure:\n\n- order \u2192 requires dynamic_data\n- otp \u2192 requires otp\n- invitation_link \u2192 requires invitation_link",
                "summary": "Send Notification",
                "tags": [
                    "Notification"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SendNotificationRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Notification created successfully"
                                        },
                                        "data": {
                                            "anyOf": [
                                                {
                                                    "type": "object",
                                                    "properties": {
                                                        "error": {
                                                            "type": "string"
                                                        },
                                                        "code": {
                                                            "type": "integer",
                                                            "const": 500
                                                        },
                                                        "data": {
                                                            "type": "array",
                                                            "items": {
                                                                "type": "string"
                                                            },
                                                            "minItems": 0,
                                                            "maxItems": 0,
                                                            "additionalItems": false
                                                        }
                                                    },
                                                    "required": [
                                                        "error",
                                                        "code",
                                                        "data"
                                                    ]
                                                },
                                                {
                                                    "type": "object"
                                                },
                                                {
                                                    "type": "boolean"
                                                }
                                            ]
                                        }
                                    },
                                    "required": [
                                        "message",
                                        "data"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/v1/notification/template": {
            "get": {
                "operationId": "template.index",
                "tags": [
                    "Template"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "template.store",
                "tags": [
                    "Template"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/TemplateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/v1/notification/template/{id}": {
            "put": {
                "operationId": "template.update",
                "tags": [
                    "Template"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/TemplateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            },
            "delete": {
                "operationId": "template.destroy",
                "tags": [
                    "Template"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "SendNotificationRequest": {
                "type": "object",
                "properties": {
                    "subject": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "body": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "recipients": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "channels": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "required": [
                    "recipients",
                    "channels"
                ],
                "title": "SendNotificationRequest"
            },
            "TemplateRequest": {
                "type": "object",
                "properties": {
                    "notification_type_id": {
                        "type": "integer"
                    },
                    "subject": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "body": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "email_view": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "required_fields": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "required": [
                    "notification_type_id",
                    "required_fields"
                ],
                "title": "TemplateRequest"
            }
        },
        "responses": {
            "ValidationException": {
                "description": "Validation error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Errors overview."
                                },
                                "errors": {
                                    "type": "object",
                                    "description": "A detailed description of each field that failed validation.",
                                    "additionalProperties": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "required": [
                                "message",
                                "errors"
                            ]
                        }
                    }
                }
            }
        }
    }
}