@salesduck/iiko-cloud-api
v1.0.0
Published
The library describes the available methods, request and response bodies, which allows you to make your own rest client based on it
Downloads
7
Readme
iiko-cloud-api
The library describes the available methods, request and response bodies, which allows you to make your own rest client based on it
All types were generated automatically based on the iiko open api schema using generator
Setup
Add package to your typescript package
yarn add @salesduck/iiko-cloud-api
Usage
With openapi-fetch
import createClient from "openapi-fetch";
import { paths } from "@salesduck/iiko-cloud-api";
const { get, post, put, patch, del } = createClient<paths>({
baseUrl: "https://myserver.com/api/v1/",
headers: {
Authorization: `Bearer token`,
},
});
Directly
- Import schemas and paths
import { paths, schemas } from "@salesduck/iiko-cloud-api";
- Define alias for types
export type getRegionsIikoParameters = paths["/api/1/regions"]["post"]["parameters"];
export type getRegionsIikoBody = schemas["iikoTransport.PublicApi.Contracts.Address.RegionsRequest"];
export type getRegionsIikoResponse = schemas["iikoTransport.PublicApi.Contracts.Address.RegionsResponse"];
- Use types in your code
const getRegionsIiko = async (
parameters: getRegionsIikoParameters,
data: getRegionsIikoBody
): Promise<getRegionsIikoResponse> => {
// ... your code
};
Run your code with type safety
getRegionsIiko({ header: { Authorization: "token" } }, { organizationIds: [] })
.then((response) => {
console.log(response.regions);
console.log(response.correlationId);
})
.catch(console.error);