_Code Structure For Provider Microservices
This document aims to provide a guide to all developers implementing Provider Microservice on behalf of OnePipe. This is to encourage standard across our code repository and not to enforce code standards.
Â
Definition Of Terms
Providers: Organisations offering a certain number of services to be enlisted on the OnePipe platform. For such services to work on OnePipe it has to be converted to its API specs.
Services: List of offerings providers are willing to enlist on the OnePipe platform.
Operation: Each process requires to fulfil a Provider’s service. A service might require more than one operation to fulfil service requests.
MicroService: An application that exposes Provider’s services via REST calls.
Â
A hierarchical structure of a Provider, Services, and its Operations:
Â
Application Structure
We strive to enforce these structure irrespective of the choice of language used in developing the application (provider).
Â
Each Provider should have its codebase and built as a MicroService.
Each Service should have a dedicated endpoint.
Each Service should be represented as a Class file.
Each operation should be represented as a Method on each Service' Class (If you envisage the Service' class file being overloaded you can make each Operations a Class and expose them via the Service class).
Â
Example
To illustrate the layout above, Here is a demonstration for a Provider (Quickteller) offering Airtime Purchase and Loan Request Services.
Â
Quickteller (Provider) Microservice is hosted on https://api.quickteller.onepipe.io
Â
(1) Service: Airtime Purchase
Endpoint: https://api.quickteller.onepipe.io/airtime_purchase
Operations:
Validate Card
Process Transaction
Validate OTP
Query Transaction
Service/Operations Implementation format:
class AirtimePurchase{
void ValidateCard(cardDetails: CardDetails);
void ProcessTransaction(transaction: Transaction);
void ValidateOtp(otpData: OTPData);
void QueryTransaction(queryData: QueryData)
}
Â
Â
Â
(2) Service: Loan Request
Endpoint: https://api.quickteller.onepipe.io/loan_request
Operations:
Get Offers
Accept Offers
Pay Back
Service/Operations Implementation format:
class LoanRequest{
List<Offers> GetOffers(customerId: string);
void AcceptOffers(offerId: string);
void PayBack(offerId: string, amount: decimal);
}