/// <inheritdoc /> /// <summary> /// Create a currency <b>Permissions Needed:</b> CURRENCIES_ADMIN /// </summary> /// <param name="currency">The currency object</param> public void CreateCurrency(CurrencyResource currency) { mWebCallEvent.WebPath = "/currencies"; 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(currency); // 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 mCreateCurrencyStartTime = DateTime.Now; mWebCallEvent.Context = mCreateCurrencyResponseContext; mWebCallEvent.RequestType = KnetikRequestType.POST; KnetikLogger.LogRequest(mCreateCurrencyStartTime, "CreateCurrency", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
private void OnGetCurrencyByGeoLocationResponse(KnetikRestResponse response) { if (!string.IsNullOrEmpty(response.Error)) { throw new KnetikException("Error calling GetCurrencyByGeoLocation: " + response.Error); } GetCurrencyByGeoLocationData = (CurrencyResource)KnetikClient.Deserialize(response.Content, typeof(CurrencyResource), response.Headers); KnetikLogger.LogResponse(mGetCurrencyByGeoLocationStartTime, "GetCurrencyByGeoLocation", string.Format("Response received successfully:\n{0}", GetCurrencyByGeoLocationData)); if (GetCurrencyByGeoLocationComplete != null) { GetCurrencyByGeoLocationComplete(response.ResponseCode, GetCurrencyByGeoLocationData); } }
/// <inheritdoc /> /// <summary> /// Update a currency <b>Permissions Needed:</b> CURRENCIES_ADMIN /// </summary> /// <param name="code">The currency code</param> /// <param name="currency">The currency object</param> public void UpdateCurrency(string code, CurrencyResource currency) { // verify the required parameter 'code' is set if (code == null) { throw new KnetikException(400, "Missing required parameter 'code' when calling UpdateCurrency"); } mWebCallEvent.WebPath = "/currencies/{code}"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "code" + "}", KnetikClient.ParameterToString(code)); mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(currency); // 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 mUpdateCurrencyStartTime = DateTime.Now; mWebCallEvent.Context = mUpdateCurrencyResponseContext; mWebCallEvent.RequestType = KnetikRequestType.PUT; KnetikLogger.LogRequest(mUpdateCurrencyStartTime, "UpdateCurrency", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
/// <summary> /// Update a currency <b>Permissions Needed:</b> CURRENCIES_ADMIN /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="code">The currency code</param> /// <param name="currency">The currency object (optional)</param> /// <returns>ApiResponse of Object(void)</returns> public ApiResponse <Object> UpdateCurrencyWithHttpInfo(string code, CurrencyResource currency = null) { // verify the required parameter 'code' is set if (code == null) { throw new ApiException(400, "Missing required parameter 'code' when calling CurrenciesApi->UpdateCurrency"); } var localVarPath = "/currencies/{code}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (code != null) { localVarPathParams.Add("code", Configuration.ApiClient.ParameterToString(code)); // path parameter } if (currency != null && currency.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(currency); // http body (model) parameter } else { localVarPostBody = currency; // byte array } // authentication (oauth2_client_credentials_grant) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // authentication (oauth2_password_grant) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath, Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("UpdateCurrency", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null)); }
/// <summary> /// Update a currency <b>Permissions Needed:</b> CURRENCIES_ADMIN /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="code">The currency code</param> /// <param name="currency">The currency object (optional)</param> /// <returns></returns> public void UpdateCurrency(string code, CurrencyResource currency = null) { UpdateCurrencyWithHttpInfo(code, currency); }
/// <summary> /// Create a currency <b>Permissions Needed:</b> CURRENCIES_ADMIN /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="currency">The currency object (optional)</param> /// <returns>CurrencyResource</returns> public CurrencyResource CreateCurrency(CurrencyResource currency = null) { ApiResponse <CurrencyResource> localVarResponse = CreateCurrencyWithHttpInfo(currency); return(localVarResponse.Data); }