# Dates

## Get pickup dates and times

<mark style="color:green;">`POST`</mark> `https://api.zapiet.com/v1.0/pickup/locations/:locationId/calendar`

This endpoint allows you to fetch calendar rules for a specific location&#x20;

#### Path Parameters

| Name                                         | Type   | Description                   |
| -------------------------------------------- | ------ | ----------------------------- |
| locationId<mark style="color:red;">\*</mark> | string | The ID of the Zapiet location |

#### Query Parameters

| Name                                   | Type   | Description                 |
| -------------------------------------- | ------ | --------------------------- |
| shop<mark style="color:red;">\*</mark> | string | The myshopify.com store url |

#### Request Body

| Name         | Type   | Description                                    |
| ------------ | ------ | ---------------------------------------------- |
| shoppingCart | string | The contents of the customers shopping basket. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
	"minDateTime": "2021-05-13 09:00:00",
	"minDate": "2021-05-13",
	"maxDate": null,
	"minTime": ["09", "00"],
	"maxTime": ["17", "00"],
	"disabled": [],
	"interval": 60,
	"daysOfWeek": {
		"sunday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"monday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"tuesday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"wednesday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"thursday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"friday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"saturday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		}
	},
	"timezone": "America\/New_York"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "shoppingCart": [
        {
            "variant_id": 9226255761451,
            "product_id": 852798275627,
            "quantity": 5
        },
        {
            "variant_id": 9226255761452,
            "product_id": 852798275628,
            "quantity": 2
        }
    ]
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
	"minDateTime": "2021-05-13 09:00:00",
	"minDate": "2021-05-13",
	"maxDate": null,
	"minDateSlots" : [],
	"minTime": ["09", "00"],
	"maxTime": ["17", "00"],
	"disabled": [],
	"interval": 60,
	"daysOfWeek": {
		"sunday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"monday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"tuesday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"wednesday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"thursday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"friday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		},
		"saturday": {
			"min": {
				"hour": "09",
				"minute": "00"
			},
			"max": {
				"hour": "17",
				"minute": "00"
			}
		}
	},
	"timezone": "America\/New_York"
}
```

{% endtab %}
{% endtabs %}

## Minimum Date Slots

If the merchant has pickup order limits, we will return an array of time slots available for the minDate

```javascript
{
    "minDate": "2024-01-16",
    "minDateSlots": [
        {
            "id": 1,
            "location_id": 1,
            "day_of_week": "tuesday",
            "available_from": "11:30",
            "available_until": "12:00",
            "limited": true,
            "limit": 10
        },
        {
            "id": 2,
            "location_id": 1,
            "day_of_week": "tuesday",
            "available_from": "12:00",
            "available_until": "12:30",
            "limited": true,
            "limit": 10
        }
}
```

## Blackout dates

If the merchant wants to prevent customers from selecting pickup on specific dates of the year we will return an array of dates as shown below.

{% hint style="info" %}
Months are javascript zero-based meaning December is 11 rather than 12
{% endhint %}

{% tabs %}
{% tab title="Blackout dates" %}

```javascript
/** 
Pickup not allowed on:

13th May 2021 
25th December 2021
**/

{
	"disabled": [
		"2021-04-13",
		"2021-11-25"
	]
}
```

{% endtab %}
{% endtabs %}

## Disabled days of the week

If merchants want to prevent customers from selecting pickup on specific days of the week then we will return an array of integers.

{% hint style="info" %}
Months are javascript zero-based meaning December is 11 rather than 12
{% endhint %}

```javascript
/** 
Pickup not allowed on Sunday or Monday

1: Sunday
2: Monday
3: Tuesday
4: Wednesday
5: Thursday
6: Friday
7: Saturday
**/

{
	"disabled": [
		1,
		2
	]
}
```

## Specifically allowed pickup dates

If a merchant wants to allow pickups only on specific dates of the year we will return the available pickup dates in the disabled array. Note the first element of the array will be `true`  &#x20;

{% hint style="info" %}
Months are javascript zero-based meaning December is 11 rather than 12
{% endhint %}

```javascript
/** 
Pickup is only available on:

13th May 2021 
25th December 2021
**/

{
	"disabled": [
		true,
		"2021-04-13",
		"2021-11-25"
	]
}
```

## Advanced date rules

Merchants can combine both specifically allowed pickup dates and days of the week.&#x20;

{% hint style="info" %}
Months are javascript zero-based meaning December is 11 rather than 12
{% endhint %}

```javascript
/** 
Pickup is only available on:

Sundays
Mondays 
13th May 2021
25th December 2021 
**/

{
	"disabled": [
		true,
		1,
		2,
		"2021-04-13",
		"2021-11-25"
	]
}
```

```javascript
/** 
Pickup is not available on:

Sundays
Mondays 
13th May 2021
25th December 2021 
**/

{
	"disabled": [
		1,
		2,
		"2021-04-13",
		"2021-11-25"
	]
}
```
