// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as WhatsappAPI from '../../auth/whatsapp/whatsapp'; import * as StepUpAPI from './step-up'; import { StepUp, StepUpRequestVerificationParams, StepUpResendParams, StepUpVerifyParams, StepUpVerifyResponse, VerificationResendModel, VerificationResendResponseModel, } from './step-up'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class Verification extends APIResource { stepUp: StepUpAPI.StepUp = new StepUpAPI.StepUp(this._client); /** * Cancel verification challenge */ cancelVerification( challengeID: string, params: VerificationCancelVerificationParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.post(path`/users/verification/${challengeID}/cancel`, { ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Get username by phone number (international format; optional '+' prefix). */ getUsernameByPhoneNumber( phoneNumber: string, params: VerificationGetUsernameByPhoneNumberParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/users/verification/username/${phoneNumber}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Request phone number or email verification */ requestVerification( params: VerificationRequestVerificationParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/users/verification/request-verification', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Resend verification code */ resendVerification( challengeID: string, params: VerificationResendVerificationParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/users/verification/${challengeID}/resend`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Resolve a channel handle to the bound GLChat user via user_identities. */ retrieveIdentity( params: VerificationRetrieveIdentityParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params; return this._client.get('/users/verification/identity', { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Unbind phone number or email from user */ unbindContact(params: VerificationUnbindContactParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/users/verification/unbind', { body, ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Verify OTP code and bind phone or email to user. Standard challenges return 204; * auxiliary profile challenges return 200 with JSON. */ verifyAndBind( challengeID: string, params: VerificationVerifyAndBindParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/users/verification/${challengeID}/verify-and-bind`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Verification channel types for SMS, WhatsApp, and email. */ export type VerificationChannel = 'SMS' | 'WHATSAPP' | 'EMAIL'; /** * Phone and email verification code verification model. * * Attributes: code: One-time password code to verify */ export interface VerificationVerifyModel { /** * OTP code to verify */ code: string; } /** * Username response model for phone number lookup. * * Attributes: username: Username associated with the phone number phone_number: * Phone number in international format that was searched display_name: Display * name associated with the username */ export interface VerificationGetUsernameByPhoneNumberResponse { /** * Phone number in international format that was searched */ phone_number: string; /** * Username associated with the phone number */ username: string; /** * Display name associated with the username */ display_name?: string | null; } /** * Response model for identity-scoped user lookup. * * Attributes: username: GLChat username bound to this identity. display_name: * Display name from the external provider. provider_type: Channel type (e.g. * "slack", "whatsapp"). external_subject: Channel-specific handle (Slack user ID, * E.164 phone, etc.). identity_verified: Whether the identity has been fully * verified. is_active: Always True in a 200 response; inactive identities are * signalled by 404. */ export interface VerificationRetrieveIdentityResponse { /** * Channel-specific handle (Slack user ID, E.164 phone, etc.) */ external_subject: string; /** * Whether the identity has been fully verified */ identity_verified: boolean; /** * Always True in a 200 response; inactive identities yield 404 */ is_active: boolean; /** * Channel type (e.g. 'slack', 'whatsapp') */ provider_type: string; /** * GLChat username bound to this identity */ username: string; /** * Display name from the external provider */ display_name?: string | null; } export type VerificationVerifyAndBindResponse = unknown; export interface VerificationCancelVerificationParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationGetUsernameByPhoneNumberParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationRequestVerificationParams { /** * Body param: Verification channel */ channel: VerificationChannel; /** * Body param: Phone number in international format (e.g., +62xxxxxxxxxx or * 62xxxxxxxxxx) or email address */ contact: string; /** * Body param: Username to bind with phone number */ username: string; /** * Body param: Optional named verification pipelines (not the default DB-backed OTP * challenge). * * Each profile may use different storage, validation, or side effects. New values * can be added for additional product flows without changing the request shape. */ verification_profile?: 'deferred_link_email_otp' | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationResendVerificationParams { /** * Body param: Channel to resend verification */ channel: VerificationChannel; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationRetrieveIdentityParams { /** * Query param: Channel-specific handle (Slack user ID, E.164 phone, etc.) */ external_subject: string; /** * Query param: Channel type (e.g. 'slack', 'whatsapp') */ provider_type: string; /** * Query param: Provider code — defaults to provider_type when omitted */ provider_code?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationUnbindContactParams { /** * Body param: Username to unbind from phone number */ username: string; /** * Body param: Channel handle: E.164 phone / Slack id / … */ external_subject?: string | null; /** * Body param: Org scope for the identity to unbind. Accepts either an org UUID or * a tenant slug. */ organization_id?: string | null; /** * Body param: Identity provider code (defaults to provider_type) */ provider_code?: string | null; /** * Body param: Identity provider type, e.g. whatsapp */ provider_type?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface VerificationVerifyAndBindParams { /** * Body param: OTP code to verify */ code: string; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } Verification.StepUp = StepUp; export declare namespace Verification { export { type VerificationChannel as VerificationChannel, type VerificationVerifyModel as VerificationVerifyModel, type VerificationGetUsernameByPhoneNumberResponse as VerificationGetUsernameByPhoneNumberResponse, type VerificationRetrieveIdentityResponse as VerificationRetrieveIdentityResponse, type VerificationVerifyAndBindResponse as VerificationVerifyAndBindResponse, type VerificationCancelVerificationParams as VerificationCancelVerificationParams, type VerificationGetUsernameByPhoneNumberParams as VerificationGetUsernameByPhoneNumberParams, type VerificationRequestVerificationParams as VerificationRequestVerificationParams, type VerificationResendVerificationParams as VerificationResendVerificationParams, type VerificationRetrieveIdentityParams as VerificationRetrieveIdentityParams, type VerificationUnbindContactParams as VerificationUnbindContactParams, type VerificationVerifyAndBindParams as VerificationVerifyAndBindParams, }; export { StepUp as StepUp, type VerificationResendModel as VerificationResendModel, type VerificationResendResponseModel as VerificationResendResponseModel, type StepUpVerifyResponse as StepUpVerifyResponse, type StepUpRequestVerificationParams as StepUpRequestVerificationParams, type StepUpResendParams as StepUpResendParams, type StepUpVerifyParams as StepUpVerifyParams, }; }