Skip to content

Commit

Permalink
docs(verify): adding doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Nov 21, 2023
1 parent d069e28 commit a9d5dc4
Show file tree
Hide file tree
Showing 75 changed files with 1,200 additions and 320 deletions.
7 changes: 4 additions & 3 deletions packages/verify/__tests__/__dataSets__/cancel.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Command, CheckStatus } from '../../lib/enums/index';
import { Command, CheckStatus } from '../../lib/enums';
import {
VerifyCancelResponse,
VerifyControlErrorResponse,
} from '../../lib/interfaces/Response/index';
import { VerifyControl, VerifyControlError } from '../../lib/interfaces/index';
VerifyControl,
VerifyControlError,
} from '../../lib/types';

export default [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/__tests__/__dataSets__/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VerifyCheckResponse, VerifyCheck } from '../../lib/interfaces/index';
import { VerifyCheckResponse, VerifyCheck } from '../../lib/types';

export default [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/verify/__tests__/__dataSets__/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
VerifySearch,
VerifySearchErrorResponse,
VerifySearchError,
} from '../../lib/interfaces/index';
} from '../../lib/types';
import {
SearchStatus,
SearchCheckStatus,
SearchEventTypes,
} from '../../lib/enums/index';
} from '../../lib/enums';

const params = new URLSearchParams({
api_key: '12345',
Expand Down
5 changes: 3 additions & 2 deletions packages/verify/__tests__/__dataSets__/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
VerifyRequest,
VerifyRequestErrorResponse,
VerifyError,
} from '../../lib/interfaces/index';
import { PSD2Parameters, VerificationParameters } from '../../lib/types/index';
PSD2Parameters,
VerificationParameters,
} from '../../lib/types/index';
import { PSD2, Verification } from '../../lib/classes/index';

