Skip to content

Commit

Permalink
Get all agreements
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlysberg committed Oct 8, 2020
1 parent f809746 commit 68c622f
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Api/Recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SincosSoftware\Vipps\Model\Agreement\RequestStopAgreement;
use SincosSoftware\Vipps\Resource\Agreement\ChargeAgreement;
use SincosSoftware\Vipps\Resource\Agreement\ContinueAgreement;
use SincosSoftware\Vipps\Resource\Agreement\GetAllAgreements;
use SincosSoftware\Vipps\Resource\Agreement\GetChargeStatus;
use SincosSoftware\Vipps\Resource\Agreement\InitiateAgreement;
use SincosSoftware\Vipps\Resource\Agreement\GetAgreement;
Expand Down Expand Up @@ -132,4 +133,10 @@ public function getChargeStatus($agreementId, $chargeId)
return $resource->call();
}

public function getAll()
{
$resource = new GetAllAgreements($this->app, $this->getSubscriptionKey());
return $resource->call();
}

}
21 changes: 21 additions & 0 deletions src/Model/Agreement/ResponseGetAllAgreements.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace SincosSoftware\Vipps\Model\Agreement;

use JMS\Serializer\Annotation as Serializer;

/**
* Class ResponseGetOrderStatus
*
* @package Vipps\Model\Payment
*/
class ResponseGetAllAgreements
{

/**
* @var \SincosSoftware\Vipps\Model\Agreement\ResponseGetAgreement[]
* @Serializer\Type("array<SincosSoftware\Vipps\Model\Agreement\ResponseGetAgreement>")
*/
protected $agreements;

}
52 changes: 52 additions & 0 deletions src/Resource/Agreement/GetAllAgreements.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace SincosSoftware\Vipps\Resource\Agreement;

use SincosSoftware\Vipps\Resource\HttpMethod;
use SincosSoftware\Vipps\Resource\Payment\PaymentResourceBase;
use SincosSoftware\Vipps\VippsInterface;

class GetAllAgreements extends PaymentResourceBase
{

/**
* @var \SincosSoftware\Vipps\Resource\HttpMethod
*/
protected $method = HttpMethod::GET;

/**
* @var string
*/
protected $path = '/recurring/v2/agreements';

/**
* InitiatePayment constructor.
*
* @param \SincosSoftware\Vipps\VippsInterface $vipps
* @param string $subscription_key
*/
public function __construct(VippsInterface $vipps, $subscription_key)
{
parent::__construct($vipps, $subscription_key);
}

/**
* @return \SincosSoftware\Vipps\Model\Agreement\ResponseGetAgreement
*/
public function call()
{
$response = $this->makeCall();

$body = $response->getBody()->getContents();

$responseObject = $this
->getSerializer()
->deserialize(
$body,
'array<array>',
'json'
);

return $responseObject;
}
}

0 comments on commit 68c622f

Please sign in to comment.