private void OnGetUserNotificationInfoListResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetUserNotificationInfoList: " + response.Error);
            }

            GetUserNotificationInfoListData = (PageResourceNotificationUserTypeResource)KnetikClient.Deserialize(response.Content, typeof(PageResourceNotificationUserTypeResource), response.Headers);
            KnetikLogger.LogResponse(mGetUserNotificationInfoListStartTime, "GetUserNotificationInfoList", string.Format("Response received successfully:\n{0}", GetUserNotificationInfoListData));

            if (GetUserNotificationInfoListComplete != null)
            {
                GetUserNotificationInfoListComplete(response.ResponseCode, GetUserNotificationInfoListData);
            }
        }
Example #2
0
        private void OnFinalizePayPalBillingAgreementResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling FinalizePayPalBillingAgreement: " + response.Error);
            }

            FinalizePayPalBillingAgreementData = (int?)KnetikClient.Deserialize(response.Content, typeof(int?), response.Headers);
            KnetikLogger.LogResponse(mFinalizePayPalBillingAgreementStartTime, "FinalizePayPalBillingAgreement", string.Format("Response received successfully:\n{0}", FinalizePayPalBillingAgreementData));

            if (FinalizePayPalBillingAgreementComplete != null)
            {
                FinalizePayPalBillingAgreementComplete(response.ResponseCode, FinalizePayPalBillingAgreementData);
            }
        }
        private void OnSendNotificationResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling SendNotification: " + response.Error);
            }

            SendNotificationData = (NotificationResource)KnetikClient.Deserialize(response.Content, typeof(NotificationResource), response.Headers);
            KnetikLogger.LogResponse(mSendNotificationStartTime, "SendNotification", string.Format("Response received successfully:\n{0}", SendNotificationData));

            if (SendNotificationComplete != null)
            {
                SendNotificationComplete(response.ResponseCode, SendNotificationData);
            }
        }
Example #4
0
        private void OnCreatePayPalExpressCheckoutResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling CreatePayPalExpressCheckout: " + response.Error);
            }

            CreatePayPalExpressCheckoutData = (string)KnetikClient.Deserialize(response.Content, typeof(string), response.Headers);
            KnetikLogger.LogResponse(mCreatePayPalExpressCheckoutStartTime, "CreatePayPalExpressCheckout", string.Format("Response received successfully:\n{0}", CreatePayPalExpressCheckoutData));

            if (CreatePayPalExpressCheckoutComplete != null)
            {
                CreatePayPalExpressCheckoutComplete(response.ResponseCode, CreatePayPalExpressCheckoutData);
            }
        }
        private void OnGetExpressionAsTextResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetExpressionAsText: " + response.Error);
            }

            GetExpressionAsTextData = (StringWrapper)KnetikClient.Deserialize(response.Content, typeof(StringWrapper), response.Headers);
            KnetikLogger.LogResponse(mGetExpressionAsTextStartTime, "GetExpressionAsText", string.Format("Response received successfully:\n{0}", GetExpressionAsTextData));

            if (GetExpressionAsTextComplete != null)
            {
                GetExpressionAsTextComplete(response.ResponseCode, GetExpressionAsTextData);
            }
        }
        private void OnGetCouponItemBySkuResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetCouponItemBySku: " + response.Error);
            }

            GetCouponItemBySkuData = (CouponItem)KnetikClient.Deserialize(response.Content, typeof(CouponItem), response.Headers);
            KnetikLogger.LogResponse(mGetCouponItemBySkuStartTime, "GetCouponItemBySku", string.Format("Response received successfully:\n{0}", GetCouponItemBySkuData));

            if (GetCouponItemBySkuComplete != null)
            {
                GetCouponItemBySkuComplete(response.ResponseCode, GetCouponItemBySkuData);
            }
        }
        private void OnGetInvoiceReportsResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetInvoiceReports: " + response.Error);
            }

            GetInvoiceReportsData = (PageResourceAggregateInvoiceReportResource)KnetikClient.Deserialize(response.Content, typeof(PageResourceAggregateInvoiceReportResource), response.Headers);
            KnetikLogger.LogResponse(mGetInvoiceReportsStartTime, "GetInvoiceReports", string.Format("Response received successfully:\n{0}", GetInvoiceReportsData));

            if (GetInvoiceReportsComplete != null)
            {
                GetInvoiceReportsComplete(response.ResponseCode, GetInvoiceReportsData);
            }
        }
