Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the fetch payments API params to contain to date and from date #18

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/marketplaceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ function createPayment(payload: CreateMarketplacePaymentPayload) {

/**
* Get payments
* @param {String} from
* @param {String} to
* @param {String} pageBefore
* @param {String} pageAfter
* @param {String} pageSize
* @param {String} merchantId
*/
function getPayments(
from: string,
to: string,
pageBefore: string,
pageAfter: string,
pageSize: string,
Expand All @@ -97,9 +101,12 @@ function getPayments(
if (prop === '') {
return null
}
return prop
}

const queryParams = {
from: nullIfEmpty(from),
to: nullIfEmpty(to),
pageBefore: nullIfEmpty(pageBefore),
pageAfter: nullIfEmpty(pageAfter),
pageSize: nullIfEmpty(pageSize),
Expand Down
13 changes: 12 additions & 1 deletion lib/paymentsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,29 @@ function createPayment(payload: CreatePaymentPayload) {

/**
* Get payments
* @param {String} from
* @param {String} to
* @param {String} pageBefore
* @param {String} pageAfter
* @param {String} pageSize
*/
function getPayments(pageBefore: string, pageAfter: string, pageSize: string) {
function getPayments(
from: string,
to: string,
pageBefore: string,
pageAfter: string,
pageSize: string
) {
const nullIfEmpty = (prop: string) => {
if (prop === '') {
return null
}
return prop
}

const queryParams = {
from: nullIfEmpty(from),
to: nullIfEmpty(to),
pageBefore: nullIfEmpty(pageBefore),
pageAfter: nullIfEmpty(pageAfter),
pageSize: nullIfEmpty(pageSize)
Expand Down
6 changes: 6 additions & 0 deletions pages/debug/marketplace/payments/fetch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<v-form>
<header>Optional filter params:</header>
<v-text-field v-model="formData.merchantId" label="Merchant Id" />
<v-text-field v-model="formData.from" label="From" />
<v-text-field v-model="formData.to" label="To" />
<v-text-field v-model="formData.pageSize" label="PageSize" />
<v-text-field v-model="formData.pageBefore" label="PageBefore" />
<v-text-field v-model="formData.pageAfter" label="PageAfter" />
Expand Down Expand Up @@ -57,6 +59,8 @@ export default class FetchPaymentsClass extends Vue {
// data
formData = {
merchantId: '',
from: '',
to: '',
pageSize: '',
pageBefore: '',
pageAfter: ''
Expand All @@ -80,6 +84,8 @@ export default class FetchPaymentsClass extends Vue {
this.loading = true
try {
await this.$marketplaceApi.getPayments(
this.formData.from,
this.formData.to,
this.formData.pageBefore,
this.formData.pageAfter,
this.formData.pageSize,
Expand Down
6 changes: 6 additions & 0 deletions pages/debug/payments/fetch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<v-col cols="12" md="4">
<v-form>
<header>Optional filter params:</header>
<v-text-field v-model="formData.from" label="From" />
<v-text-field v-model="formData.to" label="To" />
<v-text-field v-model="formData.pageSize" label="PageSize" />
<v-text-field v-model="formData.pageBefore" label="PageBefore" />
<v-text-field v-model="formData.pageAfter" label="PageAfter" />
Expand Down Expand Up @@ -55,6 +57,8 @@ import ErrorSheet from '@/components/ErrorSheet.vue'
export default class FetchPaymentsClass extends Vue {
// data
formData = {
from: '',
to: '',
pageSize: '',
pageBefore: '',
pageAfter: ''
Expand All @@ -78,6 +82,8 @@ export default class FetchPaymentsClass extends Vue {
this.loading = true
try {
await this.$paymentsApi.getPayments(
this.formData.from,
this.formData.to,
this.formData.pageBefore,
this.formData.pageAfter,
this.formData.pageSize
Expand Down