| 1 |
<?php |
| 2 |
namespace Payplug\Resource; |
| 3 |
use Payplug; |
| 4 |
|
| 5 |
/** |
| 6 |
* A Card |
| 7 |
*/ |
| 8 |
class Card extends APIResource |
| 9 |
{ |
| 10 |
/** |
| 11 |
* The factory method that constructs the API resource. |
| 12 |
* |
| 13 |
* @param array $attributes the default attributes. |
| 14 |
* |
| 15 |
* @return Card The new resource. |
| 16 |
*/ |
| 17 |
public static function fromAttributes(array $attributes) |
| 18 |
{ |
| 19 |
$object = new Card(); |
| 20 |
$object->initialize($attributes); |
| 21 |
return $object; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Delete the card. |
| 26 |
* |
| 27 |
* @param Payplug\Card $card the card or card id |
| 28 |
* @param Payplug\Payplug $payplug the client configuration |
| 29 |
* |
| 30 |
* @return Card the deleted card or null on error |
| 31 |
* |
| 32 |
* @throws Payplug\Exception\ConfigurationNotSetException |
| 33 |
*/ |
| 34 |
public static function deleteCard($card, Payplug\Payplug $payplug = null) |
| 35 |
{ |
| 36 |
if ($payplug === null) { |
| 37 |
$payplug = Payplug\Payplug::getDefaultConfiguration(); |
| 38 |
} |
| 39 |
|
| 40 |
if ($card instanceof Card) { |
| 41 |
$card = $card->id; |
| 42 |
} |
| 43 |
|
| 44 |
$httpClient = new Payplug\Core\HttpClient($payplug); |
| 45 |
$response = $httpClient->delete(Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::CARD_RESOURCE, $card)); |
| 46 |
|
| 47 |
return $response; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Delete the card. |
| 52 |
* |
| 53 |
* @param Payplug\Payplug $payplug the client configuration |
| 54 |
* |
| 55 |
* @throws Payplug\Exception\ConfigurationNotSetException |
| 56 |
*/ |
| 57 |
public function delete(Payplug\Payplug $payplug = null) |
| 58 |
{ |
| 59 |
self::deleteCard($this->id, $payplug); |
| 60 |
} |
| 61 |
} |
| 62 |
|