# Vendor MasterAPI

Table of Content

* Endpoints
* Authentication
* Type of Leads
* Request Object for `lead` Type
  * List of Accepted `case_type` values
  * Anatomy of `fields` array
  * The `ref` guide
  * Response Object
  * Understanding Responses
  * References for `case_type` - Auto Accident
    * Sample Request
  * References for `case_type` - Workers Compensation
    * Sample Request

## Endpoints <a href="#user-content-endpoints" id="user-content-endpoints"></a>

| Environment | Link                                               | Description                                                                                |
| ----------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Staging     | <https://staging.api.accident.com/api/lead-create> | Staging environment should be used for testing while integration.                          |
| Production  | <https://api.accident.com/api/lead-create>         | Production environment should be used once the integration is tested perfectly on staging. |

## Authentication <a href="#user-content-authentication" id="user-content-authentication"></a>

The `api-key` and `api-token` header should be set in order to make requests to our API.\
&#x20;These credentials will be provided to you for both production and staging servers.

```
#!curl
$ curl --location --request POST '' 

--header 'api-key: XXXXXXXXX' 

--header 'api-token: XXXXXXXXX'
```

## Request for `lead` Type <a href="#user-content-request-for-lead-type" id="user-content-request-for-lead-type"></a>

The request body for `type` - `lead` should comply with these rules.

| Name              | Required | Type        | Description                                                                                                                                                  |
| ----------------- | -------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `arrived_at`      | True     | Timestamp   | Should be in `UTC`.                                                                                                                                          |
| `test_mode`       | false    | Boolean     | `Default : false`. Should be set as true if the API call is used to send test data.                                                                          |
| `lead_first_name` | false    | Text        | First name of the lead.                                                                                                                                      |
| `lead_last_name`  | false    | Text        | Last name of the lead.                                                                                                                                       |
| `lead_email`      | True     | Email       | Email Address of the Lead.                                                                                                                                   |
| `lead_phone`      | True     | Phone       | Phone number of the lead. This can be either in US Domestic format ( Eg: `(541) 754-3010` ) or else in E.164 format ( Eg: `+14155552671` )                   |
| `case_type`       | True     | Text        | The injury type identified in the phone conversation. For Admediary, we are accepting only MVA leads and this should be specified as `Auto Accident`         |
| `zip_code`        | True     | US Zip Code | Location of the Lead                                                                                                                                         |
| `time_to_call`    | False    | Text        | If the lead has a time preference for callback, pass that in this parameter.                                                                                 |
| `fields`          | True     | Array       | The request body for each case type differs as it has a specific set of references for each case type. Each element in the `fields` array is detailed below. |

### List of Accepted `case_type` values <a href="#user-content-list-of-accepted-case_type-values" id="user-content-list-of-accepted-case_type-values"></a>

Mentioned below are `case_type` values that we support. For any `case_type` that doesn’t match with items from this list, should be entered as meaningful text. For all such new `case_type` the request body should have references of `Auto Accident`. The sample for the request is provided later in this document.

| Case Type     | Value           | Description                           |
| ------------- | --------------- | ------------------------------------- |
| Auto Accident | `Auto Accident` | If the lead case is an auto accident. |

### Anatomy of fields array <a href="#user-content-anatomy-of-fields-array" id="user-content-anatomy-of-fields-array"></a>

The fields array in the request contains objects. Each of these objects has three properties

| Property | Required | Description                                                                                                                  |
| -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `ref`    | True     | Key to identifying questions to our internal                                                                                 |
| `title`  | False    | If you believe that you want to share the question that was used, it should be passed in this field.                         |
| `answer` | True     | The answer comes from a set of choices or adheres to a type. The " `ref` guide " section explains the `ref` and their rules. |

Example :

```
{
    "ref":"have_attorney",
    "title": "Do you have an attorney representing you for this matter?",
    "answer" : "No"
}
```

### The `ref` guide <a href="#user-content-the-ref-guide" id="user-content-the-ref-guide"></a>

Below are all of the `ref` values that can be used in the `fields` array. Each `ref` has a type and can be a choice of options, a boolean or text. We have included the default question that will get considered should the ref object have a missing `title` property. The explanation of which `ref` objects to be used for each `case_type` is mentioned later in the document. The answers in the field object should come strictly from the set of values provided below.

