From a1f03533d6ec737b9089a67ec97b2544bf741b84 Mon Sep 17 00:00:00 2001 From: Raymond Julin Date: Fri, 23 Jan 2015 14:18:32 +0100 Subject: [PATCH] Added KeymediaClient::addMediaVersion() --- src/Keyteq/Keymedia/API.php | 6 ++++++ src/Keyteq/Keymedia/API/RestConnector.php | 8 ++++++++ src/Keyteq/Keymedia/KeymediaClient.php | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/Keyteq/Keymedia/API.php b/src/Keyteq/Keymedia/API.php index 90c5960..1b853ea 100644 --- a/src/Keyteq/Keymedia/API.php +++ b/src/Keyteq/Keymedia/API.php @@ -82,6 +82,12 @@ public function postMedia($file, $name, array $tags = array(), array $attributes return $result; } + public function addMediaVersion($id, array $transformations = array()) + { + $response = $this->connector->addMediaVersion($id, $transformations); + return json_decode($response, true); + } + public function isConnected() { $response = $this->connector->getCollection('media', array('q' => '')); diff --git a/src/Keyteq/Keymedia/API/RestConnector.php b/src/Keyteq/Keymedia/API/RestConnector.php index f7b19da..14e1807 100644 --- a/src/Keyteq/Keymedia/API/RestConnector.php +++ b/src/Keyteq/Keymedia/API/RestConnector.php @@ -40,6 +40,14 @@ public function postResource($resourceName, array $parameters) return $request->perform(); } + public function addMediaVersion($id, array $parameters) + { + $path = "/media/{$id}/versions.json"; + $url = $this->buildUrl($path); + $request = $this->requestBuilder->buildRequest($url, 'POST', $parameters, true); + return $request->perform(); + } + protected function buildRequest($path, $method, $parameters) { $url = $this->buildUrl($path); diff --git a/src/Keyteq/Keymedia/KeymediaClient.php b/src/Keyteq/Keymedia/KeymediaClient.php index ec497c1..84a26e5 100644 --- a/src/Keyteq/Keymedia/KeymediaClient.php +++ b/src/Keyteq/Keymedia/KeymediaClient.php @@ -41,6 +41,14 @@ public function postMedia($file, $name, array $tags = array(), array $attributes return $this->api->postMedia($file, $name, $tags, $attributes); } + public function addMediaVersion($id, array $transformations = array()) + { + if (isset($transformations['coords'])) { + $transformations['coords'] = implode(',', $transformations['coords']); + } + return $this->api->addMediaVersion($id, $transformations); + } + public function isConnected() { return $this->api->isConnected();