Skip to content

Commit d309e3c

Browse files
author
Hieu Lam - TMA
authored
feature-8998: Add new APIs to documentation (#9015)
* feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation * feature-8998: Add new APIs to documentation
1 parent 344fff8 commit d309e3c

File tree

14 files changed

+764
-2
lines changed

14 files changed

+764
-2
lines changed

docs/api/api_blueprint_source.apib

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,8 @@ The Open Event API Server
135135

136136
<!-- include(blueprint/badge_forms.apib) -->
137137

138+
<!-- include(blueprint/station_store_pax.apib) -->
139+
140+
<!-- include(blueprint/station.apib) -->
141+
138142
<!-- include(blueprint/user_check_in.apib) -->

docs/api/blueprint/badge_forms.apib

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,26 @@ Badge Forms related to the events.
88
| `badge-id` | Badge Id | string | **yes** |
99
| `badge-image-url` | Badge Image Url | String | - |
1010
| `badge-orientation` | Badge Orientation | String | - |
11+
12+
## Get Badge Form By Ticket [/v1/tickets/{ticket_id}/badge-forms]
13+
+ Parameters
14+
+ ticket_id: 1 (integer) - ID of the ticket in the form of an integer
15+
16+
### Get Badge Form By Ticket [GET]
17+
Get badge form.
18+
19+
+ Request (application/vnd.api+json)
20+
21+
+ Headers
22+
23+
Authorization: JWT <Auth Key>
24+
25+
+ Response 200 (application/json)
26+
27+
[
28+
{
29+
"custom_field": "example",
30+
"field_identifier": "example",
31+
"id": 1
32+
}
33+
]

docs/api/blueprint/station.apib

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Group Stations
2+
3+
## Create Station [/v1/station]
4+
5+
### Create Station [POST]
6+
Create station.
7+
8+
+ Request (application/vnd.api+json)
9+
10+
+ Headers
11+
12+
Authorization: JWT <Auth Key>
13+
14+
+ Body
15+
16+
{
17+
"data": {
18+
"type": "station",
19+
"attributes": {
20+
"station-name": "station name",
21+
"station-type": "registration"
22+
},
23+
"relationships": {
24+
"event": {"data": {"id": "1", "type": "event"}},
25+
"microlocation": {
26+
"data": {"id": "1", "type": "microlocation"}
27+
}
28+
}
29+
}
30+
}
31+
32+
+ Response 201 (application/vnd.api+json)
33+
34+
{
35+
"data": {
36+
"type": "station",
37+
"relationships": {
38+
"event": {
39+
"links": {
40+
"self": "/v1/station/1/relationships/event",
41+
"related": "/v1/station/1"
42+
}
43+
},
44+
"microlocation": {
45+
"links": {
46+
"self": "/v1/station/1/relationships/microlocation",
47+
"related": "/v1/station/1"
48+
}
49+
}
50+
},
51+
"attributes": {
52+
"station-name": "station name",
53+
"station-type": "registration"
54+
},
55+
"id": 1,
56+
"links": {
57+
"self": "/v1/station/1"
58+
}
59+
},
60+
"links": {
61+
"self": "/v1/station/1"
62+
},
63+
"jsonapi": {
64+
"version": "1.0"
65+
}
66+
}
67+
68+
## Get Station [/v1/stations/{station_id}]
69+
+ Parameters
70+
+ station_id: 1 (integer) - ID of the station in the form of an integer
71+
72+
### Get Station [GET]
73+
Get station.
74+
75+
+ Request (application/vnd.api+json)
76+
77+
+ Headers
78+
79+
Authorization: JWT <Auth Key>
80+
81+
+ Response 200 (application/vnd.api+json)
82+
83+
{
84+
"data": {
85+
"type": "station",
86+
"attributes": {
87+
"station-type": "example",
88+
"station-name": "example"
89+
},
90+
"relationships": {
91+
"event": {
92+
"links": {
93+
"self": "/v1/stations/1/relationships/event",
94+
"related": "/v1/events/1"
95+
}
96+
},
97+
"microlocation": {
98+
"links": {
99+
"self": "/v1/stations/1/relationships/microlocation"
100+
}
101+
}
102+
},
103+
"id": 1,
104+
"links": {
105+
"self": "/v1/stations/1"
106+
}
107+
},
108+
"links": {
109+
"self": "/v1/stations/1"
110+
},
111+
"jsonapi": {
112+
"version": "1.0"
113+
}
114+
}
115+
116+
## Get Stations by Event [/v1/events/{event_id}/stations]
117+
+ Parameters
118+
+ event_id: 1 (integer) - ID of the station in the form of an integer
119+
120+
### Get Stations by Event [GET]
121+
Get Stations by event.
122+
123+
+ Request (application/vnd.api+json)
124+
125+
+ Headers
126+
127+
Authorization: JWT <Auth Key>
128+
129+
+ Response (application/vnd.api+json)
130+
131+
{"data": [], "links": {"self": "/v1/events/1/stations"}, "meta": {"count": 0}, "jsonapi": {"version": "1.0"}}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Group Station Store Paxs
2+
3+
## Create Station Store Paxs [/v1/station-store-paxs]
4+
5+
### Create Station Store Paxs [POST]
6+
Create station store paxs.
7+
8+
+ Request (application/vnd.api+json)
9+
10+
+ Headers
11+
12+
Authorization: JWT <Auth Key>
13+
14+
+ Body
15+
16+
{
17+
"data": {
18+
"type": "station-store-pax",
19+
"relationships": {
20+
"station": {
21+
"data": {
22+
"type": "station",
23+
"id": "1"
24+
}
25+
},
26+
"session": {
27+
"data": {
28+
"type": "session",
29+
"id": "1"
30+
}
31+
}
32+
},
33+
"attributes": {
34+
"current_pax": "10"
35+
}
36+
}
37+
}
38+
39+
+ Response 201 (application/vnd.api+json)
40+
41+
{
42+
"data": {
43+
"type": "station-store-pax",
44+
"relationships": {
45+
"session": {
46+
"links": {
47+
"self": "/v1/station-store-paxs/1/relationships/session",
48+
"related": "/v1/sessions/1"
49+
}
50+
},
51+
"station": {
52+
"links": {
53+
"self": "/v1/station-store-paxs/1/relationships/station",
54+
"related": "/v1/stations/1"
55+
}
56+
}
57+
},
58+
"attributes": {
59+
"current-pax": 10,
60+
"modified-at": "2023-07-28T04:30:48.251435+00:00",
61+
"created-at": "2023-07-28T04:30:48.251430+00:00"
62+
},
63+
"id": 1,
64+
"links": {
65+
"self": "/v1/station-store-paxs/1"
66+
}
67+
},
68+
"links": {
69+
"self": "/v1/station-store-paxs/1"
70+
},
71+
"jsonapi": {
72+
"version": "1.0"
73+
}
74+
}
75+
76+
## Get Station Store Paxs By Station and Session [/v1/stations/{station_id}/sessions/{session_id}/station-store-paxs]
77+
+ Parameters
78+
+ station_id: 1 (integer) - ID of the station in the form of an integer
79+
+ session_id: 1 (integer) - ID of the session in the form of an integer
80+
81+
### Get Station Store Paxs By Station and Session [GET]
82+
Get station store paxs By station and session.
83+
84+
+ Request (application/vnd.api+json)
85+
86+
+ Headers
87+
88+
Authorization: JWT <Auth Key>
89+
90+
+ Response (application/vnd.api+json)
91+
92+
{"data": [], "links": {"self": "/v1/stations/1/sessions/1/station-store-paxs"}, "meta": {"count": 0}, "jsonapi": {"version": "1.0"}}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import json
2+
3+
from app.models.badge_field_form import BadgeFieldForms
4+
from tests.factories import common
5+
from tests.factories.badge_field_form import BadgeFieldFormFactory
6+
from tests.factories.badge_form import BadgeFormFactory
7+
from tests.factories.event import EventFactoryBasic
8+
from tests.factories.ticket import TicketFactory
9+
10+
11+
def test_get_badge_form_by_ticket(db, client, jwt):
12+
"""Test get badge form by ticket."""
13+
event = EventFactoryBasic()
14+
ticket = TicketFactory(
15+
event=event,
16+
badge_id=common.string_,
17+
)
18+
badge_form = BadgeFormFactory(
19+
event=event,
20+
badge_id=ticket.badge_id,
21+
)
22+
BadgeFieldFormFactory(
23+
badge_form=badge_form,
24+
badge_id=ticket.badge_id,
25+
)
26+
db.session.commit()
27+
28+
response = client.get(
29+
f'v1/tickets/{ticket.id}/badge-forms',
30+
content_type='application/vnd.api+json',
31+
headers=jwt,
32+
)
33+
34+
assert response.status_code == 200
35+
36+
count = BadgeFieldForms.query.filter_by(badge_id=ticket.badge_id).count()
37+
assert len(json.loads(response.data)) == count
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import json
2+
3+
from app.models.station_store_pax import StationStorePax
4+
from tests.factories.event import EventFactoryBasic
5+
from tests.factories.microlocation import MicrolocationSubFactory
6+
from tests.factories.session import SessionSubFactory
7+
from tests.factories.station import StationFactory
8+
from tests.factories.station_store_pax import StationStorePaxFactory
9+
10+
11+
def test_create_station_store_pax(db, client, jwt, user):
12+
"""Test that a station store pax can be created."""
13+
user.is_super_admin = True
14+
event = EventFactoryBasic()
15+
microlocation = MicrolocationSubFactory(
16+
event=event,
17+
)
18+
station = StationFactory(
19+
event=event, microlocation=microlocation, station_type='registration'
20+
)
21+
session = SessionSubFactory(
22+
event=event,
23+
microlocation=microlocation,
24+
)
25+
db.session.commit()
26+
27+
data = json.dumps(
28+
{
29+
"data": {
30+
"type": "station-store-pax",
31+
"attributes": {"current_pax": 10},
32+
"relationships": {
33+
"station": {"data": {"id": str(station.id), "type": "station"}},
34+
"session": {"data": {"id": str(session.id), "type": "session"}},
35+
},
36+
}
37+
}
38+
)
39+
40+
response = client.post(
41+
'/v1/station-store-paxs',
42+
data=data,
43+
content_type='application/vnd.api+json',
44+
headers=jwt,
45+
)
46+
47+
assert response.status_code == 201
48+
49+
data = response.json["data"]
50+
assert data["type"] == "station-store-pax"
51+
52+
attributes = data["attributes"]
53+
assert attributes["current-pax"] == 10
54+
assert attributes["created-at"] is not None
55+
assert attributes["modified-at"] is not None
56+
57+
58+
def test_get_station_store_pax(db, client, jwt):
59+
"""Test that a station store pax can be retrieved."""
60+
event = EventFactoryBasic()
61+
microlocation = MicrolocationSubFactory(
62+
event=event,
63+
)
64+
station = StationFactory(
65+
event=event, microlocation=microlocation, station_type='registration'
66+
)
67+
session = SessionSubFactory(
68+
event=event,
69+
microlocation=microlocation,
70+
)
71+
StationStorePaxFactory(
72+
station=station,
73+
session=session,
74+
)
75+
db.session.commit()
76+
77+
response = client.get(
78+
f"/v1/stations/{station.id}/sessions/{session.id}/station-store-paxs",
79+
headers=jwt,
80+
)
81+
82+
assert response.status_code == 200
83+
84+
count = StationStorePax.query.filter_by(
85+
station_id=station.id, session_id=session.id
86+
).count()
87+
assert len(response.json["data"]) == count

0 commit comments

Comments
 (0)