-
Notifications
You must be signed in to change notification settings - Fork 21
Module 6 Order API
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
Working knowledge of
MySQL database, SQL data types, DDL, SQL
Computer programming language
Basics of HTTP and REST protocol.
Create schema, define entities and load sample data
Party and Product dataset must be loaded in the database before working on the 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.
-
Create, Update and Get Person
Create a REST API for managing Person data.
-
Create Order
- The input schema for the Create Order API should have the parameters as per the sample request body added below, with the following constraints.
-
The currency unit of measure parameter should default to “USD” if not provided in the request.
-
The status parameter should default to “OrderPlaced” if not provided in the request.
-
The order name and placed date are required parameters.
-
- The input schema for the Create Order API should have the parameters as per the sample request body added below, with the following constraints.
{ "orderName": "Test Order 1", "currencyUomId": "USD", "salesChannelEnumId": "ScWeb", "statusId": "OrderPlaced" "productStoreId": "OMS_DEFAULT_STORE", "placedDate": "2020-04-17", "approvedDate": "2020-04-19" }
2. The successful API request should return the order identification.
3. **Add Order Items**
3. Identify the entities involved in adding items to an order as per the below input schema.
4. The add order items API definition should be as per the sample request body given below.
4. The customer data is mandatory for adding the items to an existing order.
5. The shipmentMethod parameter should default to “ShMthGround” if not provided in the request.
6. The order items list parameter should be mandatory.
7. 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"
}]
}
5. The successful API request should return the orderId and orderPartSeqId.
-
Get all Orders 6. The API request should return the list of all orders. 7. 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**
8. 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**
9. 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."
}
10. 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**
1. Create a field CREDIT_CARD in Order_Header table, it should be stored in encrypted form in the database.
2. 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: Order_Item
{
"order_item": {
"columns": {
"ORDER_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"ORDER_ITEM_SEQ_ID": {
"type": "varchar(40)",
"constraints": {
"NOT NULL": true
}
},
"ORDER_PART_SEQ_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PRODUCT_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"ITEM_DESCRIPTION": {
"type": "varchar(255)",
"constraints": {
"DEFAULT": "NULL"
}
},
"QUANTITY": {
"type": "decimal(26,6)",
"constraints": {
"DEFAULT": "NULL"
}
},
"UNIT_AMOUNT": {
"type": "decimal(25,5)",
"constraints": {
"DEFAULT": "NULL"
}
},
"ITEM_TYPE_ENUM_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
},
"PARENT_ITEM_SEQ_ID": {
"type": "varchar(40)",
"constraints": {
"DEFAULT": "NULL"
}
}
},
"primary_key": ["ORDER_ID", "ORDER_ITEM_SEQ_ID"],
"foreign_keys": [
{
"constraint_name": "order_item_ibfk_1",
"foreign_column": "ORDER_ID",
"references": {
"table": "order_header",
"column": "ORDER_ID"
}
},
{
"constraint_name": "order_item_ibfk_6",
"foreign_column": "ORDER_ID, ORDER_PART_SEQ_ID",
"references": {
"table": "order_part",
"column": "ORDER_ID, ORDER_PART_SEQ_ID"
}
},
{
"constraint_name": "order_item_ibfk_7",
"foreign_column": "PRODUCT_ID",
"references": {
"table": "product",
"column": "PRODUCT_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"
}
}