Skip to content

Commit

Permalink
refactor: removed unwanted code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdeyyy committed Apr 5, 2024
1 parent e79889d commit d099a89
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 120 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ const archived_request = await paystack.payment_request.archive("request id")
- [x] Create Customer
- [x] List Customers
- [x] Fetch Customer
- [ ] Update Customer
- [ ] Validate Customer
- [x] Update Customer
- [x] Validate Customer
- [ ] Whitelist/Blacklist Customer
- [ ] Deactivate Authorization

Expand Down
9 changes: 0 additions & 9 deletions lib/customer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ test("update customer", async () => {
}
})

// {
// "country": "NG",
// "type": "bank_account",
// "account_number": "0123456789",
// "bvn": "20012345677",
// "bank_code": "007",
// "first_name": "Asta",
// "last_name": "Lavista"
// }

test("validate customer", async () => {
let cust = (await customer())
Expand Down
110 changes: 1 addition & 109 deletions lib/payment_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export class PaymentRequest {
const resp = await json_resp.json();

let response: CreatePaymentRequestResponse = resp as CreatePaymentRequestResponse;
// if (!resp.status) {
// return response
// }
// response = this.convert_to_invoice_create_response(resp as CreatePaymentRequestResponse);

return response

}
Expand All @@ -72,15 +69,6 @@ export class PaymentRequest {
const headers = this.get_headers()
const url = new URL(this.endpoint)

let query_string = "?";

// FIXME: find a better way to handle the queries

// for (const key in Object.keys(query)) {
// const value = query[key];
// url.searchParams.set(key,value )
// }

if (query.perPage) url.searchParams.set('perPage', query.perPage.toString())
if (query.page) url.searchParams.set('page', query.page.toString())
if (query.customer) url.searchParams.set('customer', query.customer)
Expand All @@ -90,7 +78,6 @@ export class PaymentRequest {
if (query.from) url.searchParams.set('from', query.from)
if (query.to) url.searchParams.set('to', query.to)


const json_resp = await fetch(url, {
method: "GET",
headers: headers
Expand All @@ -99,34 +86,6 @@ export class PaymentRequest {
const resp = await json_resp.json();
const response: ListPaymentRequestResponse = resp as ListPaymentRequestResponse;

// if (!response.status) {

// return response;
// }

// convert the string numbers to actual numbers
// response.meta.page = Number(response.meta.page)
// response.meta.pageCount = Number(response.meta.pageCount)
// response.meta.perPage = Number(response.meta.perPage)
// response.meta.skipped = Number(response.meta.skipped)
// response.meta.total = Number(response.meta.total)

// for (let i = 0; i < response.data.length; i++) {
// response.data[i].id = Number(response.data[i].id)
// response.data[i].amount = Number(response.data[i].amount)
// response.data[i].invoice_number = Number(response.data[i].invoice_number)
// for (let j = 0; j < response.data[i].line_items.length; j++) {
// response.data[i].line_items[j].amount = Number(response.data[i].line_items[j].amount)
// if (response.data[i].line_items[j].quantity) {
// response.data[i].line_items[j].quantity = Number(response.data[i].line_items[j].quantity)
// }
// }

// for (let j = 0; j < response.data[i].tax.length; j++) {
// response.data[i].tax[j].amount = Number(response.data[i].tax[j].amount)
// }
// }

return response;
}

Expand All @@ -141,27 +100,6 @@ export class PaymentRequest {

const resp = await json_resp.json() as FetchPaymentRequestResponse;

// if (!resp.status) {
// return resp;
// }

// convert the string to actual numbers
// resp.data.amount = Number(resp.data.amount);
// resp.data.amount_paid = Number(resp.data.amount_paid);
// resp.data.discount = Number(resp.data.discount);
// resp.data.id = Number(resp.data.id);
// resp.data.integration = Number(resp.data.id)
// resp.data.pending_amount = Number(resp.data.pending_amount)
// for (let j = 0; j < resp.data.line_items.length; j++) {
// resp.data.line_items[j].amount = Number(resp.data.line_items[j].amount)
// if (resp.data.line_items[j].quantity) {
// resp.data.line_items[j].quantity = Number(resp.data.line_items[j].quantity)
// }
// }

// for (let j = 0; j < resp.data.tax.length; j++) {
// resp.data.tax[j].amount = Number(resp.data.tax[j].amount)
// }
return resp;

}
Expand All @@ -176,26 +114,6 @@ export class PaymentRequest {

const response = await resp.json() as VeryifyPaymentRequestResponse;

if (!response.status) {
return response;
}

// response.data.amount = Number(response.data.amount);
// response.data.id = Number(response.data.id);
// response.data.invoice_number = Number(response.data.invoice_number);
// response.data.pending_amount = Number(response.data.pending_amount);


// for (let j = 0; j < response.data.line_items.length; j++) {
// response.data.line_items[j].amount = Number(response.data.line_items[j].amount)
// if (response.data.line_items[j].quantity) {
// response.data.line_items[j].quantity = Number(response.data.line_items[j].quantity)
// }
// }

// for (let j = 0; j < response.data.tax.length; j++) {
// response.data.tax[j].amount = Number(response.data.tax[j].amount)
// }
return response as VeryifyPaymentRequestResponse;

}
Expand All @@ -212,7 +130,6 @@ export class PaymentRequest {
const response = resp as SendNotificationPaymentRequestResponse
return response;


}

async total(): Promise<TotalPaymentRequestResponse> {
Expand All @@ -225,23 +142,6 @@ export class PaymentRequest {

const response = await resp.json() as TotalPaymentRequestResponse;

// if (!response.status) {
// return response;
// }

// converting to numbers
// for (let i = 0; i < response.data.pending.length; i++) {
// response.data.pending[i].amount = Number(response.data.pending[i].amount)
// }

// for (let i = 0; i < response.data.successful.length; i++) {
// response.data.successful[i].amount = Number(response.data.successful[i].amount)
// }

// for (let i = 0; i < response.data.total.length; i++) {
// response.data.total[i].amount = Number(response.data.total[i].amount)
// }

return response
}

Expand Down Expand Up @@ -292,13 +192,5 @@ export class PaymentRequest {
return response;
}

private convert_to_invoice_create_response(data: CreatePaymentRequestResponse): CreatePaymentRequestResponse {
if (data.status === true) {
data.data.id = Number(data.data.id);
data.data.amount = Number(data.data.amount);
}
return data;
}


}

0 comments on commit d099a89

Please sign in to comment.