| Ref Key                  | Type        | Choices                                                                                                                  | Description                                                                                                                                                                                                                            | Default Question                                                         |
| ------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `incident_date_option_b` | Enum / Text | `Less than 1 year` , `Less than 2 years` , `Less than 3 years`, MM-DD-YY or MM-DD-YYYY or MM-YYYY or YYYY                | Single Choice. Should be used for date questions. The actual date can be specified in the mentioned format.                                                                                                                            | `How long ago did the injury happen?`                                    |
| `have_attorney`          | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. Whether lead already has an attorney. In case of unsure, the answer to choose should be `No`                                                                                                                            | `Do you already have a lawyer representing you?`                         |
| `primary_injury`         | Enum        | `Back or Neck Pain`,`Broken Bones` , `Cuts and Bruises`, `Headaches` , `Memory Loss` , `Loss of Limb` , `Other`          | Single Choice. Please use the closest possible injury type, If the answer from the caller doesn’t match the list or there is something additional to add for a particular choice, `comments` ref can be used to furnish those details. | `What is the primary type of injury?`                                    |
| `doctor_treatment`       | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. If the lead has undergone any treatment, hospitalization etc. In case of unsure, the answer to choose should be `No`                                                                                                    | `Did the injury require hospitalization, medical treatment, or surgery?` |
| `charges_filed`          | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. If the lead has lodged a police complaint. In case of unsure, the answer to choose should be `No`                                                                                                                       | `Was a police report filed?`                                             |
| `action_taken`           | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. If the lead has filed a case etc. In case of unsure, the answer to choose should be `No`                                                                                                                                | `Have you taken any action regarding your claim?`                        |
| `were_you_at_fault`      | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. Lead at fault. In case of unsure, the answer to choose should be `No`                                                                                                                                                   | `Were you at fault for the accident?`                                    |
| `were_you_injured`       | Yes/No      | `Yes` , `No`                                                                                                             | Single Choice. Did the lead have any injury?. In case of unsure, the answer to choose should be `Yes`, this field is optional and should be passed only when the lead mentions that they aren’t injured.                               | `Were you injured?`                                                      |
| `injury_cause`           | Text        | `Car Accident`, `Motorcycle Accident`, `Truck Accident`, `Bicycle Accident`, `Pedestrian Accident`, `Passenger Accident` | Text value for what caused the injury                                                                                                                                                                                                  | `What is the cause of your injury?`                                      |
| `missed_work`            | Yes/No      | `Yes`, `No`                                                                                                              | Single Choice. Lead missed work because of the injury. In case of unsure, the answer to choose should be `No`                                                                                                                          | `Did the injury require you to miss work?`                               |
| `terms`                  | Yes/No      | `I agree`, `I do not Agree`                                                                                              | Single Choice. If the lead has lodged a police complaint.                                                                                                                                                                              | `Please read and accept our Terms of Service`                            |
| `comments`               | Text        | NA                                                                                                                       | Text. Details about the case                                                                                                                                                                                                           | `Describe your case`                                                     |

### Response Object <a href="#user-content-response-object" id="user-content-response-object"></a>

Mentioned below are the properties that will be present in the response object.

| Key       | Description                                                                                                                                                       |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`  | `created` - to acknowledge we received the details. `failed` - We received the details but the request was poorly formulated. `error` - Something has gone wrong. |
| `result`  | `success` - we assert that we received this request                                                                                                               |
| `message` | acknowledgment message for the request                                                                                                                            |

Response Skeleton

```
<?xml version="1.0"?>
<response>
<message>Lead generated successfully</message>
<status>created</status>
<result>success</result>
</response>
```

### References for `case_type` - Auto Accident <a href="#user-content-references-for-case_type---auto-accident" id="user-content-references-for-case_type---auto-accident"></a>

The following set of references should be passed for `Auto Accident` case type.

* `incident_date_option_b` - OPTIONAL
* `injury_cause` - OPTIONAL
* `doctor_treatment` - OPTIONAL
* `were_you_at_fault` - OPTIONAL
* `were_you_injured` - OPTIONAL
* `have_attorney` - OPTIONAL
* `primary_injury` - OPTIONAL
* `comments` - OPTIONAL

#### Sample Request - Auto Accident <a href="#user-content-sample-request---auto-accident" id="user-content-sample-request---auto-accident"></a>

```
curl --location --request POST '' 
--header 'api-key: some_key' 
--header 'api-secret: some_secret' 
--header 'Content-Type: application/json' 
--data-raw '{
    "arrived_at":"2020-1-01T10:26:21Z",
    "test_mode":"true",
    "lead_first_name":"Test",
    "lead_last_name":"Lead",
    "lead_email":"testlead@yopmail.com",
    "lead_phone":"9999999999",
    "case_type": "Auto Accident",
    "zip_code":"10027",
    "fields":[
        {
            "ref":"were_you_injured",
            "title": "Were you or a loved one Injured in an Accident that wasn’t your fault?",
            "answer" : "No"
        },
        {
            "ref":"injury_cause",
            "title": "What caused your injury?",
            "answer" : "Motorcycle Accident"
        },
        {
            "ref":"have_attorney",
            "title": "Do you currently have a lawyer representing your claim?",
            "answer" : "No"
        },
        {
            "ref":"primary_injury",
            "title": "Did you sustain any of the following?",
            "answer" : "Headaches"
        },
        {
            "ref":"doctor_treatment",
            "title": "Did the injury require hospitalization, medical treatment, surgery or cause you to miss work?",
            "answer" : " No"
        },
        {
            "ref":"incident_date_option_b",
            "title": "Select Year of Injury",
            "answer" : "2019"
        },
        {
            "ref":"comments",
            "title": "Describe your case",
            "answer" : "test description"
        }
    ]
}
'
```
