/// <inheritdoc />
        /// <summary>
        /// Create a bundle item The SKU for the bundle itself must be unique and there can only be one SKU.  Extra notes for price_override:  The price of all the items (multiplied by the quantity) must equal the price of the bundle.  With individual prices set, items will be processed individually and can be refunded as such.  However, if all prices are set to null, the price of the bundle will be used and will be treated as one item. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; BUNDLES_ADMIN
        /// </summary>
        /// <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="bundleItem">The bundle item object</param>
        public void CreateBundleItem(bool?cascade, BundleItem bundleItem)
        {
            mWebCallEvent.WebPath = "/store/bundles";
            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 (cascade != null)
            {
                mWebCallEvent.QueryParams["cascade"] = KnetikClient.ParameterToString(cascade);
            }

            mWebCallEvent.PostBody = KnetikClient.Serialize(bundleItem); // 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
            mCreateBundleItemStartTime = DateTime.Now;
            mWebCallEvent.Context      = mCreateBundleItemResponseContext;
            mWebCallEvent.RequestType  = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateBundleItemStartTime, "CreateBundleItem", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Add a user log entry &lt;b&gt;Permissions Needed:&lt;/b&gt; owner
        /// </summary>
        /// <param name="logEntry">The user log entry to be added</param>
        public void AddUserLog(UserActionLog logEntry)
        {
            mWebCallEvent.WebPath = "/audit/logs";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(logEntry); // 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
            mAddUserLogStartTime      = DateTime.Now;
            mWebCallEvent.Context     = mAddUserLogResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mAddUserLogStartTime, "AddUserLog", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Mark an invoice paid with Google Mark an invoice paid with Google. Verifies signature from Google and treats the developerPayload field inside the json payload as the id of the invoice to pay. Returns the transaction ID if successful. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; ANY
        /// </summary>
        /// <param name="request">The request for paying an invoice through a Google in-app payment</param>
        public void HandleGooglePayment(GooglePaymentRequest request)
        {
            mWebCallEvent.WebPath = "/payment/provider/google/payments";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            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
            mHandleGooglePaymentStartTime = DateTime.Now;
            mWebCallEvent.Context         = mHandleGooglePaymentResponseContext;
            mWebCallEvent.RequestType     = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mHandleGooglePaymentStartTime, "HandleGooglePayment", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Create a device &lt;b&gt;Permissions Needed:&lt;/b&gt; ANY
        /// </summary>
        /// <param name="device">device</param>
        public void CreateDevice(DeviceResource device)
        {
            // verify the required parameter 'device' is set
            if (device == null)
            {
                throw new KnetikException(400, "Missing required parameter 'device' when calling CreateDevice");
            }

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

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(device); // 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
            mCreateDeviceStartTime    = DateTime.Now;
            mWebCallEvent.Context     = mCreateDeviceResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateDeviceStartTime, "CreateDevice", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Send a websocket message Sends a websocket message to one or more users. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; MESSAGING_ADMIN
        /// </summary>
        /// <param name="websocketResource">The new websocket message to be sent</param>
        public void SendWebsocket(WebsocketMessageResource websocketResource)
        {
            mWebCallEvent.WebPath = "/messaging/websocket-message";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(websocketResource); // 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
            mSendWebsocketStartTime   = DateTime.Now;
            mWebCallEvent.Context     = mSendWebsocketResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mSendWebsocketStartTime, "SendWebsocket", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Create a shipping template Shipping Templates define a type of shipping and the properties they have.
        /// </summary>
        /// <param name="shippingTemplateResource">The new shipping template</param>
        public void CreateShippingTemplate(ItemTemplateResource shippingTemplateResource)
        {
            mWebCallEvent.WebPath = "/store/shipping/templates";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(shippingTemplateResource); // 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
            mCreateShippingTemplateStartTime = DateTime.Now;
            mWebCallEvent.Context            = mCreateShippingTemplateResponseContext;
            mWebCallEvent.RequestType        = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateShippingTemplateStartTime, "CreateShippingTemplate", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Esempio n. 7
0
        /// <inheritdoc />
        /// <summary>
        /// Link facebook account Links the current user account to a facebook account, using the acccess token from facebook. Can also be used to update the access token after it has expired. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; Non-facebook user token
        /// </summary>
        /// <param name="facebookToken">The token from facebook</param>
        public void LinkAccounts(FacebookToken facebookToken)
        {
            mWebCallEvent.WebPath = "/social/facebook/users";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(facebookToken); // 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
            mLinkAccountsStartTime    = DateTime.Now;
            mWebCallEvent.Context     = mLinkAccountsResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mLinkAccountsStartTime, "LinkAccounts", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Returns a string representation of the provided expression &lt;b&gt;Permissions Needed:&lt;/b&gt; BRE_RULE_ENGINE_RULES_ADMIN
        /// </summary>
        /// <param name="expression">The expression</param>
        public void GetBREExpressionAsString(Expressionobject expression)
        {
            mWebCallEvent.WebPath = "/bre/rules/expression-as-string";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(expression); // 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
            mGetBREExpressionAsStringStartTime = DateTime.Now;
            mWebCallEvent.Context     = mGetBREExpressionAsStringResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mGetBREExpressionAsStringStartTime, "GetBREExpressionAsString", "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);
        }
Esempio n. 10
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 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);
        }
Esempio n. 12
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>
        /// 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>
        /// 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);
        }
Esempio n. 15
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);
        }
        /// <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>
        /// Add device users &lt;b&gt;Permissions Needed:&lt;/b&gt; DEVICES_ADMIN or owner
        /// </summary>
        /// <param name="userResources">userResources</param>
        /// <param name="id">id</param>
        public void AddDeviceUsers(List <SimpleUserResource> userResources, string id)
        {
            // verify the required parameter 'userResources' is set
            if (userResources == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userResources' when calling AddDeviceUsers");
            }
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling AddDeviceUsers");
            }

            mWebCallEvent.WebPath = "/devices/{id}/users";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            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(userResources); // 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
            mAddDeviceUsersStartTime  = DateTime.Now;
            mWebCallEvent.Context     = mAddDeviceUsersResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mAddDeviceUsersStartTime, "AddDeviceUsers", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Set redirect uris for a client &lt;b&gt;Permissions Needed:&lt;/b&gt; CLIENTS_ADMIN
        /// </summary>
        /// <param name="clientKey">The key of the client</param>
        /// <param name="redirectList">A list of unique redirect uris</param>
        public void SetClientRedirectUris(string clientKey, List <string> redirectList)
        {
            // verify the required parameter 'clientKey' is set
            if (clientKey == null)
            {
                throw new KnetikException(400, "Missing required parameter 'clientKey' when calling SetClientRedirectUris");
            }

            mWebCallEvent.WebPath = "/auth/clients/{client_key}/redirect-uris";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "client_key" + "}", KnetikClient.ParameterToString(clientKey));

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(redirectList); // 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
            mSetClientRedirectUrisStartTime = DateTime.Now;
            mWebCallEvent.Context           = mSetClientRedirectUrisResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mSetClientRedirectUrisStartTime, "SetClientRedirectUris", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Enable or disable a rule This is helpful for turning off systems rules which cannot be deleted or modified otherwise. &lt;br&gt;&lt;br&gt;&lt;b&gt;Permissions Needed:&lt;/b&gt; BRE_RULE_ENGINE_RULES_ADMIN
        /// </summary>
        /// <param name="id">The id of the rule</param>
        /// <param name="enabled">The boolean value</param>
        public void SetBRERule(string id, BooleanResource enabled)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling SetBRERule");
            }

            mWebCallEvent.WebPath = "/bre/rules/{id}/enabled";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            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(enabled); // 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
            mSetBRERuleStartTime      = DateTime.Now;
            mWebCallEvent.Context     = mSetBRERuleResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mSetBRERuleStartTime, "SetBRERule", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Esempio n. 20
0
        /// <inheritdoc />
        /// <summary>
        /// Set permissions for a role &lt;b&gt;Permissions Needed:&lt;/b&gt; ROLES_ADMIN
        /// </summary>
        /// <param name="role">The role value</param>
        /// <param name="permissionsList">The list of unique permissions</param>
        public void SetPermissionsForRole(string role, List <string> permissionsList)
        {
            // verify the required parameter 'role' is set
            if (role == null)
            {
                throw new KnetikException(400, "Missing required parameter 'role' when calling SetPermissionsForRole");
            }

            mWebCallEvent.WebPath = "/auth/roles/{role}/permissions";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "role" + "}", KnetikClient.ParameterToString(role));

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(permissionsList); // 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
            mSetPermissionsForRoleStartTime = DateTime.Now;
            mWebCallEvent.Context           = mSetPermissionsForRoleResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mSetPermissionsForRoleStartTime, "SetPermissionsForRole", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Esempio n. 21
0
        /// <inheritdoc />
        /// <summary>
        /// Redeem friendship token Immediately connects the requested user with the user mapped by the provided invite token. &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; if logged in</param>
        /// <param name="token">The invite token</param>
        public void RedeemFriendshipToken(string userId, StringWrapper token)
        {
            // verify the required parameter 'userId' is set
            if (userId == null)
            {
                throw new KnetikException(400, "Missing required parameter 'userId' when calling RedeemFriendshipToken");
            }

            mWebCallEvent.WebPath = "/users/{user_id}/friends/tokens";
            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;

            mWebCallEvent.PostBody = KnetikClient.Serialize(token); // 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
            mRedeemFriendshipTokenStartTime = DateTime.Now;
            mWebCallEvent.Context           = mRedeemFriendshipTokenResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mRedeemFriendshipTokenStartTime, "RedeemFriendshipToken", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        /// <inheritdoc />
        /// <summary>
        /// Modifies or sets the order shipping address &lt;b&gt;Permissions Needed:&lt;/b&gt; SHOPPING_CARTS_ADMIN or owner
        /// </summary>
        /// <param name="id">The id of the cart</param>
        /// <param name="cartShippingAddressRequest">The cart shipping address request object</param>
        public void UpdateShippingAddress(string id, CartShippingAddressRequest cartShippingAddressRequest)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateShippingAddress");
            }

            mWebCallEvent.WebPath = "/carts/{id}/shipping-address";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            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(cartShippingAddressRequest); // 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
            mUpdateShippingAddressStartTime = DateTime.Now;
            mWebCallEvent.Context           = mUpdateShippingAddressResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateShippingAddressStartTime, "UpdateShippingAddress", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Esempio n. 23
0
        /// <inheritdoc />
        /// <summary>
        /// Update a permission &lt;b&gt;Permissions Needed:&lt;/b&gt; PERMISSIONS_ADMIN
        /// </summary>
        /// <param name="permission">The permission value</param>
        /// <param name="permissionResource">The permission resource object</param>
        public void UpdatePermission(string permission, PermissionResource permissionResource)
        {
            // verify the required parameter 'permission' is set
            if (permission == null)
            {
                throw new KnetikException(400, "Missing required parameter 'permission' when calling UpdatePermission");
            }

            mWebCallEvent.WebPath = "/auth/permissions/{permission}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "permission" + "}", KnetikClient.ParameterToString(permission));

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

            mWebCallEvent.PostBody = KnetikClient.Serialize(permissionResource); // 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
            mUpdatePermissionStartTime = DateTime.Now;
            mWebCallEvent.Context      = mUpdatePermissionResponseContext;
            mWebCallEvent.RequestType  = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdatePermissionStartTime, "UpdatePermission", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Esempio n. 24
0
        /// <inheritdoc />
        /// <summary>
        /// Add your vote to a poll &lt;b&gt;Permissions Needed:&lt;/b&gt; POLLS_ADMIN or POLLS_USER
        /// </summary>
        /// <param name="id">The poll id</param>
        /// <param name="answerKey">The answer key</param>
        public void AnswerPoll(string id, StringWrapper answerKey)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling AnswerPoll");
            }

            mWebCallEvent.WebPath = "/media/polls/{id}/response";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            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(answerKey); // 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
            mAnswerPollStartTime      = DateTime.Now;
            mWebCallEvent.Context     = mAnswerPollResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mAnswerPollStartTime, "AnswerPoll", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }