diff --git a/src/base/Page.ts b/src/base/Page.ts index 2230e4715..e2062e270 100644 --- a/src/base/Page.ts +++ b/src/base/Page.ts @@ -249,6 +249,8 @@ export default class Page< if (keys.length === 1) { return payload[keys[0]]; } + for (const key of keys) + if (Array.isArray(payload[key])) return payload[key]; throw new Error("Page Records cannot be deserialized"); } diff --git a/src/credential_provider/NoAuthCredentialProvider.ts b/src/credential_provider/NoAuthCredentialProvider.ts index 337bd66a8..bd2415e5a 100644 --- a/src/credential_provider/NoAuthCredentialProvider.ts +++ b/src/credential_provider/NoAuthCredentialProvider.ts @@ -2,12 +2,16 @@ import CredentialProvider from "./CredentialProvider"; import AuthStrategy from "../auth_strategy/AuthStrategy"; import NoAuthStrategy from "../auth_strategy/NoAuthStrategy"; -export default class NoAuthCredentialProvider extends CredentialProvider { - constructor() { - super("client-credentials"); - } +namespace NoAuthCredentialProvider { + export class NoAuthCredentialProvider extends CredentialProvider { + constructor() { + super("client-credentials"); + } - public toAuthStrategy(): AuthStrategy { - return new NoAuthStrategy(); + public toAuthStrategy(): AuthStrategy { + return new NoAuthStrategy(); + } } } + +export = NoAuthCredentialProvider; diff --git a/src/http/bearer_token/ApiTokenManager.ts b/src/http/bearer_token/ApiTokenManager.ts index afb7715b7..e16aadabe 100644 --- a/src/http/bearer_token/ApiTokenManager.ts +++ b/src/http/bearer_token/ApiTokenManager.ts @@ -16,7 +16,8 @@ export default class ApiTokenManager implements TokenManager { } async fetchToken(): Promise { - const noAuthCredentialProvider = new NoAuthCredentialProvider(); + const noAuthCredentialProvider = + new NoAuthCredentialProvider.NoAuthCredentialProvider(); const client = new Client(); client.setCredentialProvider(noAuthCredentialProvider); diff --git a/src/index.ts b/src/index.ts index c1d3a82dc..401c508d5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import IVoiceResponse from "./twiml/VoiceResponse"; import IMessagingResponse from "./twiml/MessagingResponse"; import IFaxResponse from "./twiml/FaxResponse"; import IClientCredentialProvider from "./credential_provider/ClientCredentialProvider"; +import INoAuthCredentialProvider from "./credential_provider/NoAuthCredentialProvider"; // Shorthand to automatically create a RestClient function TwilioSDK( @@ -51,6 +52,11 @@ namespace TwilioSDK { export const ClientCredentialProviderBuilder = IClientCredentialProvider.ClientCredentialProviderBuilder; + export type NoAuthCredentialProvider = + INoAuthCredentialProvider.NoAuthCredentialProvider; + export const NoAuthCredentialProvider = + INoAuthCredentialProvider.NoAuthCredentialProvider; + // Setup webhook helper functionality export type validateBody = typeof webhooks.validateBody; export const validateBody = webhooks.validateBody; diff --git a/src/rest/previewIam/v1/authorize.ts b/src/rest/previewIam/v1/authorize.ts index 0564f7808..df8915e79 100644 --- a/src/rest/previewIam/v1/authorize.ts +++ b/src/rest/previewIam/v1/authorize.ts @@ -103,6 +103,7 @@ export function AuthorizeListInstance(version: V1): AuthorizeListInstance { if (params["state"] !== undefined) data["state"] = params["state"]; const headers: any = {}; + headers["Accept"] = "application/json"; let operationVersion = version, operationPromise = operationVersion.fetch({ diff --git a/src/rest/previewIam/v1/token.ts b/src/rest/previewIam/v1/token.ts index d9ffc86ef..4e40089a4 100644 --- a/src/rest/previewIam/v1/token.ts +++ b/src/rest/previewIam/v1/token.ts @@ -107,6 +107,7 @@ export function TokenListInstance(version: V1): TokenListInstance { const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; + headers["Accept"] = "application/json"; let operationVersion = version, operationPromise = operationVersion.create({ diff --git a/src/rest/previewIam/versionless/organization/account.ts b/src/rest/previewIam/versionless/organization/account.ts index da50fadaf..50db38f49 100644 --- a/src/rest/previewIam/versionless/organization/account.ts +++ b/src/rest/previewIam/versionless/organization/account.ts @@ -104,11 +104,15 @@ export class AccountContextImpl implements AccountContext { fetch( callback?: (error: Error | null, item?: AccountInstance) => any ): Promise { + const headers: any = {}; + headers["Accept"] = "application/json"; + const instance = this; let operationVersion = instance._version, operationPromise = operationVersion.fetch({ uri: instance._uri, method: "get", + headers, }); operationPromise = operationPromise.then( @@ -372,6 +376,7 @@ export function AccountListInstance( if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; const headers: any = {}; + headers["Accept"] = "application/json"; let operationVersion = version, operationPromise = operationVersion.page({ diff --git a/src/rest/previewIam/versionless/organization/roleAssignment.ts b/src/rest/previewIam/versionless/organization/roleAssignment.ts index 8ee251be3..8008dd8e3 100644 --- a/src/rest/previewIam/versionless/organization/roleAssignment.ts +++ b/src/rest/previewIam/versionless/organization/roleAssignment.ts @@ -141,11 +141,15 @@ export class RoleAssignmentContextImpl implements RoleAssignmentContext { remove( callback?: (error: Error | null, item?: boolean) => any ): Promise { + const headers: any = {}; + headers["Accept"] = "application/scim+json"; + const instance = this; let operationVersion = instance._version, operationPromise = operationVersion.remove({ uri: instance._uri, method: "delete", + headers, }); operationPromise = instance._version.setPromiseCallback( @@ -309,7 +313,7 @@ export interface RoleAssignmentListInstance { */ create( params: PublicApiCreateRoleAssignmentRequest, - headers: any, + headers?: any, callback?: (error: Error | null, item?: RoleAssignmentInstance) => any ): Promise; @@ -415,7 +419,7 @@ export function RoleAssignmentListInstance( instance.create = function create( params: PublicApiCreateRoleAssignmentRequest, - headers: any, + headers?: any, callback?: (error: Error | null, items: RoleAssignmentInstance) => any ): Promise { if (params === null || params === undefined) { @@ -426,7 +430,9 @@ export function RoleAssignmentListInstance( data = params; - headers["Content-Type"] = "application/json"; + if (headers === null || headers === undefined) { + headers = {}; + } let operationVersion = version, operationPromise = operationVersion.create({ @@ -475,6 +481,7 @@ export function RoleAssignmentListInstance( if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; const headers: any = {}; + headers["Accept"] = "application/json"; let operationVersion = version, operationPromise = operationVersion.page({ diff --git a/src/rest/previewIam/versionless/organization/user.ts b/src/rest/previewIam/versionless/organization/user.ts index 63805f326..0ca6ba3b7 100644 --- a/src/rest/previewIam/versionless/organization/user.ts +++ b/src/rest/previewIam/versionless/organization/user.ts @@ -222,7 +222,7 @@ export interface UserContext { */ update( params: ScimUser, - headers: any, + headers?: any, callback?: (error: Error | null, item?: UserInstance) => any ): Promise; @@ -262,11 +262,15 @@ export class UserContextImpl implements UserContext { remove( callback?: (error: Error | null, item?: boolean) => any ): Promise { + const headers: any = {}; + headers["Accept"] = "application/scim+json"; + const instance = this; let operationVersion = instance._version, operationPromise = operationVersion.remove({ uri: instance._uri, method: "delete", + headers, }); operationPromise = instance._version.setPromiseCallback( @@ -279,11 +283,15 @@ export class UserContextImpl implements UserContext { fetch( callback?: (error: Error | null, item?: UserInstance) => any ): Promise { + const headers: any = {}; + headers["Accept"] = "application/scim+json"; + const instance = this; let operationVersion = instance._version, operationPromise = operationVersion.fetch({ uri: instance._uri, method: "get", + headers, }); operationPromise = operationPromise.then( @@ -305,7 +313,7 @@ export class UserContextImpl implements UserContext { update( params: ScimUser, - headers: any, + headers?: any, callback?: (error: Error | null, item?: UserInstance) => any ): Promise { if (params === null || params === undefined) { @@ -316,7 +324,9 @@ export class UserContextImpl implements UserContext { data = params; - headers["Content-Type"] = "application/json"; + if (headers === null || headers === undefined) { + headers = {}; + } const instance = this; let operationVersion = instance._version, @@ -518,7 +528,7 @@ export class UserInstance { */ update( params: ScimUser, - headers: any, + headers?: any, callback?: (error: Error | null, item?: UserInstance) => any ): Promise; @@ -583,7 +593,7 @@ export interface UserListInstance { */ create( params: ScimUser, - headers: any, + headers?: any, callback?: (error: Error | null, item?: UserInstance) => any ): Promise; @@ -683,7 +693,7 @@ export function UserListInstance( instance.create = function create( params: ScimUser, - headers: any, + headers?: any, callback?: (error: Error | null, items: UserInstance) => any ): Promise { if (params === null || params === undefined) { @@ -694,7 +704,9 @@ export function UserListInstance( data = params; - headers["Content-Type"] = "application/json"; + if (headers === null || headers === undefined) { + headers = {}; + } let operationVersion = version, operationPromise = operationVersion.create({ @@ -741,6 +753,7 @@ export function UserListInstance( if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; const headers: any = {}; + headers["Accept"] = "application/scim+json"; let operationVersion = version, operationPromise = operationVersion.page({