Example #8
0
        private void OnCreateObjectTemplateResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling CreateObjectTemplate: " + response.Error);
            }

            CreateObjectTemplateData = (ItemTemplateResource)KnetikClient.Deserialize(response.Content, typeof(ItemTemplateResource), response.Headers);
            KnetikLogger.LogResponse(mCreateObjectTemplateStartTime, "CreateObjectTemplate", string.Format("Response received successfully:\n{0}", CreateObjectTemplateData));

            if (CreateObjectTemplateComplete != null)
            {
                CreateObjectTemplateComplete(response.ResponseCode, CreateObjectTemplateData);
            }
        }
        private void OnGetOAuthTokenResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetOAuthToken: " + response.Error);
            }

            GetOAuthTokenData = (OAuth2Resource)KnetikClient.Deserialize(response.Content, typeof(OAuth2Resource), response.Headers);
            KnetikLogger.LogResponse(mGetOAuthTokenStartTime, "GetOAuthToken", string.Format("Response received successfully:\n{0}", GetOAuthTokenData));

            if (GetOAuthTokenComplete != null)
            {
                GetOAuthTokenComplete(response.ResponseCode, GetOAuthTokenData);
            }
        }
Example #10
0
        private void OnUpdateStateTaxResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling UpdateStateTax: " + response.Error);
            }

            UpdateStateTaxData = (StateTaxResource)KnetikClient.Deserialize(response.Content, typeof(StateTaxResource), response.Headers);
            KnetikLogger.LogResponse(mUpdateStateTaxStartTime, "UpdateStateTax", string.Format("Response received successfully:\n{0}", UpdateStateTaxData));

            if (UpdateStateTaxComplete != null)
            {
                UpdateStateTaxComplete(response.ResponseCode, UpdateStateTaxData);
            }
        }
        private void OnGetChallengeEventLeaderboardResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetChallengeEventLeaderboard: " + response.Error);
            }

            GetChallengeEventLeaderboardData = (PageResourceChallengeEventParticipantResource)KnetikClient.Deserialize(response.Content, typeof(PageResourceChallengeEventParticipantResource), response.Headers);
            KnetikLogger.LogResponse(mGetChallengeEventLeaderboardStartTime, "GetChallengeEventLeaderboard", string.Format("Response received successfully:\n{0}", GetChallengeEventLeaderboardData));

            if (GetChallengeEventLeaderboardComplete != null)
            {
                GetChallengeEventLeaderboardComplete(response.ResponseCode, GetChallengeEventLeaderboardData);
            }
        }
Example #12
0
        private void OnAddFlagResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling AddFlag: " + response.Error);
            }

            AddFlagData = (FlagResource)KnetikClient.Deserialize(response.Content, typeof(FlagResource), response.Headers);
            KnetikLogger.LogResponse(mAddFlagStartTime, "AddFlag", string.Format("Response received successfully:\n{0}", AddFlagData));

            if (AddFlagComplete != null)
            {
                AddFlagComplete(response.ResponseCode, AddFlagData);
            }
        }
        private void OnGetClientGrantTypesResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetClientGrantTypes: " + response.Error);
            }

            GetClientGrantTypesData = (List <GrantTypeResource>)KnetikClient.Deserialize(response.Content, typeof(List <GrantTypeResource>), response.Headers);
            KnetikLogger.LogResponse(mGetClientGrantTypesStartTime, "GetClientGrantTypes", string.Format("Response received successfully:\n{0}", GetClientGrantTypesData));

            if (GetClientGrantTypesComplete != null)
            {
                GetClientGrantTypesComplete(response.ResponseCode, GetClientGrantTypesData);
            }
        }
        private void OnGetTemplatePropertyTypeResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling GetTemplatePropertyType: " + response.Error);
            }

            GetTemplatePropertyTypeData = (PropertyFieldListResource)KnetikClient.Deserialize(response.Content, typeof(PropertyFieldListResource), response.Headers);
            KnetikLogger.LogResponse(mGetTemplatePropertyTypeStartTime, "GetTemplatePropertyType", string.Format("Response received successfully:\n{0}", GetTemplatePropertyTypeData));

            if (GetTemplatePropertyTypeComplete != null)
            {
                GetTemplatePropertyTypeComplete(response.ResponseCode, GetTemplatePropertyTypeData);
            }
        }
