0% found this document useful (0 votes)
5 views20 pages

Order REST API Specification

The document outlines an assignment to develop REST APIs for managing CRUD operations on Order, Party, and Product entities using a MySQL database. It includes tasks such as creating a database schema, defining entities, and implementing services for various API functionalities like creating orders, adding items, and retrieving order details. Additionally, it specifies prerequisites, submission guidelines, and bonus tasks such as implementing JWT authentication and creating user interfaces.

Uploaded by

Arbaz Ali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views20 pages

Order REST API Specification

The document outlines an assignment to develop REST APIs for managing CRUD operations on Order, Party, and Product entities using a MySQL database. It includes tasks such as creating a database schema, defining entities, and implementing services for various API functionalities like creating orders, adding items, and retrieving order details. Additionally, it specifies prerequisites, submission guidelines, and bonus tasks such as implementing JWT authentication and creating user interfaces.

Uploaded by

Arbaz Ali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment

Order REST APIs

HOTWAX COMMERCE HOTWAX COMMERCE


International Headquarters India Office
136 S Main Street, Ste A200 Plot - 80, Scheme No. 78
Salt Lake City, UT 84101 Part-II, Vijay Nagar
USA Indore, MP
1-877-736-4080
[Link] +91-731 409 3684
Table of Contents

Assignment 2
Problem Statement 2
Prerequisite 3
Tasks 3
1. Create database schema, define entities and load sample data 3
2. REST APIs 3
Run APIs 8
Assignment Submission 8
Entity definition 9
Table Order_Header 9
Table Order_Part 10
Table Person 13
Table Party 15
Table Product 15
Party and Product sample data 17
Assignment

Problem Statement

In this assignment, you should be able to develop a set of REST APIs capable of
performing CRUD operations using some simple HTTP requests.

The assignment expects the development of REST APIs.

This assignment tests your ability to -


● Setup entities
● Define new REST APIs
● Implement services

Prerequisite
Working knowledge of
MySQL database, SQL data types, DDL, SQL
Computer programming language
Basics of HTTP and REST protocol.

Tasks

1. Database
Create schema, define entities and load sample data
Party and Product dataset must be loaded in the database before working on the
REST APIs.
2. REST APIs

Develop publicly accessible REST APIs to manage CRUD operations on Party,


Product and Order entities.

Note:
Ensure REST API is defined as per the specification defined using sample data.

Define the REST resources and the corresponding services for the following
scenarios to create order details for an existing customer.

1. Create, Update and Get Person


Create a REST API for managing Person data.

2. Create Order
a. The input schema for the Create Order API should have the
parameters as per the sample request body added below, with the
following constraints.
i. The currency unit of measure parameter should default to
“USD” if not provided in the request.
ii. The status parameter should default to “OrderPlaced” if not
provided in the request.
iii. The order name and placed date are required parameters.

{
"orderName": "Test Order 1",
"currencyUomId": "USD",
"salesChannelEnumId": "ScWeb",
"statusId": "OrderPlaced"
"productStoreId": "OMS_DEFAULT_STORE",
"placedDate": "2020-04-17",
"approvedDate": "2020-04-19"
}

b. The successful API request should return the order identification.

3. Add Order Items


a. Identify the entities involved in adding items to an order as per the
below input schema.

b. The add order items API definition should be as per the sample
request body given below.
i. The customer data is mandatory for adding the items to an
existing order.
ii. The shipmentMethod parameter should default to
“ShMthGround” if not provided in the request.
iii. The order items list parameter should be mandatory.
iv. For each item inside the order items, productId, quantity and
unit amount parameters should be mandatory.

{
"orderId": "100000",
"partName": "Test Order Part 1",
"facilityId": "ZIRET_WH",
"shipmentMethodEnumId": "ShMthGround",
"customerPartyId": "CustJqp",
"item_details": [{
"productId": "DEMO_UNIT",
"itemDescription": "Demo Product Unit One",
"quantity": "1",
"unitAmount": "16.99"
},
{
"productId": "DEMO_1_1",
"itemDescription": "Demo Product Unit Two",
"quantity": "2",
"unitAmount": "18.99"
}]
}

