import * as grpc from '@grpc/grpc-js'; /** * Integration types supported by Go2. */ declare enum IntegrationType { UNSPECIFIED = 0, SLACK = 1, DISCORD = 2, TELEGRAM = 3, SEGMENT = 4, ZAPIER = 5 } /** * Integration configuration. */ interface IntegrationConfig { /** Webhook URL for Slack/Discord/Zapier */ webhookUrl?: string; /** Channel for Slack */ channel?: string; /** Bot token for Telegram */ botToken?: string; /** Chat ID for Telegram */ chatId?: string; /** Write key for Segment */ writeKey?: string; } /** * Integration resource. */ interface Integration { id: string; userId: string; type: IntegrationType; name: string; config: IntegrationConfig; events: string[]; isActive: boolean; lastTriggeredAt?: Date; triggerCount: number; createdAt: Date; updatedAt: Date; } /** * Parameters for creating an integration. */ interface CreateIntegrationParams { type: IntegrationType; name: string; config: IntegrationConfig; events: string[]; } /** * Parameters for updating an integration. */ interface UpdateIntegrationParams { name?: string; config?: IntegrationConfig; events?: string[]; isActive?: boolean; } /** * Response from testing an integration. */ interface TestIntegrationResponse { success: boolean; message: string; } /** * Integration type information. */ interface IntegrationTypeInfo { type: IntegrationType; name: string; description: string; icon: string; available: boolean; configFields: ConfigField[]; } /** * Configuration field description. */ interface ConfigField { name: string; label: string; fieldType: string; required: boolean; placeholder: string; helpText: string; } /** * Response from getting integration types. */ interface GetIntegrationTypesResponse { types: IntegrationTypeInfo[]; events: string[]; } /** * Service for managing integrations. */ declare class IntegrationsService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * List all integrations. */ list(): Promise; /** * Create a new integration. */ create(params: CreateIntegrationParams): Promise; /** * Get an integration by ID. */ get(id: string): Promise; /** * Update an integration. */ update(id: string, params: UpdateIntegrationParams): Promise; /** * Delete an integration. */ delete(id: string): Promise; /** * Test an integration by sending a test notification. */ test(id: string): Promise; /** * Get available integration types and events. */ getTypes(): Promise; /** * Close the service connection. */ close(): void; private mapIntegration; private mapIntegrations; } /** * Link resource. */ interface Link { id: string; userId: string; slug: string; title: string; iosUrl?: string; androidUrl?: string; webUrl?: string; fallbackUrl?: string; huaweiUrl?: string; amazonUrl?: string; windowsUrl?: string; macosUrl?: string; appName?: string; appIconUrl?: string; description?: string; isActive: boolean; totalClicks: number; createdAt: Date; updatedAt: Date; } /** * Parameters for creating a link. */ interface CreateLinkParams { slug: string; title: string; iosUrl?: string; androidUrl?: string; webUrl?: string; fallbackUrl?: string; huaweiUrl?: string; amazonUrl?: string; windowsUrl?: string; macosUrl?: string; appName?: string; appIconUrl?: string; description?: string; } /** * Parameters for updating a link. */ interface UpdateLinkParams { slug?: string; title?: string; iosUrl?: string; androidUrl?: string; webUrl?: string; fallbackUrl?: string; isActive?: boolean; } /** * Service for managing links. */ declare class LinksService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * List all links with pagination. */ list(page?: number, perPage?: number): Promise<{ links: Link[]; total: number; }>; /** * Create a new link. */ create(params: CreateLinkParams): Promise; /** * Get a link by ID. */ get(id: string): Promise; /** * Update a link. */ update(id: string, params: UpdateLinkParams): Promise; /** * Delete a link. */ delete(id: string): Promise; /** * Check if a slug is available. */ checkSlug(slug: string): Promise<{ available: boolean; slug: string; }>; close(): void; private mapLink; } interface Stats { totalClicks: number; uniqueClicks: number; iosClicks: number; androidClicks: number; webClicks: number; otherClicks: number; topCountries: CountryStats[]; topReferrers: ReferrerStats[]; } interface TimeseriesPoint { date: string; clicks: number; uniqueClicks: number; } interface PlatformStats { platform: string; clicks: number; percentage: number; } interface CountryStats { countryCode: string; countryName: string; clicks: number; percentage: number; } interface ReferrerStats { referrer: string; clicks: number; percentage: number; } /** * Service for link analytics. */ declare class AnalyticsService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * Get overview statistics for a link. * @param period - "7d", "30d", or "90d" */ getStats(linkId: string, period?: '7d' | '30d' | '90d'): Promise; /** * Get click data over time. * @param period - "7d", "30d", or "90d" */ getTimeseries(linkId: string, period?: '7d' | '30d' | '90d'): Promise; /** * Get breakdown by platform. * @param period - "7d", "30d", or "90d" */ getPlatforms(linkId: string, period?: '7d' | '30d' | '90d'): Promise; /** * Get breakdown by country. * @param period - "7d", "30d", or "90d" * @param limit - Max number of results (default 10) */ getCountries(linkId: string, period?: '7d' | '30d' | '90d', limit?: number): Promise; /** * Get top referrers. * @param period - "7d", "30d", or "90d" * @param limit - Max number of results (default 10) */ getReferrers(linkId: string, period?: '7d' | '30d' | '90d', limit?: number): Promise; close(): void; } declare enum DomainStatus { UNSPECIFIED = 0, PENDING = 1, VERIFYING = 2, ACTIVE = 3, FAILED = 4 } declare enum SSLStatus { UNSPECIFIED = 0, PENDING = 1, PROVISIONING = 2, ACTIVE = 3, FAILED = 4 } interface Domain { id: string; userId: string; domain: string; status: DomainStatus; verificationToken: string; verifiedAt?: Date; sslStatus: SSLStatus; createdAt: Date; updatedAt: Date; } interface DNSRecord { type: string; name: string; value: string; } interface CreateDomainResponse { domain: Domain; dnsRecords: DNSRecord[]; } /** * Service for managing custom domains. */ declare class DomainsService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * List all custom domains. */ list(): Promise; /** * Add a new custom domain. */ create(domain: string): Promise; /** * Get a domain by ID. */ get(id: string): Promise; /** * Verify a domain. */ verify(id: string): Promise; /** * Delete a domain. */ delete(id: string): Promise; close(): void; private mapDomain; } interface GenerateQRParams { linkId: string; size?: number; format?: 'png' | 'svg'; foregroundColor?: string; backgroundColor?: string; logoUrl?: string; } interface QRCode { url: string; size: number; format: string; } /** * Service for QR code generation. */ declare class QRService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * Generate a QR code for a link. */ generate(params: GenerateQRParams): Promise; close(): void; } interface Campaign { id: string; userId: string; name: string; description?: string; destinationUrl: string; passRecipientId: boolean; recipientParamName: string; totalRecipients: number; totalClicks: number; uniqueClicks: number; status: 'active' | 'paused' | 'completed' | 'archived'; createdAt: Date; updatedAt: Date; expiresAt?: Date; } interface CampaignLink { id: string; campaignId: string; slug: string; recipientId: string; recipientName?: string; recipientMetadata?: Record; clicked: boolean; firstClickedAt?: Date; lastClickedAt?: Date; clickCount: number; firstClickPlatform?: string; firstClickCountry?: string; firstClickCity?: string; createdAt: Date; shortUrl: string; } interface Recipient { id: string; name?: string; metadata?: Record; } interface CreateCampaignParams { name: string; description?: string; destinationUrl: string; passRecipientId?: boolean; recipientParamName?: string; expiresAt?: Date; } interface UpdateCampaignParams { name?: string; description?: string; destinationUrl?: string; passRecipientId?: boolean; recipientParamName?: string; status?: 'active' | 'paused' | 'completed' | 'archived'; expiresAt?: Date; } interface GenerateLinksResult { campaignId: string; linksCreated: number; sampleLinks: CampaignLink[]; } interface CampaignStats { campaignId: string; totalRecipients: number; totalClicks: number; uniqueClicks: number; clickRate: number; clicksByPlatform: Record; clicksByCountry: Record; clicksByDay: Record; } interface ListCampaignsFilters { status?: string; search?: string; } interface ListCampaignLinksFilters { clickedOnly?: boolean; search?: string; } /** * Service for managing SMS/Email marketing campaigns with bulk trackable links. */ declare class CampaignsService { private client; constructor(endpoint: string, credentials: grpc.ChannelCredentials, options: grpc.ClientOptions); /** * List all campaigns with optional filters. */ list(limit?: number, offset?: number, filters?: ListCampaignsFilters): Promise<{ campaigns: Campaign[]; total: number; }>; /** * Create a new campaign. */ create(params: CreateCampaignParams): Promise; /** * Get a campaign by ID. */ get(id: string): Promise; /** * Update a campaign. */ update(id: string, params: UpdateCampaignParams): Promise; /** * Delete a campaign. */ delete(id: string): Promise; /** * Generate links for campaign recipients in bulk. * @param campaignId - The campaign ID * @param recipients - Array of recipients (max 100,000 per request) */ generateLinks(campaignId: string, recipients: Recipient[]): Promise; /** * List campaign links with pagination. */ listLinks(campaignId: string, limit?: number, offset?: number, filters?: ListCampaignLinksFilters): Promise<{ links: CampaignLink[]; total: number; }>; /** * Get campaign statistics. */ getStats(campaignId: string): Promise; /** * Export all campaign links. */ exportLinks(campaignId: string): Promise; close(): void; private mapCampaign; private mapCampaignLink; private mapInt64Map; } /** * Options for creating a Go2Client. */ interface Go2ClientOptions { /** Your Go2 API key (required) */ apiKey: string; /** gRPC endpoint (default: grpc.go2.ge:443) */ endpoint?: string; /** Use insecure connection for local development */ insecure?: boolean; } /** * Go2 gRPC API Client. * * @example * ```typescript * const client = new Go2Client({ apiKey: 'go2_xxx' }); * * // Links * const links = await client.links.list(); * const link = await client.links.create({ slug: 'myapp', title: 'My App' }); * * // Analytics * const stats = await client.analytics.getStats(link.id); * * // Integrations * const integrations = await client.integrations.list(); * * // Domains * const domains = await client.domains.list(); * * // QR Codes * const qr = await client.qr.generate({ linkId: link.id }); * * client.close(); * ``` */ declare class Go2Client { private endpoint; private credentials; private channelOptions; /** Service for managing smart links */ readonly links: LinksService; /** Service for link analytics */ readonly analytics: AnalyticsService; /** Service for managing integrations */ readonly integrations: IntegrationsService; /** Service for managing custom domains */ readonly domains: DomainsService; /** Service for QR code generation */ readonly qr: QRService; /** Service for managing marketing campaigns */ readonly campaigns: CampaignsService; constructor(options: Go2ClientOptions); /** * Close the client connection. */ close(): void; } /** * Base error class for Go2 SDK errors. */ declare class Go2Error extends Error { readonly code: grpc.status; constructor(message: string, code?: grpc.status); } /** * Raised when authentication fails (invalid API key). */ declare class AuthenticationError extends Go2Error { constructor(message?: string); } /** * Raised when a resource is not found. */ declare class NotFoundError extends Go2Error { constructor(message?: string); } /** * Raised when permission is denied. */ declare class PermissionDeniedError extends Go2Error { constructor(message?: string); } /** * Raised when input validation fails. */ declare class ValidationError extends Go2Error { constructor(message?: string); } /** * Raised when rate limit is exceeded. */ declare class RateLimitError extends Go2Error { constructor(message?: string); } export { AnalyticsService, AuthenticationError, type Campaign, type CampaignLink, type CampaignStats, CampaignsService, type ConfigField, type CountryStats, type CreateCampaignParams, type CreateDomainResponse, type CreateIntegrationParams, type CreateLinkParams, type DNSRecord, type Domain, DomainStatus, DomainsService, type GenerateLinksResult, type GenerateQRParams, type GetIntegrationTypesResponse, Go2Client, type Go2ClientOptions, Go2Error, type Integration, type IntegrationConfig, IntegrationType, type IntegrationTypeInfo, IntegrationsService, type Link, LinksService, NotFoundError, PermissionDeniedError, type PlatformStats, type QRCode, QRService, RateLimitError, type Recipient, type ReferrerStats, SSLStatus, type Stats, type TestIntegrationResponse, type TimeseriesPoint, type UpdateCampaignParams, type UpdateIntegrationParams, type UpdateLinkParams, ValidationError };