This project uses Square POS APIs to provide the following endpoints:
/location/create- Create a new location/order/create- Create a new order/orders/search- Search for orders/orders/find- Find specific orders/payment/create- Create a payment
curl --location 'localhost:8080/v1.0/location/create' \
--header 'Authorization: Bearer <auth_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"business_email": "business1@gmail.com",
"description": "Business1",
"business_name": "Business1"
}'you can create locations using this endpoints and with the location ID, you can handle the orders separately
curl --location 'localhost:8080/v1.0/order/create' \
--header 'Authorization: Bearer <auth_token> ' \
--header 'Content-Type: application/json' \
--data '{
"location_id": "L3Q8ZJYHWS11N",
"customer_id": "001",
"reference_id": "001uiqydefiuvqe",
"table_id": "002",
"line_items": [
{
"catalog_object_id": "UXHZKPGKOKXRINRN2NNWYMYR",
"name": "fish bun",
"note": "toasted",
"quantity": "5"
}
]
}'please note that the line_items catalog_object_id should be a pre created item from the square pos
curl --location 'localhost:8080/v1.0/orders/search' \
--header 'Authorization: Bearer <auth_token> ' \
--header 'Content-Type: application/json' \
--data '{
"location_id": "L3Q8ZJYHWS11N",
"table_no": "002"
}'in here, if you provide the table id, it will return all the orders relate for that table. if you leave table_id empty, it will return all the orders relate to the location
curl --location 'localhost:8080/v1.0/orders/find' \
--header 'Authorization: Bearer <auth_token> ' \
--header 'Content-Type: application/json' \
--data '{
"order_ids": [
"Z64rklvu3f4CRBHeBOggqXIdj4OZY"
],
"location_id": "L3Q8ZJYHWS11N"
}'you can provide multiple order ids
curl --location 'localhost:8080/v1.0/payment/create' \
--header 'Authorization: Bearer <auth_token> ' \
--header 'Content-Type: application/json' \
--data '{
"order_id": "TrgENvxgUwAECYxGBjnIM3tRMyOZY",
"bill_amount": 5000,
"tip_amount": 10
}'For running unit tests and see the coverage, run below commands in the terminal
To run the tests and get coverage of individual files
go test -cover ./...To run the tests and get coverage report
go test -coverprofile=c.out ./...go tool cover -html="c.out"