From cc4635eaf9112e9e5e885a509b505d9bd800ac6d Mon Sep 17 00:00:00 2001 From: Genaro Madrid Date: Tue, 16 Feb 2016 15:59:47 -0600 Subject: [PATCH 1/2] change delete to static --- Readme.md | 8 +++++--- src/BaseObject.php | 4 ++-- tests/CertificateTest.php | 6 +----- tests/DocumentTest.php | 6 +----- tests/integration/CertificateCRUDTest.php | 2 +- tests/integration/DocumentCRUDTest.php | 2 +- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index 5a0b7a8..651354a 100644 --- a/Readme.md +++ b/Readme.md @@ -58,7 +58,7 @@ Document methods: $document = new Document([ 'file' => 'path/to/my-file.pdf', // OR - 'original_hash' => hash('sha256', 'some-file-contents'), + 'original_hash' => hash('sha256', file_get_contents('path/to/my-file.pdf')), 'signatories' => [ { 'name' => 'Signer 1', @@ -78,7 +78,8 @@ Document methods: - Delete ```php - $document->delete(); + use Mifiel\Document; + Document::delete('id'); ``` Certificate methods: @@ -120,7 +121,8 @@ Certificate methods: - Delete ```php - $certificate->delete(); + use Mifiel\Certificate; + Certificate::delete('id'); ``` ## Contributing diff --git a/src/BaseObject.php b/src/BaseObject.php index a62dada..8a81adb 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -54,10 +54,10 @@ public function save(){ $this->values = (object) json_decode($response->getBody()); } - public function delete(){ + public static function delete($id){ self::validateResuorceName(); $response = ApiClient::delete( - static::$resourceName . '/' . $this->id + static::$resourceName . '/' . $id ); } diff --git a/tests/CertificateTest.php b/tests/CertificateTest.php index ffbaef6..46e2ab2 100644 --- a/tests/CertificateTest.php +++ b/tests/CertificateTest.php @@ -87,17 +87,13 @@ public function testSetGetProperties() { } public function testDelete() { - $certificate = new Certificate([ - 'id' => 'some-id' - ]); - m::mock('alias:Mifiel\ApiClient') ->shouldReceive('delete') ->with('keys/some-id') ->andReturn(new \GuzzleHttp\Psr7\Response) ->once(); - $certificate->delete(); + Certificate::delete('some-id'); } public function testSat() { diff --git a/tests/DocumentTest.php b/tests/DocumentTest.php index 7f0cf15..a271a6a 100644 --- a/tests/DocumentTest.php +++ b/tests/DocumentTest.php @@ -88,17 +88,13 @@ public function testSetGetProperties() { } public function testDelete() { - $document = new Document([ - 'id' => 'some-id' - ]); - m::mock('alias:Mifiel\ApiClient') ->shouldReceive('delete') ->with('documents/some-id') ->andReturn(new \GuzzleHttp\Psr7\Response) ->once(); - $document->delete(); + Document::delete('some-id'); } } diff --git a/tests/integration/CertificateCRUDTest.php b/tests/integration/CertificateCRUDTest.php index 374311a..1edb09f 100644 --- a/tests/integration/CertificateCRUDTest.php +++ b/tests/integration/CertificateCRUDTest.php @@ -65,7 +65,7 @@ public function testSetProperties() { public function testDelete() { $certificate = $this->getCertificate(); if ($certificate) - $certificate->delete(); + Certificate::delete($certificate->id); $certificates = Certificate::all(); $this->assertEmpty($certificates); } diff --git a/tests/integration/DocumentCRUDTest.php b/tests/integration/DocumentCRUDTest.php index 27c6b10..506feba 100644 --- a/tests/integration/DocumentCRUDTest.php +++ b/tests/integration/DocumentCRUDTest.php @@ -98,7 +98,7 @@ public function testSetProperties() { public function testDelete() { $documents = Document::all(); foreach ($documents as $document) { - $document->delete(); + Document::delete($document->id); } $documents = Document::all(); $this->assertEmpty($documents); From af5a687f5ff9f525a98d5717fc71b4ff8d84176c Mon Sep 17 00:00:00 2001 From: Genaro Madrid Date: Tue, 16 Feb 2016 16:01:05 -0600 Subject: [PATCH 2/2] bump version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 32576d1..d11fcad 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mifiel/api-client", "description": "Mifiel API Client for PHP", - "version": "1.0.1", + "version": "2.0.0", "keywords": [ "Firma electrónica", "Firma electrónica Avanzada",