-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from sourcefuse/lint
remove lint errors
- Loading branch information
Showing
17 changed files
with
7,892 additions
and
1,091 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,4 +1,4 @@ | ||
export * from './component'; | ||
export * from './keys'; | ||
export * from './types'; | ||
export * from './providers'; | ||
export * from './providers'; |
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,2 +1,2 @@ | ||
export * from './billing.provider'; | ||
export * from './sdk'; | ||
export * from './sdk'; |
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,23 +1,22 @@ | ||
import { IChargeBeeCustomer, IChargeBeeInvoice, ICustomer, IDiscount, IInvoice } from "../type"; | ||
import {AnyObject} from '@loopback/repository'; | ||
import {IChargeBeeCustomer} from '../type'; | ||
export class CustomerAdapter { | ||
constructor() {} | ||
|
||
export class CustomerAdapter{ | ||
constructor(){} | ||
|
||
convert(customer:ICustomer):IChargeBeeCustomer{ | ||
|
||
const res:IChargeBeeCustomer={ | ||
id:customer.id, | ||
firstName:customer.first_name??"", | ||
lastName:customer.last_name??"", | ||
email:customer.email??"", | ||
company:customer.company, | ||
phone:customer.phone, | ||
billingAddress:{ | ||
...customer.billing_address, | ||
firstName:customer.billing_address?.first_name, | ||
lastName:customer.billing_address?.last_name | ||
} | ||
} | ||
return res; | ||
} | ||
} | ||
convert(customer: AnyObject): IChargeBeeCustomer { | ||
const res: IChargeBeeCustomer = { | ||
id: customer.id, | ||
firstName: customer.first_name ?? '', | ||
lastName: customer.last_name ?? '', | ||
email: customer.email ?? '', | ||
company: customer.company, | ||
phone: customer.phone, | ||
billingAddress: { | ||
...customer.billing_address, | ||
firstName: customer.billing_address?.first_name, | ||
lastName: customer.billing_address?.last_name, | ||
}, | ||
}; | ||
return res; | ||
} | ||
} |
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,3 +1,3 @@ | ||
export * from './customer.adapter'; | ||
export * from './invoice.adapter'; | ||
export * from './payment-source.adapter'; | ||
export * from './payment-source.adapter'; |
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,39 +1,41 @@ | ||
import { ICharge, IChargeBeeInvoice, IDiscount, IInvoice } from "../type"; | ||
import {AnyObject} from '@loopback/repository'; | ||
import {ICharge, IChargeBeeInvoice, IDiscount} from '../type'; | ||
export class InvoiceAdapter { | ||
constructor() {} | ||
|
||
export class InvoiceAdapter{ | ||
constructor(){} | ||
|
||
convert(invoice:IInvoice):IChargeBeeInvoice{ | ||
let discounts:IDiscount[]=[]; | ||
if(invoice.discounts){ | ||
invoice.discounts.forEach(discount=>{ | ||
if(discount.entity_type==='document_level_coupon'){ | ||
discounts.push({apply_on:'invoice_amount'}); | ||
}else{ | ||
discounts.push({apply_on:'specific_item_price'}); | ||
} | ||
}) | ||
} | ||
const charges:ICharge[]=invoice.line_items?.map(item=>{ | ||
const charge:ICharge={ | ||
amount:item.amount?item.amount/100:0, | ||
description:item.description, | ||
convert(invoice: AnyObject): IChargeBeeInvoice { | ||
const discounts: IDiscount[] = []; | ||
if (invoice.discounts) { | ||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
invoice.discounts.forEach((discount: {entity_type: string}) => { | ||
if (discount.entity_type === 'document_level_coupon') { | ||
discounts.push({applyOn: 'invoice_amount'}); | ||
} else { | ||
discounts.push({applyOn: 'specific_item_price'}); | ||
} | ||
return charge | ||
})??[]; | ||
const res:IChargeBeeInvoice={ | ||
id:invoice.id, | ||
customerId:invoice.customer_id, | ||
shippingAddress:{ | ||
...invoice.shipping_address, | ||
firstName:invoice.shipping_address?.first_name, | ||
lastName:invoice.shipping_address?.last_name | ||
}, | ||
status:invoice.status, | ||
options:{discounts:discounts}, | ||
charges:charges, | ||
currencyCode:invoice.currency_code | ||
} | ||
return res; | ||
}); | ||
} | ||
} | ||
const charges: ICharge[] = | ||
invoice.line_items?.map((item: {amount: number; description: string}) => { | ||
const charge: ICharge = { | ||
amount: item.amount ? item.amount / 100 : 0, | ||
description: item.description, | ||
}; | ||
return charge; | ||
}) ?? []; | ||
const res: IChargeBeeInvoice = { | ||
id: invoice.id, | ||
customerId: invoice.customer_id, | ||
shippingAddress: { | ||
...invoice.shipping_address, | ||
firstName: invoice.shipping_address?.first_name, | ||
lastName: invoice.shipping_address?.last_name, | ||
}, | ||
status: invoice.status, | ||
options: {discounts: discounts}, | ||
charges: charges, | ||
currencyCode: invoice.currency_code, | ||
}; | ||
return res; | ||
} | ||
} |
31 changes: 16 additions & 15 deletions
31
src/providers/sdk/chargebee/adapter/payment-source.adapter.ts
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,19 +1,20 @@ | ||
import { IChargeBeePaymentSource, IPaymentSource } from "../type"; | ||
import {AnyObject} from '@loopback/repository'; | ||
import {IChargeBeePaymentSource} from '../type'; | ||
|
||
export class PaymentSourceAdapter { | ||
constructor() {} | ||
constructor() {} | ||
|
||
convert(paymentSource: IPaymentSource): IChargeBeePaymentSource { | ||
return { | ||
id: paymentSource.id, | ||
customerId: paymentSource.customer_id, | ||
card: { | ||
gatewayAccountId: paymentSource.gateway_account_id ?? '', | ||
number: paymentSource.card?.masked_number ?? '', | ||
expiryMonth: paymentSource.card?.expiry_month ?? 0, | ||
expiryYear: paymentSource.card?.expiry_year ?? 0, | ||
cvv: "***" | ||
} | ||
}; | ||
} | ||
convert(paymentSource: AnyObject): IChargeBeePaymentSource { | ||
return { | ||
id: paymentSource.id, | ||
customerId: paymentSource.customer_id, | ||
card: { | ||
gatewayAccountId: paymentSource.gateway_account_id ?? '', | ||
number: paymentSource.card?.masked_number ?? '', | ||
expiryMonth: paymentSource.card?.expiry_month ?? 0, | ||
expiryYear: paymentSource.card?.expiry_year ?? 0, | ||
cvv: '***', | ||
}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.