c. The successful API request should return the orderId and


orderPartSeqId.

4. Get all Orders


a. The API request should return the list of all orders.

b. The output schema for the Get Orders API should have the parameters
as per the sample response body added below.

{
"orders": [
{
"orderId": "105001",
"orderName": "sample order 1",
"currencyUom": "USD",
"salesChannelEnumId": "ScWeb",
"statusId": "OrderPlaced",
"placedDate": "2020-04-17",
"grandTotal": 54.97,
"customer_details": {
"customerPartyId": "100601",
"firstName": "Sam",
"middleName": "",
"lastName": "Wilson"
},
"order_parts": [{
"orderPartSeqId": "01",
"partName": "Test Order Part 1",
"facilityId": "ZIRET_WH",
"shipmentMethodEnumId": "ShMthGround",
"partStatusId": "OrderPlaced",
"partTotal": 54.97,
"item_details": [{
"orderItemSeqId": "01",
"productId": "DEMO_UNIT",
"itemDescription": "Demo Product One
Unit",
"quantity": 1,
"unitAmount": 16.99
}, {
"orderItemSeqId": "02",
"productId": "DEMO_1_1",
"itemDescription": "Demo Product
Unit Two",
"quantity": "2",
"unitAmount": "18.99"
}]
}]
}]
}

5. Get an Order
a. The API request should return information about an order by giving its
order id.
Note: This API should return the information for the order as per the output
schema for the API developed as part of point 3.

6. Update Order
a. The API request should be able to update the order name for a given
order Id, as per the sample request body added below.

{
"orderId": "100000",
"orderName": "My first order."
}

b. The output schema for the API should have the parameters as per the
sample response body added below.

{
"orderId": "100000",
"orderName": "My first order.",
"currencyUomId": "USD",
"salesChannelEnumId": "ScWeb",
"statusId": "OrderPlaced"
"productStoreId": "OMS_DEFAULT_STORE",
"placedDate": "2020-04-17",
"approvedDate": "2020-04-19",
"grandTotal": 54.97
}
3. Add Encryption
a. Create a field CREDIT_CARD in Order_Header table, it should be stored in
encrypted form in the database.
b. When fetching the data using api, it should be decrypted and then displayed.

Run APIs

1. Check the working of all the developed REST APIs by executing the requests
using Postman.

Bonus Tasks

1. Apply JWT authentication to all the APIs.


2. Create User Interfaces to interact with the APIs.

Assignment Submission

1. Push the project code to the repository on github.


2. Add the screenshot of the results for each API when testing the API in
Postman.

Entity definition

Table: Order_Header

"order_header": {
"columns": {
"ORDER_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"ORDER_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PLACED_DATE": {
"type": "datetime",
"constraints": {
"DEFAULT": "NULL"
}
},
"APPROVED_DATE": {
"type": "datetime",
"constraints": {
"DEFAULT": "NULL"
}
},
"STATUS_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"CURRENCY_UOM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PRODUCT_STORE_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"SALES_CHANNEL_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"GRAND_TOTAL": {
"type": "decimal(24,4)",
"constraints": {
"DEFAULT": "NULL"
}
},
"COMPLETED_DATE": {
"type": "datetime",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["ORDER_ID"]
}
}

Table: Order_Part

{
"order_part": {
"columns": {
"ORDER_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"ORDER_PART_SEQ_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"PART_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"STATUS_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"VENDOR_PARTY_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"CUSTOMER_PARTY_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PART_TOTAL": {
"type": "decimal(24,4)",
"constraints": {
"DEFAULT": "NULL"
}
},
"FACILITY_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"SHIPMENT_METHOD_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["ORDER_ID", "ORDER_PART_SEQ_ID"],
"foreign_keys": [
{
"constraint_name": "order_part_ibfk_1",
"foreign_column": "ORDER_ID",
"references": {
"table": "order_header",
"column": "ORDER_ID"
}
},
{
"constraint_name": "order_part_ibfk_6",
"foreign_column": "CUSTOMER_PARTY_ID",
"references": {
"table": "party",
"column": "PARTY_ID"
}
}
]
}
}

