Brazil Fulfillment Service
Purpose
The purpose of this service includes:
- Validate Brazil Customers Information: Personal, Address and Tax Information
- Validate Shipping Information for JDE Fulfilled Orders
- Consolidate Customer and Shipment Information and send it to Brazil
- Keep Track of the different Status of a Shipment
- Provide data related to Order Fulfillment to other APIs
Usage
The way the service works consists in two flows:
Customer Information Flow
The Service:
- Receives the Customer Information via HTTP request from the Brazil Customers Service
- Saves the Customer Information in its own Database for further validations
Shipments Information Flow
The Service:
- Gets Shipments from the JDE 3PL API v2
- Acknowledges the Shipments Information and Saves it in its own Database
- Adds Additional Order Information from Legacy DB
- Validates both Shipments and Customers Information
- Sends both Shipments and Customers Information together in case of a successful validation
- Receives updates from the Brazil Vendors for both Customer and Shipments Information
Technology
This Service was developed using .NetCore and C# Programming Language.
Projects
This Service consists of 6 Projects:
- Web: Contains Endpoints exposed in the Internal YL Network to Receive the Customer Information
- Gateway: Contains Endpoints exposed in the External Network to Receive Shipment Updates from the Vendors
- Importer: Contains the job that executes automatically the Shipment Processing every N minutes
- Core: Contains the all the Shipment Processing Logic
- Migrations: Contains all the Database changes
- Specs: Contains all the Testing Logic
Configurations
Service Settings This service is hosted in AWS so it takes advantage of the Parameter Store to manage sensitive information such as credentials or secrets and connection strings. Any other non-sensitive information needs to be placed in the appSettings json file. There is one general file for all environments, or you can specify settings per environment in the respective file (appSettings.{env}.json) Request Authentication It uses OIDC for authentication, so in order to connect to the service from outside of YL first, a token needs to be retrieved from the authorization server (https://auth-stage.youngliving.com/connect/token), and then add it as a Bearer token to the requests made to the Fulfillment Service. This token has an expiration time of 24 hours. There is a Postman collection in the LATAM workspace called “Brazil_fulfillment”, which contains a POST call to retrieve a new token. Or if you want you can make a curl call from the command line:
curl -sS -X POST "https://auth-stage.youngliving.com/connect/token" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=<non-prod-client>&client_secret=<non-prod-secret>&scope=digibee'
Building
This Service can be deployed to four environments:
- Testing
- Develop
- Stage
- Production (Requires CAB Form)
- Each environment has its own settings in the AppSettings files.
- You can find keys and configurations for Non Prod there.
- For Production you would need to talk to an SRE and set the values from the AWS Parameter Store. Application image is built using Bitbucket pipelines, with the four environment deployment model, there are no particular requirements.
- When create an integration or feature branch, this will be deployed to the AWS
test
environment. - When merge to
develop
it will be deoployed to thedev
AWS environment - When there is a PR to master / develop / integration, it will build and allows to deploy to
stage
environment. - When you merge to
master
it will be deployed to prod
Databases
- LegacyDB (Oracle) A database environment needs to be defined in the appSettings or parameter store (according to the team decision), either for all 3 non-prod environments or a different instance for each specific environment.
- BrazilFulfillmentDB (Postgres) There is one DB instance for each service environment
Infrastructure
- The service is running in AWS
- it does not require any particular consideration.
Service Endpoints
- If you need to know which are the endpoints provided by the API's, you can go through the following Swagger documentation in each service.
Health Checks
- If you need to know about the state of the service of each service provided, you can use the follwing url's.
How to test
In order to test the service, you can start testing it by using the swagger option, or using the postman collection which is described next. The postman collection can be located in the LATAM XFORCE workspace, in the Brazil Fulfillment collection. this collection is divided by main operations(folders) that are performed by the BFS, and in the same way, each folder is divided by the environment. Available processing types in the service:
- Process Shipments: as its name stablish, provides the endpoint to process the orders inmediatly, so there is not need to wait for the importer batch process.
- Vendor Shipment Status Update: This is the enpoint used by the vendor to update the shipment state when as the result of any operation done by the vendor side.
- Internal Status Update: This endpoint is used by YL teams to update to all type of statuses, including the ones the vendors are not allowed to.
- Save Customer Information: Provides the endpoint to insert or update customers, provided by the brazil customer service.
Shipments Processing
Testing in Non-Prod
- Create an Order in Ext2.
- Go to JDE Portal and run the following jobs for Brazil:
- Generate shipment without consolidation
- Virtual Pick Slip for Memphis
- You can check if there are new shipments available in the JDE 3PL API v2 using this request (if you need the access keys, you can ask them to the team).
- Go to execute the following request to start processing the shipments in the Brazil Fulfillment Service. This is not automatic in Non on Prod.
- The Brazil Fulfillment Service will start the shipments processing.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Testing in Prod
- Create an Order in Production.
- Wait for the order to be processed by JDE. It usually takes from 5 up to 15 min. You can periodically check if there are new shipments available in the JDE 3PL API v2 using this request (if you need the access keys, you can ask them to the team).
- The Brazil Fulfillment Service will take new orders from the JDE 3PL API v2 every 30 min (this value can be configured in the service settings).
- The Brazil Fulfillment Service will start the shipments processing.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Shipment Status Update
Testing in Non-Prod
- Authenticate by requesting an access token in Stage (if you need the access keys, you can ask them to the team).
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Testing in Prod
- Authenticate by requesting an access token in Prod (if you need the access keys, you can ask them to the team).
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Internal Status Update
Testing in Non-Prod
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Testing in Prod
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Save Customer Information
Testing in Non-Prod
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Testing in Prod
- Send a POST request to the this endpoint. You need to send the payload according to what is specified in the OpenAPI Contract.
- Check the Results from Splunk and the Brazil Fulfillment Database.
Contact
In case you need more details about this service, please contact any member of LATAM 2 Team for further assistance.