{
    "openapi": "3.0.0",
    "info": {
        "title": "Motoring Assistance API",
        "description": "Welcome to the Motoring Assistance API portal. To access the Motoring Assistance APIs an API Key is required. An API key will be assigned as part of the Motoring Assistance onboarding process. Note: Please use the Development/Test environment/server for creating test records/policies.",
        "contact": {
            "email": "tech@motoringassistance.com"
        },
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "https://devquote.motoringassistance.com/api",
            "description": "Development/Test API Server"
        },
        {
            "url": "https://quote.motoringassistance.com/api",
            "description": "Production API Server"
        }
    ],
    "paths": {
        "/packages": {
            "get": {
                "tags": [
                    "Packages"
                ],
                "summary": "Get Available Motoring Assistance Breakdown Policy Packages",
                "description": "Returns the current active breakdown policy packages and services.",
                "operationId": "getPackage",
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "packages": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer",
                                                        "example": "1"
                                                    },
                                                    "name": {
                                                        "type": "string",
                                                        "example": "Saver"
                                                    },
                                                    "price": {
                                                        "description": "Policy price in pence",
                                                        "type": "string",
                                                        "example": "2900"
                                                    },
                                                    "excess": {
                                                        "description": "Excess cost in pence",
                                                        "type": "integer",
                                                        "example": "5000"
                                                    },
                                                    "services": {
                                                        "type": "array",
                                                        "items": {
                                                            "properties": {
                                                                "name": {
                                                                    "type": "string",
                                                                    "example": "Roadside Assistance"
                                                                },
                                                                "description": {
                                                                    "type": "string",
                                                                    "example": "Covered for up to half an hour of assistance at the scene of the roadside"
                                                                }
                                                            },
                                                            "type": "object"
                                                        }
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Unauthorized"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "APIKey": []
                    }
                ]
            }
        },
        "/policy": {
            "post": {
                "tags": [
                    "Policies"
                ],
                "summary": "Create a New Motoring Assistance Breakdown Policy",
                "description": "Stores a new breakdown policy and triggers an email send to the customer with their policy documents attached. API response returns the customers new policy reference number",
                "operationId": "storePolicy",
                "requestBody": {
                    "description": "Store new breakdown policy",
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "package_id",
                                    "policy_start_date",
                                    "customer",
                                    "vehicles"
                                ],
                                "properties": {
                                    "package_id": {
                                        "description": "Breakdown package selected. 1 = Saver, 2 = Premium, 3 = Premium Plus",
                                        "type": "integer",
                                        "example": "1"
                                    },
                                    "policy_start_date": {
                                        "description": "Date the policy will start. Note: Has to be within the next 2 months.",
                                        "type": "string",
                                        "format": "date",
                                        "example": "2021-12-30"
                                    },
                                    "policy_end_date": {
                                        "description": "Date the policy will End.",
                                        "type": "string",
                                        "format": "date",
                                        "example": "2022-12-30"
                                    },
                                    "term": {
                                        "description": "Policy term length in months",
                                        "type": "integer",
                                        "example": "3"
                                    },
                                    "partner_reference": {
                                        "description": "Partner Reference/Policy Number",
                                        "type": "string",
                                        "example": "123abc"
                                    },
                                    "partner_handler_agent": {
                                        "description": "Partner Agent / Handler",
                                        "type": "string",
                                        "example": "John Smith"
                                    },
                                    "customer": {
                                        "required": [
                                            "firstname",
                                            "surname",
                                            "email",
                                            "phone",
                                            "postcode",
                                            "address_line_1"
                                        ],
                                        "properties": {
                                            "firstname": {
                                                "type": "string",
                                                "example": "Andy"
                                            },
                                            "surname": {
                                                "type": "string",
                                                "example": "Ritchie"
                                            },
                                            "dob": {
                                                "type": "string",
                                                "format": "date",
                                                "example": "1985-06-18"
                                            },
                                            "email": {
                                                "type": "string",
                                                "format": "email",
                                                "example": "test@motoringassistance.com"
                                            },
                                            "phone": {
                                                "type": "string",
                                                "example": "07777111222"
                                            },
                                            "postcode": {
                                                "type": "string",
                                                "example": "OL1 2PA"
                                            },
                                            "address_line_1": {
                                                "type": "string",
                                                "example": "1 Furtherwood Rd"
                                            },
                                            "address_line_2": {
                                                "type": "string",
                                                "example": "Chadderton"
                                            },
                                            "address_line_3": {
                                                "type": "string",
                                                "example": null
                                            },
                                            "city": {
                                                "type": "string",
                                                "example": "Oldham"
                                            }
                                        },
                                        "type": "object"
                                    },
                                    "vehicles": {
                                        "type": "array",
                                        "items": {
                                            "required": [
                                                "make",
                                                "model",
                                                "year",
                                                "vrm"
                                            ],
                                            "properties": {
                                                "make": {
                                                    "type": "string",
                                                    "example": "Ford"
                                                },
                                                "model": {
                                                    "type": "string",
                                                    "example": "Fiesta"
                                                },
                                                "year": {
                                                    "type": "string",
                                                    "format": "year",
                                                    "example": "2009"
                                                },
                                                "fuel": {
                                                    "type": "string",
                                                    "example": "Petrol"
                                                },
                                                "transmission": {
                                                    "type": "string",
                                                    "example": "Manual"
                                                },
                                                "vrm": {
                                                    "type": "string",
                                                    "example": "WJ09VMX"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Policy created"
                                        },
                                        "policy_id": {
                                            "type": "integer",
                                            "example": 123
                                        },
                                        "policy_ref": {
                                            "type": "string",
                                            "example": "26550331"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "error"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Customer email is required"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Unauthorized"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "APIKey": []
                    }
                ]
            }
        },
        "/policy/{policy_id}": {
            "put": {
                "tags": [
                    "Policies"
                ],
                "summary": "Update an Existing Motoring Assistance Breakdown Policy",
                "description": "Updates an existing breakdown policy and triggers an email send to the customer with their updated policy documents attached.",
                "operationId": "updatePolicy",
                "parameters": [
                    {
                        "name": "policy_id",
                        "in": "path",
                        "description": "policy_id of Policy to be updated",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "description": "Update an existing breakdown policy",
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "package_id",
                                    "policy_start_date",
                                    "customer",
                                    "vehicles"
                                ],
                                "properties": {
                                    "package_id": {
                                        "description": "Breakdown package selected. 1 = Saver, 2 = Premium, 3 = Premium Plus",
                                        "type": "integer",
                                        "example": "1"
                                    },
                                    "policy_start_date": {
                                        "description": "Date the policy will start. Note: Has to be within the next 2 months.",
                                        "type": "string",
                                        "format": "date",
                                        "example": "2021-12-30"
                                    },
                                    "policy_end_date": {
                                        "description": "Date the policy will End.",
                                        "type": "string",
                                        "format": "date",
                                        "example": "2022-12-30"
                                    },
                                    "term": {
                                        "description": "Policy term length in months",
                                        "type": "integer",
                                        "example": "3"
                                    },
                                    "partner_reference": {
                                        "description": "Partner Reference/Policy Number",
                                        "type": "string",
                                        "example": "123abc"
                                    },
                                    "customer": {
                                        "required": [
                                            "firstname",
                                            "surname",
                                            "email",
                                            "phone",
                                            "postcode",
                                            "address_line_1"
                                        ],
                                        "properties": {
                                            "firstname": {
                                                "type": "string",
                                                "example": "Andy"
                                            },
                                            "surname": {
                                                "type": "string",
                                                "example": "Ritchie"
                                            },
                                            "dob": {
                                                "type": "string",
                                                "format": "date",
                                                "example": "1985-06-18"
                                            },
                                            "email": {
                                                "type": "string",
                                                "format": "email",
                                                "example": "test@motoringassistance.com"
                                            },
                                            "phone": {
                                                "type": "string",
                                                "example": "07777111222"
                                            },
                                            "postcode": {
                                                "type": "string",
                                                "example": "OL1 2PA"
                                            },
                                            "address_line_1": {
                                                "type": "string",
                                                "example": "1 Furtherwood Rd"
                                            },
                                            "address_line_2": {
                                                "type": "string",
                                                "example": "Chadderton"
                                            },
                                            "address_line_3": {
                                                "type": "string",
                                                "example": null
                                            },
                                            "city": {
                                                "type": "string",
                                                "example": "Oldham"
                                            }
                                        },
                                        "type": "object"
                                    },
                                    "vehicles": {
                                        "type": "array",
                                        "items": {
                                            "required": [
                                                "make",
                                                "model",
                                                "year",
                                                "vrm"
                                            ],
                                            "properties": {
                                                "make": {
                                                    "type": "string",
                                                    "example": "Ford"
                                                },
                                                "model": {
                                                    "type": "string",
                                                    "example": "Fiesta"
                                                },
                                                "year": {
                                                    "type": "string",
                                                    "format": "year",
                                                    "example": "2009"
                                                },
                                                "fuel": {
                                                    "type": "string",
                                                    "example": "Petrol"
                                                },
                                                "transmission": {
                                                    "type": "string",
                                                    "example": "Manual"
                                                },
                                                "vrm": {
                                                    "type": "string",
                                                    "example": "WJ09VMX"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Policy updated"
                                        },
                                        "policy_id": {
                                            "type": "integer",
                                            "example": 123
                                        },
                                        "policy_ref": {
                                            "type": "string",
                                            "example": "26550331"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "error"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Customer email is required"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "error"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Policy ID not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Unauthorized"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "APIKey": []
                    }
                ]
            },
            "delete": {
                "tags": [
                    "Policies"
                ],
                "summary": "Cancel / Deactivate a Breakdown Policy",
                "description": "Deactivates a breakdown policy for the given policy_id. API response returns the deactivated policy reference number",
                "operationId": "cancelPolicy",
                "parameters": [
                    {
                        "name": "policy_id",
                        "in": "path",
                        "description": "policy_id of Policy to be Cancelled / Deactivated",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Policy deactivated"
                                        },
                                        "policy_id": {
                                            "type": "integer",
                                            "example": 123
                                        },
                                        "policy_ref": {
                                            "type": "string",
                                            "example": "26550331"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "error"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Policy ID not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Unauthorized"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "APIKey": []
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "APIKey": {
                "type": "apiKey",
                "description": "API Key required to allow access to API. An API key will be assigned as part of the Motoring Assistance onboarding process.",
                "name": "x-api-key",
                "in": "header"
            }
        }
    }
}