美文网首页
无标题文章

无标题文章

作者: Lomo_5ded | 来源:发表于2018-03-28 20:11 被阅读0次

    [toc]#API Documentation##OverviewThis documentation covers the basic coffee order and payment task web API.##URLs and OperationsBelow are the URL and operations associated with them.###OrdersThe**orders**URL is the main URL for creating and getting the**Order**objects.The associated operations are listed in below table.| Operation | URL | Method | Returns | Inputs || :-------- | --------:| :------: || AddOrder | /orders | POST |[Order](#### Orders)|[type](#### type),[additions](),[id](),[cost]()| OrderList | /orders | GET | [Order]( )| none ||OrderItem|/orders/id|GET|[Order]()|none||OrderItem|/orders/id|PUT|[Order]()|[additions](),[cancel]()||OrderItem|/orders/id|PATCH|[Order]()|[making](),[finish](),[release]()|###PaymentsThe**payments**URL is the main URL for creating and getting the**Payment**objects.The associated operations are listed in below table.| Operation | URL | Method | Returns | Inputs || :-------- | --------:| :------: ||AddPayment|/payments|POST|[Payment]()|[payment_type](),[amount](),[card_number]()||PaymentList|/payments|GET|[Payment]()|none||PaymentItem|/payments/id|GET|[payment]()|none|##ResponsesThe Orders API returns some payloads in JSON format:1. Order payload2. Payment payload3. Error payloadSee below for details.###Orders payloadThe input of making an new order must contain a parameter [type]() which can have several options such as:`latte`,`flat white`,`cap`,`short black`,`hot chocolate`.and one optional parameter [additions]() which can take any**string**as its value.A coffee**ORDER**object looks like this:```json{"coffeeOrder":[{"additions": null,"cancel": false,"cashier": "Jason","cost": 3.5,"finished": false,"id": 1,"making": false,"paid": false,"release": false,"type": "latte"}],"payment": "/payments/1"}```Order object must cantian properties such as:`type`,`cancel`,`cashier`,`cost`,`finished`,`id`,`making`,`paid`,`release`.###Payments payloadThe input of creating an new payment for the order must contain those parameters - [payment_type]() which takes either**card**or**cash**as its value. - [card_number]() if the`payment_type`is**card**, which takes a serial digits as its input.- [amount](): it takes a real number as input```json{"PaymentDetails":[{"amount": 5,"card_type": "card","details": "card number: 123456","order_id": 1,"payment_id": 1}]}OR{"paymentDetails":[{"amount": 5,"card_type": "cash","details": "paid by cash","order_id": 2,"payment_id": 2}]}```Payment object must contain properties such as`order_id`.`payment_id`,`card_type`,`details`,`amount`##Data ElementsThere is a list of data elements may appears in both request query and the response payloads.###typeIndicates the brista which kind of coffee should be done. The valid value of this element is a string type value. See[Orders payload](### orders)###additionsAdd some additions requirements to the coffee order such as soy milk, one sugar, decaff and so on. See[Orders payload](### orders)###idThe Order object identifier. See[Orders payload](### orders),[Payments payload](### Payments payload)###costIndicates the price of the coffee order. The valid value for this element must be`the real number`. See[Orders payload](### orders)###cancelIndicates cancel status of the order. The valid value for this element is either`True`or`False`. See[Orders payload](### orders)###makingIndicates the starting status of the order. The valid value for this element is either`True`or`False`. See[Orders payload](### orders)###finishIndicates the completion status of the order. The valid value for this element is either`True`or`False`. See[Orders payload](### orders)###releaseIndicates the release status of the order. The valid value for this element is either`True`or`False`. See[Orders payload](### orders)###payment_typeShow the how the customer pay the order. The valid value for this element is string type value which is either`card`or`cash`. See[Payments payload](### Payments payload)###card_numberShow the card details if the customer pay by`card`in the`payment_type`. The valid value for this element is a serial digits e.g. 123456789. See[Payments payload](### Payments payload)###amountShows how much many the customer paid either by cash or by card. The valid value for this element is the`real number`. See[Payments payload](### Payments payload)###paidIndicates the payment status of the order. The valid value of this element is either`True`or`False`. See[Orders payload](### orders)###payment_idThe payment object identifier. See[Payments payload](### Payments payload)###cashierShows the cashier of the order. In this API, it is always a string value`Jason`. See[Orders payload](### orders)

    相关文章

      网友评论

          本文标题:无标题文章

          本文链接:https://www.haomeiwen.com/subject/xugugttx.html