 
   linkCustomerIntoGroup: (customer, customerGroup) ->
     unless customerGroup?
-      Q customer
+      Q body: customer
     else
       data =
         id: customer.id

crypto = require 'crypto'
xmlHelpers = require '../lib/xmlhelpers'

class CustomerXmlImport

  NO_CUSTOMER_GROUP: 'NONE'
  CUSTOMER_GROUP_B2C_NAME: 'B2C'
  CUSTOMER_GROUP_B2B_NAME: 'B2B'
  CUSTOMER_GROUP_B2C_WITH_CARD_NAME: 'B2C with card'

  constructor: (options = {}) ->
    @client = new SphereClient options


  run: (xmlString) ->
    Q.all([
      @ensureCustomerGroupByName CUSTOMER_GROUP_B2B_NAME
      @ensureCustomerGroupByName CUSTOMER_GROUP_B2C_WITH_CARD_NAME
    ])
    .spread (b2bCustomerGroup, b2cWithCardCustomerGroup) =>
      customerGroupName2Id = {}
      customerGroupName2Id[CUSTOMER_GROUP_B2B_NAME] = b2bCustomerGroup.id
      customerGroupName2Id[CUSTOMER_GROUP_B2C_WITH_CARD_NAME] = b2cWithCardCustomerGroup.id
      @transform(xmlString, customerGroupName2Id)
    .then (customerData) =>
      @createOrUpdate customerData