Example #15
0
        private static void CreateDirectoriesInPath(string directoryPath)
        {
            if (string.IsNullOrEmpty(directoryPath))
            {
                KnetikLogger.LogError("Unity directory is empty!");
                return;
            }

            if (!DoesPathContainTrailingSlash(directoryPath))
            {
                directoryPath += KnetikAssetDatabaseUtils.DirectorySeparator;
            }

            // Ensure directory separators are correct
            directoryPath = directoryPath.Replace(KnetikAssetDatabaseUtils.OppositeDirectorySeparator, KnetikAssetDatabaseUtils.DirectorySeparator);

            string[] folders = directoryPath.Split(KnetikAssetDatabaseUtils.DirectorySeparator);

            // Error if path does NOT start from Assets
            if (folders[0] != KnetikAssetDatabaseUtils.AssetsFolderName)
            {
                string exceptionMessage = string.Format("Create Directories requires a full Unity path, including '{0}{1}'.", KnetikAssetDatabaseUtils.AssetsFolderName, KnetikAssetDatabaseUtils.DirectorySeparator);
                throw new KnetikException(0, exceptionMessage);
            }

            string pathToFolder = string.Empty;

            foreach (string folder in folders)
            {
                // Don't check for or create empty folders
                if (string.IsNullOrEmpty(folder))
                {
                    continue;
                }

                // Create folders that don't exist
                pathToFolder = string.Concat(pathToFolder, folder);

                if (!AssetDatabase.IsValidFolder(pathToFolder))
                {
                    string pathToParent = Directory.GetParent(pathToFolder).ToString();
                    AssetDatabase.CreateFolder(pathToParent, folder);
                    AssetDatabase.Refresh();
                }

                pathToFolder = string.Concat(pathToFolder, KnetikAssetDatabaseUtils.DirectorySeparator);
            }
        }
        /// <inheritdoc />
        /// <summary>
        /// Returns list of endpoints called (method and url) &lt;b&gt;Permissions Needed:&lt;/b&gt; USAGE_ADMIN
        /// </summary>
        /// <param name="startDate">The beginning of the range being requested, unix timestamp in seconds</param>
        /// <param name="endDate">The ending of the range being requested, unix timestamp in seconds</param>
        public void GetUsageEndpoints(long?startDate, long?endDate)
        {
            // verify the required parameter 'startDate' is set
            if (startDate == null)
            {
                throw new KnetikException(400, "Missing required parameter 'startDate' when calling GetUsageEndpoints");
            }
            // verify the required parameter 'endDate' is set
            if (endDate == null)
            {
                throw new KnetikException(400, "Missing required parameter 'endDate' when calling GetUsageEndpoints");
            }

            mWebCallEvent.WebPath = "/reporting/usage/endpoints";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (startDate != null)
            {
                mWebCallEvent.QueryParams["start_date"] = KnetikClient.ParameterToString(startDate);
            }

            if (endDate != null)
            {
                mWebCallEvent.QueryParams["end_date"] = KnetikClient.ParameterToString(endDate);
            }

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetUsageEndpointsStartTime = DateTime.Now;
            mWebCallEvent.Context       = mGetUsageEndpointsResponseContext;
            mWebCallEvent.RequestType   = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetUsageEndpointsStartTime, "GetUsageEndpoints", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #17
0
        /// <inheritdoc />
        /// <summary>
        /// Update an object &lt;b&gt;Permissions Needed:&lt;/b&gt; INVENTORY_ADMIN
        /// </summary>
        /// <param name="templateId">The id of the template this object is part of</param>
        /// <param name="objectId">The id of the object</param>
        /// <param name="cascade">Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.</param>
        /// <param name="objectItem">The object item object</param>
        public void UpdateObjectItem(string templateId, int?objectId, bool?cascade, ObjectResource objectItem)
        {
            // verify the required parameter 'templateId' is set
            if (templateId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'templateId' when calling UpdateObjectItem");
            }
            // verify the required parameter 'objectId' is set
            if (objectId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'objectId' when calling UpdateObjectItem");
            }

            mWebCallEvent.WebPath = "/objects/{template_id}/{object_id}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "template_id" + "}", KnetikClient.ParameterToString(templateId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "object_id" + "}", KnetikClient.ParameterToString(objectId));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (cascade != null)
            {
                mWebCallEvent.QueryParams["cascade"] = KnetikClient.ParameterToString(cascade);
            }

            mWebCallEvent.PostBody = KnetikClient.Serialize(objectItem); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdateObjectItemStartTime = DateTime.Now;
            mWebCallEvent.Context      = mUpdateObjectItemResponseContext;
            mWebCallEvent.RequestType  = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateObjectItemStartTime, "UpdateObjectItem", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Enable or disable messages for a user Useful for opt-out options on a single topic. Consider multiple topics for multiple opt-out options.
        /// </summary>
        /// <param name="id">The id of the topic</param>
        /// <param name="userId">The id of the subscriber or &#39;me&#39;</param>
        /// <param name="disabled">disabled</param>
        public void DisableTopicSubscriber(string id, string userId, ValueWrapperboolean disabled)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling DisableTopicSubscriber");
            }
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling DisableTopicSubscriber");
            }
            // verify the required parameter 'disabled' is set
            if (disabled == null)
            {
                throw new KnetikException(400, "Missing required parameter 'disabled' when calling DisableTopicSubscriber");
            }

            mWebCallEvent.WebPath = "/messaging/topics/{id}/subscribers/{user_id}/disabled";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(disabled); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mDisableTopicSubscriberStartTime = DateTime.Now;
            mWebCallEvent.Context            = mDisableTopicSubscriberResponseContext;
            mWebCallEvent.RequestType        = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mDisableTopicSubscriberStartTime, "DisableTopicSubscriber", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Enable or disable direct notifications for a user Allows enabling or disabling messages for a given notification type when sent direct to the user. Notifications can still be retrieved by endpoint. For notifications broadcased to a topic, see the topic service to disable messages for the user there.
        /// </summary>
        /// <param name="typeId">The id of the topic</param>
        /// <param name="userId">The id of the subscriber or &#39;me&#39;</param>
        /// <param name="silenced">silenced</param>
        public void SilenceDirectNotifications(string typeId, string userId, ValueWrapperboolean silenced)
        {
            // verify the required parameter 'typeId' is set
            if (typeId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'typeId' when calling SilenceDirectNotifications");
            }
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling SilenceDirectNotifications");
            }
            // verify the required parameter 'silenced' is set
            if (silenced == null)
            {
                throw new KnetikException(400, "Missing required parameter 'silenced' when calling SilenceDirectNotifications");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/notifications/types/{type_id}/silenced";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "type_id" + "}", KnetikClient.ParameterToString(typeId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(silenced); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mSilenceDirectNotificationsStartTime = DateTime.Now;
            mWebCallEvent.Context     = mSilenceDirectNotificationsResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mSilenceDirectNotificationsStartTime, "SilenceDirectNotifications", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #20
