@shopware/api-client 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -23
- package/dist/index.mjs +9 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -146,29 +146,8 @@ try {
|
|
|
146
146
|
|
|
147
147
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client-next/CHANGELOG.md)
|
|
148
148
|
|
|
149
|
-
### Latest changes: 0.
|
|
149
|
+
### Latest changes: 0.3.0
|
|
150
150
|
|
|
151
151
|
### Minor Changes
|
|
152
152
|
|
|
153
|
-
- [#
|
|
154
|
-
|
|
155
|
-
example:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { ApiClientError } from "@shopware/api-client";
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
// ... your request
|
|
162
|
-
} catch (error) {
|
|
163
|
-
if (error instanceof ApiClientError) {
|
|
164
|
-
console.error(error); // This prints message summary
|
|
165
|
-
console.error("Details:", error.details); // Raw response from API
|
|
166
|
-
} else {
|
|
167
|
-
console.error("==>", error); // Another type of error, not recognized by API client
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Patch Changes
|
|
173
|
-
|
|
174
|
-
- [#303](https://github.com/shopware/frontends/pull/303) [`aeb639a`](https://github.com/shopware/frontends/commit/aeb639a3244f812c275145345618e5bc0045be0d) Thanks [@patzick](https://github.com/patzick)! - Improved linting in packages. Types should be more reliable
|
|
153
|
+
- [#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
|
package/dist/index.mjs
CHANGED
|
@@ -29,9 +29,11 @@ function errorInterceptor(response) {
|
|
|
29
29
|
|
|
30
30
|
function createAPIClient(params) {
|
|
31
31
|
const defaultHeaders = {
|
|
32
|
-
"sw-access-key": params.accessToken
|
|
33
|
-
"sw-context-token": params.contextToken
|
|
32
|
+
"sw-access-key": params.accessToken
|
|
34
33
|
};
|
|
34
|
+
if (params.contextToken) {
|
|
35
|
+
defaultHeaders["sw-context-token"] = params.contextToken;
|
|
36
|
+
}
|
|
35
37
|
const apiFetch = ofetch.create({
|
|
36
38
|
baseURL: params.baseURL,
|
|
37
39
|
// async onRequest({ request, options }) {},
|
|
@@ -82,7 +84,11 @@ function transformPathToQuery(path, params) {
|
|
|
82
84
|
});
|
|
83
85
|
const query = {};
|
|
84
86
|
queryParamNames.forEach((paramName) => {
|
|
85
|
-
|
|
87
|
+
let queryParamName = paramName;
|
|
88
|
+
if (Array.isArray(params[paramName]) && !queryParamName.includes("[]")) {
|
|
89
|
+
queryParamName += "[]";
|
|
90
|
+
}
|
|
91
|
+
query[queryParamName] = params[paramName];
|
|
86
92
|
});
|
|
87
93
|
const returnOptions = {
|
|
88
94
|
method: method.toUpperCase(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/api-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shopware client for API connection.",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"repository": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"import": "./dist/index.mjs"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/prettier": "^
|
|
30
|
+
"@types/prettier": "^3.0.0",
|
|
31
31
|
"@vitest/coverage-c8": "^0.33.0",
|
|
32
32
|
"prettier": "^3.0.0",
|
|
33
33
|
"vitest": "^0.33.0",
|
|
34
|
-
"@shopware/api-gen": "0.0.
|
|
35
|
-
"eslint-config-shopware": "0.0.
|
|
34
|
+
"@shopware/api-gen": "0.0.6",
|
|
35
|
+
"eslint-config-shopware": "0.0.5",
|
|
36
36
|
"tsconfig": "0.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|