package model;

import com.google.gson.JsonObject;

import java.io.IOException;

/**
 * {@link Transform Transform} subclass for image transformations.
 */
public class ImageTransform extends Transform {

    public ImageTransform(Client client, String source) {
        super(client, source);
    }

    public ImageTransform(FileLink fileLink) {
        super(fileLink);
    }

    public JsonObject debug() throws IOException {
        String tasksString = getTasksString();

        if (apiKey != null) {
            // TODO Implement when we add external transforms
            return null;
        } else {
            return processService.debug(tasksString, source).execute().body();
        }
    }

    // TODO This is just for demonstration, it should be confirmed when real transforms are added
    public ImageTransform resize(Integer width, Integer height, String fit, String align) {
        Task task = new Task("resize");
        task.addOption("width", width);
        task.addOption("height", height);
        task.addOption("fit", fit);
        task.addOption("align", align);
        tasks.add(task);
        return this;
    }
}

@@ -499,18 +499,16 @@
 != null)
- %7B
 %0A       
@@ -516,81 +516,89 @@
     
-// TODO Implement when we add external transforms%0A            return null
+return processService.debugExternal(apiKey, tasksString, source).execute().body()
 ;%0A  
@@ -606,17 +606,13 @@
     
- %7D
  else
- %7B
 %0A   
@@ -691,18 +691,8 @@
 ();%0A
-        %7D%0A
     

Update ImageTransform debug method for external transforms