0
        /// <inheritdoc />
        /// <summary>
        /// Set the status of a subscription Note that the new status may be blocked if the system is not configured to allow the current status to be changed to the new, to enforce proper flow. The default options for statuses are shown below but may be altered for special use cases. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; USERS_SUBSCRIPTIONS_ADMIN or owner
        /// </summary>
        /// <param name="userId">The id of the user</param>
        /// <param name="inventoryId">The id of the user&#39;s inventory</param>
        /// <param name="status">The new status for the subscription. Actual options may differ from the indicated set if the invoice status type data has been altered.  Allowable values: (&#39;current&#39;, &#39;canceled&#39;, &#39;stopped&#39;, &#39;payment_failed&#39;, &#39;suspended&#39;)</param>
        public void SetSubscriptionStatus(int?userId, int?inventoryId, StringWrapper status)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling SetSubscriptionStatus");
            }
            // verify the required parameter 'inventoryId' is set
            if (inventoryId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'inventoryId' when calling SetSubscriptionStatus");
            }
            // verify the required parameter 'status' is set
            if (status == null)
            {
                throw new KnetikException(400, "Missing required parameter 'status' when calling SetSubscriptionStatus");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/subscriptions/{inventory_id}/status";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "inventory_id" + "}", KnetikClient.ParameterToString(inventoryId));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(status); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mSetSubscriptionStatusStartTime = DateTime.Now;
            mWebCallEvent.Context           = mSetSubscriptionStatusResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mSetSubscriptionStatusStartTime, "SetSubscriptionStatus", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Get all payment method types &lt;b&gt;Permissions Needed:&lt;/b&gt; ANY
        /// </summary>
        /// <param name="filterName">Filter for payment method types whose name matches a given string</param>
        /// <param name="size">The number of objects returned per page</param>
        /// <param name="page">The number of the page returned, starting with 1</param>
        /// <param name="order">a comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]</param>
        public void GetPaymentMethodTypes(string filterName, int?size, int?page, string order)
        {
            mWebCallEvent.WebPath = "/payment/types";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (filterName != null)
            {
                mWebCallEvent.QueryParams["filter_name"] = KnetikClient.ParameterToString(filterName);
            }

            if (size != null)
            {
                mWebCallEvent.QueryParams["size"] = KnetikClient.ParameterToString(size);
            }

            if (page != null)
            {
                mWebCallEvent.QueryParams["page"] = KnetikClient.ParameterToString(page);
            }

            if (order != null)
            {
                mWebCallEvent.QueryParams["order"] = KnetikClient.ParameterToString(order);
            }

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetPaymentMethodTypesStartTime = DateTime.Now;
            mWebCallEvent.Context           = mGetPaymentMethodTypesResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetPaymentMethodTypesStartTime, "GetPaymentMethodTypes", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Get a list of available actions &lt;b&gt;Permissions Needed:&lt;/b&gt; BRE_RULE_ENGINE_ACTIONS_USER
        /// </summary>
        /// <param name="filterCategory">Filter for actions that are within a specific category</param>
        /// <param name="filterName">Filter for actions that have names containing the given string</param>
        /// <param name="filterTags">Filter for actions that have all of the given tags (comma separated list)</param>
        /// <param name="filterSearch">Filter for actions containing the given words somewhere within name, description and tags</param>
        public void GetBREActions(string filterCategory, string filterName, string filterTags, string filterSearch)
        {
            mWebCallEvent.WebPath = "/bre/actions";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (filterCategory != null)
            {
                mWebCallEvent.QueryParams["filter_category"] = KnetikClient.ParameterToString(filterCategory);
            }

            if (filterName != null)
            {
                mWebCallEvent.QueryParams["filter_name"] = KnetikClient.ParameterToString(filterName);
            }

            if (filterTags != null)
            {
                mWebCallEvent.QueryParams["filter_tags"] = KnetikClient.ParameterToString(filterTags);
            }

            if (filterSearch != null)
            {
                mWebCallEvent.QueryParams["filter_search"] = KnetikClient.ParameterToString(filterSearch);
            }

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetBREActionsStartTime   = DateTime.Now;
            mWebCallEvent.Context     = mGetBREActionsResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetBREActionsStartTime, "GetBREActions", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #23
0
        /// <inheritdoc />
        /// <summary>
        /// Retrieves a specific user entry with rank The context type identifies the type of entity (i.e., &#39;activity&#39;) being tracked on the leaderboard. The context ID is the unique ID of the actual entity tracked by the leaderboard. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; ANY
        /// </summary>
        /// <param name="contextType">The context type for the leaderboard</param>
        /// <param name="contextId">The context id for the leaderboard</param>
        /// <param name="id">The id of a user</param>
        public void GetLeaderboardRank(string contextType, string contextId, string id)
        {
            // verify the required parameter 'contextType' is set
            if (contextType == null)
            {
                throw new KnetikException(400, "Missing required parameter 'contextType' when calling GetLeaderboardRank");
            }
            // verify the required parameter 'contextId' is set
            if (contextId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'contextId' when calling GetLeaderboardRank");
            }
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling GetLeaderboardRank");
            }

            mWebCallEvent.WebPath = "/leaderboards/{context_type}/{context_id}/users/{id}/rank";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "context_type" + "}", KnetikClient.ParameterToString(contextType));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "context_id" + "}", KnetikClient.ParameterToString(contextId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetLeaderboardRankStartTime = DateTime.Now;
            mWebCallEvent.Context        = mGetLeaderboardRankResponseContext;
            mWebCallEvent.RequestType    = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetLeaderboardRankStartTime, "GetLeaderboardRank", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #24
0
        public void Publish(IKnetikEvent e)
        {
            UnityEngine.Debug.Assert(e != null, "Event System - parameter 'e' cannot be null!");

            EventPublisherBase subscriber = GetEventPublisherBase(e.GetType());

            if (subscriber != null)
            {
                try
                {
                    subscriber.PostEvent(e);
                }
                catch (Exception ex)
                {
                    KnetikLogger.LogError(string.Format("There was an error processing an event! Event: {0} : {1}, Reason: {2}.", e.GetType(), e, ex));
                }
            }
        }
Example #25
0
        /// <inheritdoc />
        /// <summary>
        /// Get pending invites Invites that the specified user received. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; FRIENDSHIPS_ADMIN or (FRIENDSHIPS_USER and owner)
        /// </summary>
        /// <param name="userId">The id of the user or &#39;me&#39;</param>
        /// <param name="size">The number of objects returned per page</param>
        /// <param name="page">The number of the page returned, starting with 1</param>
        public void GetInvites(string userId, int?size, int?page)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling GetInvites");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/invites";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (size != null)
            {
                mWebCallEvent.QueryParams["size"] = KnetikClient.ParameterToString(size);
            }

            if (page != null)
            {
                mWebCallEvent.QueryParams["page"] = KnetikClient.ParameterToString(page);
            }

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetInvitesStartTime      = DateTime.Now;
            mWebCallEvent.Context     = mGetInvitesResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetInvitesStartTime, "GetInvites", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #26
0
        /// <inheritdoc />
        /// <summary>
        /// Get a temporary signed S3 URL for download To give access to files in your own S3 account, you will need to grant KnetikcCloud access to the file by adjusting your bucket policy accordingly. See S3 documentation for details. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; S3_ADMIN
        /// </summary>
        /// <param name="bucket">S3 bucket name</param>
        /// <param name="path">The path to the file relative the bucket (the s3 object key)</param>
        /// <param name="expiration">The number of seconds this URL will be valid. Default to 60</param>
        public void GetDownloadURL(string bucket, string path, int?expiration)
        {
            mWebCallEvent.WebPath = "/amazon/s3/downloadurl";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            if (bucket != null)
            {
                mWebCallEvent.QueryParams["bucket"] = KnetikClient.ParameterToString(bucket);
            }

            if (path != null)
            {
                mWebCallEvent.QueryParams["path"] = KnetikClient.ParameterToString(path);
            }

            if (expiration != null)
            {
                mWebCallEvent.QueryParams["expiration"] = KnetikClient.ParameterToString(expiration);
            }

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mGetDownloadURLStartTime  = DateTime.Now;
            mWebCallEvent.Context     = mGetDownloadURLResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.GET;

            KnetikLogger.LogRequest(mGetDownloadURLStartTime, "GetDownloadURL", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Update an existing payment method for a user &lt;b&gt;Permissions Needed:&lt;/b&gt; PAYMENTS_ADMIN or owner
        /// </summary>
        /// <param name="userId">ID of the user for whom the payment method is being updated</param>
        /// <param name="id">ID of the payment method being updated</param>
        /// <param name="paymentMethod">The updated payment method data</param>
        public void UpdatePaymentMethod(int?userId, int?id, PaymentMethodResource paymentMethod)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling UpdatePaymentMethod");
            }
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdatePaymentMethod");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/payment-methods/{id}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(paymentMethod); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdatePaymentMethodStartTime = DateTime.Now;
            mWebCallEvent.Context         = mUpdatePaymentMethodResponseContext;
            mWebCallEvent.RequestType     = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdatePaymentMethodStartTime, "UpdatePaymentMethod", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Updates the balance for a user&#39;s wallet &lt;b&gt;Permissions Needed:&lt;/b&gt; WALLETS_ADMIN
        /// </summary>
        /// <param name="userId">The ID of the user for whom wallet is being modified</param>
        /// <param name="currencyCode">Currency code of the user&#39;s wallet</param>
        /// <param name="request">The requested balance modification to be made to the user&#39;s wallet</param>
        public void UpdateWalletBalance(int?userId, string currencyCode, WalletAlterRequest request)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling UpdateWalletBalance");
            }
            // verify the required parameter 'currencyCode' is set
            if (currencyCode == null)
            {
                throw new KnetikException(400, "Missing required parameter 'currencyCode' when calling UpdateWalletBalance");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/wallets/{currency_code}/balance";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "currency_code" + "}", KnetikClient.ParameterToString(currencyCode));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(request); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdateWalletBalanceStartTime = DateTime.Now;
            mWebCallEvent.Context         = mUpdateWalletBalanceResponseContext;
            mWebCallEvent.RequestType     = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateWalletBalanceStartTime, "UpdateWalletBalance", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Update or create a leveling progress record for a user If no progress record yet exists for the user, it will be created. Otherwise the provided value will be added to it. May be negative. If progress meets or exceeds the level&#39;s max_value it will be marked as earned and a BRE event will be triggered for the &lt;code&gt;BreAchievementEarnedTrigger&lt;/code&gt;. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; LEVELING_ADMIN
        /// </summary>
        /// <param name="userId">The id of the user</param>
        /// <param name="name">The level schema name</param>
        /// <param name="progress">The amount of progress to add</param>
        public void IncrementProgress(int?userId, string name, IntWrapper progress)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling IncrementProgress");
            }
            // verify the required parameter 'name' is set
            if (name == null)
            {
                throw new KnetikException(400, "Missing required parameter 'name' when calling IncrementProgress");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/leveling/{name}/progress";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "user_id" + "}", KnetikClient.ParameterToString(userId));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "name" + "}", KnetikClient.ParameterToString(name));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(progress); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mIncrementProgressStartTime = DateTime.Now;
            mWebCallEvent.Context       = mIncrementProgressResponseContext;
            mWebCallEvent.RequestType   = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mIncrementProgressStartTime, "IncrementProgress", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Example #30
