Skip to content

Commit

Permalink
Merge pull request #353 from mollie/pimm/alias
Browse files Browse the repository at this point in the history
Re-introduce runtime aliases.
  • Loading branch information
Pimm authored Jul 10, 2024
2 parents c9ccf84 + 2f0e32d commit d748888
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 67 deletions.
2 changes: 2 additions & 0 deletions src/binders/chargebacks/ChargebacksBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type TransformingNetworkClient from '../../communication/TransformingNetw
import type Chargeback from '../../data/chargebacks/Chargeback';
import { type ChargebackData } from '../../data/chargebacks/Chargeback';
import type Page from '../../data/page/Page';
import alias from '../../plumbing/alias';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
Expand All @@ -12,6 +13,7 @@ const pathSegment = 'chargebacks';
export default class ChargebacksBinder extends Binder<ChargebackData, Chargeback> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/customers/CustomersBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Customer from '../../data/customers/Customer';
import { type CustomerData } from '../../data/customers/Customer';
import type Page from '../../data/page/Page';
import ApiError from '../../errors/ApiError';
import alias from '../../plumbing/alias';
import checkId from '../../plumbing/checkId';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
Expand All @@ -14,6 +15,7 @@ const pathSegment = 'customers';
export default class CustomersBinder extends Binder<CustomerData, Customer> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], delete: 'cancel' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/customers/mandates/CustomerMandatesBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { type MandateData } from '../../../data/customers/mandates/data';
import type Mandate from '../../../data/customers/mandates/Mandate';
import type Page from '../../../data/page/Page';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(customerId: string) {
export default class CustomerMandatesBinder extends Binder<MandateData, Mandate> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], revoke: ['cancel', 'delete'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/customers/payments/CustomerPaymentsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import { type PaymentData } from '../../../data/payments/data';
import type Payment from '../../../data/payments/Payment';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(customerId: string) {
export default class CustomerPaymentsBinder extends Binder<PaymentData, Payment> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import { type SubscriptionData } from '../../../data/subscriptions/data';
import type Subscription from '../../../data/subscriptions/Subscription';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(customerId: string) {
export default class CustomerSubscriptionsBinder extends Binder<SubscriptionData, Subscription> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], cancel: 'delete' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/methods/MethodsBinder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type TransformingNetworkClient from '../../communication/TransformingNetworkClient';
import type Method from '../../data/methods/Method';
import { type MethodData } from '../../data/methods/data';
import alias from '../../plumbing/alias';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
Expand All @@ -11,6 +12,7 @@ const pathSegment = 'methods';
export default class MethodsBinder extends Binder<MethodData, Method> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { list: ['all', 'page'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/orders/OrdersBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
import { type CancelParameters, type CreateParameters, type GetParameters, type IterateParameters, type PageParameters, type UpdateParameters } from './parameters';
import alias from '../../plumbing/alias';

export const pathSegment = 'orders';

Expand Down Expand Up @@ -36,6 +37,7 @@ export const pathSegment = 'orders';
export default class OrdersBinder extends Binder<OrderData, Order> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], cancel: 'delete' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/orders/orderlines/OrderLinesBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type TransformingNetworkClient from '../../../communication/TransformingN
import { type OrderData } from '../../../data/orders/data';
import type Order from '../../../data/orders/Order';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -15,6 +16,7 @@ function getPathSegments(orderId: string) {
export default class OrderLinesBinder extends Binder<OrderData, Order> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { cancel: 'delete' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/orders/shipments/OrderShipmentsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type TransformingNetworkClient from '../../../communication/TransformingN
import type Shipment from '../../../data/orders/shipments/Shipment';
import { type ShipmentData } from '../../../data/orders/shipments/Shipment';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -15,6 +16,7 @@ export function getPathSegments(orderId: string) {
export default class OrderShipmentsBinder extends Binder<ShipmentData, Shipment> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { list: ['all', 'page'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/payments/PaymentsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../data/page/Page';
import { type PaymentData } from '../../data/payments/data';
import type Payment from '../../data/payments/Payment';
import ApiError from '../../errors/ApiError';
import alias from '../../plumbing/alias';
import checkId from '../../plumbing/checkId';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
Expand All @@ -14,6 +15,7 @@ const pathSegment = 'payments';
export default class PaymentsBinder extends Binder<PaymentData, Payment> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], cancel: 'delete' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/payments/captures/PaymentCapturesBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import type Capture from '../../../data/payments/captures/Capture';
import { type CaptureData } from '../../../data/payments/captures/data';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(paymentId: string) {
export default class PaymentCapturesBinder extends Binder<CaptureData, Capture> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/payments/chargebacks/PaymentChargebacksBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Chargeback from '../../../data/chargebacks/Chargeback';
import { type ChargebackData } from '../../../data/chargebacks/Chargeback';
import type Page from '../../../data/page/Page';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(paymentId: string) {
export default class PaymentChargebacksBinder extends Binder<ChargebackData, Chargeback> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/payments/refunds/PaymentRefundsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import { type RefundData } from '../../../data/refunds/data';
import type Refund from '../../../data/refunds/Refund';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(paymentId: string) {
export default class PaymentRefundsBinder extends Binder<RefundData, Refund> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'], cancel: 'delete' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/permissions/PermissionsBinder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type TransformingNetworkClient from '../../communication/TransformingNetworkClient';
import type Permission from '../../data/permissions/Permission';
import { type PermissionData } from '../../data/permissions/Permission';
import alias from '../../plumbing/alias';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
Expand All @@ -10,6 +11,7 @@ const pathSegment = 'permissions';
export default class PermissionsBinder extends Binder<PermissionData, Permission> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { list: 'page' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/profiles/ProfilesBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../data/page/Page';
import { type ProfileData } from '../../data/profiles/data';
import type Profile from '../../data/profiles/Profile';
import ApiError from '../../errors/ApiError';
import alias from '../../plumbing/alias';
import checkId from '../../plumbing/checkId';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
Expand All @@ -14,6 +15,7 @@ const pathSegment = 'profiles';
export default class ProfilesBinder extends Binder<ProfileData, Profile> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: 'list' });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/refunds/RefundsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type TransformingNetworkClient from '../../communication/TransformingNetw
import type Page from '../../data/page/Page';
import { type RefundData } from '../../data/refunds/data';
import type Refund from '../../data/refunds/Refund';
import alias from '../../plumbing/alias';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
Expand All @@ -12,6 +13,7 @@ const pathSegment = 'refunds';
export default class RefundsBinder extends Binder<RefundData, Refund> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/refunds/orders/OrderRefundsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import { type RefundData } from '../../../data/refunds/data';
import type Refund from '../../../data/refunds/Refund';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ export function getPathSegments(orderId: string) {
export default class OrderRefundsBinder extends Binder<RefundData, Refund> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: ['all', 'list'] });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/binders/subscriptions/SubscriptionsBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type TransformingNetworkClient from '../../communication/TransformingNetw
import type Page from '../../data/page/Page';
import { type SubscriptionData } from '../../data/subscriptions/data';
import type Subscription from '../../data/subscriptions/Subscription';
import alias from '../../plumbing/alias';
import renege from '../../plumbing/renege';
import type Callback from '../../types/Callback';
import Binder from '../Binder';
Expand All @@ -12,6 +13,7 @@ const pathSegment = 'subscriptions';
export default class SubscriptionsBinder extends Binder<SubscriptionData, Subscription> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: 'list' });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Page from '../../../data/page/Page';
import { type PaymentData } from '../../../data/payments/data';
import type Payment from '../../../data/payments/Payment';
import ApiError from '../../../errors/ApiError';
import alias from '../../../plumbing/alias';
import checkId from '../../../plumbing/checkId';
import renege from '../../../plumbing/renege';
import type Callback from '../../../types/Callback';
Expand All @@ -16,6 +17,7 @@ function getPathSegments(customerId: string, subscriptionId: string): string {
export default class SubscriptionPaymentsBinder extends Binder<PaymentData, Payment> {
constructor(protected readonly networkClient: TransformingNetworkClient) {
super();
alias(this, { page: 'list' });
}

/**
Expand Down
Loading

0 comments on commit d748888

Please sign in to comment.