@mittwald/api-client 2.0.21 → 3.0.1

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 CHANGED
@@ -37,6 +37,71 @@ different types of authentication:
37
37
  Have a look at our [API introduction][api-getting-started] for more information
38
38
  on how to obtain an API token and how to get started with the API.
39
39
 
40
+ ### Setting request parameters
41
+
42
+ API requests may require these type of parameters:
43
+
44
+ - path parameters
45
+ - headers
46
+ - query parameters
47
+ - request body
48
+
49
+ #### Path parameters
50
+
51
+ Path parameters are variable parts of a URL path. They are typically used to
52
+ point to a specific resource within a collection, such as a project identified
53
+ by ID. A URL can have several path parameters, each denoted with curly braces
54
+ `{ }`.
55
+
56
+ ```
57
+ /v2/projects/{projectId}
58
+ ```
59
+
60
+ Path parameters **are required** and must be directly defined inside the request
61
+ object.
62
+
63
+ ```javascript
64
+ // Setting the projectId path parameters
65
+ const project = await mittwaldApi.project.get({
66
+ projectId: "p-xxxxx",
67
+ });
68
+ ```
69
+
70
+ #### Headers, query parameters and request body
71
+
72
+ Depending on the operation, you must configure additional parameters, such as
73
+ `queryParameters` (URL query parameters), `headers` (HTTP headers), and `data`
74
+ (request body).
75
+
76
+ The operations and their parameters are documented in the
77
+ [API documentation](https://developer.mittwald.de/reference/v2/).
78
+
79
+ When using TypeScript all parameter schemas are reflected by the request type,
80
+ so you will get compile errors, when a request does not match the schema.
81
+
82
+ ```javascript
83
+ // Setting the projectId path parameters
84
+ const response = await mittwaldApi.category.operation({
85
+ // path parameters
86
+ pathParameter1: "param1",
87
+ pathParameter2: "param2",
88
+ // parameters in header
89
+ headers: {
90
+ "x-header": "header",
91
+ },
92
+ // query parameters
93
+ queryParameters: {
94
+ queryParameters1: "queryParam1",
95
+ queryParameters2: "queryParam2",
96
+ },
97
+ // JSON object in request body
98
+ data: {
99
+ data1: "data1",
100
+ data2: "data2",
101
+ },
102
+ });
103
+ ```
104
+
40
105
  ## Example
41
106
 
42
107
  ```typescript
@@ -89,3 +154,28 @@ import { MittwaldAPIV2 } from "@mittwald/api-client";
89
154
  type Project =
90
155
  MittwaldAPIV2.Paths.V2Projects.Get.Responses.$200.Content.ApplicationJson[number];
91
156
  ```
157
+
158
+ ## Migrating from package version V2 to V3
159
+
160
+ **This instruction considers migrating from _package_ version V2 to V3, which
161
+ has a breaking change in the call signature of request calls. The API itself has
162
+ not changed and is still at version 2.**
163
+
164
+ Path parameters are a primary component of the request and thus should not be
165
+ "hidden" in the request config object. In V3 the API of the request
166
+ configuration object has changed, and you have to set the path parameters
167
+ directly in the root level of the request object.
168
+
169
+ ```javascript
170
+ // V2
171
+ mittwaldApi.project.get({
172
+ pathParameters: {
173
+ projectId: "p-xxxxx",
174
+ },
175
+ });
176
+
177
+ // V3
178
+ mittwaldApi.project.get({
179
+ projectId: "p-xxxxx",
180
+ });
181
+ ```