/// <summary>
        ///  Updates an existing address with the specified ID
        /// </summary>
        /// <param name="id">ID of address to update</param>
        /// <param name="data"></param>
        /// <returns>Task of AddressResponseSingle</returns>
        public async System.Threading.Tasks.Task<AddressResponseSingle> EditAddressAsync (long? id, Address data)
        {
             ApiResponse<AddressResponseSingle> response = await EditAddressAsyncWithHttpInfo(id, data);
             return response.Data;

        }
        /// <summary>
        ///  Updates an existing address with the specified ID
        /// </summary>
        /// <param name="id">ID of address to update</param>
        /// <param name="data"></param>
        /// <returns>Task of ApiResponse (AddressResponseSingle)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<AddressResponseSingle>> EditAddressAsyncWithHttpInfo (long? id, Address data)
        {
            // verify the required parameter 'id' is set
            if (id == null) throw new ApiException(400, "Missing required parameter 'id' when calling EditAddress");
            // verify the required parameter 'data' is set
            if (data == null) throw new ApiException(400, "Missing required parameter 'data' when calling EditAddress");
            
    
            var path_ = "/addresses/{id}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (id != null) pathParams.Add("id", Configuration.ApiClient.ParameterToString(id)); // path parameter
            
            
            
            
            postBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            

            
            // authentication (jwt) required
            
            var apiKeyValue = Configuration.GetApiKeyWithPrefix("Authorization");
            if (!String.IsNullOrEmpty(apiKeyValue))
            {
                headerParams["Authorization"] = apiKeyValue;
            }
            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, 
                Method.PATCH, queryParams, postBody, headerParams, formParams, fileParams, 
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling EditAddress: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling EditAddress: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<AddressResponseSingle>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (AddressResponseSingle) Configuration.ApiClient.Deserialize(response, typeof(AddressResponseSingle)));
            
        }
        /// <summary>
        ///  Creates a new address
        /// </summary>
        /// <param name="data"></param>
        /// <returns>Task of AddressResponseSingle</returns>
        public async System.Threading.Tasks.Task<AddressResponseSingle> AddAddressAsync (Address data)
        {
             ApiResponse<AddressResponseSingle> response = await AddAddressAsyncWithHttpInfo(data);
             return response.Data;

        }
 /// <summary>
 ///  Updates an existing address with the specified ID
 /// </summary>
 /// <param name="id">ID of address to update</param> 
 /// <param name="data"></param> 
 /// <returns>AddressResponseSingle</returns>
 public AddressResponseSingle EditAddress (long? id, Address data)
 {
      ApiResponse<AddressResponseSingle> response = EditAddressWithHttpInfo(id, data);
      return response.Data;
 }
 /// <summary>
 ///  Creates a new address
 /// </summary>
 /// <param name="data"></param> 
 /// <returns>AddressResponseSingle</returns>
 public AddressResponseSingle AddAddress (Address data)
 {
      ApiResponse<AddressResponseSingle> response = AddAddressWithHttpInfo(data);
      return response.Data;
 }
        /// <summary>
        ///  Creates a new address
        /// </summary>
        /// <param name="data"></param> 
        /// <returns>ApiResponse of AddressResponseSingle</returns>
        public ApiResponse< AddressResponseSingle > AddAddressWithHttpInfo (Address data)
        {
            
            // verify the required parameter 'data' is set
            if (data == null)
                throw new ApiException(400, "Missing required parameter 'data' when calling SquiggleApi->AddAddress");
            
    
            var path_ = "/addresses";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            if (data.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            }
            else
            {
                postBody = data; // byte array
            }

            // authentication (jwt) required
            
            var apiKeyValue = Configuration.GetApiKeyWithPrefix("Authorization");
            if (!String.IsNullOrEmpty(apiKeyValue))
            {
                headerParams["Authorization"] = apiKeyValue;
            }
            
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
    
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling AddAddress: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling AddAddress: " + response.ErrorMessage, response.ErrorMessage);
    
            return new ApiResponse<AddressResponseSingle>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (AddressResponseSingle) Configuration.ApiClient.Deserialize(response, typeof(AddressResponseSingle)));
            
        }
 public void Init()
 {
     instance = new Address();
 }
        /// <summary>
        ///  Creates a new address
        /// </summary>
        /// <exception cref="Squiggle.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="data"></param>
        /// <returns>ApiResponse of Address</returns>
        public ApiResponse<Address> AddAddressWithHttpInfo(Address data)
        {
            // verify the required parameter 'data' is set
            if (data == null)
                throw new ApiException(400, "Missing required parameter 'data' when calling DefaultApi->AddAddress");

            var localVarPath = "/addresses";
            var localVarPathParams = new Dictionary<String, String>();
            var localVarQueryParams = new Dictionary<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);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (data != null && data.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            }
            else
            {
                localVarPostBody = data; // byte array
            }

            // authentication (jwt) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
                Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("AddAddress", localVarResponse);
                if (exception != null) throw exception;
            }

            return new ApiResponse<Address>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Address) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Address)));
        }
 /// <summary>
 ///  Creates a new address
 /// </summary>
 /// <exception cref="Squiggle.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="data"></param>
 /// <returns>Address</returns>
 public Address AddAddress(Address data)
 {
     ApiResponse<Address> localVarResponse = AddAddressWithHttpInfo(data);
      return localVarResponse.Data;
 }
 /// <summary>
 ///  Updates an existing address with the specified ID
 /// </summary>
 /// <exception cref="Squiggle.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="id">ID of address to update</param>
 /// <param name="data"></param>
 /// <returns>Address</returns>
 public Address EditAddress(long? id, Address data)
 {
     ApiResponse<Address> localVarResponse = EditAddressWithHttpInfo(id, data);
      return localVarResponse.Data;
 }
     /// <summary>
     ///  Updates an existing address with the specified ID
     /// </summary>
     /// <param name="id">ID of address to update</param> 
     /// <param name="data"></param> 
     /// <returns>AddressResponseSingle</returns>            
     public AddressResponseSingle EditAddress (long? id, Address data)
     {
         
         // verify the required parameter 'id' is set
         if (id == null) throw new ApiException(400, "Missing required parameter 'id' when calling EditAddress");
         
         // verify the required parameter 'data' is set
         if (data == null) throw new ApiException(400, "Missing required parameter 'data' when calling EditAddress");
         
 
         var path = "/addresses/{id}";
         path = path.Replace("{format}", "json");
         path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id));
         
 
         var queryParams = new Dictionary<String, String>();
         var headerParams = new Dictionary<String, String>();
         var formParams = new Dictionary<String, String>();
         var fileParams = new Dictionary<String, FileParameter>();
         String postBody = null;
 
         
         
         
         postBody = ApiClient.Serialize(data); // http body (model) parameter
         
 
         // authentication setting, if any
         String[] authSettings = new String[] { "jwt" };
 
         // make the HTTP request
         IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PATCH, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
 
         if (((int)response.StatusCode) >= 400)
             throw new ApiException ((int)response.StatusCode, "Error calling EditAddress: " + response.Content, response.Content);
         else if (((int)response.StatusCode) == 0)
             throw new ApiException ((int)response.StatusCode, "Error calling EditAddress: " + response.ErrorMessage, response.ErrorMessage);
 
         return (AddressResponseSingle) ApiClient.Deserialize(response.Content, typeof(AddressResponseSingle), response.Headers);
     }