Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
Implemented method getApiKey to retrieve API key before each request.
  • Loading branch information
brunoceleste committed Jun 19, 2019
1 parent 72bbd1c commit c588c62
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/Coconut.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,38 +146,35 @@ public static function config($options=array()) {

class Coconut_Job {
public static function create($options=array()) {
$api_key = null;
if(isset($options['api_key'])) {
$api_key = $options['api_key'];
}
$api_key = self::getApiKey($options);

return Coconut::submit(Coconut::config($options), $api_key);
}

public static function get($jid, $options=array()) {
$api_key = null;
if(isset($options['api_key'])) {
$api_key = $options['api_key'];
}
$api_key = self::getApiKey($options);

return Coconut::get('/v1/jobs/' . $jid, $api_key);
}

public static function getAllMetadata($jid, $options=array()) {
$api_key = null;
if(isset($options['api_key'])) {
$api_key = $options['api_key'];
}
$api_key = self::getApiKey($options);

return Coconut::get('/v1/metadata/jobs/' . $jid, $api_key);
}

public static function getMetadataFor($jid, $source_or_output, $options=array()) {
$api_key = null;
if(isset($options['api_key'])) {
$api_key = $options['api_key'];
}
$api_key = self::getApiKey($options);

return Coconut::get('/v1/metadata/jobs/' . $jid . '/' . $source_or_output, $api_key);
}


private static function getApiKey($options=array()) {
$api_key = null;
if(isset($options['api_key'])) {
$api_key = $options['api_key'];
}
return $api_key;
}
}

0 comments on commit c588c62

Please sign in to comment.