@mittwald/api-client 1.0.0-alpha.12

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 ADDED
@@ -0,0 +1,114 @@
1
+ # mittwald API JavaScript client
2
+
3
+ This package contains a (mostly auto-generated) JavaScript client for the
4
+ mittwald API.
5
+
6
+ ## License
7
+
8
+ Copyright (c) 2023 Mittwald CM Service GmbH & Co. KG and contributors
9
+
10
+ This project (and all NPM packages) therein is licensed under the MIT License;
11
+ see the [LICENSE](../../LICENSE) file for details.
12
+
13
+ ## ⚠️ STABILITY NOTICE
14
+
15
+ This package is currently in an early stage of development. While our API is
16
+ generally stable, the client is not. Especially the operation IDs (which are
17
+ used as method names) are SUBJECT TO CHANGE in the future. Since the underlying
18
+ API routes are stable, the client will continue to work, but you may need to
19
+ update your code with subsequent versions.
20
+
21
+ ## Installing
22
+
23
+ ### With Yarn
24
+
25
+ #### Install Yarn 4
26
+
27
+ At this moment you need to use Yarn 4 due to this
28
+ [registry login issue](https://github.com/yarnpkg/berry/issues/4341#issuecomment-1477122723).
29
+
30
+ ```shell
31
+ yarn set version berry
32
+ yarn set version 4
33
+ ```
34
+
35
+ #### Configure package registry
36
+
37
+ In order to install the package from https://npm.pkg.github.com, you must
38
+ configure the `mittwald` scope.
39
+
40
+ ```shell
41
+ yarn config set npmScopes.mittwald.npmRegistryServer https://npm.pkg.github.com
42
+ ```
43
+
44
+ Login to the registry. **You need a personal access token with with the `repo`,
45
+ `write:packages`, and `read:packages` permissions.**
46
+
47
+ ```shell
48
+ yarn npm login --scope mittwald
49
+ ```
50
+
51
+ Alternatively you can add the token to the config. Do not commit the
52
+ `.yarnrc.yml` file to VCS when using this method!
53
+
54
+ ```shell
55
+ yarn config set npmScopes.mittwald.npmAuthToken <TOKEN>
56
+ ```
57
+
58
+ Now you can install the package as usual.
59
+
60
+ ```shell
61
+ yarn add @mittwald/api-client
62
+ ```
63
+
64
+ Also see the section on [working with the npm registry][pkg-auth] in the Github
65
+ docs.
66
+
67
+ ## Usage
68
+
69
+ Import the client:
70
+
71
+ ```typescript
72
+ import MittwaldAPIClient from "@mittwald/api-client/dist/v2.js";
73
+ ```
74
+
75
+ To create a client instance you can use one of the following factory method for
76
+ different types of authentication:
77
+
78
+ 1. `MittwaldAPIClient.newUnauthenticated()`
79
+ 2. `MittwaldAPIClient.newWithToken(apiToken: string)` (recommended)
80
+ 3. `MittwaldAPIClient.newWithCredentials(email: string, password: string)` (does
81
+ actually perform a login in the background and thus returns a promise)
82
+
83
+ Have a look at our [API introduction][api-getting-started] for more information
84
+ on how to obtain an API token and how to get started with the API.
85
+
86
+ ## Example
87
+
88
+ ```typescript
89
+ import MittwaldAPIClient from "@mittwald/api-client/dist/v2.js";
90
+
91
+ const mittwaldApi = MittwaldAPIClient.newWithToken("your-access-token");
92
+
93
+ const projects = await mittwaldApi.project.listProjects();
94
+ ```
95
+
96
+ ## API documentation
97
+
98
+ The API documentation can be found at
99
+ [https://api.mittwald.de/v2/docs/](https://api.mittwald.de/v2/docs/). You can
100
+ find the operation ID on the right side of each operation.
101
+
102
+ ## Accessing the underlying Axios instance
103
+
104
+ The client uses the popular [Axios HTTP client](https://axios-http.com) under
105
+ the hood. You may access the Axios instance with the clients `axios` property.
106
+
107
+ ### Intercepting requests or responses
108
+
109
+ To intercept requests or responses you can use
110
+ [Axios' interceptors](https://axios-http.com/docs/interceptors).
111
+
112
+ [pkg-auth]:
113
+ https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages
114
+ [api-getting-started]: https://developer.mittwald.de/docs/v2/api/intro