Skip to content
Khush Agarwal edited this page Oct 25, 2022 · 31 revisions

Shop Module API

this path goes under /shop/***


Get Requests

Get products in cart

Get the product id of all the products in a user's cart

URL

GET /prodCart

Request Body

Parameter Type Description
cartId int Cart Id of user

Example

   {
      "cartId": 447
   }

Success

RESPONSE

Parameter Type Description
products 2d Array of Int An array of product ids and corresponding quantities
  • Returns Empty Array is no products found

Example

  {
    "products": "[[455, 3], [345, 2], [678, 6], [431, 1]]"
  }

Fail

001 Cart Id not found


Get cart of user

Get the cart id of a user

URL

GET /userCart

Request Body

Parameter Type Description
userId String User Id of user

Example

   {
      "userId":"s34e"
   }

Success

RESPONSE

Parameter Type Description
cartId int Id of user's cart

Example

   {
      "cartId":445
   }

Fail

002 User Id not found


Get total price of products

Get the total price including delivery fees of all the provided products and discount

URL

GET /totalCart

Request Body

Parameter Type Description
products 2d Array of int a 2d array which contains products and their corresponding quantity
couponCode String Code of the coupon applied (Optional)

Example

   {
      "products":"[445, 2], [345, 3], [210, 1]",
      "couponCode": "free50"
   }

Success

RESPONSE

Parameter Type Description
totalPrice Decimal The total price of all the products provided including price, delivery fees and coupon discount (if any)

Example

   {
      "totalPrice": 25578.00
   }

Fail

003 One or More Products do not exist 004 Coupon Code is not valid 005 No product provided


Get subtotal price of products

Get the subtotal price of all the provided products

URL

GET /subTotalCart

Request Body

Parameter Type Description
products 2d Array of int a 2d array which contains products and their corresponding quantity

Example

   {
      "products":"[445, 2], [345, 3], [210, 1]"
   }

Success

RESPONSE

Parameter Type Description
subTotalPrice Decimal The sub-total price of all the products provided (includes only price of products)

Example

   {
      "subTotalPrice": 21047.00
   }

Fail

003 One or More Products do not exist 005 No product provided


Get total delivery fees of products

Get the total delivery fees of all the provided products

URL

GET /totalDeliveryCart

Request Body

Parameter Type Description
products 2d Array of int a 2d array which contains products and their corresponding quantity

Example

   {
      "products":"[445, 2], [345, 3], [210, 1]"
   }

Success

RESPONSE

Parameter Type Description
totalDeliveryFees Decimal The sub-total price of all the products provided (includes only price of products)

Example

   {
      "totalDeliveryFees": 1047.00
   }

Fail

003 One or More Products do not exist 005 No product provided


Get order information

Get the details of an order by orderId

URL

GET /orderDetails

Request Body

Parameter Type Description
orderId int The order id of an order

Example

   {
      "orderId": 447
   }

Success

RESPONSE

Parameter Type Description
orderId int The order id of an order
userId String the id of the user who did this order
couponCode String the code of the coupon used in this order (if any)
totalPrice Decimal the total priceof the order
totalDeliveryFees Decimal the total delivery fees of all products in the order
orderPlaceOn DateTime When the order was placed
orderStatus String the current status of the order
shippingAddress String the address where the order is shipped
tranasactionId int the id of the transaction (use to find payment info)
products 2d array of int a 2d array which contains products and their corresponding quantity

Example

   {
      "orderId": 447,
      "userId": "d44ef",
      "couponCode":"off40",
      "totalPrice": 450.32,
      "totalDeliveryFees": 40.00,
      "orderPlaceOn": "04-08-2023 13:44",
      "orderStatus":"Out for Delivery",
      "shippingAddress": "43 Street Silom House 4553 Silom Bangkok Thailand",
      "transactionId": 5778,
      "products": "[[44,3], [678, 1]]"
   }

Fail

006 Order Does not exist


Get orders of a user

Get all the orders a user has made

URL

GET /ordersOfUser

Request Body

Parameter Type Description
userId String id of the user

Example

   {
      "userId":"e558"
   }

Success

RESPONSE

Parameter Type Description
orders Array of int An array of orderIds under UserId
  • Return Empty Array if user has made no orders

Example

   {
      "orders":"[445, 587, 154, 4848]"
   }

Fail

007 User does not exist


Get user of the order

Get the userid of the given orderId

URL

GET /userOfOrder

Request Body

Parameter Type Description
orderId int id of the order

Example

   {
      "orderId": 201
   }

Success

RESPONSE

Parameter Type Description
userId String Id of the user which has made the order

Example

   {
      "uderId":"f4478"
   }

Fail

008 Order does not exist


Get review infromation

Get the details of a review by using reviewId

URL

GET /reviewDetails

Request Body

Parameter Type Description
reviewId int id of the review

Example

   {
      "reviewId": 201
   }

Success

RESPONSE

Parameter Type Description
reviewId int Id of the review
productId int Id of the product of this review
reviewTitle String Title of the review
reviewDescription String User's experience of the product
dateReview DateTime When the review was posted
imagePath String Location of the image posted in review (if any)
userId String Id of the user who made the review

Example

   {
      "reviewId": 78,
      "productId": 887,
      "reviewTitle":"The best watch I have bought",
      "reviewDescription":"This is one of the best watches I have bought in my whole life",
      "dateReview":"04-08-2023 13:44",
      "imagePath":"/res/review/6553_99_8.png",
      "userId":"s789",
   }

Fail

009 Review does not exist


Get reviews of product

Get all the reviewId's of a product

URL

GET /productReviews

Request Body

Parameter Type Description
productId int id of the product

Example

   {
      "productId": 201
   }

Success

RESPONSE

Parameter Type Description
reviews Array of Int An array which stores the reviewIds
  • Returns empty array if product has no reviews

Example

   {
      "reviews":"[789, 441, 258]",
   }

Fail

010 Product does not exist


Get product infromation

Get the details of a product by using productId

URL

GET /productDetails

Request Body

Parameter Type Description
productId int id of the product

Example

   {
      "productId": 201
   }

Success

RESPONSE

Parameter Type Description
productId int Id of the product
categoryId int Id of the category the product is in
stock int The quantity of product available in stock
productDescription String Details of the product
name String Name of the product
color String Color of the product (if any)
Size String Size of product (if any)
price decimal Price of the product
deliveryFees decimal Price of delivery of the product
contactId int Id of the contact (seller)
brandname String Name of the product brand
views Bigint The number of times this product was veiwed
images Array of String An array which stores the path of images of a product

Example

   {
      "productId": 887,
      "categoryId": 5,
      "stock": 700,
      "productDescription":"A blue ball pen to help you write more",
      "name":"Pzxyma Ball Pen",
      "color":"blue",
      "size":"20cm",
      "price": 34.00,
      "deliveryFees": 25.00,
      "contactId": 558,
      "brandName":"Pzxyma",
      "views": 56,
      "images":"["res/products/887/1.png", "res/products/887/2.png","res/products/887/3.png"]"
   }

Fail

011 Product does not exist


Get Orders of product

Get orders the product has been in

URL

GET /ordersOfProduct

Request Body

Parameter Type Description
productId int id of the product

Example

   {
      "productId": 201
   }

Success

RESPONSE

Parameter Type Description
orders Array of Int An array of orderId

Example

   {
      "orders":"[884,557,223]"
   }

Fail

011 Product does not exist


Get all products

Get all the products in the database

URL

GET /allProducts

Request Body

None

Success

RESPONSE

Parameter Type Description
products Array of Int An array of productId

Example

   {
      "products":"[884,557,223, 789, 254, 100, 2567, 104]"
   }

Fail

012 No products found 013 Cannot get the products


Get search suggestions

Get suggestion based on the given String

URL

GET /searchSuggestions

Request Body

Parameter Type Description
searchQuery String Search Query

Example

   {
      "searchQuery":"ba"
   }

Success

RESPONSE

Parameter Type Description
suggestions Array of String An array of suggestions based on searchQuery (size: 10) (if 10 is not found then size n)

Example

   {
      "suggestions":"["ball pen", "battery", "baking soda", "backpack", "bag", "ball", "balloons", "bat", "bamboo", "band"]"
   }

Fail

011 Suggestions not found


Get search results

Get products based on search query

URL

GET /searchResults

Request Body

Parameter Type Description
searchQuery String Search Query

Example

   {
      "searchQuery":"bat"
   }

Success

RESPONSE

Parameter Type Description
products Array of int An array of product id

Example

   {
      "products":"[244, 102 ,154 ,157, 4845]"
   }

Fail

014 No products found


Get coupon details

Get details of a coupon based on couponCode

URL

GET /couponDetails

Request Body

Parameter Type Description
couponCode String Code of Coupon

Example

   {
      "couponCode":"free50"
   }

Success

RESPONSE

Parameter Type Description
couponCode String Code of Coupon
desription String About Coupon
discountAmount Decimal Amount of Discount the coupon provides
validFrom Date When the coupon starts to be valid
validTill Date Expiry date of the coupon
minimumSpend Decimal The minimum amount a order needs to be before the coupon can be applied
productId int The product on which this coupon can be applied
quota int The amount of times this coupon can be used in total
isValid boolean Is coupon valid (expired, quota exceeded etc.)

Example

   {
      "couponCode":"free50",
      "description":"A coupon which can be used on Ball Pen Pzxyma blue color",
      "discountAmount": 12.00,
      "validFrom":"12/08/2023",
      "validTill":"14/12/2023",
      "minimumSpend": 40.00,
      "productId": 726,
      "quota": 10,
      "isValid":"false"
   }

Fail

015 coupon does not exist


Get user coupons

Get all the couponid for a userid

URL

GET /couponsOfUser

Request Body

Parameter Type Description
userId String Id of user

Example

   {
      "userId":"s2254"
   }

Success

RESPONSE

Parameter Type Description
coupons Array of String Array of couponCodes

Example

   {
      "coupons":"["free50", "get12", "discount11"]",
   }

Fail

015 User does not exist


Get filtered Products

Get products based on filters

URL

GET /filteredProducts

Request Body

Parameter Type Description Optional?
products Array of int An array of product id False
popularityFilter Array of Bigint Array of Bigint format: [minViews, maxViews] (len must be 2) True
brandFilter Array of String Array of String format: [brandname, brandname] (len > 0) True
priceFilter Array of Decimal Array of Decimal format: [minPrice, maxPrice] (len must be 2) True
colorFilter Array of String Array of String format: [colorname, colorname] (len > 0) True
rating int int which indicates (1 = 1 star and up, 2 = 2 star and up .... 5 = 5 star) True

Example

   {
      "products":"[224,221,447]",
      "popularityFilter":"[7777888,9999999998]",
      "brandFilter":"["Nike", "adidas", "Rebook"]",
      "priceFilter":"[884.00, 4000.00]",
      "colorFilter":"["blue", "black", "orange"]",
      "rating": 4
   }

Success

RESPONSE

Parameter Type Description
products Array of int An array of product id which is filtered

Example

   {
      "products":"[244]"
   }

Fail

015 Filter is not valid 016 Max value is lower than min Value


Get contact information

Get details of a contact by providing contact id

URL

GET /contactDetails

Request Body

Parameter Type Description
contactId int Id of the contact

Example

   {
      "contcatId": 44
   }

Success

RESPONSE

Parameter Type Description
contactId int Id of the contact
phoneNo String Phone no of the contact
address String Address of contact
lineId String Id of contact

Example

   {
      "contactId": 44,
      "phoneNo":"092 298 8989",
      "address":"877 Si Lom, Silom, Bang Rak, Bangkok 10500",
      "lineId":"abcdd"
   }

Fail

017 Contact Id is not valid


Get category information

Get details of a category by providing contact id

URL

GET /categoryDetails

Request Body

Parameter Type Description
categoryId int Id of the category

Example

   {
      "categoryId": 44
   }

Success

RESPONSE

Parameter Type Description
categoryId int Id of the category
category String Name of category
imagePath String Path of the Image

Example

   {
      "contactId": 44,
      "category":"Stationary",
      "imagePath":"res/categories/334.png",
   }

Fail

017 Category Id is not valid


Get all products in category

Get all the products in a category

URL

GET /allProductsInCategory

Request Body

Parameter Type Description
categoryId int Id of Category

Example

   {
      "categoryId": 22
   }

Success

RESPONSE

Parameter Type Description
products Array of Int An array of productId
categoryId int Id of Category

Example

   {
      "products":"[884,557,223, 789, 254, 100, 2567, 104]",
      "categoryId": 22,
   }

Fail

012 No products found 013 Cannot get the products 014 Category does not exist


Get all categories

Get all categories

URL

GET /allCategories

Request Body

None

Success

RESPONSE

Parameter Type Description
categorys Array of int Array of category id

Example

   {
      "categoryId":"[22, 10 ,1, 2, 3 ,40]",
   }

Fail

013 Cannot get the categories 014 Category does not exist


Get all recommended products

Get all the recommended products of a user

URL

GET /allRecomProducts

Request Body

Parameter Type Description
userId String Id of the user

Example

   {
      "userId":"e1",
   }

Success

RESPONSE

Parameter Type Description
products Array of int Array of product id

Example

   {
      "products":"[22, 10 ,1, 2, 3 ,40]",
   }

Fail

013 Cannot get the products


Get user of cart

Get the userid of provided cartid

URL

GET /userOfCart

Request Body

Parameter Type Description
cartId int Id of the cart

Example

   {
      "cartId": 1,
   }

Success

RESPONSE

Parameter Type Description
userId String Id of user

Example

   {
      "userId":"f11",
   }

Fail

013 Cartid does not exist


POST Requests

Post product to user's cart

Post the productid to user's cart with 1 quantity

URL

POST /addToCart

Request Body

Parameter Type Description
cartId int Id of the cart
productId int Id of the product
Example
   {
      "cartId": 1,
      "productId": 445
   }

Success

RESPONSE

Parameter Type Description
cartId int Id of the cart
productId int Id of the product
quantity int the amount of product
Example
   {
      "cartId": 1,
      "productId": 445,
      "quantity": 2
   }

Fail

013 Cannot update cart 014 Product out of stock


Post make an order

Post order to a user

URL

POST /makeOrder

Request Body

Parameter Type Description
userId String Id of the user who made the order
couponCode String Code of the coupon applied (if any)
totalPrice Decimal total price of the order
totalDeliveryFees Decimal Price of delivery
shippingAddress String The address at which the product is shipped
transactionId int Link to the transaction (payment)
products 2d Array of int 2d Array in the format productId, quantity
Example
   {
      "userId": 1,
      "couponCode": "free50",
      "totalPrice": 55214.00,
      "totalDeliveryFees": 25.00,
      "shippingAddress": "877 Si Lom, Silom, Bang Rak, Bangkok 10500",
      "transactionId" : 44,
      "products": "[[334, 2], [221,2], [77, 5]]"
   }

Success

RESPONSE

Parameter Type Description
orderId int id of the order
userId String Id of the user who made the order
couponCode String Code of the coupon applied (if any)
totalPrice Decimal total price of the order
totalDeliveryFees Decimal Price of delivery
orderPlacedOn DateTime When the order was placed
orderStatus String Status of the order
shippingAddress String The address at which the product is shipped
transactionId int Link to the transaction (payment)
products 2d Array of int 2d Array in the format productId, quantity
Example
   {
      "orderId": 1,
      "userId": 1,
      "couponCode": "free50",
      "totalPrice": 55214.00,
      "totalDeliveryFees": 25.00,
      "orderPlacedOn": "25/03/2023 16:45",
      "orderStatus": "Packing",
      "shippingAddress": "877 Si Lom, Silom, Bang Rak, Bangkok 10500",
      "transactionId" : 44,
      "products": "[[334, 2], [221,2], [77, 5]]"
   }

Fail

013 Cannot post order 014 Coupon is invalid


Post a review

Post a review made by user

URL

POST /userReview

Request Body

Parameter Type Description
userId String Id of the user who made the order
productId int Id of the product
reviewTitle String Title of the review
rating int Rating the user provides in the review
reviewDescription String Description of the review
imagePath String Path if image (if any)

Example

   {
      "userId": 1,
      "productId": 44,
      "reviewTitle": "The best watch",
      "rating": 5,
      "reviewDescription" : "This is the best watch ever",
      "imagePath": "res/review/1123.png"
   }

Success

RESPONSE

Parameter Type Description
userId String Id of the user who made the order
reviewId int Id of the review
productId int Id of the product
reviewTitle String Title of the review
rating int Rating the user provides in the review (Must be between 1-5)
reviewDescription String Description of the review
imagePath String Path if image (if any)

Example

   {
      "userId": 1,
      "reviewId": 41,
      "productId": 44,
      "reviewTitle": "The best watch",
      "rating": 5,
      "reviewDescription" : "This is the best watch ever",
      "imagePath": "res/review/1123.png"
   }

Fail

013 Cannot post review 014 Image path is not valid


POST product

POST a product to the database

URL

POST /productAdd

Request Body

Parameter Type Description
categoryId int Id of the category the product is in
stock int The quantity of product available in stock
productDescription String Details of the product
name String Name of the product
color String Color of the product (if any)
Size String Size of product (if any)
price decimal Price of the product
deliveryFees decimal Price of delivery of the product
contactId int Id of the contact (seller)
brandname String Name of the product brand
views Bigint The number of times this product was veiwed
images Array of String An array which stores the path of images of a product

Example

   {
      "categoryId": 45,
      "stock": 700,
      "productDescription":"A blue ball pen to help you write more",
      "name":"Pzxyma Ball Pen",
      "color":"blue",
      "size":"20cm",
      "price": 34.00,
      "deliveryFees": 25.00,
      "contactId": 558,
      "brandName":"Pzxyma",
      "views": 56,
      "images":"["res/products/887/1.png", "res/products/887/2.png","res/products/887/3.png"]"
   }

Success

RESPONSE

Parameter Type Description
productId int Id of the product
stock int The quantity of product available in stock
productDescription String Details of the product
name String Name of the product
color String Color of the product (if any)
Size String Size of product (if any)
price decimal Price of the product
deliveryFees decimal Price of delivery of the product
contactId int Id of the contact (seller)
brandname String Name of the product brand
views Bigint The number of times this product was veiwed
images Array of String An array which stores the path of images of a product

Example

   {
      "productId": 887,
      "categoryId": 45,
      "stock": 700,
      "productDescription":"A blue ball pen to help you write more",
      "name":"Pzxyma Ball Pen",
      "color":"blue",
      "size":"20cm",
      "price": 34.00,
      "deliveryFees": 25.00,
      "contactId": 558,
      "brandName":"Pzxyma",
      "views": 56,
      "images":"["res/products/887/1.png", "res/products/887/2.png","res/products/887/3.png"]"
   }

Fail

011Cannot post the product


Post a contact

Post a new contact (seller) to database

URL

POST /newContact

Request Body

Parameter Type Description
phoneNo String Phone no of the contact
address String Address of the contact
lineId String Line id of the contact

Example

   {
      "phoneNo": "098 999 9941",
      "address" : "877 Si Lom, Silom, Bang Rak, Bangkok 10500",
      "lineId": "hello11"
   }

Success

RESPONSE

Parameter Type Description
contactId int Id of the contact
phoneNo String Phone no of the contact
address String Address of the contact
lineId String Line id of the contact

Example

   {
      "contactId": 4,
      "phoneNo": "098 999 9941",
      "address" : "877 Si Lom, Silom, Bang Rak, Bangkok 10500",
      "lineId": "hello11"
   }

Fail

013 Cannot post the contact


Post a coupon

Post a new coupon to database

URL

POST /newCoupon

Request Body

Parameter Type Description
couponCode String Code of Coupon
desription String About Coupon
discountAmount Decimal Amount of Discount the coupon provides
validFrom Date When the coupon starts to be valid
validTill Date Expiry date of the coupon
minimumSpend Decimal The minimum amount a order needs to be before the coupon can be applied
productId int The product on which this coupon can be applied
quota int The amount of times this coupon can be used in total
isValid boolean Is coupon valid (expired, quota exceeded etc.)

Example

   {
      "couponCode":"free50",
      "description":"A coupon which can be used on Ball Pen Pzxyma blue color",
      "discountAmount": 12.00,
      "validFrom":"12/08/2023",
      "validTill":"14/12/2023",
      "minimumSpend": 40.00,
      "productId": 726,
      "quota": 10,
      "isValid":"false"
   }

Success

RESPONSE

Parameter Type Description
couponCode String Code of Coupon
desription String About Coupon
discountAmount Decimal Amount of Discount the coupon provides
validFrom Date When the coupon starts to be valid
validTill Date Expiry date of the coupon
minimumSpend Decimal The minimum amount a order needs to be before the coupon can be applied
productId int The product on which this coupon can be applied
quota int The amount of times this coupon can be used in total
isValid boolean Is coupon valid (expired, quota exceeded etc.)

Example

   {
      "couponCode":"free50",
      "description":"A coupon which can be used on Ball Pen Pzxyma blue color",
      "discountAmount": 12.00,
      "validFrom":"12/08/2023",
      "validTill":"14/12/2023",
      "minimumSpend": 40.00,
      "productId": 726,
      "quota": 10,
      "isValid":"false"
   }

Fail

013 Cannot post the coupon 014 Coupon code already used


Provide a coupon to user

Post a new userCoupon and give it to user

URL

POST /newUserCoupon

Request Body

Parameter Type Description
couponCode String Code of Coupon
userId String id of the user
Example
   {
      "couponCode":"free50",
      "userId": "5"
   }

Success

RESPONSE

Parameter Type Description
couponCode String Code of Coupon
userId String Id of user

Example

   {
      "couponCode":"free50",
      "userId": "5"
   }

Fail

013 Cannot post the coupon 014 Coupon code quota finished 015 Coupon code expired 016 User did not make an order with the required product before


PUT Requests

Update quantity of product

Put change the qunatity of a product in a user's cart

URL

PUT /changeQtCart

Request Body

Parameter Type Description
cartId int id of the cart
productId int id of the product
quantity int quantity of the product
Example
   {
      "cartId": 5,
      "productId": 6,
      "quantity": 7
   }

Success

RESPONSE

Parameter Type Description
cartId int id of the cart
productId int id of the product
quantity int quantity of the product
Example
   {
      "cartId": 5,
      "productId": 6,
      "quantity": 7
   }

Fail

013 Cannot update quantity 014 product does not exist in the cart 015 Not enough stock


Update order status

PUT update the status of an order

URL

PUT /orderStatus

Request Body

Parameter Type Description
orderId int id of the order
status String Status of the order
Example
   {
      "orderId": 5,
      "status": "Processing"
   }

Success

RESPONSE

Parameter Type Description
orderId int id of the order
status String Status of the order
Example
   {
      "orderId": 5,
      "status": "Processing"
   }

Fail

013 Order does not exist 014 Cannot update order status


Update product veiws

PUT update the views of a product

URL

PUT /viewChange

Request Body

Parameter Type Description
productId int id of the product
views int Views of the order
Example
   {
      "productId": 8,
      "views": 54441
   }

Success

RESPONSE

Parameter Type Description
productId int id of the product
views int Views of the order
Example
   {
      "productId": 8,
      "views": 54441
   }

Fail

013 Product does not exist 014 Cannot update product views


Delete Requests

Delete product from cart

Delete product(s) from a user's cart

URL

DELETE /productFromCart

Request Body

Parameter Type Description
cartId int id of the cart
products Array of int Array of productid
Example
   {
      "cartId": 5,
      "productId": "[4,5,3,12,2]"
   }

Success

RESPONSE

Parameter Type Description
cartId int id of the cart
products Array of int Array of productid
Example
   {
      "cartId": 5,
      "productId": "[4,5,3,12,2]"
   }

Fail

013 Cannot delete the products 014 One or more products do not exist in the cart 015 Cart does not exist

Clone this wiki locally