### Initiate Purchase Source: https://romanlee17.com/ru/unity/mirrasdk/payments Starts the process of purchasing a specific product. ```APIDOC ## POST /payments/purchase ### Description Initiates the purchase of a specified product. This method should be called when a user decides to buy an item. ### Method POST ### Endpoint `/payments/purchase` ### Parameters #### Request Body - **productTag** (string) - Required - The unique identifier for the product to be purchased. - **onSuccess** (callback) - Required - A callback function to be executed upon successful purchase. - **onError** (callback) - Required - A callback function to be executed if the purchase fails. ### Request Example ```json { "productTag": "exampleProduct", "onSuccess": "() => { Debug.Log(\"Товар успешно куплен\"); // Выдать товар игроку }", "onError": "() => Debug.Log(\"Товар не был куплен\")" } ``` ### Response #### Success Response (200) Indicates that the purchase process has been initiated. The actual success or failure is handled by the provided callbacks. #### Response Example ```json { "message": "Purchase initiated successfully" } ``` ``` -------------------------------- ### Get and Set Boolean Values with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Demonstrates how to retrieve and store boolean values using MirraSDK's data persistence features. The `GetBool` method retrieves a boolean value by its key, while `SetBool` stores a boolean value associated with a given key. These operations are fundamental for managing game states or user preferences. ```csharp bool value = MirraSDK.Data.GetBool("key"); ``` ```csharp MirraSDK.Data.SetBool("key", true); ``` -------------------------------- ### Get Product Information Source: https://romanlee17.com/ru/unity/mirrasdk/payments Retrieves detailed information about a specific product. ```APIDOC ## GET /payments/products/{productTag} ### Description Retrieves detailed information about a specific product using its tag. ### Method GET ### Endpoint `/payments/products/{productTag}` ### Parameters #### Path Parameters - **productTag** (string) - Required - The unique identifier for the product. ### Request Example None ### Response #### Success Response (200) - **Tag** (string) - The unique identifier of the product. - **PriceInteger** (integer) - The price of the product as an integer. - **PriceFloat** (float) - The price of the product as a float. - **Currency** (string) - The currency of the product price. #### Response Example ```json { "Tag": "exampleProduct", "PriceInteger": 100, "PriceFloat": 100.00, "Currency": "USD" } ``` ``` -------------------------------- ### Get and Set Integer Values with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Illustrates the process of obtaining and saving integer data using the MirraSDK. The `GetInt` method fetches an integer value based on its key, and `SetInt` persists an integer value identified by a key. This is useful for tracking scores, levels, or other numerical game data. ```csharp int value = MirraSDK.Data.GetInt("key"); ``` ```csharp MirraSDK.Data.SetInt("key", 512); ``` -------------------------------- ### Get and Set String Values with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Details the methods for retrieving and saving string data using MirraSDK. `GetString` fetches a string value using its key, while `SetString` stores a string value under a specified key. This functionality is essential for handling text-based data like player names or messages. ```csharp MirraSDK.Data.GetString("key"); ``` ```csharp MirraSDK.Data.SetString("key", "value"); ``` -------------------------------- ### Get and Set Serializable Objects with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Covers the process of retrieving and storing serializable objects, such as `Vector3`, using MirraSDK. The `GetObject` method deserializes an object of type `T` from storage, and `SetObject` serializes and saves an object of type `T`. This is useful for complex data structures. ```csharp Vector3 value = MirraSDK.Data.GetObject("key"); ``` ```csharp MirraSDK.Data.SetObject("key", Vector3.one); ``` -------------------------------- ### Wait for MirraSDK Initialization using Callback (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/initialization This example demonstrates how to use a callback function to be notified when the MirraSDK is initialized. The `MirraSDK.WaitForProviders` method accepts a lambda expression that will be executed once the SDK is ready. This is an alternative to coroutines for handling initialization completion. ```csharp MirraSDK.WaitForProviders(() => { // MirraSDK инициализирован. }); ``` -------------------------------- ### Initiate Product Purchase Source: https://romanlee17.com/ru/unity/mirrasdk/payments Starts the process of purchasing a specific product. It requires the product's tag and provides callbacks for success and error scenarios. Ensure the product tag is correctly defined in your store. ```csharp MirraSDK.Payments.Purchase( productTag: "exampleProduct", onSuccess: () => { Debug.Log("Товар успешно куплен"); // Выдать товар игроку }, onError: () => Debug.Log("Товар не был куплен") ); ``` -------------------------------- ### Get and Set Float Values with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Explains how to retrieve and store floating-point numbers with MirraSDK. The `GetFloat` method retrieves a float value by its key, and `SetFloat` saves a float value associated with a specific key. This is applicable for managing values that require decimal precision, such as health or currency. ```csharp float value = MirraSDK.Data.GetFloat("key"); ``` ```csharp MirraSDK.Data.SetFloat("key", 3.14f); ``` -------------------------------- ### Get Product Information Source: https://romanlee17.com/ru/unity/mirrasdk/payments Retrieves detailed information about a specific product using its tag. This includes the product's tag, price in integer and float formats, and currency. The `GetFullPriceInteger` and `GetFullPriceFloat` methods format the price for display. ```csharp ProductData productData = MirraSDK.Payments.GetProductData("exampleProduct"); Debug.Log($"Тег продукта: '{productData.Tag}'"); Debug.Log($"Цена продукта (int): '{productData.PriceInteger}'"); Debug.Log($"Цена продукта (float): '{productData.PriceFloat}'"); Debug.Log($"Валюта продукта: '{productData.Currency}'"); // Получить цену товара в формате '100 валюта' string fullPriceInteger = productData.GetFullPriceInteger(); // Получить цену товара в формате '100.00 валюта' string fullPriceFloat = productData.GetFullPriceFloat(); ``` -------------------------------- ### MirraSDK Flags API - Get Methods Source: https://romanlee17.com/ru/unity/mirrasdk/flags This section details the methods for retrieving flag values of different data types. All GET methods support an optional `defaultValue` parameter. ```APIDOC ## MirraSDK Flags API - Get Methods ### Description Provides methods to retrieve flag values of boolean, integer, float, and string types. An optional `defaultValue` can be provided to all `Get` methods, which will be returned if the specified key is not found. ### Method GET (Conceptual - these are SDK method calls, not HTTP endpoints) ### Endpoints N/A (SDK methods) ### Parameters #### Query Parameters - **key** (string) - Required - The unique identifier for the flag. - **defaultValue** (type of flag) - Optional - The value to return if the key is not found. ### Request Example ```csharp // Example for GetInt with defaultValue int value = MirraSDK.Flags.GetInt("my_feature_flag", 100); // Example for GetBool bool boolValue = MirraSDK.Flags.GetBool("enable_new_ui"); // Example for GetFloat float floatValue = MirraSDK.Flags.GetFloat("api_timeout"); // Example for GetString string stringValue = MirraSDK.Flags.GetString("welcome_message"); ``` ### Response #### Success Response - **value** (type of flag) - The retrieved flag value or the `defaultValue` if the key is not found. #### Response Example ```json { "value": "retrieved_flag_value" } ``` ``` -------------------------------- ### Wait for MirraSDK Initialization using Coroutine (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/initialization This coroutine example shows how to safely wait for the MirraSDK to become initialized before proceeding. It uses `yield return WaitUntil` to pause execution until `MirraSDK.IsInitialized` returns true. This is a common pattern in Unity for managing asynchronous operations. ```csharp public IEnumerator WaitForMirraSDK() { yield return WaitUntil(() => MirraSDK.IsInitialized); // MirraSDK инициализирован. } ``` -------------------------------- ### Signal Game Readiness (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Signals that the game is ready for user interaction after all loading screens and initial setup are complete. This event should be called when the game is fully interactive. ```csharp MirraSDK.Analytics.GameIsReady(); ``` -------------------------------- ### Get Integer Value from MirraSDK Flags Source: https://romanlee17.com/ru/unity/mirrasdk/flags Retrieves an integer value from MirraSDK Flags using a specified key. An optional `defaultValue` can be provided to be returned if the key is not found. Example: `MirraSDK.Flags.GetInt("key", 100)`. ```csharp int value = MirraSDK.Flags.GetInt("key"); ``` -------------------------------- ### Check for Key Existence with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Shows how to verify if a specific key exists in the MirraSDK's data storage. The `MirraSDK.Data.HasKey("key")` method returns a boolean indicating whether data associated with the provided key is present, allowing for conditional logic before attempting to retrieve or modify data. ```csharp bool valueExists = MirraSDK.Data.HasKey("key"); ``` -------------------------------- ### Get Deployment Environment using MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/platform Determines the deployment environment (e.g., production, staging) of the game. Useful for differentiating behavior across various deployment stages. Relies on the MirraSDK. ```csharp DeploymentType deployment = MirraSDK.Platform.Deployment; ``` -------------------------------- ### Delete All Saved Data with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Details the method for clearing all persistent data managed by MirraSDK. `MirraSDK.Data.DeleteAll()` removes all stored keys and their corresponding values, effectively resetting the application's saved state. This is typically used for features like account logout or starting a new game from scratch. ```csharp MirraSDK.Data.DeleteAll(); ``` -------------------------------- ### Explicitly Save Data with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Demonstrates how to trigger an explicit save of all pending data changes using MirraSDK. The `MirraSDK.Data.Save()` method ensures that all modified data is written to persistent storage immediately, which is crucial for critical save points or after significant game events. ```csharp MirraSDK.Data.Save(); ``` -------------------------------- ### Device Information Source: https://romanlee17.com/ru/unity/mirrasdk/device Provides methods to check if the current device is a mobile device and to get the type of the operating system. ```APIDOC ## Device Information ### Description Provides methods to check if the current device is a mobile device and to get the type of the operating system. ### Method N/A (These are property accesses and method calls within the SDK) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Check if the device is mobile bool isMobile = MirraSDK.Device.IsMobile; // Get the operating system type SystemType systemType = MirraSDK.Device.SystemType; ``` ### Response #### Success Response (N/A - these are SDK properties/methods) - **IsMobile** (bool) - Returns true if the device is mobile, false otherwise. - **SystemType** (SystemType enum) - Returns the type of the operating system (e.g., iOS, Android, Windows, macOS, Linux). #### Response Example ```json { "isMobile": true, "systemType": "Android" } ``` ``` -------------------------------- ### Get Player First Name (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Retrieves the first name of the player. This is a specific field for player identification. ```csharp string firstName = MirraSDK.Player.FirstName; ``` -------------------------------- ### Get Audio Volume with MirraSDK (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/audio Retrieves the current audio volume level managed by MirraSDK. This is a direct replacement for Unity's AudioListener.volume getter. ```csharp float currentVolume = MirraSDK.Audio.Volume; ``` -------------------------------- ### Track Gameplay State (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Tracks the active state of the gameplay. Includes methods to signal the start, restart, or stop of the active gameplay session, optionally with a level identifier. ```csharp MirraSDK.Analytics.GameplayStart(int level = 0); MirraSDK.Analytics.GameplayRestart(int level = 0); MirraSDK.Analytics.GameplayStop(int level = 0); ``` -------------------------------- ### Get Player Username (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Retrieves the player's username or tag. This is used for unique identification within the system. ```csharp string username = MirraSDK.Player.Username; ``` -------------------------------- ### Get Operating System Type (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/device Retrieves the type of the operating system the application is running on. The result is an enum value of type SystemType. ```csharp SystemType systemType = MirraSDK.Device.SystemType; ``` -------------------------------- ### Get Player Unique ID (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Retrieves the unique identifier for the player. This ID is guaranteed to be unique across all users. ```csharp string uniqueId = MirraSDK.Player.UniqueId; ``` -------------------------------- ### Current Holiday Retrieval Source: https://romanlee17.com/ru/unity/mirrasdk/time Get the current holiday type using MirraSDK.Time.CurrentHoliday. ```APIDOC ## Current Holiday Retrieval ### Description Retrieves the current holiday type. ### Method GET ### Endpoint MirraSDK.Time.CurrentHoliday ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```csharp // Get the current holiday type HolidayType currentHoliday = MirraSDK.Time.CurrentHoliday; ``` ### Response #### Success Response (200) - **HolidayType** - An enum representing the current holiday. #### Response Example ```json { "currentHoliday": "NewYear" } ``` ``` -------------------------------- ### Get Player Last Name (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Retrieves the last name of the player. This is a specific field for player identification. ```csharp string lastName = MirraSDK.Player.LastName; ``` -------------------------------- ### Get Current Date with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/time Retrieve the current date as a `DateTime` object using the `MirraSDK.Time.CurrentDate` property. This allows for time-sensitive game logic or display. ```csharp DateTime currentDate = MirraSDK.Time.CurrentDate; ``` -------------------------------- ### Get Player Display Name (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Retrieves the guaranteed full display name of the player. This field is available across all platforms. ```csharp string displayName = MirraSDK.Player.DisplayName; ``` -------------------------------- ### Delete Specific Key and Value with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/data Explains how to remove a specific key and its associated value from MirraSDK's data storage. The `MirraSDK.Data.DeleteKey("key")` method permanently removes the entry, which can be useful for clearing outdated information or resetting specific game settings. ```csharp MirraSDK.Data.DeleteKey("key"); ``` -------------------------------- ### Get Application ID using MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/platform Fetches the unique identifier for the game on its current platform. This ID is crucial for platform-specific integrations and analytics. Requires MirraSDK. ```csharp string appId = MirraSDK.Platform.AppId; ``` -------------------------------- ### Get String Value from MirraSDK Flags Source: https://romanlee17.com/ru/unity/mirrasdk/flags Retrieves a string value from MirraSDK Flags using a specified key. An optional `defaultValue` can be provided to be returned if the key is not found. ```csharp string value = MirraSDK.Flags.GetString("key"); ``` -------------------------------- ### Get Audio Pause State with MirraSDK (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/audio Checks the current pause state of the audio managed by MirraSDK. This replaces Unity's AudioListener.pause getter. ```csharp bool isAudioPaused = MirraSDK.Audio.Pause; ``` -------------------------------- ### Get Leaderboard with Player Array in MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/achievements Retrieves a leaderboard, including an array of player scores. The leaderboard can contain between 0 and 50 players. The function takes a leaderboard ID and a callback to process the leaderboard data. ```csharp MirraSDK.Achievements.GetLeaderboard("leaderboard_id", (leaderboard) => { Debug.Log($"получено '{leaderboard.players.Length}' игроков в лидерборде 'leaderboard_id'"); // итерация по массиву игроков foreach(PlayerScore player in leaderboard.players) { // имя игрока string displayName = player.displayName; // позиция игрока в лидерборде int position = player.position; // рекорд игрока в лидерборде int score = player.score; // URL аватара игрока string profilePictureUrl = player.profilePictureUrl; } }); ``` -------------------------------- ### Get Float Value from MirraSDK Flags Source: https://romanlee17.com/ru/unity/mirrasdk/flags Retrieves a float value from MirraSDK Flags using a specified key. An optional `defaultValue` can be provided to be returned if the key is not found. ```csharp float value = MirraSDK.Flags.GetFloat("key"); ``` -------------------------------- ### Get Boolean Value from MirraSDK Flags Source: https://romanlee17.com/ru/unity/mirrasdk/flags Retrieves a boolean value from MirraSDK Flags using a specified key. An optional `defaultValue` can be provided to be returned if the key is not found. ```csharp bool value = MirraSDK.Flags.GetBool("key"); ``` -------------------------------- ### Get Current Platform Type using MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/platform Retrieves the current platform type where the game is running. This is a core function for platform-specific logic. No external dependencies are required beyond the MirraSDK. ```csharp PlatformType platform = MirraSDK.Platform.Current; ``` -------------------------------- ### Get Current Holiday with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/time Access the current holiday information using the `MirraSDK.Time.CurrentHoliday` property. This returns a `HolidayType` enum, enabling specific holiday-related game events or content. ```csharp HolidayType holiday = MirraSDK.Time.CurrentHoliday; ``` -------------------------------- ### Control Time Scale with MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/time Replace all calls to `Time.timeScale` with `MirraSDK.Time.Scale`. This ensures that MirraSDK can manage game pauses effectively. You can get the current time scale or set a new value. ```csharp // Get the current time scale float timeScale = MirraSDK.Time.Scale; // Change the time scale value MirraSDK.Time.Scale = 1.0f; ``` -------------------------------- ### Get Player Score from Leaderboard in MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/achievements Retrieves the player's score from a specified leaderboard. This operation requires the player to be authorized. It takes a leaderboard ID and a callback function that receives the score. ```csharp MirraSDK.Achievements.GetScore("leaderboard_id", (score) => { Debug.Log($"рекорд игрока: '{score}'"); }); ``` -------------------------------- ### Get Current Platform Language (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/language Retrieves the current language of the platform using the MirraSDK.Language.Current property. This is essential for binding game localization to pass moderation on most web platforms. The output is a LanguageType enum value. ```csharp LanguageType languageType = MirraSDK.Language.Current; ``` -------------------------------- ### Rewarded Ads: Get Last Success Time Source: https://romanlee17.com/ru/unity/mirrasdk/ads Retrieves the exact time when a rewarded ad was successfully closed, optionally filtered by a reward tag. Returns null if the specified rewarded ad has not been closed during the current session. It logs the time and calculates the time elapsed since the last closure. ```csharp DateTime? lastRewardedSuccess = MirraSDK.Ads.GetLastRewardedSuccess("extra_lives"); if (lastRewardedSuccess.HasValue) { Debug.Log($"Последний раз 'extra_lives' был закрыт '{lastRewardedSuccess.Value}'"); TimeSpan = DateTime.Now - lastRewardedSuccess.Value; Debug.Log($"Прошло {TimeSpan.TotalSeconds} секунд с момента последнего закрытия 'extra_lives'"); } else { Debug.Log("'extra_lives' никогда не был закрыт за игровую сессию"); } ``` -------------------------------- ### Interstitial Ads: Get Last Success Time Source: https://romanlee17.com/ru/unity/mirrasdk/ads Retrieves the exact time when the last interstitial ad was successfully closed. Returns null if no interstitial ad has been closed during the current session. It logs the time and calculates the time elapsed since the last closure. ```csharp DateTime? lastInterstitialSuccess = MirraSDK.Ads.GetLastInterstitialSuccess(); if (lastInterstitialSuccess.HasValue) { Debug.Log($"Последний раз межстраничная реклама была закрыта '{lastInterstitialSuccess.Value}'"); TimeSpan timeSinceSuccess = DateTime.Now - lastInterstitialSuccess.Value; Debug.Log($"Прошло {timeSinceSuccess.TotalSeconds} секунд с момента последнего закрытия межстраничной рекламы"); } else { Debug.Log("Межстраничная реклама никогда не была закрыта за игровую сессию"); } ``` -------------------------------- ### Open URL in Browser (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/device Opens a specified URL in the device's default web browser. Ensure the URL is valid. ```csharp MirraSDK.Device.OpenURL("https://example.com"); ``` -------------------------------- ### Open URL in Browser Source: https://romanlee17.com/ru/unity/mirrasdk/device Opens a specified URL in the device's default web browser. ```APIDOC ## Open URL in Browser ### Description Opens a specified URL in the device's default web browser. ### Method N/A (This is a method call within the SDK) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp MirraSDK.Device.OpenURL("https://example.com"); ``` ### Response #### Success Response (N/A - this is an SDK method call) No direct response, but the browser should open with the specified URL. #### Response Example N/A ``` -------------------------------- ### Invoke Player Login (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Initiates the player login process. It accepts two callback functions: one for successful authorization and one for authorization errors. ```csharp MirraSDK.Player.InvokeLogin( () => Debug.Log("авторизация успешна"), () => Debug.LogError("ошибка авторизации") ); ``` -------------------------------- ### Check MirraSDK Initialization Status (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/initialization This snippet demonstrates how to check if the MirraSDK has been initialized. The `IsInitialized` property returns a boolean indicating the readiness of all components requiring asynchronous loading. Accessing SDK methods before initialization will result in errors. ```csharp bool isSDKInitialized = MirraSDK.IsInitialized; ``` -------------------------------- ### Restore All Pending Purchases Source: https://romanlee17.com/ru/unity/mirrasdk/payments Initiates the process to restore any unfulfilled purchases. It asynchronously fetches a list of all purchases and specifically identifies pending products that need to be delivered to the player. This is crucial for handling cases where a purchase was successful but the item was not delivered due to errors. ```csharp // Получить объект типа RestoreData, который содержит информацию о невыданных товарах // Колбек будет выполнен после асинхронного получения данных с сервера MirraSDK.Payments.RestorePurchases((restoreData) => { // Список всех покупок игрока (содержит и выданные и невыданные товары) string[] allPurchases = restoreData.AllPurchases; Debug.Log($"Игрок совершил '{allPurchases.Length}' успешных покупок"); // Список невыданных товаров, которые нужно выдать игроку (содержит уникальные теги товаров, т.е. если товар не выдан множество раз, он будет упомянут только один раз в массиве) string[] pendingProducts = restoreData.PendingProducts; Debug.Log($"Игрок не получил '{pendingProducts.Length}' разных товаров: [{string.Join(", ", pendingProducts)}]"); // Выдать невыданные товары игроку // [пример кода ниже] }); ``` -------------------------------- ### Rewarded Ads: Check Readiness Source: https://romanlee17.com/ru/unity/mirrasdk/ads Verifies if a rewarded ad is ready to be displayed. This ensures that the ad content has loaded and is prepared for presentation, allowing the player to earn rewards. ```csharp bool isRewardedReady = MirraSDK.Ads.IsRewardedReady; ``` -------------------------------- ### Restore Specific Pending Purchases Source: https://romanlee17.com/ru/unity/mirrasdk/payments Allows for the restoration of specific unfulfilled purchases by iterating through the pending products obtained from `RestorePurchases`. The `RestoreProduct` method handles the delivery and registration of each item, ensuring it's only delivered once. ```csharp foreach(string productTag in pendingProducts) { // Метод RestoreProduct выдает товар игроку, и регистрирует его как выданный // Колбек onProductRestore будет выполнен столько раз, сколько раз данный товар не был выдан игроку // От 0 раз до того сколько раз товар не был выдан игроку restoreData.RestoreProduct(productTag, onProductRestore: () => { // Ваш метод выдачи товара игроку YourCode_GiveProduct(productTag); Debug.Log($"Товар '{productTag}' восстановлен"); }); } ``` -------------------------------- ### Check In-App Purchase Availability Source: https://romanlee17.com/ru/unity/mirrasdk/payments Checks if in-app purchases are available in the current environment. This is a simple boolean check that returns true if purchases are supported and false otherwise. No external dependencies are required for this check. ```csharp bool isAvailable = MirraSDK.Payments.IsAvailable; ``` -------------------------------- ### Check if Product Already Purchased Source: https://romanlee17.com/ru/unity/mirrasdk/payments Determines if a specific product has been purchased at least once by the user. ```APIDOC ## GET /payments/purchased/{productTag} ### Description Checks if a specific product has already been purchased by the user at least once. ### Method GET ### Endpoint `/payments/purchased/{productTag}` ### Parameters #### Path Parameters - **productTag** (string) - Required - The unique identifier for the product. ### Request Example None ### Response #### Success Response (200) - **isAlreadyPurchased** (boolean) - True if the product has been purchased before, false otherwise. #### Response Example ```json { "isAlreadyPurchased": false } ``` ``` -------------------------------- ### Banner Ads: Check Readiness Source: https://romanlee17.com/ru/unity/mirrasdk/ads Verifies if a banner ad is ready to be displayed to the player. This ensures that the ad content has loaded and is prepared for presentation. ```csharp bool isBannerReady = MirraSDK.Ads.IsBannerReady; ``` -------------------------------- ### Check In-App Purchase Availability Source: https://romanlee17.com/ru/unity/mirrasdk/payments Checks if in-app purchases are available in the current environment. ```APIDOC ## GET /payments/availability ### Description Checks if in-app purchases are available in the current environment where the game is running. ### Method GET ### Endpoint `/payments/availability` ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **isAvailable** (boolean) - True if in-app purchases are available, false otherwise. #### Response Example ```json { "isAvailable": true } ``` ``` -------------------------------- ### Restore a Single Specific Purchase Source: https://romanlee17.com/ru/unity/mirrasdk/payments Restores a single, specific product purchase by its tag. This method is called within the context of a `RestoreData` object and includes a callback to execute upon successful restoration of that particular item. ```csharp // Выдача конкретного товара игроку restoreData.RestoreProduct( productTag: "exampleProduct", onProductRestore: () => { // Выдать товар игроку Debug.Log("Товар 'exampleProduct' восстановлен"); } ); // Можно выдавать несколько конкретных товаров в одном объекте RestoreData // [вызов restoreData.RestoreProduct для другого товара] ``` -------------------------------- ### Load Streaming Audio Clip - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads an audio file from the StreamingAssets folder. It requires the file path, audio type, and callbacks for success and failure. This is useful for including audio assets directly in the build. ```csharp MirraSDK.Assets.LoadStreamingAudioClip("example/audio.ogg", AudioType.MPEG, (audioClip) => { Debug.Log($"Аудио файл загружен: '{audioClip}'"); }, () => { Debug.LogError("Не удалось загрузить аудио файл."); }); ``` -------------------------------- ### Restore Purchases Source: https://romanlee17.com/ru/unity/mirrasdk/payments Restores any unconsumed purchases for the user. ```APIDOC ## POST /payments/restore ### Description Restores any unconsumed purchases for the user. This is typically called after game startup or when a user explicitly requests to restore purchases. It ensures the user receives items they may have paid for but not received due to errors. ### Method POST ### Endpoint `/payments/restore` ### Parameters #### Request Body - **onComplete** (callback) - Required - A callback function that receives a `RestoreData` object containing information about pending products. ### Request Example ```json { "onComplete": "(restoreData) => { ... }" } ``` ### Response #### Success Response (200) Indicates that the restore process has been initiated. The actual restoration logic is handled within the `onComplete` callback. #### Response Example ```json { "message": "Purchase restoration initiated" } ``` ### RestoreData Object - **AllPurchases** (array of strings) - A list of all successful purchases made by the player (both consumed and unconsumed). - **PendingProducts** (array of strings) - A list of unique product tags that have been purchased but not yet consumed (i.e., need to be delivered to the player). ### RestoreProduct Method This method is called on the `RestoreData` object to restore a specific product. #### Parameters - **productTag** (string) - Required - The tag of the product to restore. - **onProductRestore** (callback) - Required - A callback function executed when the product is successfully restored and delivered. #### Example Usage (Restoring all pending products) ```javascript restoreData.PendingProducts.forEach(productTag => { restoreData.RestoreProduct(productTag, () => { YourCode_GiveProduct(productTag); Debug.Log(`Товар '${productTag}' восстановлен`); }); }); ``` #### Example Usage (Restoring a specific product) ```javascript restoreData.RestoreProduct("exampleProduct", () => { // Выдать товар игроку Debug.Log("Товар 'exampleProduct' восстановлен"); }); ``` ``` -------------------------------- ### Report Event with Parameters (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Reports an analytics event with a name and a dictionary of parameters. This allows for detailed event tracking with multiple attributes. ```csharp MirraSDK.Analytics.Report( eventName: "tutorial", eventParameters: new() { ["timeToComplete"] = 100, ["doneCompletely"] = true } ); ``` -------------------------------- ### StreamingAssets API Source: https://romanlee17.com/ru/unity/mirrasdk/assets Functions for loading various file types from the StreamingAssets folder. ```APIDOC ## Load Streaming Audio Clip ### Description Loads an audio file from the StreamingAssets folder. ### Method MirraSDK.Assets.LoadStreamingAudioClip ### Parameters - **path** (string) - The path to the audio file within StreamingAssets. - **audioType** (AudioType) - The type of the audio file. - **onSuccess** (Action) - Callback function executed upon successful loading. - **onFailure** (Action) - Callback function executed if loading fails. ### Request Example ```csharp MirraSDK.Assets.LoadStreamingAudioClip("example/audio.ogg", AudioType.MPEG, (audioClip) => { Debug.Log($"Аудио файл загружен: '{audioClip}'"); }, () => { Debug.LogError("Не удалось загрузить аудио файл."); }); ``` ## Load Streaming Text ### Description Loads a text file from the StreamingAssets folder. ### Method MirraSDK.Assets.LoadStreamingText ### Parameters - **path** (string) - The path to the text file within StreamingAssets. - **onSuccess** (Action) - Callback function executed upon successful loading. - **onFailure** (Action) - Callback function executed if loading fails. ### Request Example ```csharp MirraSDK.Assets.LoadStreamingText("example/text.txt", (text) => { Debug.Log($"Текстовый файл загружен: '{text}'"); }, () => { Debug.LogError("Не удалось загрузить текстовый файл."); }); ``` ## Load Streaming Texture2D ### Description Loads a texture file from the StreamingAssets folder. ### Method MirraSDK.Assets.LoadStreamingTexture2D ### Parameters - **path** (string) - The path to the texture file within StreamingAssets. - **onSuccess** (Action) - Callback function executed upon successful loading. - **onFailure** (Action) - Callback function executed if loading fails. ### Request Example ```csharp MirraSDK.Assets.LoadStreamingTexture2D("example/texture.tga", (texture) => { Debug.Log($"Текстура загружена: '{texture}'"); }, () => { Debug.LogError("Не удалось загрузить текстуру."); }); ``` ## Load Streaming JSON ### Description Loads and deserializes a JSON file from the StreamingAssets folder into a specified C# object. ### Method MirraSDK.Assets.LoadStreamingJSON ### Parameters - **path** (string) - The path to the JSON file within StreamingAssets. - **onSuccess** (Action) - Callback function executed upon successful loading and deserialization. - **onFailure** (Action) - Callback function executed if loading or deserialization fails. ### Request Example ```csharp [System.Serializable] public class ExampleObject { public string name; public int value; } MirraSDK.Assets.LoadStreamingJSON("example/object.json", (example) => { Debug.Log($"JSON объект загружен: '{example}'"); }, () => { Debug.LogError("Не удалось загрузить JSON объект."); }); ``` ``` -------------------------------- ### Rewarded Ads: Check Availability Source: https://romanlee17.com/ru/unity/mirrasdk/ads Checks if rewarded ads are available in the current environment. This is a necessary step before attempting to show a rewarded ad. ```csharp bool isRewardedAvailable = MirraSDK.Ads.IsRewardedAvailable; ``` -------------------------------- ### Check if Product Already Purchased Source: https://romanlee17.com/ru/unity/mirrasdk/payments Determines if a specific product has already been purchased at least once by the player. This is useful for managing consumable vs. non-consumable items. ```csharp bool isAlreadyPurchased = MirraSDK.Payments.IsAlreadyPurchased("exampleProduct"); ``` -------------------------------- ### Load Streaming Text File - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads a text file from the StreamingAssets folder. It takes the file path and callbacks for success and failure. This is suitable for loading configuration files or other text-based assets. ```csharp MirraSDK.Assets.LoadStreamingText("example/text.txt", (text) => { Debug.Log($"Текстовый файл загружен: '{text}'"); }, () => { Debug.LogError("Не удалось загрузить текстовый файл."); }); ``` -------------------------------- ### Cursor Control Source: https://romanlee17.com/ru/unity/mirrasdk/device Allows control over the cursor's visibility and lock state. ```APIDOC ## Cursor Control ### Description Allows control over the cursor's visibility and lock state. ### Method N/A (These are property assignments within the SDK) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Show the cursor MirraSDK.Device.CursorVisible = true; // Hide the cursor MirraSDK.Device.CursorVisible = false; // Lock the cursor to the center of the screen MirraSDK.Device.CursorLock = CursorLockMode.Locked; // Unlock the cursor MirraSDK.Device.CursorLock = CursorLockMode.None; ``` ### Response #### Success Response (N/A - these are SDK property assignments) No direct response, but the cursor's state will be updated accordingly. #### Response Example N/A ``` -------------------------------- ### Check if Ads are Available Source: https://romanlee17.com/ru/unity/mirrasdk/ads Checks if ads are available in the current environment where the game is running. This is a general check for any ad type. ```csharp bool isAdsAvailable = MirraSDK.Ads.IsAvailable; ``` -------------------------------- ### Addressables API Source: https://romanlee17.com/ru/unity/mirrasdk/assets Functions for loading and releasing Addressable assets by their keys. ```APIDOC ## Load Addressable Asset ### Description Loads an Addressable asset using its key. ### Method MirraSDK.Assets.LoadAddressable ### Parameters - **addressablePath** (string) - The key for the Addressable asset. - **onSuccess** (Action) - Callback function executed upon successful loading. - **onFailure** (Action) - Callback function executed if loading fails. ### Request Example ```csharp MirraSDK.Assets.LoadAddressable("addressablePath", (addressable) => { Debug.Log($"Addressable загружен: '{addressable}'"); }, () => { Debug.LogError("Не удалось загрузить Addressable."); }); ``` ## Release Addressable Asset ### Description Releases an Addressable asset by its key. ### Method MirraSDK.Remote.ReleaseAddressable ### Parameters - **addressablePath** (string) - The key for the Addressable asset to release. ### Request Example ```csharp MirraSDK.Remote.ReleaseAddressable("addressablePath"); ``` ``` -------------------------------- ### Load Addressable GameObject by Key - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads an Addressable asset of type GameObject using its key. It takes a success callback to process the loaded asset and an error callback if loading fails. This method is part of the MirraSDK's asset management system. ```csharp MirraSDK.Assets.LoadAddressable("addressablePath", (addressable) => { Debug.Log($"Addressable загружен: '{addressable}'"); }, () => { Debug.LogError("Не удалось загрузить Addressable."); }); ``` -------------------------------- ### Control Cursor Visibility (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/device Allows showing or hiding the mouse cursor. Set the CursorVisible property to true to show and false to hide. ```csharp // show cursor MirraSDK.Device.CursorVisible = true; // hide cursor MirraSDK.Device.CursorVisible = false; ``` -------------------------------- ### Check Gameplay Reporter Availability (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Checks if the gameplay event reporter is available in the current environment. This is a prerequisite for sending gameplay-related analytics. ```csharp bool isAvailable = MirraSDK.Analytics.IsGameplayReporterAvailable; ``` -------------------------------- ### Load Streaming JSON Object - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads and deserializes a JSON file from the StreamingAssets folder into a specified serializable class. It requires the file path, the target type, and callbacks for success and failure. This is ideal for loading game data or settings. ```csharp [System.Serializable] public class Example { public string name; public int value; } MirraSDK.Assets.LoadStreamingJSON("example/object.json", (example) => { Debug.Log($"JSON объект загружен: '{example}'"); }, () => { Debug.LogError("Не удалось загрузить JSON объект."); }); ``` -------------------------------- ### AssetBundles API Source: https://romanlee17.com/ru/unity/mirrasdk/assets Functions for loading and releasing AssetBundles by their tags and URLs. ```APIDOC ## Load AssetBundle ### Description Loads an AssetBundle from a given URL using its tag. ### Method MirraSDK.Assets.LoadBundle ### Parameters - **bundleTag** (string) - The tag to identify the AssetBundle. - **url** (string) - The URL where the AssetBundle is located. - **onSuccess** (Action) - Callback function executed upon successful loading. - **onFailure** (Action) - Callback function executed if loading fails. ### Request Example ```csharp MirraSDK.Assets.LoadBundle("bundleTag", "https://example.com/bundle", (bundle) => { Debug.Log($"AssetBundle загружен: '{bundle}'"); }, () => { Debug.LogError("Не удалось загрузить AssetBundle."); }); ``` ## Release AssetBundle ### Description Releases an AssetBundle and optionally all its associated objects by its tag. ### Method MirraSDK.Assets.ReleaseBundle ### Parameters - **bundleTag** (string) - The tag of the AssetBundle to release. - **unloadAllObjects** (bool) - If true, all objects loaded from the bundle will also be unloaded. ### Request Example ```csharp MirraSDK.Assets.ReleaseBundle("bundleTag", unloadAllObjects: true); ``` ``` -------------------------------- ### Current Date Retrieval Source: https://romanlee17.com/ru/unity/mirrasdk/time Retrieve the current date as a DateTime object using MirraSDK.Time.CurrentDate. ```APIDOC ## Current Date Retrieval ### Description Retrieves the current date and time. ### Method GET ### Endpoint MirraSDK.Time.CurrentDate ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```csharp // Get the current date and time DateTime currentDate = MirraSDK.Time.CurrentDate; ``` ### Response #### Success Response (200) - **DateTime** - The current date and time. #### Response Example ```json { "currentDate": "2023-10-27T10:30:00Z" } ``` ``` -------------------------------- ### Share Game using MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/platform Initiates the game sharing functionality, allowing users to share the game with a provided message. This function interacts with the platform's native sharing capabilities. Input is a string message. ```csharp MirraSDK.Platform.ShareGame("message text"); ``` -------------------------------- ### Load AssetBundle from URL - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads an AssetBundle from a specified URL using a bundle tag. It provides callbacks for successful loading and failure. This function is useful for dynamically loading asset bundles from remote sources. ```csharp MirraSDK.Assets.LoadBundle("bundleTag", "https://example.com/bundle", (bundle) => { Debug.Log($"AssetBundle загружен: '{bundle}'"); }, () => { Debug.LogError("Не удалось загрузить AssetBundle."); }); ``` -------------------------------- ### Rate Game using MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/platform Triggers the game rating prompt for the user. This function leverages the platform's review or rating system. No input parameters are required. ```csharp MirraSDK.Platform.RateGame(); ``` -------------------------------- ### Report Event with Value (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Reports an analytics event with both a name and a single string value. Useful for simple key-value tracking. ```csharp MirraSDK.Analytics.Report("event", "value"); ``` -------------------------------- ### Interstitial Ads: Check Readiness Source: https://romanlee17.com/ru/unity/mirrasdk/ads Verifies if an interstitial ad is ready to be displayed. This indicates that the ad content has been pre-loaded and is prepared for presentation. ```csharp bool isInterstitialReady = MirraSDK.Ads.IsInterstitialReady; ``` -------------------------------- ### Check Player Login Status (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/player Checks whether the player is currently logged in. Returns a boolean value. ```csharp bool isLoggedIn = MirraSDK.Player.IsLoggedIn; ``` -------------------------------- ### Rewarded Ads: Invoke Display with Callbacks and Reward Tag Source: https://romanlee17.com/ru/unity/mirrasdk/ads Displays a rewarded ad to the player with callbacks for success, open, and close events. A reward tag can be provided to track specific rewarded ad types. The onClose callback indicates if the reward was successfully granted. ```csharp MirraSDK.Ads.InvokeRewarded( onSuccess: () => Debug.Log("Реклама за вознаграждение успешно показана"), onOpen: () => Debug.Log("Реклама за вознаграждение открыта"), onClose: (isSuccess) => Debug.Log($"Реклама за вознаграждение закрыта с наградой '{isSuccess}'"), rewardTag: "extra_lives" // Тег для отслеживания закрытия рекламы за вознаграждение ); ``` -------------------------------- ### Load Streaming Texture2D - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Loads a texture from the StreamingAssets folder. It requires the file path and callbacks for success and failure. This allows for including image assets directly within the build. ```csharp MirraSDK.Assets.LoadStreamingTexture2D("example/texture.tga", (texture) => { Debug.Log($"Текстура загружена: '{texture}'"); }, () => { Debug.LogError("Не удалось загрузить текстуру."); }); ``` -------------------------------- ### Banner Ads: Invoke Display Source: https://romanlee17.com/ru/unity/mirrasdk/ads Triggers the display of a banner ad to the player. This function initiates the ad presentation process. ```csharp MirraSDK.Ads.InvokeBanner(); ``` -------------------------------- ### MirraSDK Flags API - HasKey Method Source: https://romanlee17.com/ru/unity/mirrasdk/flags This method checks for the existence of a flag by its key. ```APIDOC ## MirraSDK Flags API - HasKey Method ### Description Checks whether a flag with the specified key exists in the system. ### Method GET (Conceptual - this is an SDK method call, not an HTTP endpoint) ### Endpoint N/A (SDK method) ### Parameters #### Query Parameters - **key** (string) - Required - The unique identifier for the flag to check. ### Request Example ```csharp bool exists = MirraSDK.Flags.HasKey("user_segment_a"); ``` ### Response #### Success Response - **valueExists** (bool) - `true` if the key exists, `false` otherwise. #### Response Example ```json { "valueExists": true } ``` ``` -------------------------------- ### Check Events Reporter Availability (C#) Source: https://romanlee17.com/ru/unity/mirrasdk/analytics Checks if the custom events reporter is available in the current environment. This is necessary before sending custom analytics events. ```csharp bool isAvailable = MirraSDK.Analytics.IsEventsReporterAvailable; ``` -------------------------------- ### Banner Ads: Check Availability Source: https://romanlee17.com/ru/unity/mirrasdk/ads Checks if banner ads are available in the environment where the game is running. This is specific to banner ad functionality. ```csharp bool isBannerAvailable = MirraSDK.Ads.IsBannerAvailable; ``` -------------------------------- ### Release Addressable by Key - MirraSDK Source: https://romanlee17.com/ru/unity/mirrasdk/assets Releases an Addressable asset identified by its key. This is crucial for memory management to unload assets that are no longer needed. It's a simple call to the MirraSDK's remote asset handling. ```csharp MirraSDK.Remote.ReleaseAddressable("addressablePath"); ```