/** * SMS API SDK * Auto-generated — v1.0 */ class SmsClient { constructor(token, baseUrl = 'https://api.aikdata.com/v1/sms') { this.token = token; this.baseUrl = baseUrl.replace(/\/$/, ''); } // ── Messages ── /** * Send an SMS message */ async sendSMS(body = null) { return this._request('POST', `/send`, {}, body); } /** * Get delivery status of a message */ async getMessageStatus(id) { return this._request('GET', `/messages/${id}`); } // ── HTTP helper ── async _request(method, path, query = {}, body = null) { const url = new URL(this.baseUrl + path); Object.entries(query).forEach(([k, v]) => { if (v !== undefined && v !== null) url.searchParams.set(k, v); }); const opts = { method, headers: { 'Authorization': `Bearer ${this.token}`, 'Content-Type': 'application/json', 'Accept': 'application/json', }, }; if (body && ['POST', 'PUT', 'PATCH'].includes(method)) { opts.body = JSON.stringify(body); } const res = await fetch(url.toString(), opts); return { status: res.status, data: await res.json() }; } } module.exports = { SmsClient };