-
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 #107 from bobbrodie/SP-794
SP-794 Update examples to use async
- Loading branch information
Showing
14 changed files
with
106 additions
and
81 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
|
@@ -3,22 +3,24 @@ import {Bill} from "../../src/Model"; | |
import {Item} from "../../src/Model/Bill/Item"; | ||
|
||
class BillRequests { | ||
public createBill(): void { | ||
public async createBill(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const bill = new Bill('someNumber', "USD", "[email protected]", []) | ||
client.createBill(bill); | ||
await client.createBill(bill); | ||
} | ||
|
||
public getBill(): void { | ||
public async getBill(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const bill = client.getBill('someBillId'); | ||
// Get one bill | ||
const bill = await client.getBill('someBillId'); | ||
|
||
const bills = client.getBills('draft'); | ||
// Get bills by status | ||
const bills = await client.getBills('draft'); | ||
} | ||
|
||
public updateBill(): void { | ||
public async updateBill(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const item = new Item() | ||
|
@@ -28,12 +30,14 @@ class BillRequests { | |
|
||
const bill = new Bill('someNumber', "USD", "[email protected]", []); | ||
|
||
client.updateBill(bill, bill.id) | ||
if (bill.id) { | ||
await client.updateBill(bill, bill.id) | ||
} | ||
} | ||
|
||
public deliverBillViaEmail(): void { | ||
public async deliverBillViaEmail(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
client.deliverBill('someBillId', 'myBillToken'); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import {Buyer} from "../../src/Model/Invoice/Buyer"; | |
import {ClientProvider} from "../ClientProvider"; | ||
|
||
class InvoiceRequests { | ||
public createInvoice(): void { | ||
public async createInvoice(): Promise<void> { | ||
const invoice = new Invoice(10.0, 'USD'); | ||
invoice.notificationEmail = '[email protected]'; | ||
invoice.notificationURL = 'https://some-url.com'; | ||
|
@@ -23,10 +23,10 @@ class InvoiceRequests { | |
|
||
const client = ClientProvider.create(); | ||
|
||
const createdInvoice = client.createInvoice(invoice); | ||
const createdInvoice = await client.createInvoice(invoice); | ||
} | ||
|
||
public getInvoice(): void { | ||
public async getInvoice(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const invoice = client.getInvoice('myInvoiceId'); | ||
|
@@ -40,28 +40,29 @@ class InvoiceRequests { | |
limit: null, | ||
offset: null | ||
}; | ||
const invoices = client.getInvoices(params) | ||
const invoices = await client.getInvoices(params) | ||
} | ||
|
||
public updateInvoice(): void { | ||
public async updateInvoice(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
const params = []; | ||
params['buyerSms'] = '123321312'; | ||
const params = { | ||
buyerSms: '123321312' | ||
}; | ||
|
||
const updatedInvoice = client.updateInvoice('someId', params) | ||
const updatedInvoice = await client.updateInvoice('someId', params) | ||
} | ||
|
||
public cancelInvoice(): void { | ||
public async cancelInvoice(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
client.cancelInvoice('someInvoiceId'); | ||
await client.cancelInvoice('someInvoiceId'); | ||
|
||
client.cancelInvoiceByGuid('someGuid'); | ||
await client.cancelInvoiceByGuid('someGuid'); | ||
} | ||
|
||
public requestInvoiceWebhookToBeResent(): void { | ||
public async requestInvoiceWebhookToBeResent(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
client.deliverBill('someBillId', 'myBillToken'); | ||
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
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 |
---|---|---|
|
@@ -3,41 +3,46 @@ import {Payout} from "../../src/Model"; | |
import {PayoutStatus} from "../../src"; | ||
|
||
class PayoutRequests { | ||
public createPayout(): void { | ||
public async createPayout(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const payout = new Payout(12.34, 'USD', 'USD'); | ||
payout.notificationEmail = '[email protected]'; | ||
payout.notificationURL = 'https://my-url.com'; | ||
|
||
const createdPayout = client.submitPayout(payout); | ||
// Submit one payout | ||
const createdPayout = await client.submitPayout(payout); | ||
|
||
const payouts = client.submitPayouts([ | ||
// Submit multiple payouts | ||
const payouts = await client.submitPayouts([ | ||
new Payout(12.34, 'USD', 'USD'), | ||
new Payout(56.14, 'USD', 'USD'), | ||
]) | ||
} | ||
|
||
public getPayouts(): void { | ||
public async getPayouts(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const payout = client.getPayout('myPayoutId') | ||
// Get one payout | ||
const payout = await client.getPayout('myPayoutId') | ||
|
||
const payouts = client.getPayouts({ status: PayoutStatus.New }); | ||
// Get payouts by filter | ||
const payouts = await client.getPayouts({ status: PayoutStatus.New }); | ||
} | ||
|
||
public cancelPayout(): void { | ||
public async cancelPayout(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const result = client.cancelPayout('somePayoutId'); | ||
// Cancel one payout | ||
const result = await client.cancelPayout('somePayoutId'); | ||
|
||
// const payoutGroupId = payout.groupId; | ||
// Cancel payout group | ||
const cancelledPayouts = client.cancelPayouts('payoutGroupId'); | ||
} | ||
|
||
public requestPayoutWebhookToBeResent(): void { | ||
public async requestPayoutWebhookToBeResent(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const result = client.requestPayoutNotification('somePayoutId'); | ||
const result = await client.requestPayoutNotification('somePayoutId'); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,36 +2,38 @@ import {ClientProvider} from "../ClientProvider"; | |
import {PayoutRecipient, PayoutRecipients} from "../../src/Model"; | ||
|
||
class RecipientRequests { | ||
public inviteRecipients(): void { | ||
public async inviteRecipients(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const payoutRecipient = new PayoutRecipient('[email protected]', 'someLabel', 'https://notification.com'); | ||
|
||
const payoutRecipients = new PayoutRecipients([payoutRecipient]); | ||
|
||
const recipients = client.submitPayoutRecipients(payoutRecipients); | ||
const recipients = await client.submitPayoutRecipients(payoutRecipients); | ||
} | ||
|
||
public getRecipient(): void { | ||
public async getRecipient(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const recipient = client.getPayoutRecipient('someRecipientId'); | ||
// Get one payout recipient | ||
const recipient = await client.getPayoutRecipient('someRecipientId'); | ||
|
||
const recipients = client.getPayoutRecipients('invited'); | ||
// Get payout recipients by filter | ||
const recipients = await client.getPayoutRecipients('invited'); | ||
} | ||
|
||
public updateRecipient(): void { | ||
public async updateRecipient(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const payoutRecipient = new PayoutRecipient('[email protected]', 'someLabel', 'https://notification.com'); | ||
payoutRecipient.label = 'some label'; | ||
|
||
const recipient = client.updatePayoutRecipient(payoutRecipient.id, payoutRecipient); | ||
const recipient = await client.updatePayoutRecipient(payoutRecipient.id, payoutRecipient); | ||
} | ||
|
||
public removeRecipient(): void { | ||
public async removeRecipient(): Promise<void> { | ||
const client = ClientProvider.create(); | ||
|
||
const result = client.deletePayoutRecipient('somePayoutRecipientId'); | ||
const result = await client.deletePayoutRecipient('somePayoutRecipientId'); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,22 +3,22 @@ import {Bill} from "../../src/Model"; | |
import {Item} from "../../src/Model/Bill/Item"; | ||
|
||
class BillRequests { | ||
public createBill(): void { | ||
public async createBill(): Promise<void> { | ||
const client = ClientProvider.createPos(); | ||
|
||
const bill = new Bill('someNumber', "USD", "[email protected]", []) | ||
client.createBill(bill); | ||
await client.createBill(bill); | ||
} | ||
|
||
public getBill(): void { | ||
public async getBill(): Promise<void> { | ||
const client = ClientProvider.createPos(); | ||
|
||
const bill = client.getBill('someBillId'); | ||
const bill = await client.getBill('someBillId'); | ||
} | ||
|
||
public deliverBillViaEmail(): void { | ||
public async deliverBillViaEmail(): Promise<void> { | ||
const client = ClientProvider.createPos(); | ||
|
||
client.deliverBill('someBillId', 'myBillToken'); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import {Buyer} from "../../src/Model/Invoice/Buyer"; | |
import {ClientProvider} from "../ClientProvider"; | ||
|
||
class InvoiceRequests { | ||
public createInvoice(): void { | ||
public async createInvoice(): Promise<void> { | ||
const invoice = new Invoice(10.0, 'USD'); | ||
invoice.notificationEmail = '[email protected]'; | ||
invoice.notificationURL = 'https://some-url.com'; | ||
|
@@ -23,12 +23,12 @@ class InvoiceRequests { | |
|
||
const client = ClientProvider.createPos(); | ||
|
||
const createdInvoice = client.createInvoice(invoice); | ||
const createdInvoice = await client.createInvoice(invoice); | ||
} | ||
|
||
public getInvoice(): void { | ||
public async getInvoice(): Promise<void> { | ||
const client = ClientProvider.createPos(); | ||
|
||
const invoice = client.getInvoice('myInvoiceId'); | ||
const invoice = await client.getInvoice('myInvoiceId'); | ||
} | ||
} |
Oops, something went wrong.