voicegate 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +11 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -124,6 +124,13 @@ class VoiceGate {
|
|
|
124
124
|
return text ? JSON.parse(text) : null;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// Чем представляться шлюзу. Сессия агента (вход по KYA-удостоверению) важнее
|
|
128
|
+
// ключа-интегратора: если агент вошёл сам, он и платит за свои звонки. Ключ
|
|
129
|
+
// от нас нужен только тем, кто ведёт много агентов из собственной системы.
|
|
130
|
+
_creds() {
|
|
131
|
+
return this._session ? [this._session, null] : [null, this.apiKey];
|
|
132
|
+
}
|
|
133
|
+
|
|
127
134
|
// ── voice call (private beta) ──────────────────────────────────────────────
|
|
128
135
|
/**
|
|
129
136
|
* Place an outbound call.
|
|
@@ -140,13 +147,13 @@ class VoiceGate {
|
|
|
140
147
|
const body = { to, greeting, prompt, language, voice };
|
|
141
148
|
if (agentId) body.agent_id = agentId;
|
|
142
149
|
if (callerId) body.caller_id = callerId;
|
|
143
|
-
return this._request('POST', this.base + '/v1/agent-call', body,
|
|
150
|
+
return this._request('POST', this.base + '/v1/agent-call', body, ...this._creds());
|
|
144
151
|
}
|
|
145
152
|
|
|
146
153
|
// ── billing ────────────────────────────────────────────────────────────────
|
|
147
154
|
/** Balance, holds and the terms this account is charged under. */
|
|
148
155
|
async balance(agentId) {
|
|
149
|
-
return this._request('GET', `${this.base}/v1/billing/${agentId}/balance`, null,
|
|
156
|
+
return this._request('GET', `${this.base}/v1/billing/${agentId}/balance`, null, ...this._creds());
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
/**
|
|
@@ -156,12 +163,12 @@ class VoiceGate {
|
|
|
156
163
|
*/
|
|
157
164
|
async linkWallet(agentId, walletAddress) {
|
|
158
165
|
return this._request('POST', `${this.base}/v1/billing/${agentId}/wallet`,
|
|
159
|
-
{ wallet_address: walletAddress },
|
|
166
|
+
{ wallet_address: walletAddress }, ...this._creds());
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
/** Append-only ledger: topup, hold, release, charge, refund, adjust. */
|
|
163
170
|
async transactions(agentId) {
|
|
164
|
-
return this._request('GET', `${this.base}/v1/billing/${agentId}/transactions`, null,
|
|
171
|
+
return this._request('GET', `${this.base}/v1/billing/${agentId}/transactions`, null, ...this._creds());
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
// ── KYA — Know Your Agent (live) ───────────────────────────────────────────
|