credix
Version:
Official SDK for Credix Credit Management System
174 lines • 4.19 kB
TypeScript
/**
* User types for SDK
*/
/**
* Create user request
*/
export interface CreateUserRequest {
/** External user ID (your system's user ID) */
externalUserId: string;
/** User name (optional) */
name?: string;
/** Email address (optional) */
email?: string;
/** Custom metadata (optional) */
metadata?: Record<string, unknown>;
/** Initial credits to grant (optional) */
initialCredits?: number;
}
/**
* Update user request
*/
export interface UpdateUserRequest {
/** User name (optional) */
name?: string;
/** Email address (optional) */
email?: string;
/** Custom metadata (optional) */
metadata?: Record<string, unknown>;
}
/**
* User response
*/
export interface User {
/** Internal user ID */
id: string;
/** External user ID */
externalUserId: string;
/** User name */
name: string | null;
/** Email address */
email: string | null;
/** Current credit balance */
balance: number;
/** Custom metadata */
metadata: Record<string, unknown> | null;
/** Created timestamp */
createdAt: string;
/** Updated timestamp */
updatedAt: string;
}
/**
* Credit balance response
*/
export interface CreditBalance {
/** External user ID */
externalUserId: string;
/** Current credit balance */
balance: number;
/** Total credits allocated */
totalAllocated: number;
/** Total credits consumed */
totalConsumed: number;
/** Last updated timestamp */
lastUpdated: string;
}
/**
* Transaction types
*/
export type TransactionType = 'allocation' | 'consumption' | 'refund' | 'adjustment';
/**
* Credit transaction
*/
export interface CreditTransaction {
/** Transaction ID */
id: string;
/** Transaction type */
type: TransactionType;
/** Transaction amount */
amount: string;
/** Balance after transaction */
balanceAfter: string;
/** Transaction description */
description?: string | null;
/** Transaction metadata */
metadata?: Record<string, unknown> | null;
/** Created timestamp */
createdAt: string;
}
/**
* Get transactions request
*/
export interface GetTransactionsRequest {
/** Number of records to return (default: 50, max: 100) */
limit?: number;
/** Number of records to skip */
offset?: number;
/** Filter by transaction type */
type?: TransactionType;
/** Filter by start date (ISO 8601) */
startDate?: string;
/** Filter by end date (ISO 8601) */
endDate?: string;
}
/**
* Get transactions response
*/
export interface GetTransactionsResponse {
/** List of transactions */
transactions: CreditTransaction[];
/** Pagination info */
pagination: {
total: number;
limit: number;
offset: number;
hasMore: boolean;
};
/** Summary statistics */
summary: {
totalAllocated: string;
totalConsumed: string;
netChange: string;
};
}
/**
* Credit analytics query
*/
export interface GetCreditAnalyticsRequest {
/** Start date (YYYY-MM-DD) */
startDate?: string;
/** End date (YYYY-MM-DD) */
endDate?: string;
/** Aggregation unit */
aggregation?: 'daily' | 'weekly' | 'monthly';
/** IANA timezone */
timezone?: string;
}
/**
* Credit analytics response
*/
export interface GetCreditAnalyticsResponse {
data: Array<{
date: string;
consumed: number;
allocated: number;
balance: number;
usageRate: number;
transactionCount: number;
}>;
summary: {
totalConsumed: number;
totalAllocated: number;
averageDaily: number;
peakDay: string | null;
peakUsage: number;
startBalance: number;
endBalance: number;
};
period: {
startDate: string;
endDate: string;
aggregation: string;
};
meters: Array<{
meterId: string;
name: string | null;
totalConsumed: number;
data: Array<{
date: string;
consumed: number;
eventCount: number;
}>;
}>;
}
//# sourceMappingURL=users.d.ts.map