コード例 #1
0
        public AcumaticaCustomer PushCustomer(ShopifyCustomer shopifyRecord)
        {
            if (shopifyRecord.HasMatch())
            {
                // Already matched - push updates to Acumatica
                //
                UpdateCustomerInAcumatica(shopifyRecord);
                return(shopifyRecord.AcumaticaCustomer);
            }
            else
            {
                // No matching record
                //
                var customerInAcumatica = FindAcumaticaCustomer(shopifyRecord);

                if (customerInAcumatica == null)
                {
                    // Unable to locate Customer in Acumatica? Push brand new Customer to Acumatica API
                    //
                    _logService.Log(LogBuilder.CreateAcumaticaCustomer(shopifyRecord));
                    var newCustomer       = BuildCustomer(shopifyRecord);
                    var newCustomerResult = _customerClient.WriteCustomer(newCustomer);

                    // Then create a SQL record thereof
                    //
                    var acumaticaRecord = CreateAcumaticaCustomerRecord(shopifyRecord, newCustomerResult);

                    return(acumaticaRecord);
                }
                else
                {
                    // Found Customer in Acumatica! Create a SQL record for it...
                    //
                    _logService.Log(LogBuilder.AutomatchingCustomers(shopifyRecord, customerInAcumatica));
                    var acumaticaRecord = CreateAcumaticaCustomerRecord(shopifyRecord, customerInAcumatica);

                    // ... and then now push an update from Shopify into Acumatica
                    // TODO - make this update in Acumatica optional
                    //
                    UpdateCustomerInAcumatica(shopifyRecord);

                    return(acumaticaRecord);
                }
            }
        }
コード例 #2
0
 public static string AcumaticaCustId(this ShopifyCustomer input)
 {
     return(input.HasMatch() ? input.Match().AcumaticaCustomerId : null);
 }