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

Remove sending phone number if not present #37

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
21 changes: 17 additions & 4 deletions lib/cardsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import axios from 'axios'
import { getAPIHostname } from './apiTarget'

interface MetaData {
email: string
phoneNumber: string
email?: string
phoneNumber?: string
sessionId: string
ipAddress: string
}
Expand Down Expand Up @@ -71,6 +71,13 @@ instance.interceptors.response.use(
}
)

const nullIfEmpty = (prop: string | undefined) => {
if (prop !== undefined && prop.trim() === '') {
return undefined
}
return prop
}

/** Returns the axios instance */
function getInstance() {
return instance
Expand Down Expand Up @@ -121,7 +128,10 @@ function getCards(pageBefore: string, pageAfter: string, pageSize: string) {
*/
function createCard(payload: CreateCardPayload) {
const url = `/v1/cards`

if (payload.metadata) {
payload.metadata.email = nullIfEmpty(payload.metadata.email)
payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber)
}
return instance.post(url, payload)
}

Expand All @@ -133,7 +143,10 @@ function createCard(payload: CreateCardPayload) {
*/
function updateCard(cardId: string, payload: UpdateCardPayload) {
const url = `/v1/cards/${cardId}`

if (payload.metadata) {
payload.metadata.email = nullIfEmpty(payload.metadata.email)
payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber)
}
return instance.put(url, payload)
}

Expand Down
12 changes: 11 additions & 1 deletion lib/marketplaceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getAPIHostname } from './apiTarget'

interface MetaData {
email: string
phoneNumber: string
phoneNumber?: string
sessionId: string
ipAddress: string
}
Expand Down Expand Up @@ -71,6 +71,13 @@ instance.interceptors.response.use(
}
)

const nullIfEmpty = (prop: string | undefined) => {
if (prop === '') {
return undefined
}
return prop
}

/** Returns the axios instance */
function getInstance() {
return instance
Expand All @@ -82,6 +89,9 @@ function getInstance() {
*/
function createPayment(payload: CreateMarketplacePaymentPayload) {
const url = `/v1/marketplace/payments`
if (payload.metadata) {
payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber)
}
return instance.post(url, payload)
}

Expand Down
19 changes: 11 additions & 8 deletions lib/paymentsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getAPIHostname } from './apiTarget'

interface MetaData {
email: string
phoneNumber: string
phoneNumber?: string
sessionId: string
ipAddress: string
}
Expand Down Expand Up @@ -59,6 +59,13 @@ instance.interceptors.response.use(
}
)

const nullIfEmpty = (prop: string | undefined) => {
if (prop === '') {
return undefined
}
return prop
}

/** Returns the axios instance */
function getInstance() {
return instance
Expand Down Expand Up @@ -91,6 +98,9 @@ function cancelPayment(id: string, payload: any) {
*/
function createPayment(payload: CreatePaymentPayload) {
const url = `/v1/payments`
if (payload.metadata) {
payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber)
}
return instance.post(url, payload)
}

Expand All @@ -109,13 +119,6 @@ function getPayments(
pageAfter: string,
pageSize: string
) {
const nullIfEmpty = (prop: string) => {
if (prop === '') {
return null
}
return prop
}

const queryParams = {
from: nullIfEmpty(from),
to: nullIfEmpty(to),
Expand Down
1 change: 0 additions & 1 deletion pages/flow/charge/existing-card/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

<v-text-field
v-model="formData.phoneNumber"
:rules="[rules.required]"
label="Phone"
:disabled="loading"
/>
Expand Down
1 change: 0 additions & 1 deletion pages/flow/charge/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@

<v-text-field
v-model="formData.cardData.phoneNumber"
:rules="[rules.required]"
label="Phone"
:disabled="loading"
/>
Expand Down