/// <summary>
        /// Call UDP store asynchronously to retrieve the Organization Identifier.
        /// </summary>
        /// <param name="accessToken">The bearer token to UDP.</param>
        /// <param name="projectGuid">The project id.</param>
        /// <returns>The HTTP GET Request to get the organization identifier.</returns>
        public static object GetOrgId(string accessToken, string projectGuid)
        {
            CheckUdpBuildConfig();

            string api = "/v1/core/api/projects/" + projectGuid;

            return(asyncRequest(kHttpVerbGET, BuildConfigInterface.GetApiEndpoint(), api, accessToken, null));
        }
        /// <summary>
        /// Call UDP store asynchronously to update a store item.
        /// </summary>
        /// <param name="accessToken">The bearer token to UDP.</param>
        /// <param name="iapItem">The updated store item.</param>
        /// <returns>The HTTP PUT Request to update a store item.</returns>
        public static object UpdateStoreItem(string accessToken, IapItem iapItem)
        {
            CheckUdpBuildConfig();

            string api = "/v1/store/items/" + iapItem.id;

            return(asyncRequest(kHttpVerbPUT, BuildConfigInterface.GetUdpEndpoint(), api, accessToken, iapItem));
        }
        /// <summary>
        /// Call UDP store asynchronously to create a store item.
        /// </summary>
        /// <param name="accessToken">The bearer token to UDP.</param>
        /// <param name="orgId">The organization identifier to create the store item under.</param>
        /// <param name="iapItem">The store item to create.</param>
        /// <returns>The HTTP POST Request to create a store item.</returns>
        public static object CreateStoreItem(string accessToken, string orgId, IapItem iapItem)
        {
            CheckUdpBuildConfig();

            string api = "/v1/store/items";

            iapItem.ownerId = orgId;
            return(asyncRequest(kHttpVerbPOST, BuildConfigInterface.GetUdpEndpoint(), api, accessToken, iapItem));
        }
        /// <summary>
        /// Call UDP store asynchronously to search for a store item.
        /// </summary>
        /// <param name="accessToken">The bearer token to UDP.</param>
        /// <param name="orgId">The organization identifier where to find the store item.</param>
        /// <param name="appItemSlug">The store item slug name.</param>
        /// <returns>The HTTP GET Request to update a store item.</returns>
        public static object SearchStoreItem(string accessToken, string orgId, string appItemSlug)
        {
            CheckUdpBuildConfig();

            string api = "/v1/store/items/search?ownerId=" + orgId +
                         "&ownerType=ORGANIZATION&start=0&count=20&type=IAP&masterItemSlug=" + appItemSlug;

            return(asyncRequest(kHttpVerbGET, BuildConfigInterface.GetUdpEndpoint(), api, accessToken, null));
        }
        private static void CheckUdpBuildConfig()
        {
            Type udpBuildConfig = BuildConfigInterface.GetClassType();

            if (udpBuildConfig == null)
            {
                Debug.LogError("Cannot Retrieve Build Config Endpoints for UDP. Please make sure the UDP package is installed");
                throw new NotImplementedException();
            }
        }
        /// <summary>
        /// Get Access Token according to authCode.
        /// </summary>
        /// <param name="authCode"> Acquired by UnityOAuth</param>
        /// <returns></returns>
        public static object GetAccessToken(string authCode)
        {
            CheckUdpBuildConfig();

            TokenRequest req = new TokenRequest();

            req.code          = authCode;
            req.client_id     = kOAuthClientId;
            req.client_secret = kOAuthClientSecret;
            req.grant_type    = "authorization_code";
            req.redirect_uri  = BuildConfigInterface.GetIdEndpoint();
            return(asyncRequest(kHttpVerbPOST, BuildConfigInterface.GetApiEndpoint(), "/v1/oauth2/token", null, req));
        }
        internal static bool CheckUdpCompatibility()
        {
            Type udpBuildConfig = BuildConfigInterface.GetClassType();

            if (udpBuildConfig == null)
            {
                Debug.LogError("Cannot Retrieve Build Config Endpoints for UDP. Please make sure the UDP package is installed");
                return(false);
            }

            var udpVersion   = BuildConfigInterface.GetVersion();
            int majorVersion = 0;

            int.TryParse(udpVersion.Split('.')[0], out majorVersion);

            return(majorVersion >= 2);
        }