Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
maztch committed Apr 18, 2017
2 parents 5accf80 + 592e4be commit a005341
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
43 changes: 43 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Changelog
---------

v1.0.11

* Bug AuthException warning

v1.0.10

* Remove unused vars
* Add try_pdf_repair
* Correct sample files typos

v1.0.9

* Add params check
* Remove unused classes

v1.0.8

* bug on response codes

v1.0.7

* Add Pdf to Pdf-A tool

v1.0.6

* fix warning method signature

v1.0.5

* Add library version
* bug fixes

v1.0.4

* added deleteFile Method

v1.0.3

* Add delete method for tasks
* Add getStatus method for tasks
17 changes: 12 additions & 5 deletions src/Ilovepdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ class Ilovepdf
// @var string|null The version of the Ilovepdf API to use for requests.
public static $apiVersion = 'v1';

const VERSION = 'php.1.0.10';
const VERSION = 'php.1.0.11';

public $token = null;

/*
* @var int delay in seconds, for timezone exceptions.
* Time sholud be UTC, but some servers maybe are not using NAT.
* This var is here to correct this delay. Currently 5400 seconds : 1h:30'
*/
public $timeDelay = 5400;

private $encrypted = false;
private $encryptKey;

Expand Down Expand Up @@ -108,9 +115,9 @@ public function getJWT()
$token = array_merge([
'iss' => $hostInfo,
'aud' => $hostInfo,
'iat' => $currentTime - 600, //add some "delay"
'nbf' => $currentTime - 600, //add some "delay"
'exp' => $currentTime + 3600 + 600 ////add some "delay"
'iat' => $currentTime - $this->timeDelay,
'nbf' => $currentTime - $this->timeDelay,
'exp' => $currentTime + 3600 + $this->timeDelay
], []);

// Set up id
Expand Down Expand Up @@ -164,11 +171,11 @@ public function sendRequest($method, $endpoint, $body=null)
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $this->getJWT()
), $body);

if ($response->code != '200' && $response->code != '201') {
if ($response->code == 401) {
throw new AuthException($response->body->name, $response->code, null, $response);
}

if ($endpoint == 'upload') {
throw new UploadException($response->body->error->message, $response->code, null, $response);
}
Expand Down
14 changes: 13 additions & 1 deletion src/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ class Task extends Ilovepdf
// @var string The Ilovepdf API Task ID.
public $task = null;
//private $server = null;
public $files = array();
public $files = [];
public $tool;
public $packaged_filename;
public $output_filename;
public $ignore_errors = true;
public $ignore_password = true;
public $try_pdf_repair = true;
public $meta = [];

/**
* Task constructor.
Expand Down Expand Up @@ -314,4 +315,15 @@ public function setFileEncryption($value, $encryptKey=null)

parent::setFileEncryption($value, $encryptKey);
}

/**
* @param $key
* @param $value
*
* set meta values as http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf (page 844)
*/
public function setMeta($key, $value)
{
$this->meta[$key] = $value;
}
}

0 comments on commit a005341

Please sign in to comment.