-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from dmatuszczak/SP-999
SP-999 Node.js: Add linter / formatter for examples
- Loading branch information
Showing
14 changed files
with
202 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import {LoggerProvider} from "../../src/Logger/LoggerProvider"; | ||
import {BitPayLogger} from "../../src/Logger/BitPayLogger"; | ||
import { LoggerProvider } from '../../src/Logger/LoggerProvider'; | ||
import { BitPayLogger } from '../../src/Logger/BitPayLogger'; | ||
|
||
class UseLogger { | ||
export class UseLogger { | ||
public execute(): void { | ||
const logger: BitPayLogger = { | ||
logError(message: string): void { | ||
console.log(message); | ||
}, | ||
|
||
logRequest(method: string, endpoint: string, json: string | null): void { | ||
console.log(method + ' ' + endpoint + ' ' + json) | ||
console.log(method + ' ' + endpoint + ' ' + json); | ||
}, | ||
|
||
logResponse(method: string, endpoint: string, json: string): void { | ||
console.log(method + ' ' + endpoint + ' ' + json) | ||
console.log(method + ' ' + endpoint + ' ' + json); | ||
} | ||
} | ||
}; | ||
|
||
LoggerProvider.setLogger(logger); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
import {ClientProvider} from "../ClientProvider"; | ||
import {Bill} from "../../src/Model"; | ||
import {Item} from "../../src/Model/Bill/Item"; | ||
import { ClientProvider } from '../ClientProvider'; | ||
import { Bill } from '../../src/Model'; | ||
import { Item } from '../../src/Model/Bill/Item'; | ||
|
||
class BillRequests { | ||
public async createBill(): Promise<void> { | ||
export class BillRequests { | ||
public async createBill() { | ||
const client = ClientProvider.create(); | ||
|
||
const bill = new Bill('someNumber', "USD", "some@email.com", []) | ||
await client.createBill(bill); | ||
const bill = new Bill('someNumber', 'USD', 'some@email.com', []); | ||
return client.createBill(bill); | ||
} | ||
|
||
public async getBill(): Promise<void> { | ||
public async getBill() { | ||
const client = ClientProvider.create(); | ||
|
||
// Get one bill | ||
const bill = await client.getBill('someBillId'); | ||
return await client.getBill('someBillId'); | ||
} | ||
|
||
// Get bills by status | ||
const bills = await client.getBills('draft'); | ||
public async getBills() { | ||
const client = ClientProvider.create(); | ||
return await client.getBills('draft'); | ||
} | ||
|
||
public async updateBill(): Promise<void> { | ||
public async updateBill() { | ||
const client = ClientProvider.create(); | ||
|
||
const item = new Item() | ||
const item = new Item(); | ||
item.price = 12.34; | ||
item.quantity = 2; | ||
item.description = 'someDescription'; | ||
|
||
const bill = new Bill('someNumber', "USD", "some@email.com", []); | ||
const bill = new Bill('someNumber', 'USD', 'some@email.com', []); | ||
|
||
if (bill.id) { | ||
await client.updateBill(bill, bill.id) | ||
await client.updateBill(bill, bill.id); | ||
} | ||
} | ||
|
||
public async deliverBillViaEmail(): Promise<void> { | ||
public async deliverBillViaEmail() { | ||
const client = ClientProvider.create(); | ||
|
||
await client.deliverBill('someBillId', 'myBillToken'); | ||
return await client.deliverBill('someBillId', 'myBillToken'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,54 @@ | ||
import {ClientProvider} from "../ClientProvider"; | ||
import {Refund} from "../../src/Model/Invoice/Refund"; | ||
import { ClientProvider } from '../ClientProvider'; | ||
import { Refund } from '../../src/Model/Invoice/Refund'; | ||
|
||
class RefundRequests { | ||
public async createRefund(): Promise<void> { | ||
export class RefundRequests { | ||
public async createRefund() { | ||
const client = ClientProvider.create(); | ||
|
||
const refund = new Refund(12, "someInvoiceId", "someToken"); | ||
const refund = new Refund(12, 'someInvoiceId', 'someToken'); | ||
|
||
const result = await client.createRefund(refund); | ||
return await client.createRefund(refund); | ||
} | ||
|
||
public async updateRefund(): Promise<void> { | ||
public async updateRefund() { | ||
const client = ClientProvider.create(); | ||
|
||
// Update a refund by ID | ||
const updateRefund = await client.updateRefund('myRefundId','created'); | ||
return await client.updateRefund('myRefundId', 'created'); | ||
} | ||
|
||
public async updateRefundByGuid() { | ||
const client = ClientProvider.create(); | ||
|
||
// Update a refund by GUID | ||
const updatedRefundByGuid = await client.updateRefundByGuid('myRefundId','created'); | ||
return await client.updateRefundByGuid('myRefundGuid', 'created'); | ||
} | ||
|
||
public async getRefund(): Promise<void> { | ||
public async getRefund() { | ||
const client = ClientProvider.create(); | ||
|
||
// Get a refund by ID | ||
const refund = await client.getRefund('someRefundId'); | ||
return await client.getRefund('someRefundId'); | ||
} | ||
|
||
// Get a refund by GUID | ||
const refundByGuid = await client.getRefundByGuid('someGuid'); | ||
public async getRefundByGuid() { | ||
const client = ClientProvider.create(); | ||
|
||
await client.getRefundByGuid('someGuid'); | ||
} | ||
|
||
public async cancelRefund(): Promise<void> { | ||
public async cancelRefund() { | ||
const client = ClientProvider.create(); | ||
|
||
// Cancel a refund by ID | ||
const cancelRefund = await client.cancelRefund('myRefundId'); | ||
return await client.cancelRefund('myRefundId'); | ||
} | ||
|
||
public async cancleRefundByGuid() { | ||
const client = ClientProvider.create(); | ||
|
||
// Cancel a refund by GUID | ||
const cancelRefundByGuid = await client.cancelRefundByGuid('someGuid'); | ||
return await client.cancelRefundByGuid('someGuid'); | ||
} | ||
|
||
public async requestRefundNotificationToBeResent(): Promise<void> { | ||
public async requestRefundNotificationToBeResent() { | ||
const client = ClientProvider.create(); | ||
|
||
const result = await client.sendRefundNotification('someRefundId'); | ||
return await client.sendRefundNotification('someRefundId'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import {ClientProvider} from "../ClientProvider"; | ||
import {Settlement} from "../../src/Model/Settlement/Settlement"; | ||
import { ClientProvider } from '../ClientProvider'; | ||
import { Settlement } from '../../src/Model/Settlement/Settlement'; | ||
|
||
class SettlementRequests { | ||
public async getSettlement(): Promise<void> { | ||
export class SettlementRequests { | ||
public async getSettlement() { | ||
const client = ClientProvider.create(); | ||
|
||
// Get one settlement | ||
const settlement = await client.getSettlement('someSettlementId'); | ||
return await client.getSettlement('someSettlementId'); | ||
} | ||
|
||
public async getSettlementsByFilters() { | ||
const client = ClientProvider.create(); | ||
|
||
// Get settlements by filter | ||
const params = { | ||
startDate: '2021-05-10', | ||
endDate: '2021-05-12', | ||
status: 'processing', | ||
limit: 100, | ||
offset: 0 | ||
}; | ||
const settlements = await client.getSettlements(params) | ||
|
||
return await client.getSettlements(params); | ||
} | ||
|
||
public async fetchReconciliationReport(): Promise<void> { | ||
public async fetchReconciliationReport() { | ||
const client = ClientProvider.create(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const settlement = new Settlement(); | ||
|
||
const result = await client.getSettlementReconciliationReport('settlementId', 'settlementToken'); | ||
return await client.getSettlementReconciliationReport('settlementId', 'settlementToken'); | ||
} | ||
} | ||
} |
Oops, something went wrong.