...
Place order with User Panel API
This is the older legacy API. Use it if you want to offer your customers a UI for creating orders, that is very similar to the 3yourmind User Panel.
Place order with Service Panel API
This is the newer API, it is easier to work with. Use it if you want to interface with the 3yourmind API, from some other backend service, or if you already have your own UI for order creation.
Place order with User Panel API
Do all the steps in Upload a file
For every line: Update the basket line to set an offer and post-processing.
(optional) Create Shipping and billing addresses.
(optional) Check the order total with the Get Basket Price endpoint.
Create order for basket. Depending on your Printing Service, you will have to choose:
way of delivery
and a Payment method.
Place order with Service Panel API
Choose user for which to create order (from all users of the service). Fetch users - GET
Assign the previous chosen user to the basket Update basket with user - PATCH
Get addresses of the user, choose address for this order Fetch addresses of user - GET
Choose payment method Fetch available payment methods - GET
Choose shipping method Fetch available shipping methods - GET
Choose material for this line Fetch available materials - GET
Update print price and material/offer and post processings for this line - PATCH
Wait until file upload has finished, periodically call this endpoint (each 1s): Fetch the file upload status - GET
Submit the final order, that links all previous steps together
See the following code, as an example of all the steps. It is written as JetBrains .http file format, even if you can not execute with your IDE, you can still read the code examples in it.
Code Block |
---|
###
< {%
client.global.set("token", "dd247ae0d9cddcefa32e3ef502c4798b6ae531d8");
client.global.set("service_id", "1");
%}
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/internal-ordering/users/?search=Ortega
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("customer_id", response.body.results[0].id);
client.log(JSON.stringify(client.global["vars"]["customer_id"]))
%}
###
POST http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/baskets/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("basked_id", response.body.id);
client.log(JSON.stringify(client.global["vars"]["basked_id"]))
%}
###
PATCH http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/baskets/{{basked_id}}/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
{
"customer_id": {{customer_id}}
}
###
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/internal-ordering/users/{{customer_id}}/addresses/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("customer_address_id", response.body[2].id);
client.log(JSON.stringify(client.global["vars"]["customer_address_id"]))
%}
###
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/payment-methods/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("payment_method_id", response.body[0].id);
client.log(JSON.stringify(client.global["vars"]["payment_method_id"]))
%}
###
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/shipping-methods/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("shipping_method_id", response.body[0].id);
client.log(JSON.stringify(client.global["vars"]["shipping_method_id"]))
%}
###
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/offers/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("offer_id", response.body[0].id);
client.log(JSON.stringify(client.global["vars"]["offer_id"]))
%}
###
POST http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/baskets/{{basked_id}}/lines/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
> {%
client.global.set("line_id", response.body.id);
client.log(JSON.stringify(client.global["vars"]["line_id"]))
%}
###
PATCH http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/baskets/{{basked_id}}/lines/{{line_id}}/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
{
"offer_id": {{offer_id}},
"postProcessings": [],
"unitPrintPrice": "12.34"
}
###
POST http://multi.my.3yd/api/v2.0/files/
Content-Type: multipart/form-data; boundary=boundary
--boundaryd
Content-Disposition: form-data; name="file"; filename="test_areas (copy).stl"
Content-Type: model/x.stl-binary
< ./cube_10_inch.stl
--boundary
Content-Disposition: form-data; name="basket_id"
{{basked_id}}
--boundary
Content-Disposition: form-data; name="line_id"
{{line_id}}
--boundary
Content-Disposition: form-data; name="unit"
inch
###
GET http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/baskets/{{basked_id}}/lines/{{line_id}}/file-status/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
###
POST http://multi.my.3yd/api/v2.0/service-panel/services/{{service_id}}/internal-ordering/orders/
Accept: application/json
Content-Type: application/json
Authorization: Token {{token}}
{
"additionalInformation": {
"reference": "some test reference"
},
"basketId": {{basked_id}},
"billingAddressId": {{customer_address_id}},
"pickupLocationId": null,
"fees": [],
"shippingPrice": "12.34",
"shipping": {
"methodId": {{shipping_method_id}},
"addressId": {{customer_address_id}},
"deliveryInstructions": "string"
},
"payment": {
"methodId": {{payment_method_id}},
"authorizedAmount": "12.34",
"currency": "EUR",
"details": { }
},
"voucherCode": null,
"userId": {{customer_id}}
} |
example.http