import { NgZone } from '@angular/core'; import { ApiConnectionService } from './api-connection.service'; import { LocalStorageService } from './local-storage.service'; import { Observable, ReplaySubject } from 'rxjs'; import { MatDialog } from '@angular/material/dialog'; import { User, Inapp, App, AppGroup, NewsFeedObj } from './app.models'; export * from './app.models'; /**@ignore*/ export interface UserParams { coins?: number; email?: string; token_email?: string; token?: string; freebie_used?: boolean; rated_app?: boolean; logging_in?: boolean; push_id?: string; username?: string; } /** * The UserService. * * ```typescript * // Import in any component this is to be used: * import { UserService } from 'WickeyAppStore'; * * // Inject it in the constructor * constructor(userService: UserService) { } * * // Get user: * this.userService.user().subscribe(); * ``` */ export declare class UserService { private apiConnectionService; private localStorageService; private _ngZone; dialog: MatDialog; /** * @property * @ignore */ private readonly merchantID; private _user; private _loginChange; private _onAccountCreate; private _inapps; private _favorites; private _favoritesObj; private _newsfeedObj; private _newsfeed; private _is_favorite; private _is_favoriteObj; private _freebieSettings; private _freebieSettingsObj; private _inappsObj; private _userObj; private _createNewUser; private _isLoggedIn; private _loaded; private standalone; /** Number of new WasNews items. */ badgeCountObj: number; /** An observable of new WasNews items. */ badgeCount: ReplaySubject; private lut; /**@ignore*/ constructor(apiConnectionService: ApiConnectionService, localStorageService: LocalStorageService, _ngZone: NgZone, dialog: MatDialog); /** * // test if the string is empty or null * @ignore */ isEmpty(str: string): boolean; /** * Pushes boolean to all subscribers on login status changes and also on initial load. * So this can be used to monitor login status changes to route url, or to check login status on user load. * * @example * Use in angular template with the `async` pipe * userService.loginChange | async * Subscribe in ts: userService.loginChange.subscribe * * @readonly */ get loginChange(): ReplaySubject; get onAccountCreate(): ReplaySubject; /** * Returns true if user is logged in and else false. * NOTE: This should only be used if UserService has already loaded the User, otherwise the result is un-reliable (Check out loginChange). */ get isLoggedInVal(): boolean; get isLoggedInObs(): Observable; /** * Returns promise of user login status (true if logged in). * NOTE: It also on page load it emits the login status. * * @readonly */ isLoggedIn(): Promise; /** * Pushes User Object to all subscribers on every user update. * * @example * Use in angular template with the `async` pipe * userService.user | async * Subscribe in ts: userService.user.subscribe * * @readonly */ get user(): ReplaySubject; get userObject(): User; get coins(): number; get inapps(): ReplaySubject<[Inapp]>; get inappsObject(): [Inapp]; get newsfeed(): ReplaySubject<[NewsFeedObj]>; /** @ignore */ savenewsfeed(updatednews: [NewsFeedObj]): void; get newsfeedObject(): [NewsFeedObj]; get isLoaded(): boolean; get favorites(): ReplaySubject; get favoritesObject(): AppGroup; get isFavorite(): ReplaySubject; get isFavoriteObject(): Boolean; get freebieSettings(): ReplaySubject; private pushSubscribers; private pushInappSubscribers; private saveLocal; /** @ignore */ loadUser(): void; /** @ignore */ loadInapps(): void; /** @ignore */ loadFreebieSettings(): void; /** @ignore */ loadNewsfeed(): void; /** @ignore */ loadIfFavorite(): void; private handleError; /** * @ignore */ checkStandalone(): void; /** * Fast UUID generator, RFC4122 version 4 compliant. * @author Jeff Ward (jcward.com). * @license MIT license * @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136 * @ignore **/ guid(): string; /** * @ignore */ checkIfValue(_obj: any, _key: string): boolean; /** * Update User object, saves locally and to server. * * @param [userParams] OPTIONAL object of parameters to update user. * @ignore */ updateUser(userParams: UserParams): Observable; /** * Update the user's push_id only if this id is different than the currenly saved id. * * @param push_id The OneSignal user_id (push_id) * @ignore */ updateUserPushId(push_id: string): void; /** * Updates the user's username only if this username is different than the currenly saved username and is acceptable. * Returns an error if username is not acceptable (e.g. not unique). * * @param username The globally unique username. * @ignore */ updateUsername(username: string): Observable; private handleNewsfeedReturn; /** * Return a list of newsfeed items. */ getNewsfeed(): Observable<{ newsfeed: [NewsFeedObj]; }>; /** * Add an action to another user e.g. show an alert to the other person. */ setNewsfeed(toUsername: string, action: string): Observable<{ newsfeed: [NewsFeedObj]; }>; /** * Sets news items as seen. */ seenNewsfeed(newsIds: string[], globalNewsIds?: number[]): Observable<{ newsfeed: [NewsFeedObj]; }>; /** * Return if the current app is a favorite is_favorite */ getFavoriteCheck(): Observable<{ is_favorite: boolean; }>; /** * Return a list of favorite apps {favorites:[{app},...]} */ getFavorites(): Observable<{ apps: [App]; }>; /** * Add an app to the favorites list. * Returns {favorites:[{app},...]} * * @param [storeapp_id] This is only sent in from WickeyAppStore (on actual app sites it uses the hostname). */ setFavorite(storeapp_id?: number): Observable<{ apps: [App]; }>; /** * Remove an app from the list of favorite apps. * Returns {favorites:[{app},...]} * * @param [storeapp_id] This is only sent in from WickeyAppStore (on actual app sites it uses the hostname). */ deleteFavorite(storeapp_id?: number): Observable<{ apps: [App]; }>; /** * Pipe save favorite through login alert. * @ignore */ savefavoriteLogin(storeapp_id?: number): Observable; /** * Update favorite and show alert. * @ignore */ updateFavorite(): void; /** * Save favorite if logged in, else asks to login/create account, then saves to favorite. */ saveFavorite(): void; /** * Add/Update a user's pin/pass code used in faster or more secure logins. * * @param password The password, or current password if updating. * @param new_password OPTIONAL: New password. * @ignore */ setPassword(password: string, new_password?: string): Observable; /** * Step 1 of email verification. * Sends token to email, to begin email verification process. * * @param userParams {token_email: string} * @ignore */ sendToken(userParams: UserParams): Observable; /** * @ignore */ stopToken(): void; /** * Step 2 of email verification. * Send token that was sent via email to complete email verification. * * @param userParams {token_email: string, token: string} * @ignore */ verifyToken(userParams: UserParams): Observable; /** * Add a review to this app (uses the calling hostname to determine app). * * @param _title string: The review title. * @param _text string: The review text/body. * @param _rating number: The review reating 0-5. * @ignore */ createReview(_title: string, _text: string, _rating: number): Observable; /** * Creates a purchase on the server. It processed the payment for the following services: * - ApplePay * * Coming soon: * - GooglePay * - Credit Card * @ignore * @param _purchase_id The id of the inapp. * @param _receipt The purchase receipt, if purchase handled locally (not used right now, can use empty string). * @param _amount The inapp coins purchased. * @param [_email] The email of the purchaser person. * @param [_first_name] The billing first name of the purchaser person. * @param [_last_name] The billing last name of the purchaser person. * @param [_zip_code] The billing zip code of the purchaser person. * @param [_wallet_token] The applepay wallet token, this is used to process the payment. * @param [_address] The billing address. * @param [_city] The billing city. * @param [_state] The billing state. * @param [_country] The billing country. * @returns The same as updateUser. */ createPurchase(_purchase_id: number, _receipt: string, _amount: number, _email?: string, _first_name?: string, _last_name?: string, _zip_code?: string, _wallet_token?: string, _address?: any, _city?: string, _state?: string, _country?: string, _store_id?: string): Observable; /** * Consumes coins recieved from purchases or videos. * * @param coins The number of coins charged for this item. * @param [reason] An identifier for this item (e.g. LEVEL_ONE, BONUS_CHEST, etc.). * @returns The same as updateUser. */ consumeCoins(coins: number, reason?: string): Observable; /** * Returns the inapp object, given the purchaseId. * @param _purchaseId The id of the inapp, found in developer.wickeyappstore.com * @returns Returns the inapp object, if found, else it returns null. */ getInapp(_purchaseId: number): Inapp | null; /** * This returns true if the inapp was purchased. NOTE: This only works with non-consumables. * @param _purchaseId The id of the inapp, found in developer.wickeyappstore.com * @returns A boolean, true if purchased, and false if not. */ checkIfPurchased(_purchaseId: number): Observable; /** * @ignore */ getInapps(): Observable; /** * Performs the merchant validation in ApplePay. * https://developers.bluesnap.com/v8976-Basics/docs/apple-pay#section-step-4-set-up-the-onvalidatemerchant-callback * * @ignore * @param validationURL The `event.validationURL` from the BlueSnap onvalidatemerchant callback * @returns The token object. */ getBluesnapWallet(validationURL: string): Observable; /** * @ignore */ getBluesnapShopper(): Observable; /** * Notifies the server that a video ad has started by this user and video id. * @ignore */ adVideoStart(_video_id: string): Observable; /** * Notifies the server that a video ad has ended by this user and video id. * @ignore */ adVideoEnd(_video_id: string): Observable; /** * Get the leaderboard for app. Optional pass in username to return rank of user. * * @param [username] OPTIONAL: Returns rank and score of username. */ getLeaderboard(username?: string): Observable<{ leaderboard: [any]; rank?: number; score?: number; name?: string; icon?: string; }>; /** * Stores/Updates the highscore of user. * * @param setHighscore The user's high score. * @returns returns {rank?: number} */ setHighscore(highscore: number): Observable<{ status: number; rank?: number; }>; private _handleleaderboardnotification; /** @ignore */ _addToLeaderboard(highscore: number, _alreadyTaken?: boolean): Observable; /** * Get/Update username, then add score to the leaderboard. */ addToLeaderboard(highscore: number): Observable; /** * Get/Update username, then add score to the leaderboard. * NOTE: If using WASjs. */ addToLeaderboardjs(highscore: number): Observable; /** * Get value(s) from key val store. * NOTE: Deprecated, use WasDataService * * @param _keys [string]: A list of keys to get from the key val store. */ getStore(_keys: string[]): Observable<{}>; /** * Set data in the key val store. * NOTE: Deprecated, use WasDataService * * @param _was_data {key:val, ...}: A key val dict of data to save. */ setStore(_was_data: {}): Observable; /** * Delete value(s) from key val store. * NOTE: Deprecated, use WasDataService * * @param _keys [string]: A list of keys to delete from the key val store. */ deleteStore(_keys: string[]): Observable; /** * Log user out, this deletes all local storage and cookies. * @ignore */ logOut(): void; /** @ignore */ _opensso(): Observable; /** * Open SSO if not logged in, else confirm logout. * NOTE: If using WASjs. */ openssojs(): Observable; /** * Open SSO if not logged in, else confirm logout. */ opensso(): Observable; /** * Opens WasNewsfeed */ opennewsfeed(): Observable; /** * Open WasProfile which shows Help or Account Info * @ignore */ openuserinfo(): void; /** @ignore */ _leavereview(): Observable; /** * Open review if logged in, else ask to login/create account. * NOTE: If using WASjs. */ leavereviewjs(): Observable; /** * Open review if logged in, else ask to login/create account. */ leavereview(): Observable; /** @ignore */ _showLeaderboard(): Observable; /** * Open your app's leaderboard. * NOTE: If using WASjs. */ showLeaderboardjs(): Observable; /** * Open your app's leaderboard. */ showLeaderboard(): Observable; /** * Open WickeyAppStore. * @ignore */ openstore(): void; /** * Open WasShop. * @ignore */ openshop(): void; /** * Open WasPay to the selected inapp, and returns true if successful. */ openpay(_inapp: Inapp): Observable; /** * Open WasPay to the selected inapp, and returns true if successful. * NOTE: If using WASjs. */ openpayjs(_inapp: Inapp): Observable; /** * Returns true if this is an apple device, else false. * @ignore */ isAppleDevice(): boolean; /** * Returns true if this ApplePay is available, else false. * @ignore */ isApplePayAvailable(): boolean; /** * Makes a purchase via ApplePay. * @ignore */ makeApplePurchase(_inapp: Inapp): Promise; /** * Makes a purchase via PaymentRequest (not implemented). * ref: https://developers.bluesnap.com/v8976-Basics/docs/payment-request-api * @ignore */ makePaymentRequestPurchase(_inapp: Inapp): Promise; /** * Shows either ApplePay or PaymentRequest pending on the device. * @ignore */ showWebPay(_inapp: Inapp): Promise; } //# sourceMappingURL=user.service.d.ts.map