Skip to content

Commit

Permalink
Added KeymediaClient::addMediaVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed Jan 23, 2015
1 parent cbb3968 commit a1f0353
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Keyteq/Keymedia/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => ''));
Expand Down
8 changes: 8 additions & 0 deletions src/Keyteq/Keymedia/API/RestConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/Keyteq/Keymedia/KeymediaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a1f0353

Please sign in to comment.