Table Person

{
"person": {
"columns": {
"PARTY_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"SALUTATION": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"FIRST_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"MIDDLE_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"LAST_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"GENDER": {
"type": "char(1)",
"constraints": {
"DEFAULT": "NULL"
}
},
"BIRTH_DATE": {
"type": "date",
"constraints": {
"DEFAULT": "NULL"
}
},
"MARITAL_STATUS_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"EMPLOYMENT_STATUS_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"OCCUPATION": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["PARTY_ID"],
"foreign_keys": [
{
"constraint_name": "person_ibfk_1",
"foreign_column": "PARTY_ID",
"references": {
"table": "party",
"column": "PARTY_ID"
}
}
]
}
}

Table Party

{
"party": {
"columns": {
"PARTY_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"PARTY_TYPE_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["PARTY_ID"]
}
}

Table Product

{
"product": {
"columns": {
"PRODUCT_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"OWNER_PARTY_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PRODUCT_NAME": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"DESCRIPTION": {
"type": "varchar(4095)",
"constraints": {
"DEFAULT": "NULL"
}
},
"CHARGE_SHIPPING": {
"type": "char(1)",
"constraints": {
"DEFAULT": "NULL"
}
},
"RETURNABLE": {
"type": "char(1)",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["PRODUCT_ID"],
"foreign_keys": [
{
"constraint_name": "product_ibfk_1",
"foreign_column": "OWNER_PARTY_ID",
"references": {
"table": "party",
"column": "PARTY_ID"
}
}
]
}
}

Party and Product sample data

"Party": {
"partyId": "ORG_ZIZI_RETAIL",
"pseudoId": "ZIRET",
"partyTypeEnumId": "PtyOrganization",
"ownerPartyId": "ORG_ZIZI_RETAIL",
"organization": {
"organizationName": "Ziziwork Retail & Wholesale"
},
"roles": {
"roleTypeId": "OrgInternal"
}
}

"Party": {
"partyId": "CustJqp",
"partyTypeEnumId": "PtyPerson",
"ownerPartyId": "ORG_ZIZI_RETAIL",
"person": {
"firstName": "Joe",
"middleName": "Q",
"lastName": "Public",
"gender": "F",
"maritalStatusEnumId": "MarsSingle"
},
"roles": {
"roleTypeId": "Customer"
}
}

"Party": {
"partyId": "CustDemo2",
"partyTypeEnumId": "PtyPerson",
"ownerPartyId": "ORG_ZIZI_RETAIL",
"person": {
"firstName": "Jack",
"middleName": "Q",
"lastName": "Smith",
"gender": "M",
"maritalStatusEnumId": "MarsMarried"
},
"roles": {
"roleTypeId": "Customer"
}
}

"Product": {
"productId": "DEMO_UNIT",
"productTypeEnumId": "PtAsset",
"assetTypeEnumId": "AstTpInventory",
"assetClassEnumId": "AsClsInventoryFin",
"chargeShipping": "Y",
"returnable": "Y",
"productName": "Demo Product One Unit",
"description": "",
"ownerPartyId": "ORG_ZIZI_RETAIL"
}

"Product": {
"productId": "DEMO_1_1",
"productTypeEnumId": "PtAsset",
"assetTypeEnumId": "AstTpInventory",
"assetClassEnumId": "AsClsInventoryFin",
"chargeShipping": "Y",
"returnable": "Y",
"productName": "Demo Product One One",
"description": "",
"ownerPartyId": "ORG_ZIZI_RETAIL"
}

"Product": {
"productId": "DEMO_1_2",
"productTypeEnumId": "PtAsset",
"assetTypeEnumId": "AstTpInventory",
"assetClassEnumId": "AsClsInventoryFin",
"chargeShipping": "Y",
"returnable": "Y",
"productName": "Demo Product One Two",
"description": "",
"ownerPartyId": "ORG_ZIZI_RETAIL"
}
}

You might also like