private void OnUpdateAddressResponse(KnetikRestResponse response) { if (!string.IsNullOrEmpty(response.Error)) { throw new KnetikException("Error calling UpdateAddress: " + response.Error); } UpdateAddressData = (SavedAddressResource)KnetikClient.Deserialize(response.Content, typeof(SavedAddressResource), response.Headers); KnetikLogger.LogResponse(mUpdateAddressStartTime, "UpdateAddress", string.Format("Response received successfully:\n{0}", UpdateAddressData)); if (UpdateAddressComplete != null) { UpdateAddressComplete(response.ResponseCode, UpdateAddressData); } }
/// <inheritdoc /> /// <summary> /// Update an address <b>Permissions Needed:</b> USERS_ADMIN or owner /// </summary> /// <param name="userId">The id of the user</param> /// <param name="id">The id of the address</param> /// <param name="savedAddressResource">The saved address resource object</param> public void UpdateAddress(string userId, int?id, SavedAddressResource savedAddressResource) { // verify the required parameter 'userId' is set if (userId == null) { throw new KnetikException(400, "Missing required parameter 'userId' when calling UpdateAddress"); } // verify the required parameter 'id' is set if (id == null) { throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateAddress"); } mWebCallEvent.WebPath = "/users/{user_id}/addresses/{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(savedAddressResource); // 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 mUpdateAddressStartTime = DateTime.Now; mWebCallEvent.Context = mUpdateAddressResponseContext; mWebCallEvent.RequestType = KnetikRequestType.PUT; KnetikLogger.LogRequest(mUpdateAddressStartTime, "UpdateAddress", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
/// <summary> /// Update an address <b>Permissions Needed:</b> USERS_ADMIN or owner /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="userId">The id of the user</param> /// <param name="id">The id of the address</param> /// <param name="savedAddressResource">The saved address resource object (optional)</param> /// <returns>ApiResponse of SavedAddressResource</returns> public ApiResponse <SavedAddressResource> UpdateAddressWithHttpInfo(string userId, int?id, SavedAddressResource savedAddressResource = null) { // verify the required parameter 'userId' is set if (userId == null) { throw new ApiException(400, "Missing required parameter 'userId' when calling Users_AddressesApi->UpdateAddress"); } // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling Users_AddressesApi->UpdateAddress"); } var localVarPath = "/users/{user_id}/addresses/{id}"; 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 (userId != null) { localVarPathParams.Add("user_id", Configuration.ApiClient.ParameterToString(userId)); // path parameter } if (id != null) { localVarPathParams.Add("id", Configuration.ApiClient.ParameterToString(id)); // path parameter } if (savedAddressResource != null && savedAddressResource.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(savedAddressResource); // http body (model) parameter } else { localVarPostBody = savedAddressResource; // 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("UpdateAddress", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <SavedAddressResource>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (SavedAddressResource)Configuration.ApiClient.Deserialize(localVarResponse, typeof(SavedAddressResource)))); }
/// <summary> /// Update an address <b>Permissions Needed:</b> USERS_ADMIN or owner /// </summary> /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="userId">The id of the user</param> /// <param name="id">The id of the address</param> /// <param name="savedAddressResource">The saved address resource object (optional)</param> /// <returns>SavedAddressResource</returns> public SavedAddressResource UpdateAddress(string userId, int?id, SavedAddressResource savedAddressResource = null) { ApiResponse <SavedAddressResource> localVarResponse = UpdateAddressWithHttpInfo(userId, id, savedAddressResource); return(localVarResponse.Data); }