Skip to content

Commit

Permalink
chore: Enable dredd tests for some of the Orders API endpoints (#7261)
Browse files Browse the repository at this point in the history
  • Loading branch information
blossom2017 authored Sep 12, 2020
1 parent 38f024e commit b872fe2
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 141 deletions.
2 changes: 1 addition & 1 deletion app/api/custom/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def create_order():
db.session.commit()
order.populate_and_save()

return OrderSchema().dumps(order)
return OrderSchema().dump(order)


@order_blueprint.route('/complete-order/<order_id>', methods=['PATCH'])
Expand Down
202 changes: 72 additions & 130 deletions docs/api/blueprint/order/orders.apib
Original file line number Diff line number Diff line change
Expand Up @@ -50,167 +50,113 @@ Get a list of all orders
}
}

## Create Order [/v1/orders/create-order]

### Create Order [POST]
Create a new Order

+ Request (application/vnd.api+json)
+ Request (application/json)

+ Headers

Accept: application/json

Authorization: JWT <Auth Key>

+ Body

{
"data": {
"attributes": {
"payment-mode": "paypal",
"country": "India",
"status": "pending",
"amount": "10",
"order-notes": "example"
},
"type": "order",
"relationships": {
"attendees": {
"data": [
{
"id": "1",
"type": "attendee"
}
]
},
"event": {
"data": {
"id": "1",
"type": "event"
}
}
}
}
}
+ Response 201 (application/vnd.api+json)
{
"tickets": [
{"id": 1, "quantity": 2},
{"id": 2, "quantity": 4},
{"id": 3, "quantity": 3, "price": 789.7},
{"id": 4, "quantity": 3}
],
"discount_code": "1"
}

+ Response 200 (application/json)

{
"included": [
{
"relationships": {
"ticket": {
"links": {
"self": "/v1/attendees/1/relationships/ticket",
"related": "/v1/attendees/1/ticket"
}
},
"event": {
"links": {
"self": "/v1/attendees/1/relationships/event",
"related": "/v1/attendees/1/event"
}
}
},
"attributes": {
"city": null,
"firstname": "Open Event User",
"lastname": null,
"ticket-id": "1",
"is-checked-in": false,
"checkin-times": null,
"is-checked-out": null,
"checkout-times": null,
"state": null,
"address": null,
"pdf-url": "http://example.com",
"country": null,
"email": null,
"created-at": "2018-07-08T01:05:09.904696+00:00",
"order-notes": "example"
},
"type": "attendee",
"id": "1",
"links": {
"self": "/v1/attendees/1"
}
}
],
"data": {
"type": "order",
"attributes": {
"completed-at": null,
"paid-via": null,
"exp-year": null,
"discount-code-id": "1",
"status": "initializing",
"deleted-at": null,
"exp-month": null,
"country": null,
"is-billing-enabled": false,
"transaction-id": null,
"order-notes": null,
"tickets-pdf-url": null,
"payment-mode": null,
"city": null,
"tax-business-info": null,
"amount": 4745.81,
"identifier": "300d7722-7005-4776-89d7-037cc7ceec0d",
"brand": null,
"created-at": "2020-09-11T12:11:24.169351+00:00",
"zipcode": null,
"company": null,
"last4": null,
"state": null,
"cancel-note": null,
"address": null
},
"id": "1",
"relationships": {
"tickets": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/ticket",
"related": "/v1/orders/11/tickets"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/ticket",
"related": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/tickets"
}
},
"attendees": {
"data": [
{
"type": "attendee",
"id": "1"
}
],
"user": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/attendee",
"related": "/v1/orders/11/attendees"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/user",
"related": "/v1/users/1"
}
},
"marketer": {
"discount-code": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/marketer"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/discount-code",
"related": "/v1/discount-codes/1"
}
},
"user": {
"attendees": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/user"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/attendee",
"related": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/attendees"
}
},
"discount-code": {
"event": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/discount-code"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/event",
"related": "/v1/events/1"
}
},
"event": {
"event-invoice": {
"links": {
"self": "/v1/orders/617ed24c-9a07-4084-b076-ed73552db27e/relationships/event",
"related": "/v1/events/1"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/event-invoice/",
"related": "/v1/event-invoices/1"
}
},
"marketer": {
"links": {
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d/relationships/marketer"
}
}
},
"attributes": {
"status": "pending",
"city": null,
"identifier": "617ed24c-9a07-4084-b076-ed73552db27e",
"paid-via": null,
"exp-year": null,
"transaction-id": null,
"discount-code-id": null,
"brand": null,
"zipcode": null,
"company": null,
"tax-business-info": null,
"is-billing-enabled": false,
"payment-mode": "paypal",
"last4": null,
"state": null,
"payment-url": "https://www.sandbox.paypal.com/cgi-bin/webscr?token=EC-62113287PK247472B&cmd=_express-checkout",
"address": null,
"exp-month": null,
"amount": 10.0,
"country": "India",
"completed-at": null,
"created-at": "2018-07-08T01:05:09.904696+00:00",
"order-notes": "example",
"tickets-pdf-url": "https://example.com/media/attendees/tickets/pdf/order_identifier.pdf"
},
"type": "order",
"id": "11",
"links": {
"self": "/v1/orders/1"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d"
}
},
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "/v1/orders/11"
"self": "/v1/orders/300d7722-7005-4776-89d7-037cc7ceec0d"
}
}

Expand Down Expand Up @@ -281,8 +227,7 @@ Get a single Order detail.
"company": null,
"tax-business-info": null,
"is-billing-enabled": false,
"payment-mode": "paypal",
"payment-url": "https://www.sandbox.paypal.com/cgi-bin/webscr?token=EC-62113287PK247472B&cmd=_express-checkout",
"payment-mode": "free",
"last4": null,
"state": null,
"address": null,
Expand All @@ -307,8 +252,6 @@ Get a single Order detail.
"self": "/v1/orders/ab25a170-f36d-4dd6-b99c-9c202e693afc"
}
}


### Update Order [PATCH]
Update a single custom form with `id`.

Expand All @@ -325,7 +268,7 @@ Update a single custom form with `id`.
{
"data": {
"attributes": {
"status": "confirmed",
"payment-mode": "paypal",
"order-notes": "example"
},
"type": "order",
Expand Down Expand Up @@ -387,7 +330,6 @@ Update a single custom form with `id`.
"tax-business-info": null,
"is-billing-enabled": false,
"payment-mode": "paypal",
"payment-url": "https://www.sandbox.paypal.com/cgi-bin/webscr?token=EC-62113287PK247472B&cmd=_express-checkout",
"last4": null,
"state": null,
"address": null,
Expand Down Expand Up @@ -549,7 +491,7 @@ Create a new Order with on site attendees
"payment-mode": "free",
"last4": null,
"state": null,
"payment-url": "https://www.sandbox.paypal.com/cgi-bin/webscr?token=EC-62113287PK247472B&cmd=_express-checkout",
"payment-url": "https://www.sandbox.paypal.com/cgi-bin/webscr?token=EC-62113287PK247472B&cmd=_express-checkout",
"address": null,
"exp-month": null,
"amount": null,
Expand Down
Loading

0 comments on commit b872fe2

Please sign in to comment.