-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
sobhan azimzadeh edited this page Sep 18, 2025
·
1 revision
This document provides detailed information about TECSOQR's API structure and usage.
Primary service for QR code generation and manipulation.
class QRCodeService {
static async generateQRCode(
content: QRCodeContent,
customization?: QRCodeCustomization,
output: QRCodeOutput = {
format: "svg",
size: 1000,
margin: 4,
errorCorrectionLevel: "M",
}
): Promise<string>;
}-
content: QR code content (various types supported) -
customization: Style customization options -
output: Output format configuration
type QRCodeContent =
| QRCodeURL
| QRCodeText
| QRCodeEmail
| QRCodePhone
| QRCodeSMS
| QRCodeVCard
| QRCodeMeCard
| QRCodeLocation
| QRCodeWiFi
| QRCodeEvent
| QRCodeBitcoin
| QRCodeSocial;interface QRCodeURL {
type: "url";
url: string;
}interface QRCodeText {
type: "text";
text: string;
}interface QRCodeEmail {
type: "email";
email: string;
subject?: string;
body?: string;
}interface QRCodeWiFi {
type: "wifi";
ssid: string;
password?: string;
encryption: "WEP" | "WPA" | "nopass";
hidden?: boolean;
}interface QRCodeVCard {
type: "vcard";
firstName: string;
lastName: string;
organization?: string;
title?: string;
workPhone?: string;
homePhone?: string;
mobilePhone?: string;
email?: string;
website?: string;
street?: string;
city?: string;
state?: string;
zipCode?: string;
country?: string;
}interface QRCodeCustomization {
foreground?: string;
background?: string;
gradient?: {
type: "linear" | "radial";
colorStops: Array<{ offset: number; color: string }>;
};
logo?: {
file: File;
size?: number; // 1-30
};
cornerStyle?: "square" | "rounded" | "dots";
dotStyle?: "square" | "rounded" | "dots";
}interface QRCodeOutput {
format: "png" | "svg" | "pdf" | "eps";
size: number;
margin: number;
errorCorrectionLevel: "L" | "M" | "Q" | "H";
}const modifySvgStyles = (
svg: string,
customization?: {
cornerStyle?: "square" | "rounded" | "dots";
dotStyle?: "square" | "rounded" | "dots";
}
) => string;-
svg: Input SVG string -
customization: Style customization options
Modified SVG string with applied styles
interface QRPreviewProps {
content: QRCodeContent;
customization?: QRCodeCustomization;
}
export const QRPreview: React.FC<QRPreviewProps>;interface QRCustomizationProps {
value: QRCodeCustomization;
onChange: (value: QRCodeCustomization) => void;
}
export const QRCustomization: React.FC<QRCustomizationProps>;interface FormProps<T extends QRCodeContent> {
value: T;
onChange: (value: T) => void;
}
export const URLForm: React.FC<FormProps<QRCodeURL>>;
export const TextForm: React.FC<FormProps<QRCodeText>>;
export const WiFiForm: React.FC<FormProps<QRCodeWiFi>>;
export const VCardForm: React.FC<FormProps<QRCodeVCard>>;
export const EmailForm: React.FC<FormProps<QRCodeEmail>>;const content: QRCodeURL = {
type: "url",
url: "https://example.com",
};
const customization: QRCodeCustomization = {
cornerStyle: "rounded",
dotStyle: "dots",
foreground: "#000000",
background: "#FFFFFF",
};
const qrCode = await QRCodeService.generateQRCode(content, customization);const content: QRCodeWiFi = {
type: "wifi",
ssid: "MyNetwork",
password: "password123",
encryption: "WPA",
hidden: false,
};
const qrCode = await QRCodeService.generateQRCode(content);const content: QRCodeVCard = {
type: "vcard",
firstName: "John",
lastName: "Doe",
organization: "TECSO",
title: "Developer",
email: "john@example.com",
workPhone: "+1234567890",
};
const qrCode = await QRCodeService.generateQRCode(content);type QRCodeError =
| "INVALID_CONTENT"
| "GENERATION_FAILED"
| "INVALID_STYLE"
| "SVG_MODIFICATION_FAILED";
class QRCodeGenerationError extends Error {
constructor(message: string, public type: QRCodeError);
}try {
const qrCode = await QRCodeService.generateQRCode(content);
} catch (error) {
if (error instanceof QRCodeGenerationError) {
switch (error.type) {
case "INVALID_CONTENT":
// Handle invalid content
break;
case "GENERATION_FAILED":
// Handle generation failure
break;
// Handle other cases
}
}
}