export default [
Expand Down
45 changes: 42 additions & 3 deletions packages/verify/lib/classes/PSD2.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
import { PSD2Parameters } from '../types/index';
import { VerifyWorkflows, VerifyLanguages } from '../enums/index';

/**
* Represents parameters for a PSD2 (Payment Services Directive 2) verification request.
*/
export class PSD2 implements PSD2Parameters {
/**
* The phone number to be verified.
*/
number: string;

/**
* The payee's name or identifier for the payment confirmation.
*/
payee: string;

/**
* The decimal amount of the payment to be confirmed, in Euros.
*/
amount: number;

/**
* The country code associated with the phone number (optional).
*/
country?: string;

/**
* The desired length of the verification code (optional).
*/
codeLength?: number;
lg?: VerifyLanguages;

/**
* @deprecated
*/
* @deprecated This property is deprecated. Use `lg` instead.
*/
language?: string;

/**
* The language for sending verification messages (optional).
*/
lg?: VerifyLanguages;

/**
* The duration in seconds for which the verification code will be valid (optional).
*/
pinExpiry?: number;

/**
* The duration in seconds to wait before sending the next verification event (optional).
*/
nextEventWait?: number;

/**
* The workflow ID for customizing the verification process (optional).
*/
workflowId?: VerifyWorkflows;

constructor(
Expand Down
43 changes: 41 additions & 2 deletions packages/verify/lib/classes/Verification.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
import { VerificationParameters } from '../types/index';
import { VerifyWorkflows, VerifyLanguages } from '../enums/index';

/**
* Represents parameters for a verification request.
*/
export class Verification implements VerificationParameters {
/**
* The phone number to be verified.
*/
number: string;

/**
* The brand or application name associated with the verification request.
*/
brand: string;

/**
* The country code associated with the phone number (optional).
*/
country?: string;

/**
* The sender ID or phone number that will be used to send verification messages (optional).
*/
senderId?: string;

/**
* The desired length of the verification code (optional).
*/
codeLength?: number;

/**
* @deprecated
*/
* @deprecated This property is deprecated. Use `lg` instead.
*/
language?: string;

/**
* The language for sending verification messages (optional).
*/
lg?: VerifyLanguages;

/**
* The duration in seconds for which the verification code will be valid (optional).
*/
pinExpiry?: number;

/**
* The duration in seconds to wait before sending the next verification event (optional).
*/
nextEventWait?: number;

/**
* The workflow ID for customizing the verification process (optional).
*/
workflowId?: VerifyWorkflows;

constructor(
Expand Down
98 changes: 82 additions & 16 deletions packages/verify/lib/enums/CheckStatus.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,84 @@
/**
* Enum representing the status of a verification check.
*/
export enum CheckStatus {
SUCCESS = '0',
THROTTLED = '1',
MISSING_REQUIRED_PARAM = '2',
INVALID_PARAM = '3',
INVALID_CREDENTIALS = '4',
INTERNAL_ERROR = '5',
FAILED_TO_PROCESS = '6',
BARRED_API_KEY = '8',
PARTNER_QUOTA_EXCEEDED = '9',
CONCURRENT_VERIFICATIONS = '10',
UNSUPPORTED_NETWORK = '15',
CODE_MISMATCH = '16',
INVALID_CODE = '17',
DELIEVERY_FAILED = '19',
PIN_NOT_SUPPORTED = '20',
NON_PREMITTED_DESTINATION = '29',
/**
* The verification check was successful.
*/
SUCCESS = '0',

/**
* The verification request was throttled.
*/
THROTTLED = '1',

/**
* A required parameter was missing in the verification request.
*/
MISSING_REQUIRED_PARAM = '2',

/**
* An invalid parameter was provided in the verification request.
*/
INVALID_PARAM = '3',

/**
* Invalid credentials were used in the verification request.
*/
INVALID_CREDENTIALS = '4',

/**
* An internal error occurred during the verification process.
*/
INTERNAL_ERROR = '5',

/**
* Failed to process the verification request.
*/
FAILED_TO_PROCESS = '6',

/**
* The API key used in the verification request is barred.
*/
BARRED_API_KEY = '8',

/**
* Partner quota for verifications exceeded.
*/
PARTNER_QUOTA_EXCEEDED = '9',

/**
* Concurrent verifications not allowed.
*/
CONCURRENT_VERIFICATIONS = '10',

/**
* The network is not supported for verification.
*/
UNSUPPORTED_NETWORK = '15',

/**
* Code mismatch in the verification request.
*/
CODE_MISMATCH = '16',

/**
* Invalid verification code provided.
*/
INVALID_CODE = '17',

/**
* Delivery of the verification failed.
*/
DELIVERY_FAILED = '19',

/**
* PIN not supported for verification.
*/
PIN_NOT_SUPPORTED = '20',

/**
* Destination not permitted for verification.
*/
NON_PERMITTED_DESTINATION = '29',
}
14 changes: 12 additions & 2 deletions packages/verify/lib/enums/Command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/**
* Enum representing commands for controlling Verify requests.
*/
export enum Command {
CANCEL = 'cancel',
TRIGGER_NEXT_EVENT = 'trigger_next_event',
/**
* Command to request cancellation of the verification process.
*/
CANCEL = 'cancel',

/**
* Command to trigger the next verification event (if any).
*/
TRIGGER_NEXT_EVENT = 'trigger_next_event',
}
14 changes: 12 additions & 2 deletions packages/verify/lib/enums/SearchCheckStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/**
* Enum representing the status of a verification check during Verify search.
*/
export enum SearchCheckStatus {
INVALID = 'INVALID',
VALID = 'VALID',
/**
* The verification check is invalid.
*/
INVALID = 'INVALID',

/**
* The verification check is valid.
*/
VALID = 'VALID',
}
14 changes: 12 additions & 2 deletions packages/verify/lib/enums/SearchEventTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/**
* Enum representing the types of events that can occur during Verify search.
*/
export enum SearchEventTypes {
TTS = 'TTS',
SMS = 'SMS',
/**
* Text-to-Speech event.
*/
TTS = 'TTS',

/**
* Short Message Service (SMS) event.
*/
SMS = 'SMS',
}
32 changes: 27 additions & 5 deletions packages/verify/lib/enums/SearchStatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
/**
* Enum representing the status of a Verify search request.
*/
export enum SearchStatus {
IN_PROGRESS = 'IN PROGRESS',
SUCCESS = 'SUCCESS',
FAILED = 'FAILED',
EXPIRED = 'EXPIRED',
CANCELLED = 'CANCELLED',
/**
* The search is still in progress.
*/
IN_PROGRESS = 'IN PROGRESS',

/**
* Your user entered a correct verification code.
*/
SUCCESS = 'SUCCESS',

/**
* Your user entered an incorrect code more than three times.
*/
FAILED = 'FAILED',

/**
* Your user did not enter a code before the pin_expiry time elapsed.
*/
EXPIRED = 'EXPIRED',

/**
* The verification process was canceled by a Verify control request.
*/
CANCELLED = 'CANCELLED',
}
Loading

0 comments on commit a9d5dc4

Please sign in to comment.