@pulsebyshiga/node 0.2.0

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.
@@ -0,0 +1,21 @@
1
+ export class Banks {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** Supported banks (name + NIP code) for offramp payout targets. */
7
+ list() {
8
+ return this.http.request({
9
+ method: 'GET',
10
+ path: '/v1/banks',
11
+ });
12
+ }
13
+ /** Name enquiry — verify an account before creating an offramp order against it. */
14
+ resolve(params) {
15
+ return this.http.request({
16
+ method: 'POST',
17
+ path: '/v1/banks/resolve',
18
+ body: params,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,12 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { CollectionOrder, ListOrdersParams, Page } from '../types.js';
3
+ export declare class CollectionOrders {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /** Ground truth for an order — the fallback when a webhook is missed. */
7
+ retrieve(orderId: string): Promise<CollectionOrder>;
8
+ /** Re-lock the quote for an expired order (new 10-minute window). */
9
+ refreshQuote(orderId: string): Promise<CollectionOrder>;
10
+ /** Partner-scoped listing for reconciliation. */
11
+ list(params?: ListOrdersParams): Promise<Page<CollectionOrder>>;
12
+ }
@@ -0,0 +1,36 @@
1
+ export class CollectionOrders {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** Ground truth for an order — the fallback when a webhook is missed. */
7
+ retrieve(orderId) {
8
+ return this.http.request({
9
+ method: 'GET',
10
+ path: `/v1/collection-orders/${encodeURIComponent(orderId)}`,
11
+ });
12
+ }
13
+ /** Re-lock the quote for an expired order (new 10-minute window). */
14
+ refreshQuote(orderId) {
15
+ return this.http.request({
16
+ method: 'POST',
17
+ path: `/v1/collection-orders/${encodeURIComponent(orderId)}/refresh_quote`,
18
+ });
19
+ }
20
+ /** Partner-scoped listing for reconciliation. */
21
+ list(params = {}) {
22
+ return this.http.request({
23
+ method: 'GET',
24
+ path: '/v1/collection-orders',
25
+ query: {
26
+ gate: params.gate,
27
+ status: params.status,
28
+ user_ref: params.user_ref,
29
+ created_after: params.created_after,
30
+ created_before: params.created_before,
31
+ limit: params.limit,
32
+ cursor: params.cursor,
33
+ },
34
+ });
35
+ }
36
+ }
@@ -0,0 +1,16 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { CollectionSession, CreateCollectionSessionParams } from '../types.js';
3
+ export type CreateSessionOptions = {
4
+ /** Client idempotency key; auto-generated when omitted. */
5
+ idempotencyKey?: string;
6
+ };
7
+ export declare class CollectionSessions {
8
+ private readonly http;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Create a collection order plus the single-order session token the hosted
12
+ * flow is opened with. Naira gate carries the account block (BVN/NIN on
13
+ * first use); USD gate carries no per-user identity.
14
+ */
15
+ create(params: CreateCollectionSessionParams, options?: CreateSessionOptions): Promise<CollectionSession>;
16
+ }
@@ -0,0 +1,19 @@
1
+ export class CollectionSessions {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Create a collection order plus the single-order session token the hosted
8
+ * flow is opened with. Naira gate carries the account block (BVN/NIN on
9
+ * first use); USD gate carries no per-user identity.
10
+ */
11
+ create(params, options = {}) {
12
+ return this.http.request({
13
+ method: 'POST',
14
+ path: '/v1/collection-sessions',
15
+ body: params,
16
+ idempotencyKey: options.idempotencyKey,
17
+ });
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { CreateOfframpOrderParams, OfframpOrder } from '../types.js';
3
+ /** Crypto → fiat: user sends stablecoin to the order's deposit address; fiat settles to the bank account. */
4
+ export declare class Offramp {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ /** Create an offramp order from a live quote. Resolve the bank account first (banks.resolve). */
8
+ create(params: CreateOfframpOrderParams): Promise<OfframpOrder>;
9
+ /** Ground truth for an order's lifecycle — poll until a terminal status. */
10
+ retrieve(orderId: string): Promise<OfframpOrder>;
11
+ }
@@ -0,0 +1,22 @@
1
+ /** Crypto → fiat: user sends stablecoin to the order's deposit address; fiat settles to the bank account. */
2
+ export class Offramp {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ /** Create an offramp order from a live quote. Resolve the bank account first (banks.resolve). */
8
+ create(params) {
9
+ return this.http.request({
10
+ method: 'POST',
11
+ path: '/v1/offramp/orders',
12
+ body: params,
13
+ });
14
+ }
15
+ /** Ground truth for an order's lifecycle — poll until a terminal status. */
16
+ retrieve(orderId) {
17
+ return this.http.request({
18
+ method: 'GET',
19
+ path: `/v1/offramp/orders/${encodeURIComponent(orderId)}`,
20
+ });
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { CreateOnrampOrderParams, OnrampOrder } from '../types.js';
3
+ /** Fiat → crypto: user pays the order's virtual bank account; crypto is sent to the destination address. */
4
+ export declare class Onramp {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ /** Create an onramp order from a live quote. The response carries the virtual account to pay. */
8
+ create(params: CreateOnrampOrderParams): Promise<OnrampOrder>;
9
+ /** Ground truth for an order's lifecycle — poll until a terminal status. */
10
+ retrieve(orderId: string): Promise<OnrampOrder>;
11
+ }
@@ -0,0 +1,22 @@
1
+ /** Fiat → crypto: user pays the order's virtual bank account; crypto is sent to the destination address. */
2
+ export class Onramp {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ /** Create an onramp order from a live quote. The response carries the virtual account to pay. */
8
+ create(params) {
9
+ return this.http.request({
10
+ method: 'POST',
11
+ path: '/v1/onramp/orders',
12
+ body: params,
13
+ });
14
+ }
15
+ /** Ground truth for an order's lifecycle — poll until a terminal status. */
16
+ retrieve(orderId) {
17
+ return this.http.request({
18
+ method: 'GET',
19
+ path: `/v1/onramp/orders/${encodeURIComponent(orderId)}`,
20
+ });
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { CreateQuoteParams, Quote } from '../types.js';
3
+ export declare class Quotes {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /**
7
+ * Lock a price. The returned `quote.id` is what offramp/onramp orders are
8
+ * created from — create the order before `expires_at` passes.
9
+ */
10
+ create(params: CreateQuoteParams): Promise<Quote>;
11
+ }
@@ -0,0 +1,17 @@
1
+ export class Quotes {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Lock a price. The returned `quote.id` is what offramp/onramp orders are
8
+ * created from — create the order before `expires_at` passes.
9
+ */
10
+ create(params) {
11
+ return this.http.request({
12
+ method: 'POST',
13
+ path: '/v1/quotes',
14
+ body: params,
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,38 @@
1
+ import type { HttpClient } from '../client.js';
2
+ import type { EngineNetwork } from '../types.js';
3
+ export type RatePreviewParams = {
4
+ /** Source currency/asset, e.g. "USDC". */
5
+ from: string;
6
+ /** Destination currency, e.g. "NGN". */
7
+ to: string;
8
+ /** Decimal amount in the source currency, e.g. "100.00". */
9
+ amount: string;
10
+ network?: EngineNetwork;
11
+ };
12
+ /**
13
+ * A rate you can show before any transaction. Backed by a quote, so the price
14
+ * is real and locked — but no order exists and no funds move until you create
15
+ * one from `quoteId`.
16
+ */
17
+ export type RatePreview = {
18
+ /** Units of `to` per one unit of `from`, decimal string. */
19
+ rate: string;
20
+ /** What the user parts with (equals the requested amount), decimal string. */
21
+ youSend: string;
22
+ /** What the user gets at this rate, decimal string. */
23
+ youReceive: string;
24
+ /** When the locked rate expires (ISO 8601). */
25
+ expiresAt: string;
26
+ /** Pass to offramp/onramp create to transact at exactly this locked rate. */
27
+ quoteId: string;
28
+ };
29
+ export declare class Rates {
30
+ private readonly http;
31
+ constructor(http: HttpClient);
32
+ /**
33
+ * Look up the live rate without placing an order. Wraps POST /v1/quotes and
34
+ * reshapes it for display; the returned `quoteId` lets you proceed to an
35
+ * order at the same locked price if the user decides to.
36
+ */
37
+ preview(params: RatePreviewParams): Promise<RatePreview>;
38
+ }
@@ -0,0 +1,30 @@
1
+ export class Rates {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Look up the live rate without placing an order. Wraps POST /v1/quotes and
8
+ * reshapes it for display; the returned `quoteId` lets you proceed to an
9
+ * order at the same locked price if the user decides to.
10
+ */
11
+ async preview(params) {
12
+ const quote = await this.http.request({
13
+ method: 'POST',
14
+ path: '/v1/quotes',
15
+ body: {
16
+ amount: params.amount,
17
+ source_currency: params.from,
18
+ destination_currency: params.to,
19
+ network: params.network,
20
+ },
21
+ });
22
+ return {
23
+ rate: quote.rate,
24
+ youSend: quote.source_amount,
25
+ youReceive: quote.destination_amount,
26
+ expiresAt: quote.expires_at,
27
+ quoteId: quote.id,
28
+ };
29
+ }
30
+ }