Skip to content

Commit

Permalink
feat(checkout): CHECKOUT-4223 Add CheckoutSupport interface, to be …
Browse files Browse the repository at this point in the history
…implemented by classes used to check if feature is supported by certain type of checkout
  • Loading branch information
davidchin committed Aug 8, 2019
1 parent cc06eff commit 8115957
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/checkout/CheckoutSupport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default interface CheckoutSupport {
/**
* Check if a feature is supported.
*
* If a feature is not supported, the call will throw an error.
* Otherwise, it will return true. It will always return true if the
* application is not running as Embedded Checkout.
*/
isSupported(...ids: string[]): boolean;
}
7 changes: 7 additions & 0 deletions src/app/checkout/NoopCheckoutSupport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import CheckoutSupport from './CheckoutSupport';

export default class NoopCheckoutSupport implements CheckoutSupport {
isSupported(): boolean {
return true;
}
}
3 changes: 3 additions & 0 deletions src/app/checkout/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { CheckoutContextProps } from './CheckoutContext';
import { CheckoutProviderProps, CheckoutProviderState } from './CheckoutProvider';
import CheckoutSupport from './CheckoutSupport';

export type CheckoutContextProps = CheckoutContextProps;
export type CheckoutProviderProps = CheckoutProviderProps;
export type CheckoutProviderState = CheckoutProviderState;
export type CheckoutSupport = CheckoutSupport;

export { default as CheckoutContext } from './CheckoutContext';
export { default as CheckoutProvider } from './CheckoutProvider';
export { default as withCheckout } from './withCheckout';
export { default as NoopCheckoutSupport } from './NoopCheckoutSupport';

0 comments on commit 8115957

Please sign in to comment.