Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add path param validator #836

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions lib/rest/accounts/v1/authTokenPromotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { inspect, InspectOptions } from "util";
import V1 from "../V1";
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
import { isValidPathParam } from "../../../base/utility";

export interface AuthTokenPromotionContext {
/**
Expand Down
1 change: 1 addition & 0 deletions lib/rest/accounts/v1/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { inspect, InspectOptions } from "util";
import V1 from "../V1";
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
import { isValidPathParam } from "../../../base/utility";
import { AwsListInstance } from "./credential/aws";
import { PublicKeyListInstance } from "./credential/publicKey";

Expand Down
5 changes: 5 additions & 0 deletions lib/rest/accounts/v1/credential/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V1 from "../../V1";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";

/**
* Options to pass to update a AwsInstance
Expand Down Expand Up @@ -150,6 +151,10 @@ export class AwsContextImpl implements AwsContext {
protected _uri: string;

constructor(protected _version: V1, sid: string) {
if (!isValidPathParam(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}

this._solution = { sid };
this._uri = `/Credentials/AWS/${sid}`;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/rest/accounts/v1/credential/publicKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V1 from "../../V1";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";

/**
* Options to pass to update a PublicKeyInstance
Expand Down Expand Up @@ -150,6 +151,10 @@ export class PublicKeyContextImpl implements PublicKeyContext {
protected _uri: string;

constructor(protected _version: V1, sid: string) {
if (!isValidPathParam(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}

this._solution = { sid };
this._uri = `/Credentials/PublicKeys/${sid}`;
}
Expand Down
1 change: 1 addition & 0 deletions lib/rest/accounts/v1/secondaryAuthToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { inspect, InspectOptions } from "util";
import V1 from "../V1";
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
import { isValidPathParam } from "../../../base/utility";

export interface SecondaryAuthTokenContext {
/**
Expand Down
5 changes: 5 additions & 0 deletions lib/rest/api/v2010/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../http/response";
import V2010 from "../V2010";
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
import { isValidPathParam } from "../../../base/utility";
import { AddressListInstance } from "./account/address";
import { ApplicationListInstance } from "./account/application";
import { AuthorizedConnectAppListInstance } from "./account/authorizedConnectApp";
Expand Down Expand Up @@ -227,6 +228,10 @@ export class AccountContextImpl implements AccountContext {
protected _validationRequests?: ValidationRequestListInstance;

constructor(protected _version: V2010, sid: string) {
if (!isValidPathParam(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}

this._solution = { sid };
this._uri = `/Accounts/${sid}.json`;
}
Expand Down
13 changes: 13 additions & 0 deletions lib/rest/api/v2010/account/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V2010 from "../../V2010";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";
import { DependentPhoneNumberListInstance } from "./address/dependentPhoneNumber";

/**
Expand Down Expand Up @@ -200,6 +201,14 @@ export class AddressContextImpl implements AddressContext {
protected _dependentPhoneNumbers?: DependentPhoneNumberListInstance;

constructor(protected _version: V2010, accountSid: string, sid: string) {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}

this._solution = { accountSid, sid };
this._uri = `/Accounts/${accountSid}/Addresses/${sid}.json`;
}
Expand Down Expand Up @@ -690,6 +699,10 @@ export function AddressListInstance(
version: V2010,
accountSid: string
): AddressListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

const instance = ((sid) => instance.get(sid)) as AddressListInstanceImpl;

instance.get = function get(sid): AddressContext {
Expand Down
9 changes: 9 additions & 0 deletions lib/rest/api/v2010/account/address/dependentPhoneNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";

type DependentPhoneNumberAddressRequirement =
| "none"
Expand Down Expand Up @@ -238,6 +239,14 @@ export function DependentPhoneNumberListInstance(
accountSid: string,
addressSid: string
): DependentPhoneNumberListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(addressSid)) {
throw new Error("Parameter 'addressSid' is not valid.");
}

const instance = {} as DependentPhoneNumberListInstanceImpl;

instance._version = version;
Expand Down
13 changes: 13 additions & 0 deletions lib/rest/api/v2010/account/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V2010 from "../../V2010";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";

/**
* Options to pass to update a ApplicationInstance
Expand Down Expand Up @@ -209,6 +210,14 @@ export class ApplicationContextImpl implements ApplicationContext {
protected _uri: string;

constructor(protected _version: V2010, accountSid: string, sid: string) {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}

this._solution = { accountSid, sid };
this._uri = `/Accounts/${accountSid}/Applications/${sid}.json`;
}
Expand Down Expand Up @@ -780,6 +789,10 @@ export function ApplicationListInstance(
version: V2010,
accountSid: string
): ApplicationListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

const instance = ((sid) => instance.get(sid)) as ApplicationListInstanceImpl;

instance.get = function get(sid): ApplicationContext {
Expand Down
13 changes: 13 additions & 0 deletions lib/rest/api/v2010/account/authorizedConnectApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V2010 from "../../V2010";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";

type AuthorizedConnectAppPermission = "get-all" | "post-all";

Expand Down Expand Up @@ -106,6 +107,14 @@ export class AuthorizedConnectAppContextImpl
accountSid: string,
connectAppSid: string
) {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(connectAppSid)) {
throw new Error("Parameter 'connectAppSid' is not valid.");
}

this._solution = { accountSid, connectAppSid };
this._uri = `/Accounts/${accountSid}/AuthorizedConnectApps/${connectAppSid}.json`;
}
Expand Down Expand Up @@ -444,6 +453,10 @@ export function AuthorizedConnectAppListInstance(
version: V2010,
accountSid: string
): AuthorizedConnectAppListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

const instance = ((connectAppSid) =>
instance.get(connectAppSid)) as AuthorizedConnectAppListInstanceImpl;

Expand Down
13 changes: 13 additions & 0 deletions lib/rest/api/v2010/account/availablePhoneNumberCountry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../http/response";
import V2010 from "../../V2010";
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
import { isValidPathParam } from "../../../../base/utility";
import { LocalListInstance } from "./availablePhoneNumberCountry/local";
import { MachineToMachineListInstance } from "./availablePhoneNumberCountry/machineToMachine";
import { MobileListInstance } from "./availablePhoneNumberCountry/mobile";
Expand Down Expand Up @@ -130,6 +131,14 @@ export class AvailablePhoneNumberCountryContextImpl
accountSid: string,
countryCode: string
) {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

this._solution = { accountSid, countryCode };
this._uri = `/Accounts/${accountSid}/AvailablePhoneNumbers/${countryCode}.json`;
}
Expand Down Expand Up @@ -580,6 +589,10 @@ export function AvailablePhoneNumberCountryListInstance(
version: V2010,
accountSid: string
): AvailablePhoneNumberCountryListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

const instance = ((countryCode) =>
instance.get(countryCode)) as AvailablePhoneNumberCountryListInstanceImpl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -321,6 +322,14 @@ export function LocalListInstance(
accountSid: string,
countryCode: string
): LocalListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as LocalListInstanceImpl;

instance._version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -331,6 +332,14 @@ export function MachineToMachineListInstance(
accountSid: string,
countryCode: string
): MachineToMachineListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as MachineToMachineListInstanceImpl;

instance._version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -321,6 +322,14 @@ export function MobileListInstance(
accountSid: string,
countryCode: string
): MobileListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as MobileListInstanceImpl;

instance._version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -321,6 +322,14 @@ export function NationalListInstance(
accountSid: string,
countryCode: string
): NationalListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as NationalListInstanceImpl;

instance._version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -321,6 +322,14 @@ export function SharedCostListInstance(
accountSid: string,
countryCode: string
): SharedCostListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as SharedCostListInstanceImpl;

instance._version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Response from "../../../../../http/response";
import V2010 from "../../../V2010";
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
import { isValidPathParam } from "../../../../../base/utility";
import { PhoneNumberCapabilities } from "../../../../../interfaces";

/**
Expand Down Expand Up @@ -321,6 +322,14 @@ export function TollFreeListInstance(
accountSid: string,
countryCode: string
): TollFreeListInstance {
if (!isValidPathParam(accountSid)) {
throw new Error("Parameter 'accountSid' is not valid.");
}

if (!isValidPathParam(countryCode)) {
throw new Error("Parameter 'countryCode' is not valid.");
}

const instance = {} as TollFreeListInstanceImpl;

instance._version = version;
Expand Down
Loading