From b52710696d27bfef9ffc5ead0899d0e33fdf3abf Mon Sep 17 00:00:00 2001
From: Remco Koopmans <me@remcokoopmans.com>
Date: Tue, 20 Sep 2022 14:11:32 +0200
Subject: [PATCH] Change transcode to convert

---
 lib/Tinify/Source.php     |  4 ++--
 test/TinifySourceTest.php | 14 +++++++-------
 test/integration.php      |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/Tinify/Source.php b/lib/Tinify/Source.php
index 5c20e9c..304040a 100644
--- a/lib/Tinify/Source.php
+++ b/lib/Tinify/Source.php
@@ -42,8 +42,8 @@ public function store($options) {
         return new Result($response->headers, $response->body);
     }
 
-    public function transcode($types) {
-        $commands = array_merge($this->commands, array("type" => $types));
+    public function convert($options) {
+        $commands = array_merge($this->commands, array("convert" => $options));
         return new self($this->url, $commands);
     }
 
diff --git a/test/TinifySourceTest.php b/test/TinifySourceTest.php
index 786bc81..80c5fd8 100644
--- a/test/TinifySourceTest.php
+++ b/test/TinifySourceTest.php
@@ -226,7 +226,7 @@ public function testResizeShouldReturnSourceWithData() {
         $this->assertSame("{\"resize\":{\"width\":400}}", CurlMock::last(CURLOPT_POSTFIELDS));
     }
 
-    public function testTranscodeShouldReturnSource() {
+    public function testConvertShouldReturnSource() {
         Tinify\setKey("valid");
 
         CurlMock::register("https://api.tinify.com/shrink", array(
@@ -234,14 +234,14 @@ public function testTranscodeShouldReturnSource() {
         ));
 
         CurlMock::register("https://api.tinify.com/some/location", array(
-            "status" => 200, "body" => "transcoded file"
+            "status" => 200, "body" => "Convertd file"
         ));
 
-        $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->transcode("image/webp"));
+        $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->Convert(array("type" =>"image/webp")));
         $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS));
     }
 
-    public function testTranscodeShouldReturnSourceWithData() {
+    public function testConvertShouldReturnSourceWithData() {
         Tinify\setKey("valid");
 
         CurlMock::register("https://api.tinify.com/shrink", array(
@@ -249,11 +249,11 @@ public function testTranscodeShouldReturnSourceWithData() {
         ));
 
         CurlMock::register("https://api.tinify.com/some/location", array(
-            "status" => 200, "body" => "transcoded file"
+            "status" => 200, "body" => "Convertd file"
         ));
 
-        $this->assertSame("transcoded file", Tinify\Source::fromBuffer("png file")->transcode("image/webp")->toBuffer());
-        $this->assertSame("{\"type\":\"image\/webp\"}", CurlMock::last(CURLOPT_POSTFIELDS));
+        $this->assertSame("Convertd file", Tinify\Source::fromBuffer("png file")->convert(array("type" => "image/webp"))->toBuffer());
+        $this->assertSame("{\"convert\":{\"type\":\"image\/webp\"}}", CurlMock::last(CURLOPT_POSTFIELDS));
     }
 
     public function testTransformShouldReturnSource() {
diff --git a/test/integration.php b/test/integration.php
index 7167315..32226ac 100644
--- a/test/integration.php
+++ b/test/integration.php
@@ -78,9 +78,9 @@ public function testShouldPreserveMetadata() {
         $this->assertStringContainsString("Copyright Voormedia", $contents);
     }
 
-    public function testShouldTranscode() {
+    public function testShouldConvert() {
         $path = tempnam(sys_get_temp_dir(), "tinify-php");
-        self::$optimized->transcode(["image/webp"])->toFile($path);
+        self::$optimized->convert(array("type" => ["image/webp"]))->toFile($path);
 
         $size = filesize($path);
         $contents = fread(fopen($path, "rb"), $size);