Skip to content

Commit

Permalink
Merge pull request #101 from getAlby/invoices-method
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 authored Oct 17, 2023
2 parents 9f65d52 + 0f429b5 commit 240e62b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Please have a look a the Alby OAuth2 Wallet API:
- accountSummary
- accountInformation
- accountValue4Value
- invoices
- incomingInvoices
- outgoingInvoices
- getInvoice
Expand Down
19 changes: 17 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CreateWebhookEndpointResponse,
GetAccountBalanceResponse,
GetAccountInformationResponse,
GetInvoicesRequestParams,
Invoice,
InvoiceRequestParams,
KeysendRequestParams,
Expand Down Expand Up @@ -86,7 +87,7 @@ export class Client {
}

incomingInvoices(
params: {},
params: GetInvoicesRequestParams,
request_options?: Partial<RequestOptions>,
): Promise<Invoice[]> {
return rest({
Expand All @@ -100,7 +101,7 @@ export class Client {
}

outgoingInvoices(
params: {},
params: GetInvoicesRequestParams,
request_options?: Partial<RequestOptions>,
): Promise<Invoice[]> {
return rest({
Expand All @@ -113,6 +114,20 @@ export class Client {
});
}

invoices(
params: GetInvoicesRequestParams,
request_options?: Partial<RequestOptions>,
): Promise<Invoice[]> {
return rest({
auth: this.auth,
...this.defaultRequestOptions,
...request_options,
endpoint: `/invoices`,
params,
method: "GET",
});
}

getInvoice(
paymentHash: string,
request_options?: Partial<RequestOptions>,
Expand Down
10 changes: 10 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ export type ExtractAlbyResponse<T> = "responses" extends keyof T
? GetSuccess<T["responses"]>
: never;

export type GetInvoicesRequestParams = {
q?: {
since?: string;
created_at_lt?: string;
created_at_gt?: string;
};
page?: number;
items?: number;
};

export type InvoiceRequestParams = {
description?: string;
description_hash?: string;
Expand Down

0 comments on commit 240e62b

Please sign in to comment.