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

Existence objednavky a detail objednavky

parent 1c4ba17e
No related branches found
No related tags found
No related merge requests found
Pipeline #6050 passed
......@@ -2,7 +2,7 @@ image: docker:20.10.9
variables:
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_VER: 0.7.0
IMAGE_VER: 0.8.0
services:
- docker:20.10.9-dind
......
......@@ -157,4 +157,53 @@ sub create ($c ) {
);
}
sub exists ($c ) {
$c->openapi->valid_input or return;
my $key = $c->param('key');
my $field = ( $key =~ /\@/ ) ? 'email' : 'sso_uuid';
my $exists = $c->schema->resultset('Order')->search({
deleted => undef,
$field => $key,
})->count;
$c->render(
status => 200,
openapi => { exists => $exists },
);
}
sub get ($c ) {
$c->openapi->valid_input or return;
$c->oauth_token($c->tx->req->content->headers->header('X-Token'));
my $claims = $c->oauth_claims;
return $c->error(403, 'Invalid token') if ! $claims;
my $order = $c->schema->resultset('Order')->search({
deleted => undef,
sso_uuid => $claims->{sub},
})->first;
return $c->error(404, 'NOT FOUND') if ! $order;
# datas z pretixu
$c->app->log->error($order->api . $order->order_id);
my $ua = Mojo::UserAgent->new;
my $rc = $ua->get( $order->api . $order->order_id . '/',
{ Authorization => 'Token ' . $c->config->{pretix_token} },
)->result;
return $c->error(400, $rc->body) if ! $rc->is_success;
$c->render(
status => 200,
openapi => { order => $rc->json },
);
}
1;
......@@ -162,3 +162,51 @@ paths:
url:
type: string
description: Tickets url
/orders/exists:
get:
x-mojo-to: orders#exists
tags:
- order
summary: "Existence objednavky"
operationId: checkOrder
parameters:
- name: key
in: query
required: true
example: andrej.ramaseuski@pirati.cz
description: "Email nebo SSO UUID"
schema:
type: string
responses:
200:
description: Stav
content:
application/json:
schema:
type: object
properties:
exists:
type: boolean
/orders/detail:
get:
x-mojo-to: orders#get
tags:
- order
summary: "Objednavka"
operationId: getOrder
parameters:
- name: "X-Token"
in: header
required: true
description: "SSO Token"
schema:
type: string
responses:
200:
description: Objednavka
content:
application/json:
schema:
type: object
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment