diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 755680b30a7b8a6f9f5ecb7db62913eccd21ff35..486f5707cc6826f1b95c9e67a4d377a19ea34f79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/lib/CF2022/Controller/Lists.pm b/lib/CF2022/Controller/Lists.pm index 0d982e5d1defd82a66b1c11517495b838c6417cc..bd9c587edf883c91e48461be5c77246806aa9b4c 100644 --- a/lib/CF2022/Controller/Lists.pm +++ b/lib/CF2022/Controller/Lists.pm @@ -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}, diff --git a/openapi.yaml b/openapi.yaml index e6ac1967b8ed6daf3d0a61bdf826deb37b3b0d4d..b11b1d6a50410bdba6b11f3433158c218bc2c8b7 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -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 diff --git a/openapi2.yaml b/openapi2.yaml deleted file mode 100644 index a39b85e934a863935d4abbdabcce8260f5b0b224..0000000000000000000000000000000000000000 --- a/openapi2.yaml +++ /dev/null @@ -1,130 +0,0 @@ -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 diff --git a/order-parametrs.txt b/order-parametrs.txt deleted file mode 100644 index 75cc0f4a2bebd609de8159e035cc29f570c575da..0000000000000000000000000000000000000000 --- a/order-parametrs.txt +++ /dev/null @@ -1,68 +0,0 @@ -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 - } - ] -}