Here are some examples that show how to use the FftApiClient
in your TypeScript application to make REST calls to the fulfillmenttools API.
To follow this tutorial, you will need to:
- have access to a fulfillmenttools project
- have a basic understanding of TypeScript
- have Node.js and npm installed
You can use this little TypeScript app to run the examples against your fulfillmenttools tenant.
The basic steps that you need to do are:
-
Clone this repository
-
Open a terminal session and navigate to the
examples/examples
folder -
Install the required packages and build the app
npm install
npm run build
- Create a
.env
file with the credentials of your fulfillmenttools tenant:
FFT_API_KEY=<your-api-key>
FFT_API_USER=<your-api-user>
FFT_API_PASSWORD=<your-api-password>
FFT_PROJECT_ID=<ocff-your-fft-tenant>
Use the env.sample file as a template for your own settings. Do not check in actual credentials into this repository!
- Run the example app
npm run example
- The output of the example will be displayed on the console
Getting all facilities...
┌──────────────────┬───────────────────────────────────┬──────────────────────────────────────┬─────────┐
│ TenantFacilityId │ Name │ Id │ Version │
├──────────────────┼───────────────────────────────────┼──────────────────────────────────────┼─────────┤
│ STORE-001 │ Store Cologne │ 990e84f3-fbcd-4f4e-b369-6351c35a751d │ 4 │
├──────────────────┼───────────────────────────────────┼──────────────────────────────────────┼─────────┤
│ STORE-002 │ Store Munich │ bdf50a15-c9a3-4b9d-b7ab-46c25ffbb68b │ 3 │
├──────────────────┼───────────────────────────────────┼──────────────────────────────────────┼─────────┤
...
- If you need to pass command line arguments to the app you can do it like this
npm run example -- -f 977fac55-5bb7-42ac-87b7-68379943b8e7
See the index.ts file for the complete example.
- Create an instance of the
FftApiClient
like this:
import { FftApiClient } from '@fulfillmenttools/fulfillmenttools-sdk-typescript';
const fftApiClient = new FftApiClient(
process.env.FFT_PROJECT_ID || '',
process.env.FFT_API_USER || '',
process.env.FFT_API_PASSWORD || '',
process.env.FFT_API_KEY || ''
);
- Import the example you want to use/run
import { runExample } from './example01';
- Use the provided utility functions like
getFacilityId()
,getTenantArticleId()
, ... to obtain the required parameters from the command line arguments.
const facilityId = getFacilityId();
- Run the example
runExample(fftApiClient, facilityId);
Have a look at the included examples: