public static VirtoCommerceDomainCustomerModelContact ToServiceModel(this CustomerInfo customer)
        {
            var retVal = new VirtoCommerceDomainCustomerModelContact();
            retVal.InjectFrom<NullableAndEnumValueInjecter>(customer);
            if (customer.Addresses != null)
            {
                retVal.Addresses = customer.Addresses.Select(x => x.ToServiceModel()).ToList();
            }
            if (!string.IsNullOrEmpty(customer.Email))
            {
                retVal.Emails = new[] { customer.Email }.ToList();
            }
            retVal.FullName = customer.FullName;

            return retVal;
        }
Пример #2
0
        public static VirtoCommerceDomainCustomerModelContact ToServiceModel(this CustomerInfo customer)
        {
            var retVal = new VirtoCommerceDomainCustomerModelContact();

            retVal.InjectFrom <NullableAndEnumValueInjecter>(customer);
            if (customer.Addresses != null)
            {
                retVal.Addresses = customer.Addresses.Select(x => x.ToServiceModel()).ToList();
            }
            if (!string.IsNullOrEmpty(customer.Email))
            {
                retVal.Emails = new[] { customer.Email }.ToList();
            }
            retVal.FullName = customer.FullName;

            return(retVal);
        }
Пример #3
0
        public static CustomerInfo ToWebModel(this VirtoCommerceDomainCustomerModelContact contact)
        {
            var retVal = new CustomerInfo();

            retVal.InjectFrom(contact);

            retVal.IsRegisteredUser = true;
            if (contact.Addresses != null)
            {
                retVal.Addresses = contact.Addresses.Select(a => a.ToWebModel()).ToList();
            }

            retVal.DefaultBillingAddress  = retVal.Addresses.FirstOrDefault(a => (a.Type & AddressType.Billing) == AddressType.Billing);
            retVal.DefaultShippingAddress = retVal.Addresses.FirstOrDefault(a => (a.Type & AddressType.Shipping) == AddressType.Shipping);

            // TODO: Need separate properties for first, middle and last name
            if (!string.IsNullOrEmpty(contact.FullName))
            {
                var nameParts = contact.FullName.Split(_nameSeparator, 2);

                if (nameParts.Length > 0)
                {
                    retVal.FirstName = nameParts[0];
                }

                if (nameParts.Length > 1)
                {
                    retVal.LastName = nameParts[1];
                }
            }

            if (contact.Emails != null)
            {
                retVal.Email = contact.Emails.FirstOrDefault();
            }

            return(retVal);
        }
        /// <summary>
        /// Create contact 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contact"></param>
        /// <returns>Task of ApiResponse (VirtoCommerceDomainCustomerModelContact)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<VirtoCommerceDomainCustomerModelContact>> CustomerModuleCreateContactAsyncWithHttpInfo (VirtoCommerceDomainCustomerModelContact contact)
        {
            // verify the required parameter 'contact' is set
            if (contact == null)
                throw new ApiException(400, "Missing required parameter 'contact' when calling CustomerManagementModuleApi->CustomerModuleCreateContact");

            var localVarPath = "/api/contacts";
            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", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml"
            };
            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 (contact.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(contact); // http body (model) parameter
            }
            else
            {
                localVarPostBody = contact; // byte array
            }


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

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException (localVarStatusCode, "Error calling CustomerModuleCreateContact: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException (localVarStatusCode, "Error calling CustomerModuleCreateContact: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            return new ApiResponse<VirtoCommerceDomainCustomerModelContact>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (VirtoCommerceDomainCustomerModelContact) Configuration.ApiClient.Deserialize(localVarResponse, typeof(VirtoCommerceDomainCustomerModelContact)));
            
        }
        /// <summary>
        /// Create contact 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contact"></param>
        /// <returns>Task of VirtoCommerceDomainCustomerModelContact</returns>
        public async System.Threading.Tasks.Task<VirtoCommerceDomainCustomerModelContact> CustomerModuleCreateContactAsync (VirtoCommerceDomainCustomerModelContact contact)
        {
             ApiResponse<VirtoCommerceDomainCustomerModelContact> localVarResponse = await CustomerModuleCreateContactAsyncWithHttpInfo(contact);
             return localVarResponse.Data;

        }
 /// <summary>
 /// Create contact 
 /// </summary>
 /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="contact"></param>
 /// <returns>VirtoCommerceDomainCustomerModelContact</returns>
 public VirtoCommerceDomainCustomerModelContact CustomerModuleCreateContact (VirtoCommerceDomainCustomerModelContact contact)
 {
      ApiResponse<VirtoCommerceDomainCustomerModelContact> localVarResponse = CustomerModuleCreateContactWithHttpInfo(contact);
      return localVarResponse.Data;
 }
        /// <summary>
        /// Update contact 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="contact"></param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task CustomerModuleUpdateContactAsync (VirtoCommerceDomainCustomerModelContact contact)
        {
             await CustomerModuleUpdateContactAsyncWithHttpInfo(contact);

        }
 /// <summary>
 /// Update contact 
 /// </summary>
 /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="contact"></param>
 /// <returns></returns>
 public void CustomerModuleUpdateContact (VirtoCommerceDomainCustomerModelContact contact)
 {
      CustomerModuleUpdateContactWithHttpInfo(contact);
 }