aipp-node 1.0.1 → 1.0.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/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/package.json +1 -1
- package/src/client.ts +8 -6
- package/src/types.ts +2 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -58,15 +58,15 @@ var Aipp = class {
|
|
|
58
58
|
* Creates a new Lightning Invoice
|
|
59
59
|
*/
|
|
60
60
|
async createCharge(params) {
|
|
61
|
-
if (!params.amountSats
|
|
62
|
-
throw new Error("AIPP: amountSats
|
|
61
|
+
if (!params.amountSats && !params.amountUsd) {
|
|
62
|
+
throw new Error("AIPP: Either amountSats or amountUsd is required");
|
|
63
63
|
}
|
|
64
|
+
const body = { memo: params.memo };
|
|
65
|
+
if (params.amountSats) body.amount_sats = params.amountSats;
|
|
66
|
+
if (params.amountUsd) body.amount_usd = params.amountUsd;
|
|
64
67
|
return this.request("/invoice/create", {
|
|
65
68
|
method: "POST",
|
|
66
|
-
body: JSON.stringify(
|
|
67
|
-
amount_sats: params.amountSats,
|
|
68
|
-
memo: params.memo
|
|
69
|
-
})
|
|
69
|
+
body: JSON.stringify(body)
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -32,15 +32,15 @@ var Aipp = class {
|
|
|
32
32
|
* Creates a new Lightning Invoice
|
|
33
33
|
*/
|
|
34
34
|
async createCharge(params) {
|
|
35
|
-
if (!params.amountSats
|
|
36
|
-
throw new Error("AIPP: amountSats
|
|
35
|
+
if (!params.amountSats && !params.amountUsd) {
|
|
36
|
+
throw new Error("AIPP: Either amountSats or amountUsd is required");
|
|
37
37
|
}
|
|
38
|
+
const body = { memo: params.memo };
|
|
39
|
+
if (params.amountSats) body.amount_sats = params.amountSats;
|
|
40
|
+
if (params.amountUsd) body.amount_usd = params.amountUsd;
|
|
38
41
|
return this.request("/invoice/create", {
|
|
39
42
|
method: "POST",
|
|
40
|
-
body: JSON.stringify(
|
|
41
|
-
amount_sats: params.amountSats,
|
|
42
|
-
memo: params.memo
|
|
43
|
-
})
|
|
43
|
+
body: JSON.stringify(body)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
/**
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -39,15 +39,17 @@ export class Aipp {
|
|
|
39
39
|
* Creates a new Lightning Invoice
|
|
40
40
|
*/
|
|
41
41
|
async createCharge(params: ChargeParams): Promise<ChargeResponse> {
|
|
42
|
-
if (!params.amountSats
|
|
43
|
-
throw new Error('AIPP: amountSats
|
|
42
|
+
if (!params.amountSats && !params.amountUsd) {
|
|
43
|
+
throw new Error('AIPP: Either amountSats or amountUsd is required');
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
const body: any = { memo: params.memo };
|
|
47
|
+
if (params.amountSats) body.amount_sats = params.amountSats;
|
|
48
|
+
if (params.amountUsd) body.amount_usd = params.amountUsd;
|
|
49
|
+
|
|
45
50
|
return this.request<ChargeResponse>('/invoice/create', {
|
|
46
51
|
method: 'POST',
|
|
47
|
-
body: JSON.stringify(
|
|
48
|
-
amount_sats: params.amountSats,
|
|
49
|
-
memo: params.memo,
|
|
50
|
-
}),
|
|
52
|
+
body: JSON.stringify(body),
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
|