UNPKG

toki-app

Version:

Toki - frontend packages

309 lines (302 loc) 10.3 kB
import React, { ReactElement } from 'react'; /** * Webview will be closed When `closeWebView` triggers * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function closeWebView(): void; /** * `buy` when triggers * Application will navigate to merchant payment screen * and you need to fill the parameters * * If payments succeeds * Callback function will be called * also BE will send [POST] request to provided `callbackUrl` * * [NOTE] Function throttle 1000ms * * * @param {Object} options Options for payment * @param {String} options.merchantId The merchant id that you get from our end * @param {Number} options.amount The payment amount * @param {String} options.orderId Unique generated string for order * @param {String} options.description Payment description or note * @param {String} options.callbackUrl Endpoint that will be requested when payment succeeds * @param {String} options.paymentType Wallet type * @param {String} options.requestId MS request id * @param {Function} callback Function that triggers when payment succeeds * * * @version 1.2.4 * @see {@link https://library.toki.mn} * */ declare const buy: (options: { merchantId: string; amount: number; orderId: string; description: string; callbackUrl: string; requestId?: string; paymentType?: "HOLD"; }, callback: Function) => void; /** * `selectContact` is function that allows webview to access phone contacts * * @param type Boolean value that indicates application to fetch all the contacts or open bottom sheet for single contact * @param callback when application done fetching contact, callback function will be fired with array or object param * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function selectContact(type: boolean, callback: any): void; /** * `checkNotification` is function that checks and prompts to enable notification for application * * @param callback The function that returns boolean value which indicates application notification is enabled or not * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function checkNotification(callback: Function): void; /** * `setColor` is function that change the color of header * * @param color The header color * @param isStatusDark Header status bar text color * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function setColor(color: string, isStatusDark: boolean): void; /** * `openLink` is function that allows webview to open external browser * * @param url * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function openLink(url: string): void; /** * `buyfromDynamiclink` is function that opens dynamic link * only available for payment deeplinks * * @param url * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function buyfromDynamiclink(url: string, callback: Function): void; /** * Function that enables or desables screenshot or screenrecordings * * @param status * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function setScreenProtection(status: boolean): void; /** * Function that downloads images to OS * [NOTE] shows prompt when OS already disabled access to image * * @param url The image URL to download * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function downloadImage({ url }: { url: string; }, callback: (success: boolean) => void): void; /** * Function that downloads images to OS * [NOTE] shows prompt when OS already disabled access to image * * @param url The image URL to download * * @version 1.2.2 * @see {@link https://library.toki.mn} */ declare function openScanner(callback: (url: string) => void, button?: { name?: string; onClick?: () => void; }): void; /** * Function that used for Unit & Data MP * [NOTE] sends operator data to App FE * * @param name The name of operator that user entered * * @version 1.2.2 * @see {@link https://library.toki.mn} */ declare function setOperatorName(name: string): void; /** * Function for Kids MP * * @version 1.2.6 * @see {@link https://library.toki.mn} */ declare function onNavigateToRoute(route: "topup" | "history" | "invoice" | "debit" | "profile" | "location" | "card", childId: string, successText?: string, callback?: () => void): void; /** * Function for Kids MP * * @version 1.2.13 * @see {@link https://library.toki.mn} */ declare function openUbcab(lat?: number, long?: number, childId?: string, childPhoneNo?: string, childName?: string): void; /** * `buyFromBatchPayment` нь олон төлбөрийн багцыг эхлүүлдэг функц. * * @param data Төлбөрийн багцын мэдээлэл * @param callback Худалдан авалтын дараах callback функц (заавал биш) * * @version 1.2.2 * @see {@link https://library.toki.mn} */ declare function buyFromBatchPayment(data: { parentMerchantId: string; parentDescription: string; parentOrderId: string; parentCheckUrl: string; items: { merchantId: string; amount: number; orderId: string; description: string; callbackUrl: string; checkUrl: string; }[]; }, callback?: Function): void; /** * Function for native share * * @version 1.2.21 * @see {@link https://library.toki.mn} */ declare function share(props: { url?: string; file?: string[]; text?: string; title?: string; callback?: (success: boolean) => void; }): void; /** * Function for native shareStory * * @version 1.2.21 * @see {@link https://library.toki.mn} */ declare function shareStory(props: { image?: { src: string; link?: string; }; background?: { src: string; }; url?: { name: string; value: string; }; method: "FACEBOOK" | "INSTAGRAM"; }, callback: (success: boolean) => void): void; /** * Function that downloads files to OS * [NOTE] shows prompt when OS already disabled access to files * * @param url The file URL to download * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function downloadFile(props: { files: string[]; }, callback: (success: boolean) => void): void; /** * Function for native share * * @version 1.2.21 * @see {@link https://library.toki.mn} */ declare function shareDynamicLink(props: { title: string; description: string; image: string; url: string; }, callback?: (success: boolean) => void): void; /** * Function that downloads files to OS * [NOTE] shows prompt when OS already disabled access to files * * @param callback notifies if success or not * * @version 1.2.0 * @see {@link https://library.toki.mn} */ declare function initiateKycCheck(options: { request_id: string; }, callback: (props: { status: boolean; request_id: string; }) => void): void; declare const appFunctions_buy: typeof buy; declare const appFunctions_buyFromBatchPayment: typeof buyFromBatchPayment; declare const appFunctions_buyfromDynamiclink: typeof buyfromDynamiclink; declare const appFunctions_checkNotification: typeof checkNotification; declare const appFunctions_closeWebView: typeof closeWebView; declare const appFunctions_downloadFile: typeof downloadFile; declare const appFunctions_downloadImage: typeof downloadImage; declare const appFunctions_initiateKycCheck: typeof initiateKycCheck; declare const appFunctions_onNavigateToRoute: typeof onNavigateToRoute; declare const appFunctions_openLink: typeof openLink; declare const appFunctions_openScanner: typeof openScanner; declare const appFunctions_openUbcab: typeof openUbcab; declare const appFunctions_selectContact: typeof selectContact; declare const appFunctions_setColor: typeof setColor; declare const appFunctions_setOperatorName: typeof setOperatorName; declare const appFunctions_setScreenProtection: typeof setScreenProtection; declare const appFunctions_share: typeof share; declare const appFunctions_shareDynamicLink: typeof shareDynamicLink; declare const appFunctions_shareStory: typeof shareStory; declare namespace appFunctions { export { appFunctions_buy as buy, appFunctions_buyFromBatchPayment as buyFromBatchPayment, appFunctions_buyfromDynamiclink as buyfromDynamiclink, appFunctions_checkNotification as checkNotification, appFunctions_closeWebView as closeWebView, appFunctions_downloadFile as downloadFile, appFunctions_downloadImage as downloadImage, appFunctions_initiateKycCheck as initiateKycCheck, appFunctions_onNavigateToRoute as onNavigateToRoute, appFunctions_openLink as openLink, appFunctions_openScanner as openScanner, appFunctions_openUbcab as openUbcab, appFunctions_selectContact as selectContact, appFunctions_setColor as setColor, appFunctions_setOperatorName as setOperatorName, appFunctions_setScreenProtection as setScreenProtection, appFunctions_share as share, appFunctions_shareDynamicLink as shareDynamicLink, appFunctions_shareStory as shareStory }; } type ButtonProps = { text: string; type?: "primary" | "secondary" | "clean" | "warning"; disabled?: boolean; className?: string; onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void; }; declare function Button({ text, type, disabled, className, onClick, }: ButtonProps): React.JSX.Element; type InputProps = { icon?: React.ReactElement<any, any>; value?: string; placeholder?: string; onChange?: React.ChangeEventHandler<HTMLInputElement> | undefined; onClear?: React.MouseEventHandler<HTMLDivElement>; secondaryIcon?: React.ReactElement<any, any>; onClickSecondaryIcon?: React.MouseEventHandler<HTMLDivElement>; helperText?: string; error?: boolean; }; declare function Input({ value, icon, placeholder, onChange, secondaryIcon, onClickSecondaryIcon, helperText, error, }: InputProps): React.JSX.Element; type propType = { info?: { logo: string; title: string; description: string; links?: { icon: string; text: string; url: string; }[]; }; children: ReactElement; }; declare function TokiApp({ info, children }: propType): React.JSX.Element; export { Button, type ButtonProps, Input, type InputProps, TokiApp, appFunctions as app };