...

/

Solution: Modeling APIs

Solution: Modeling APIs

Let's try to model APIs on a Credit-Check service.

Solution

We introduced the related Credit-Check service. This is used to check the creditworthiness of BigCo’s new onboarded customers.

The specific task is to create the credit-check-workflow.txt document. By inspecting the credit-check-story.md document provided in the credit-check folder, we should be able to come up with a simple workflow that captures the Credit-Check service. To open these documents, execute following commands: To open these documents execute following commands:

root@educative:/$ cd credit-check

root@educative:/credit-check$ cat credit-check-story.md

This file looks like:

Press + to interact
## Credit-Check Story at BigCo Inc.
We run a simple credit check periodically on companies that are our customers in order to update their
baseline spending limit and discount percentages.
### Background
Each company record has one or more `account` records. Each `account` record as a `spendingLimit`
property and a `discountPercentage` property. By default, these two values are set to `5000`
and `5%`, respectively. However, we can modify those values by running a simple credit check
using the customer name to see if we need to adjust those values up or down.
We have an internal account history that is used to generate suggested ratings for companies we
deal with. The details on how we generate these numbers is kept secret.
### Credit Checking
The credit-check service has a safe method called `CreditCheckForm` which accepts a `companyName` and
returns a `CreditCheckItem` response that contains the property `rating` (a single value between
1 and 10). That `rating` value can then be used to determine BigCo's standard `spendingLimit`
and `discountPercentage` for that company's account record.
Each time the credit-check service is queried, it also writes a history record called `CreditCheckItem`
that can be called up later for review. The action `CreditCheckHistory` is recalled using the same
`companyName` that was used when making the initial credit check. History records contain the
following properties: `identifier`, `companyName`, `dateRequested`, and `rating`.
We run this credit check when we first add a company account record and once a year after that (on January 1st).

Updating the credit-check-workflow document

...