0
        /// <inheritdoc />
        /// <summary>
        /// Create or update a state tax &lt;b&gt;Permissions Needed:&lt;/b&gt; TAX_ADMIN
        /// </summary>
        /// <param name="countryCodeIso3">The iso3 code of the country</param>
        /// <param name="stateCode">The code of the state</param>
        /// <param name="taxResource">The tax object</param>
        public void UpdateStateTax(string countryCodeIso3, string stateCode, StateTaxResource taxResource)
        {
            // verify the required parameter 'countryCodeIso3' is set
            if (countryCodeIso3 == null)
            {
                throw new KnetikException(400, "Missing required parameter 'countryCodeIso3' when calling UpdateStateTax");
            }
            // verify the required parameter 'stateCode' is set
            if (stateCode == null)
            {
                throw new KnetikException(400, "Missing required parameter 'stateCode' when calling UpdateStateTax");
            }

            mWebCallEvent.WebPath = "/tax/countries/{country_code_iso3}/states/{state_code}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "country_code_iso3" + "}", KnetikClient.ParameterToString(countryCodeIso3));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "state_code" + "}", KnetikClient.ParameterToString(stateCode));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(taxResource); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdateStateTaxStartTime  = DateTime.Now;
            mWebCallEvent.Context     = mUpdateStateTaxResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateStateTaxStartTime, "UpdateStateTax", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }