         else
           deferred.reject 'Problem on creating new product: ' + body
     deferred.promise
+
+  adjustmentsAfterCreation: (product, respondedProduct, deferred) ->
+    @addExternalImages(product, respondedProduct).then (respondedProduct) =>
+      @publishProduct(respondedProduct).then (msg) ->
+        deferred.resolve 'New product created.'
+      .fail (msg) ->
+        deferred.reject msg
+    .fail (msg) ->
+      deferred.reject msg
 
   publishProduct: (product, publish = true) ->
     deferred = Q.defer()

          deferred.reject "Problem on publishing product:\n" + humanReadable
        else
          deferred.reject 'Problem on publishing product: ' + body
    deferred.promise

  addExternalImages: (product) ->
    deferred = Q.defer()
    imageActions = @createExternalImageActions(product.masterVariant)
    for variant in product.variants
      imageActions = imageActions.concat(@createExternalImageActions(variant))
    if _.size(imageActions) is 0
      return deferred.resolve "No images."
    data =
      version: product.version
      actions: imageActions
    @rest.POST "/products/#{product.id}", JSON.stringify(date), (error, response, body) ->
      if error
        deferred.reject 'Error on adding external images to product: ' + error
      else
        if response.statusCode is 200
          deferred.resolve 'External images added.'
        else if response.statusCode is 400
          parsed = JSON.parse body
          humanReadable = JSON.stringify parsed, null, '  '
          deferred.reject "Problem on adding external images to product:\n" + humanReadable
        else
          deferred.reject 'Problem on adding external images to product: ' + body
    deferred.promise

  createExternalImageActions: (variant) ->

        variantId: variant.id
        image:
          url: image.url
          dimensions: image.dimensions
#          label: image.label
      actions.push action

    actions


module.exports = Import
