Skip to content

Commit

Permalink
Adding 2 methods.
Browse files Browse the repository at this point in the history
Adding the createGuarantee and cancelGuarantee methods.
  • Loading branch information
cristian-vatca-osf committed May 26, 2017
1 parent 6a457bc commit 58acece
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
45 changes: 43 additions & 2 deletions lib/Core/SignifydAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public function getCase($caseId, $entry = null)
public function closeCase($caseId)
{
$url = $this->makeUrl("cases/$caseId");
$data = array('status' => 'DISMISSED');
$curl = $this->_setupPutJsonRequest($url, $data);
$blob = array('status' => 'DISMISSED');
$curl = $this->_setupPutJsonRequest($url, $blob);
$response = curl_exec($curl);
$info = curl_getinfo($curl);
$error = curl_error($curl);
Expand All @@ -119,6 +119,47 @@ public function closeCase($caseId)
return json_decode($response);
}

public function createGuarantee($guarantee)
{
$curl = $this->_setupPostJsonRequest($this->makeUrl("guarantees"), $guarantee);
$response = curl_exec($curl);
$info = curl_getinfo($curl);
$this->logInfo("Raw request create guaranty: " . json_encode($info));

$error = curl_error($curl);
curl_close($curl);

if ($this->checkResultError($info['http_code'], $response)) {
return false;
}

$this->logInfo("Raw response create guaranty: " . $response);

return json_decode($response)->disposition;
}

public function cancelGuarantee($caseId)
{
$url = $this->makeUrl("cases/$caseId/guarantee");
$blob = ['guaranteeDisposition' => 'CANCELED'];
$curl = $this->_setupPutJsonRequest($url, $blob);
$response = curl_exec($curl);
$info = curl_getinfo($curl);
$error = curl_error($curl);
curl_close($curl);
if ($this->checkResultError($info['http_code'], $response)) {
return false;
}
if(!empty($error)){
$this->logError("Curl call error: {$error}");
return false;
}

$this->logInfo("Raw response create guaranty: " . $response);

return json_decode($response)->disposition;
}

public function updatePayment($caseId, $paymentUpdate)
{
$url = $this->makeUrl("cases/$caseId");
Expand Down
22 changes: 22 additions & 0 deletions lib/Models/Guarantee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Copyright 2015 SIGNIFYD Inc. All rights reserved.
* See LICENSE.txt for license details.
*/

namespace Signifyd\Models;

use Signifyd\Core\SignifydModel;

class Guarantee extends SignifydModel
{
/**
* Case id
*/
public $caseId;

public function __construct()
{
}

}

0 comments on commit 58acece

Please sign in to comment.