Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/auto-merge-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Auto Merge Release

on:
workflow_dispatch:
inputs:
release-branch:
description: 'Target branch for release'
required: false
default: 'master'
type: string
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
release:
uses: tastyigniter/workflows/.github/workflows/auto-merge-release.yml@main
with:
release-branch: ${{ inputs.release-branch || 'master' }}
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
10 changes: 1 addition & 9 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: API CI Pipeline
name: CI Pipeline

on: [ push, workflow_dispatch ]

Expand All @@ -10,11 +10,3 @@ jobs:
uses: tastyigniter/workflows/.github/workflows/php-tests.yml@main
with:
php-version: ${{ matrix.php }}

auto-merge-release:
needs: [ php-tests ]
uses: tastyigniter/workflows/.github/workflows/auto-merge-release.yml@main
with:
release-branch: master
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
"test:coverage": "vendor/bin/pest --coverage --exactly=100 --compact",
"test:type-coverage": "vendor/bin/pest --type-coverage --min=100",
"test": [
"@test:lint",
"@test:refactor",
"@test:static",
"@test:lint",
"@test:coverage"
]
}
Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ The API extension provides endpoints for all core TastyIgniter resources. Here i
`customers` - List, create, retrieve, update and delete customers
- [Locations](https://github.com/tastyigniter/ti-ext-api/blob/master/docs/locations.md)
`locations` - List, create, retrieve, update and delete locations
- [Location Settings](https://github.com/tastyigniter/ti-ext-api/blob/master/docs/location_settings.md)
`location_settings` - List, create, retrieve, update and delete location settings
- [Menus](https://github.com/tastyigniter/ti-ext-api/blob/master/docs/menus.md)
`menus` - List, create, retrieve, update and delete menus
- [Orders](https://github.com/tastyigniter/ti-ext-api/blob/master/docs/orders.md)
Expand Down
294 changes: 294 additions & 0 deletions docs/location_settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
## Location Settings

This endpoint allows you to `list`, `create`, `retrieve`, `update` and `delete` location settings on your TastyIgniter site.

The endpoint responses are formatted according to the [JSON:API specification](https://jsonapi.org).

### The location setting object

#### Attributes

| Key | Type | Description |
|---------------|----------|-----------------------------------------------------------------------------|
| `location_id` | `integer` | **Required**. The ID of the location this setting belongs to |
| `item` | `string` | **Required**. The setting item/key identifier |
| `data` | `array` | **Required**. The setting data/value as an array |

#### Location setting object example

```json
{
"id": 1,
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 10.00,
"delivery_fee": 2.50
}
}
```

### List location settings

Retrieves a list of location settings.

Required abilities: `location_settings:read`

```
GET /api/location_settings
```

#### Parameters

| Key | Type | Description |
|-------------|-----------|------------------------------------|
| `page` | `integer` | The page number. |
| `pageLimit` | `integer` | The number of items per page. |
| `location_id` | `integer` | Filter settings by location ID. |

#### Response

```html
Status: 200 OK
```

```json
{
"data": [
{
"type": "location_settings",
"id": "1",
"attributes": {
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 10.00,
"delivery_fee": 2.50
}
}
},
{
"type": "location_settings",
"id": "2",
"attributes": {
"location_id": 1,
"item": "payment_settings",
"data": {
"cash_enabled": true,
"card_enabled": true,
"online_payment_enabled": false
}
}
}
],
"included": [],
"meta": {
"pagination": {
"total": 2,
"count": 2,
"per_page": 20,
"current_page": 1,
"total_pages": 1
}
},
"links": {
"self": "https://your.url/api/location_settings?page=1",
"first": "https://your.url/api/location_settings?page=1",
"last": "https://your.url/api/location_settings?page=1"
}
}
```

### Create a location setting

Creates a new location setting.

Required abilities: `location_settings:write`

```
POST /api/location_settings
```

#### Parameters

| Key | Type | Description |
|--------------|----------|-----------------------------------------------------------------------------|
| `location_id` | `integer` | **Required**. The ID of the location this setting belongs to |
| `item` | `string` | **Required**. The setting item/key identifier |
| `data` | `array` | **Required**. The setting data/value as an array |

#### Payload example

```json
{
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 10.00,
"delivery_fee": 2.50,
"free_delivery_threshold": 25.00
}
}
```

#### Response

```html
Status: 201 Created
```

```json
{
"data": [
{
"type": "location_settings",
"id": "1",
"attributes": {
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 10.00,
"delivery_fee": 2.50,
"free_delivery_threshold": 25.00
}
}
}
]
}
```

### Retrieve a location setting

Retrieves a specific location setting.

Required abilities: `location_settings:read`

```
GET /api/location_settings/:id
```

#### Parameters

No query parameters.

#### Response

```html
Status: 200 OK
```

```json
{
"data": [
{
"type": "location_settings",
"id": "1",
"attributes": {
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 10.00,
"delivery_fee": 2.50,
"free_delivery_threshold": 25.00
}
}
}
],
"included": []
}
```

### Update a location setting

Updates a location setting.

Required abilities: `location_settings:write`

```
PATCH /api/location_settings/:id
```

#### Parameters

| Key | Type | Description |
|--------------|----------|-----------------------------------------------------------------------------|
| `location_id` | `integer` | **Required**. The ID of the location this setting belongs to |
| `item` | `string` | **Required**. The setting item/key identifier |
| `data` | `array` | **Required**. The setting data/value as an array |

#### Payload example

```json
{
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 15.00,
"delivery_fee": 3.00,
"free_delivery_threshold": 30.00
}
}
```

#### Response

```html
Status: 200 OK
```

```json
{
"data": [
{
"type": "location_settings",
"id": "1",
"attributes": {
"location_id": 1,
"item": "delivery_settings",
"data": {
"enabled": true,
"minimum_order": 15.00,
"delivery_fee": 3.00,
"free_delivery_threshold": 30.00
}
}
}
]
}
```

### Delete a location setting

Permanently deletes a location setting. It cannot be undone.

Required abilities: `location_settings:write`

```
DELETE /api/location_settings/:id
```

#### Parameters

No parameters.

#### Response

Returns an object with a deleted parameter on success. If the location setting ID does not exist, this call returns an error.

```html
Status: 200 OK
```

```json
{
"id": 1,
"object": "location_setting",
"deleted": true
}
```
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ parameters:
count: 1
path: src/ApiResources/Transformers/CategoryTransformer.php

-
message: '#^Access to an undefined property Igniter\\Cart\\Models\\Category\:\:\$menus\.$#'
identifier: property.notFound
count: 1
path: src/ApiResources/Transformers/CategoryTransformer.php

-
message: '#^Access to an undefined property Igniter\\User\\Models\\Customer\:\:\$orders\.$#'
identifier: property.notFound
Expand Down
Loading