Skip to content
Snippets Groups Projects
Verified Commit 23ca3d73 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Update API, cleanup

parent 55ffce03
No related branches found
No related tags found
No related merge requests found
Pipeline #5987 passed
......@@ -2,7 +2,7 @@ image: docker:20.10.9
variables:
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 0.1.0
IMAGE_VER: 0.2.0
services:
- docker:20.10.9-dind
......
......@@ -15,6 +15,9 @@ sub options {
$c->config->{pretix_event},
);
if ( $args->{type} eq 'products' ) {
$url .= 'items/';
}
if ( $args->{type} eq 'variations' ) {
$url .= 'items/' . $args->{product_id} . '/variations/';
}
......@@ -30,7 +33,16 @@ sub options {
RECORD:
foreach my $record ( @{ $records->{results} } ) {
if ( $args->{type} eq 'questions' ) {
if ( $args->{type} eq 'products' ) {
next RECORD if ! $record->{active};
next RECORD if $args->{category_id} && $record->{category} != $args->{category_id};
push @options, {
value => $record->{id},
label => $record->{name}{en},
price => $record->{default_price} + 0,
};
}
elsif ( $args->{type} eq 'questions' ) {
next RECORD if $record->{hidden};
push @options, {
value => $record->{id},
......
......@@ -29,6 +29,15 @@ components:
type: string
response:
type: string
Product:
type: object
properties:
id:
type: integer
variation:
type: integer
price:
type: integer
Option:
type: object
properties:
......@@ -54,13 +63,19 @@ paths:
required: true
schema:
type: string
enum: ['variations', 'questions']
enum: ['products', 'variations', 'questions']
- name: product_id
in: query
description: Product ID for variations
required: false
schema:
type: integer
- name: category_id
in: query
description: Category ID for variations
required: false
schema:
type: integer
responses:
200:
description: Options list
......@@ -71,3 +86,60 @@ paths:
items:
$ref: '#/components/schemas/Option'
/orders:
post:
x-mojo-to: orders#create
tags:
- orders
summary: "Vytvorit registraci"
operationId: createOrder
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
token:
type: string
name:
type: string
maxLength: 128
example: 'Ivan Bartoš'
email:
type: string
maxLength: 128
example: 'ivan.bartos@pirati.cz'
organization:
type: string
example: 'ČTK'
products:
type: array
items:
$ref: '#/components/schemas/Product'
responses:
type: array
items:
$ref: '#/components/schemas/Response'
example:
- question_id: 1
response: XXXXX
- question_id: 2
response: ZZZZZ
required:
- type
- name
- email
- products
- responses
responses:
201:
description: Order created
content:
application/json:
schema:
type: object
properties:
url:
type: string
description: Tickets url
openapi: 3.0.3
info:
version: "2.0"
title: CF 2022
description: CF 2022
license:
name: Artistic License 2.0
url: https://www.perlfoundation.org/artistic-license-20.html
contact:
name: Andrej Ramašeuski
email: andrej.ramaseuski@pirati.cz
url: https://pardubicky.pirati.cz/lide/andrej-ramaseuski/
servers:
- url: https://cf2022.pirati.cz/api
description: Production server
- url: https://cf2022.pir-test.eu/api
description: Developement server
- url: http://127.0.0.1:3000/api
description: Local server
components:
schemas:
Response:
type: object
properties:
request_id:
type: string
response:
type: string
Option:
type: object
properties:
value:
type: string
label:
type: string
price:
type: string
paths:
/options:
get:
x-mojo-to: lists#options
tags:
- options
summary: "Options"
operationId: getOptions
parameters:
- name: list
in: query
description: List ID
type: string
required: true
enum: ['lunch', 'questions']
responses:
200:
description: Options list
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Option'
/orders:
post:
x-mojo-to: orders#create
tags:
- orders
summary: "Vytvorit registraci"
operationId: createOrder
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
type:
type: integer
enum: [1, 2, 3]
example: 1
token:
type: string
name:
type: string
maxLength: 128
example: 'Ivan Bartoš'
email:
type: string
maxLength: 128
example: 'ivan.bartos@pirati.cz'
organization:
type: string
example: 'ČTK'
lunch:
type: integer
example: 2
party:
type: array
items:
type: integer
responses:
type: array
items:
$ref: '#/components/schemas/Response'
example:
- question_id: 1
response: XXXXX
- question_id: 2
response: ZZZZZ
notes:
type: string
required:
- type
- name
- email
responses:
201:
description: Order created
content:
application/json:
schema:
type: object
properties:
url:
type: string
description: Tickets url
status (potrebuje platbu) - 'n', jinak 'p'
email
payment_provider "manual" ? "free"
positions
[
]
iPOST /api/v1/organizers/bigevents/events/sampleconf/orders/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
{
"email": "dummy@example.org",
"locale": "en",
"sales_channel": "web",
"fees": [
{
"fee_type": "payment",
"value": "0.25",
"description": "",
"internal_type": "",
"tax_rule": 2
}
],
"payment_provider": "banktransfer",
"invoice_address": {
"is_business": false,
"company": "Sample company",
"name_parts": {"full_name": "John Doe"},
"street": "Sesam Street 12",
"zipcode": "12345",
"city": "Sample City",
"country": "UK",
"state": "",
"internal_reference": "",
"vat_id": ""
},
"positions": [
{
"positionid": 1,
"item": 1,
"variation": null,
"price": "23.00",
"attendee_name_parts": {
"full_name": "Peter"
},
"attendee_email": null,
"addon_to": null,
"answers": [
{
"question": 1,
"answer": "23",
"options": []
}
],
"subevent": null
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment