-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39acb23
commit c2e00a6
Showing
7 changed files
with
139 additions
and
144 deletions.
There are no files selected for viewing
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,42 +1,41 @@ | ||
import type { RequestData, ModalAdapterArgs } from "./ModalAdapter.types.ts"; | ||
|
||
export abstract class ModalAdapter { | ||
requestData?: RequestData; | ||
successCallback?: Function; | ||
exitCallback?: Function; | ||
requestData?: RequestData; | ||
successCallback?: Function; | ||
exitCallback?: Function; | ||
|
||
abstract open(): void; | ||
abstract onEvent(eventName: string, eventPayload: any): void; | ||
load() {}; | ||
abstract open(): void; | ||
abstract onEvent(eventName: string, eventPayload: any): void; | ||
load() {}; | ||
|
||
constructor() { | ||
this.load(); | ||
} | ||
|
||
init(args: ModalAdapterArgs) { | ||
constructor() { | ||
this.load(); | ||
} | ||
|
||
if (args.onSuccess) { | ||
this.successCallback = args.onSuccess; | ||
} | ||
init(args: ModalAdapterArgs) { | ||
if (args.onSuccess) { | ||
this.successCallback = args.onSuccess; | ||
} | ||
|
||
if (args.onExit) { | ||
this.exitCallback = args.onExit; | ||
if (args.onExit) { | ||
this.exitCallback = args.onExit; | ||
|
||
} | ||
if (args.requestData) { | ||
this.requestData = args.requestData; | ||
} | ||
} | ||
} | ||
if (args.requestData) { | ||
this.requestData = args.requestData; | ||
} | ||
} | ||
|
||
async onExit(eventPayload: any) { | ||
if (this.exitCallback) { | ||
this.exitCallback(); | ||
} | ||
async onExit(eventPayload: any) { | ||
if (this.exitCallback) { | ||
this.exitCallback(); | ||
} | ||
} | ||
|
||
async onSuccess(eventPayload: any) { | ||
if (this.successCallback) { | ||
this.successCallback(); | ||
} | ||
async onSuccess(eventPayload: any) { | ||
if (this.successCallback) { | ||
this.successCallback(); | ||
} | ||
} | ||
} |
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,13 +1,13 @@ | ||
export interface ModalAdapterArgs { | ||
requestData: RequestData; | ||
onSuccess?: Function; | ||
onExit?: Function; | ||
requestData: RequestData; | ||
onSuccess?: Function; | ||
onExit?: Function; | ||
} | ||
|
||
export interface RequestData { | ||
responseType: string; | ||
id: string; | ||
isDefaultOption: boolean; | ||
providerName: string; | ||
name: string; | ||
} | ||
responseType: string; | ||
id: string; | ||
isDefaultOption: boolean; | ||
providerName: string; | ||
name: string; | ||
} |
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,25 +1,24 @@ | ||
type LinkResult = { | ||
accountId: string; | ||
platformId: string; | ||
job: string; | ||
params: { | ||
amount?: { value: number, unit: '%' | '$' } | ||
} | ||
accountId: string; | ||
platformId: string; | ||
job: string; | ||
params: { | ||
amount?: { value: number, unit: '%' | '$' } | ||
} | ||
} | ||
|
||
type PinwheelError = { type: string; code: string; message: string, pendingRetry: boolean } | ||
|
||
|
||
type InitializationParams = { | ||
linkToken: string; | ||
onLogin?: (result: { accountId: string, platformId: string }) => void; | ||
onSuccess?: (result: LinkResult) => void; | ||
onError?: (error: PinwheelError) => void; | ||
onExit?: (error?: PinwheelError) => void; | ||
onEvent?: (name: string, payload: EventPayload) => void; | ||
}; | ||
linkToken: string; | ||
onLogin?: (result: { accountId: string, platformId: string }) => void; | ||
onSuccess?: (result: LinkResult) => void; | ||
onError?: (error: PinwheelError) => void; | ||
onExit?: (error?: PinwheelError) => void; | ||
onEvent?: (name: string, payload: EventPayload) => void; | ||
}; | ||
|
||
type Pinwheel = { | ||
open: (params : InitializationParams) => void; | ||
close: () => void; | ||
open: (params : InitializationParams) => void; | ||
close: () => void; | ||
} |
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,5 +1,5 @@ | ||
declare global { | ||
var Pinwheel: Pinwheel; | ||
var Pinwheel: Pinwheel; | ||
} | ||
|
||
export {}; | ||
export {}; |
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,6 +1,5 @@ | ||
declare module "load-script" { | ||
type loadScriptCallback = (error : object, script: object) => void; | ||
function loadScript(url: string, callback: loadScriptCallback): void; | ||
export = loadScript; | ||
type loadScriptCallback = (error : object, script: object) => void; | ||
function loadScript(url: string, callback: loadScriptCallback): void; | ||
export = loadScript; | ||
} | ||
|
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,9 +1,8 @@ | ||
import PinwheelModalAdapter from "../adapters/PinwheelModalAdapter.js"; | ||
|
||
|
||
export const createModalAdapter = (providerName: string) => { | ||
switch (providerName) { | ||
default: | ||
return new PinwheelModalAdapter(); | ||
} | ||
switch (providerName) { | ||
default: | ||
return new PinwheelModalAdapter(); | ||
} | ||
}; |