mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
662 lines
20 KiB
YAML
662 lines
20 KiB
YAML
---
|
|
openapi: 3.0.1
|
|
info:
|
|
title: API V1
|
|
version: v1
|
|
components:
|
|
schemas:
|
|
error_response:
|
|
type: object
|
|
properties:
|
|
errors:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
title:
|
|
type: string
|
|
detail:
|
|
type: string
|
|
source:
|
|
type: object
|
|
required:
|
|
- detail
|
|
required:
|
|
- errors
|
|
customer:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
example: '1'
|
|
type:
|
|
type: string
|
|
example: customer
|
|
attributes:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
example: 1
|
|
enterprise_id:
|
|
type: integer
|
|
example: 2
|
|
first_name:
|
|
type: string
|
|
nullable: true
|
|
example: Alice
|
|
last_name:
|
|
type: string
|
|
nullable: true
|
|
example: Springs
|
|
code:
|
|
type: string
|
|
nullable: true
|
|
example: BUYER1
|
|
email:
|
|
type: string
|
|
example: alice@example.com
|
|
allow_charges:
|
|
type: boolean
|
|
example: false
|
|
tags:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example:
|
|
- staff
|
|
- discount
|
|
terms_and_conditions_accepted_at:
|
|
type: string
|
|
format: date-time
|
|
nullable: true
|
|
example: '2022-03-12T15:55:00.000+11:00'
|
|
billing_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
shipping_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
phone: 0404 333 222 111
|
|
latitude: -37.8173751
|
|
longitude: 144.964803195704
|
|
first_name: Alice
|
|
last_name: Springs
|
|
street_address_1: 1 Flinders Street
|
|
street_address_2: ''
|
|
postal_code: '1234'
|
|
locality: Melbourne
|
|
region:
|
|
code: Vic
|
|
name: Victoria
|
|
country:
|
|
code: AU
|
|
name: Australia
|
|
required:
|
|
- id
|
|
- enterprise_id
|
|
- first_name
|
|
- last_name
|
|
- code
|
|
- email
|
|
- allow_charges
|
|
- tags
|
|
- terms_and_conditions_accepted_at
|
|
- billing_address
|
|
- shipping_address
|
|
relationships:
|
|
type: object
|
|
properties:
|
|
enterprise:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
type:
|
|
type: string
|
|
example: enterprise
|
|
links:
|
|
type: object
|
|
properties:
|
|
related:
|
|
type: string
|
|
meta:
|
|
type: object
|
|
links:
|
|
type: object
|
|
required:
|
|
- data
|
|
customers_collection:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
example: '1'
|
|
type:
|
|
type: string
|
|
example: customer
|
|
attributes:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
example: 1
|
|
enterprise_id:
|
|
type: integer
|
|
example: 2
|
|
first_name:
|
|
type: string
|
|
nullable: true
|
|
example: Alice
|
|
last_name:
|
|
type: string
|
|
nullable: true
|
|
example: Springs
|
|
code:
|
|
type: string
|
|
nullable: true
|
|
example: BUYER1
|
|
email:
|
|
type: string
|
|
example: alice@example.com
|
|
allow_charges:
|
|
type: boolean
|
|
example: false
|
|
tags:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example:
|
|
- staff
|
|
- discount
|
|
terms_and_conditions_accepted_at:
|
|
type: string
|
|
format: date-time
|
|
nullable: true
|
|
example: '2022-03-12T15:55:00.000+11:00'
|
|
billing_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
shipping_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
phone: 0404 333 222 111
|
|
latitude: -37.8173751
|
|
longitude: 144.964803195704
|
|
first_name: Alice
|
|
last_name: Springs
|
|
street_address_1: 1 Flinders Street
|
|
street_address_2: ''
|
|
postal_code: '1234'
|
|
locality: Melbourne
|
|
region:
|
|
code: Vic
|
|
name: Victoria
|
|
country:
|
|
code: AU
|
|
name: Australia
|
|
balance:
|
|
type: number
|
|
format: double
|
|
required:
|
|
- id
|
|
- enterprise_id
|
|
- first_name
|
|
- last_name
|
|
- code
|
|
- email
|
|
- allow_charges
|
|
- tags
|
|
- terms_and_conditions_accepted_at
|
|
- billing_address
|
|
- shipping_address
|
|
relationships:
|
|
type: object
|
|
properties:
|
|
enterprise:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
type:
|
|
type: string
|
|
example: enterprise
|
|
links:
|
|
type: object
|
|
properties:
|
|
related:
|
|
type: string
|
|
meta:
|
|
type: object
|
|
properties:
|
|
pagination:
|
|
type: object
|
|
properties:
|
|
results:
|
|
type: integer
|
|
example: 250
|
|
pages:
|
|
type: integer
|
|
example: 5
|
|
page:
|
|
type: integer
|
|
example: 2
|
|
per_page:
|
|
type: integer
|
|
example: 50
|
|
required:
|
|
- pagination
|
|
links:
|
|
type: object
|
|
properties:
|
|
self:
|
|
type: string
|
|
first:
|
|
type: string
|
|
prev:
|
|
type: string
|
|
nullable: true
|
|
next:
|
|
type: string
|
|
nullable: true
|
|
last:
|
|
type: string
|
|
required:
|
|
- data
|
|
- meta
|
|
- links
|
|
securitySchemes:
|
|
api_key_header:
|
|
type: apiKey
|
|
name: X-Api-Token
|
|
in: header
|
|
description: Authenticates via API key passed in specified header
|
|
api_key_param:
|
|
type: apiKey
|
|
name: token
|
|
in: query
|
|
description: Authenticates via API key passed in specified query param
|
|
session:
|
|
type: apiKey
|
|
name: _ofn_session_id
|
|
in: cookie
|
|
description: Authenticates using the current user's session if logged in
|
|
paths:
|
|
"/api/v1/customers":
|
|
get:
|
|
summary: List customers
|
|
tags:
|
|
- Customers
|
|
parameters:
|
|
- name: enterprise_id
|
|
in: query
|
|
schema:
|
|
type: string
|
|
- name: extra_fields[customer]
|
|
in: query
|
|
example: balance
|
|
description: Add extra fields to each customer
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Customers list
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/customers_collection"
|
|
post:
|
|
summary: Create customer
|
|
tags:
|
|
- Customers
|
|
parameters: []
|
|
responses:
|
|
'201':
|
|
description: Example customer created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/customer"
|
|
'422':
|
|
description: Unprocessable entity
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/error_response"
|
|
requestBody:
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
enterprise_id:
|
|
type: integer
|
|
example: 2
|
|
first_name:
|
|
type: string
|
|
nullable: true
|
|
example: Alice
|
|
last_name:
|
|
type: string
|
|
nullable: true
|
|
example: Springs
|
|
code:
|
|
type: string
|
|
nullable: true
|
|
example: BUYER1
|
|
email:
|
|
type: string
|
|
example: alice@example.com
|
|
tags:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example:
|
|
- staff
|
|
- discount
|
|
billing_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
shipping_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
phone: 0404 333 222 111
|
|
latitude: -37.8173751
|
|
longitude: 144.964803195704
|
|
first_name: Alice
|
|
last_name: Springs
|
|
street_address_1: 1 Flinders Street
|
|
street_address_2: ''
|
|
postal_code: '1234'
|
|
locality: Melbourne
|
|
region:
|
|
code: Vic
|
|
name: Victoria
|
|
country:
|
|
code: AU
|
|
name: Australia
|
|
required:
|
|
- enterprise_id
|
|
- email
|
|
"/api/v1/customers/{id}":
|
|
get:
|
|
summary: Show customer
|
|
tags:
|
|
- Customers
|
|
parameters:
|
|
- name: id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Customer
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
example: '1'
|
|
type:
|
|
type: string
|
|
example: customer
|
|
attributes:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
example: 1
|
|
enterprise_id:
|
|
type: integer
|
|
example: 2
|
|
first_name:
|
|
type: string
|
|
nullable: true
|
|
example: Alice
|
|
last_name:
|
|
type: string
|
|
nullable: true
|
|
example: Springs
|
|
code:
|
|
type: string
|
|
nullable: true
|
|
example: BUYER1
|
|
email:
|
|
type: string
|
|
example: alice@example.com
|
|
allow_charges:
|
|
type: boolean
|
|
example: false
|
|
tags:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example:
|
|
- staff
|
|
- discount
|
|
terms_and_conditions_accepted_at:
|
|
type: string
|
|
format: date-time
|
|
nullable: true
|
|
example: '2022-03-12T15:55:00.000+11:00'
|
|
billing_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
shipping_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
phone: 0404 333 222 111
|
|
latitude: -37.8173751
|
|
longitude: 144.964803195704
|
|
first_name: Alice
|
|
last_name: Springs
|
|
street_address_1: 1 Flinders Street
|
|
street_address_2: ''
|
|
postal_code: '1234'
|
|
locality: Melbourne
|
|
region:
|
|
code: Vic
|
|
name: Victoria
|
|
country:
|
|
code: AU
|
|
name: Australia
|
|
balance:
|
|
type: number
|
|
format: double
|
|
required:
|
|
- id
|
|
- enterprise_id
|
|
- first_name
|
|
- last_name
|
|
- code
|
|
- email
|
|
- allow_charges
|
|
- tags
|
|
- terms_and_conditions_accepted_at
|
|
- billing_address
|
|
- shipping_address
|
|
- balance
|
|
relationships:
|
|
type: object
|
|
properties:
|
|
enterprise:
|
|
type: object
|
|
properties:
|
|
data:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
type:
|
|
type: string
|
|
example: enterprise
|
|
links:
|
|
type: object
|
|
properties:
|
|
related:
|
|
type: string
|
|
meta:
|
|
type: object
|
|
links:
|
|
type: object
|
|
required:
|
|
- data
|
|
'404':
|
|
description: Not found
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/error_response"
|
|
'401':
|
|
description: Unauthorized
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/error_response"
|
|
put:
|
|
summary: Update customer
|
|
tags:
|
|
- Customers
|
|
parameters:
|
|
- name: id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Customer updated
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/customer"
|
|
'422':
|
|
description: Unprocessable entity
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/error_response"
|
|
requestBody:
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
enterprise_id:
|
|
type: integer
|
|
example: 2
|
|
first_name:
|
|
type: string
|
|
nullable: true
|
|
example: Alice
|
|
last_name:
|
|
type: string
|
|
nullable: true
|
|
example: Springs
|
|
code:
|
|
type: string
|
|
nullable: true
|
|
example: BUYER1
|
|
email:
|
|
type: string
|
|
example: alice@example.com
|
|
tags:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example:
|
|
- staff
|
|
- discount
|
|
billing_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
shipping_address:
|
|
type: object
|
|
nullable: true
|
|
example:
|
|
phone: 0404 333 222 111
|
|
latitude: -37.8173751
|
|
longitude: 144.964803195704
|
|
first_name: Alice
|
|
last_name: Springs
|
|
street_address_1: 1 Flinders Street
|
|
street_address_2: ''
|
|
postal_code: '1234'
|
|
locality: Melbourne
|
|
region:
|
|
code: Vic
|
|
name: Victoria
|
|
country:
|
|
code: AU
|
|
name: Australia
|
|
required:
|
|
- enterprise_id
|
|
- email
|
|
delete:
|
|
summary: Delete customer
|
|
tags:
|
|
- Customers
|
|
parameters:
|
|
- name: id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Customer deleted
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/customer"
|
|
"/api/v1/enterprises/{enterprise_id}/customers":
|
|
get:
|
|
summary: List customers of an enterprise
|
|
tags:
|
|
- Customers
|
|
- Enterprises
|
|
parameters:
|
|
- name: enterprise_id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Customers list
|
|
content:
|
|
application/json:
|
|
schema:
|
|
"$ref": "#/components/schemas/customers_collection"
|
|
servers:
|
|
- url: "/"
|