You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,29 +28,38 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
28
28
scheme:'https',
29
29
host:'api.netlify.com',
30
30
pathPrefix:'/api/v1',
31
-
globalParams: {} // parameters you want available for every request
31
+
globalParams: {} // parameters you want available for every request.
32
+
// Global params are only sent of the open-api spec specifies the provided params.
32
33
}
33
34
```
34
35
35
36
### `client.accessToken`
36
37
37
-
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
38
+
A setter/getter that returns the `accessToken` that the client is configured to use.
39
+
You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
38
40
39
41
### `client.basePath`
40
42
41
43
A getter that returns the formatted base URL of the endpoint the client is configured to use.
42
44
43
45
### Open API Client methods
44
46
45
-
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each endpoint action. **To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
47
+
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file.
48
+
Each method is is named after the `operationId` name of each endpoint action.
49
+
**To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
46
50
47
51
Every open-api method has the following signature:
Perform a call to the given endpoint corresponding with the `operationId`. Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached. Rejects if the `status` > 400. Successful response objects have `status` and `statusText` properties on their prototype.
55
+
Perform a call to the given endpoint corresponding with the `operationId`.
56
+
Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached.
57
+
Rejects if the `status` > 400.
58
+
Successful response objects have `status` and `statusText` properties on their prototype.
52
59
53
-
`params` is an object that includes any of the required or optional endpoint parameters. `params.body` should be an object which gets serialized to JSON automatically. If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
60
+
`params` is an object that includes any of the required or optional endpoint parameters.
61
+
`params.body` should be an object which gets serialized to JSON automatically.
62
+
If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
54
63
55
64
```js
56
65
// example params
@@ -63,7 +72,8 @@ Perform a call to the given endpoint corresponding with the `operationId`. Retu
63
72
}
64
73
```
65
74
66
-
Optional `opts` can include any property you want passed to `node-fetch`. The `headers` property is merged with some `defaultHeaders`.
75
+
Optional `opts` can include any property you want passed to `node-fetch`.
76
+
The `headers` property is merged with some `defaultHeaders`.
67
77
68
78
```js
69
79
// example opts
@@ -82,23 +92,28 @@ All methods are conveniently consumed with async/await:
82
92
asyncfunctiongetSomeData () {
83
93
// Calls may fail!
84
94
try {
85
-
constresposnse=awaitclient.getSites()
86
-
return response
95
+
returnawaitclient.getSiteDeploy({
96
+
siteId:'1234abcd',
97
+
deploy_id:'4567'
98
+
})
87
99
} catch (e) {
88
100
// handle error
89
101
}
90
102
}
91
103
```
92
104
93
-
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
105
+
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body.
106
+
Otherwise the `text` of the response is returned.
94
107
95
-
### Convenience Methods
108
+
### API Flow Methods
96
109
97
110
Some methods have been added in addition to the open API methods that make certain actions simpler to perform.
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
114
+
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`.
115
+
Call this with the response from a `client.createTicket({ client_id })` call.
116
+
Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
0 commit comments