@shopware/api-client
Advanced tools
Comparing version
{ | ||
"name": "@shopware/api-client", | ||
"version": "0.0.0-canary-20230817152453", | ||
"version": "0.0.0-canary-20230822131551", | ||
"description": "Shopware client for API connection.", | ||
@@ -32,6 +32,6 @@ "author": "Shopware", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"prettier": "^3.0.0", | ||
"vitest": "^0.33.0", | ||
"@shopware/api-gen": "0.0.6", | ||
"eslint-config-shopware": "0.0.5", | ||
"prettier": "^3.0.2", | ||
"vitest": "^0.34.2", | ||
"@shopware/api-gen": "0.0.0-canary-20230822131551", | ||
"eslint-config-shopware": "0.0.0-canary-20230822131551", | ||
"tsconfig": "0.0.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -53,3 +53,2 @@ # shopware/frontends - api-client | ||
contextToken: Cookies.get("sw-context-token"), | ||
apiType: "store-api", | ||
onContextChanged(newContextToken) { | ||
@@ -74,2 +73,43 @@ Cookies.set("sw-context-token", newContextToken, { | ||
## Admin API client setup | ||
The setup works the same way as `creteAPIClient` function, with few differences: | ||
```typescript | ||
// example adminApiClient.ts file | ||
import { createAdminAPIClient } from "@shopware/api-client"; // we use different function to create admin api client | ||
import { | ||
RequestParameters, | ||
RequestReturnType, | ||
createAdminAPIClient, | ||
} from "@shopware/api-client"; | ||
import { | ||
operationPaths, | ||
operations, | ||
components, | ||
} from "@shopware/api-client/admin-api-types"; // we take default admin api types from different directory than store-api | ||
import Cookies from "js-cookie"; | ||
export const adminApiClient = createAdminAPIClient<operations, operationPaths>({ | ||
baseURL: "https://demo-frontends.shopware.store/api", | ||
sessionData: JSON.parse(Cookies.get("sw-admin-session-data") || "{}"), | ||
onAuthChange(sessionData) { | ||
Cookies.set("sw-admin-session-data", JSON.stringify(sessionData), { | ||
expires: 1, // days | ||
path: "/", | ||
sameSite: "lax", | ||
}); | ||
}, | ||
}); | ||
export type AdminApiSchemas = components["schemas"]; | ||
export type AdminApiRequestParams<OPERATION_NAME extends keyof operations> = | ||
RequestParameters<OPERATION_NAME, operations>; | ||
export type AdminApiReturnType<OPERATION_NAME extends keyof operations> = | ||
RequestReturnType<OPERATION_NAME, operations>; | ||
``` | ||
the rest works the same as store-api client. | ||
## Basic usage | ||
@@ -151,6 +191,10 @@ | ||
### Latest changes: 0.0.0-canary-20230817152453 | ||
### Latest changes: 0.0.0-canary-20230822131551 | ||
### Minor Changes | ||
- [#330](https://github.com/shopware/frontends/pull/330) [`3683116`](https://github.com/shopware/frontends/commit/3683116588a7ef75e750fc33deee119f038c88e8) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Add `setCurrentCountry` for changing context countryId | ||
- [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - New method `createAdminAPIClient` supporting Admin API π °π Ώπ Έ | ||
### Patch Changes | ||
- [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - Deprecated `apiType` param in `createAPIClient`, for Admin API client use `createAdminAPIClient` instead. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5633874
46.07%174262
50.74%198
28.57%