Skip to content

Commit

Permalink
feat: OpenAPI spec update via Stainless API (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Mar 4, 2024
1 parent 045f10c commit 5360ce4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ The full API of this library can be found in [api.md](api.md).
```js
import Cloudflare from 'cloudflare';

const cloudflare = new Cloudflare();
const cloudflare = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

async function main() {
const zoneCreateResponse = await cloudflare.zones.create({
Expand All @@ -46,7 +49,10 @@ This library includes TypeScript definitions for all request params and response
```ts
import Cloudflare from 'cloudflare';

const cloudflare = new Cloudflare();
const cloudflare = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

async function main() {
const params: Cloudflare.ZoneCreateParams = {
Expand Down
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ export class Cloudflare extends Core.APIClient {
const apiKeyAuth = this.apiKeyAuth(opts);
const apiTokenAuth = this.apiTokenAuth(opts);
const userServiceKeyAuth = this.userServiceKeyAuth(opts);

if (
apiEmailAuth != null &&
!Core.isEmptyObj(apiEmailAuth) &&
apiKeyAuth != null &&
!Core.isEmptyObj(apiKeyAuth)
) {
return { ...apiEmailAuth, ...apiKeyAuth };
}

if (apiTokenAuth != null && !Core.isEmptyObj(apiTokenAuth)) {
return apiTokenAuth;
}

if (userServiceKeyAuth != null && !Core.isEmptyObj(userServiceKeyAuth)) {
return userServiceKeyAuth;
}
return {};
}

Expand Down

0 comments on commit 5360ce4

Please sign in to comment.