Skip to content

Commit

Permalink
fix(core): optimize parse function
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Oct 11, 2023
1 parent 1ccc3a2 commit e3d76ee
Show file tree
Hide file tree
Showing 122 changed files with 1 addition and 606 deletions.
5 changes: 0 additions & 5 deletions gen/templates/resource.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class ##__RESOURCE_CLASS__## extends ##__RESOURCE_MODEL_TYPE__##<##__MODEL_RESOU
return ##__RESOURCE_CLASS__##.TYPE
}


parse(payload: any): ##__MODEL_RESOURCE_INTERFACE__## | ##__MODEL_RESOURCE_INTERFACE__##[] {
return super.parse(payload)
}

}


Expand Down
2 changes: 1 addition & 1 deletion src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ abstract class ApiResourceBase<R extends Resource> {

abstract type(): ResourceTypeLock

protected parse(resource: any): R | R[] {
parse(resource: any): R | R[] {
try {
const res = JSON.parse(resource)
if (res.data?.type !== this.type()) throw new SdkError({ message: `Invalid resource type [${res.data?.type}]`, type: ErrorType.PARSE })
Expand Down
5 changes: 0 additions & 5 deletions src/resources/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ class Addresses extends ApiResource<Address> {
return Addresses.TYPE
}


parse(payload: any): Address | Address[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/adjustments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ class Adjustments extends ApiResource<Adjustment> {
return Adjustments.TYPE
}


parse(payload: any): Adjustment | Adjustment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/adyen_gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ class AdyenGateways extends ApiResource<AdyenGateway> {
return AdyenGateways.TYPE
}


parse(payload: any): AdyenGateway | AdyenGateway[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/adyen_payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ class AdyenPayments extends ApiResource<AdyenPayment> {
return AdyenPayments.TYPE
}


parse(payload: any): AdyenPayment | AdyenPayment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ class Applications extends ApiSingleton<Application> {
return Applications.TYPE
}


parse(payload: any): Application | Application[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ class Attachments extends ApiResource<Attachment> {
return Attachments.TYPE
}


parse(payload: any): Attachment | Attachment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/authorizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ class Authorizations extends ApiResource<Authorization> {
return Authorizations.TYPE
}


parse(payload: any): Authorization | Authorization[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/avalara_accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ class AvalaraAccounts extends ApiResource<AvalaraAccount> {
return AvalaraAccounts.TYPE
}


parse(payload: any): AvalaraAccount | AvalaraAccount[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/axerve_gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ class AxerveGateways extends ApiResource<AxerveGateway> {
return AxerveGateways.TYPE
}


parse(payload: any): AxerveGateway | AxerveGateway[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/axerve_payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ class AxervePayments extends ApiResource<AxervePayment> {
return AxervePayments.TYPE
}


parse(payload: any): AxervePayment | AxervePayment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/billing_info_validation_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class BillingInfoValidationRules extends ApiResource<BillingInfoValidationRule>
return BillingInfoValidationRules.TYPE
}


parse(payload: any): BillingInfoValidationRule | BillingInfoValidationRule[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/bing_geocoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ class BingGeocoders extends ApiResource<BingGeocoder> {
return BingGeocoders.TYPE
}


parse(payload: any): BingGeocoder | BingGeocoder[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/braintree_gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ class BraintreeGateways extends ApiResource<BraintreeGateway> {
return BraintreeGateways.TYPE
}


parse(payload: any): BraintreeGateway | BraintreeGateway[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/braintree_payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class BraintreePayments extends ApiResource<BraintreePayment> {
return BraintreePayments.TYPE
}


parse(payload: any): BraintreePayment | BraintreePayment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ class Bundles extends ApiResource<Bundle> {
return Bundles.TYPE
}


parse(payload: any): Bundle | Bundle[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/buy_x_pay_y_promotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ class BuyXPayYPromotions extends ApiResource<BuyXPayYPromotion> {
return BuyXPayYPromotions.TYPE
}


parse(payload: any): BuyXPayYPromotion | BuyXPayYPromotion[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/captures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ class Captures extends ApiResource<Capture> {
return Captures.TYPE
}


parse(payload: any): Capture | Capture[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/carrier_accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ class CarrierAccounts extends ApiResource<CarrierAccount> {
return CarrierAccounts.TYPE
}


parse(payload: any): CarrierAccount | CarrierAccount[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/checkout_com_gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ class CheckoutComGateways extends ApiResource<CheckoutComGateway> {
return CheckoutComGateways.TYPE
}


parse(payload: any): CheckoutComGateway | CheckoutComGateway[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/checkout_com_payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ class CheckoutComPayments extends ApiResource<CheckoutComPayment> {
return CheckoutComPayments.TYPE
}


parse(payload: any): CheckoutComPayment | CheckoutComPayment[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/cleanups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class Cleanups extends ApiResource<Cleanup> {
return Cleanups.TYPE
}


parse(payload: any): Cleanup | Cleanup[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/coupon_codes_promotion_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ class CouponCodesPromotionRules extends ApiResource<CouponCodesPromotionRule> {
return CouponCodesPromotionRules.TYPE
}


parse(payload: any): CouponCodesPromotionRule | CouponCodesPromotionRule[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/coupon_recipients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ class CouponRecipients extends ApiResource<CouponRecipient> {
return CouponRecipients.TYPE
}


parse(payload: any): CouponRecipient | CouponRecipient[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/coupons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ class Coupons extends ApiResource<Coupon> {
return Coupons.TYPE
}


parse(payload: any): Coupon | Coupon[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/custom_promotion_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ class CustomPromotionRules extends ApiResource<CustomPromotionRule> {
return CustomPromotionRules.TYPE
}


parse(payload: any): CustomPromotionRule | CustomPromotionRule[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customer_addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ class CustomerAddresses extends ApiResource<CustomerAddress> {
return CustomerAddresses.TYPE
}


parse(payload: any): CustomerAddress | CustomerAddress[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customer_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ class CustomerGroups extends ApiResource<CustomerGroup> {
return CustomerGroups.TYPE
}


parse(payload: any): CustomerGroup | CustomerGroup[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customer_password_resets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class CustomerPasswordResets extends ApiResource<CustomerPasswordReset> {
return CustomerPasswordResets.TYPE
}


parse(payload: any): CustomerPasswordReset | CustomerPasswordReset[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customer_payment_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class CustomerPaymentSources extends ApiResource<CustomerPaymentSource> {
return CustomerPaymentSources.TYPE
}


parse(payload: any): CustomerPaymentSource | CustomerPaymentSource[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customer_subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ class CustomerSubscriptions extends ApiResource<CustomerSubscription> {
return CustomerSubscriptions.TYPE
}


parse(payload: any): CustomerSubscription | CustomerSubscription[] {
return super.parse(payload)
}

}


Expand Down
5 changes: 0 additions & 5 deletions src/resources/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ class Customers extends ApiResource<Customer> {
return Customers.TYPE
}


parse(payload: any): Customer | Customer[] {
return super.parse(payload)
}

}


Expand Down
Loading

0 comments on commit e3d76ee

Please sign in to comment.