-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMandate.php
More file actions
44 lines (38 loc) · 1.29 KB
/
Mandate.php
File metadata and controls
44 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace MatchBot\Client;
use GuzzleHttp\Exception\GuzzleException;
use MatchBot\Application\Messenger\MandateUpserted;
use MatchBot\Domain\RegularGivingMandate;
use MatchBot\Domain\Salesforce18Id;
/**
* Client to push / upsert copies of Regular Giving mandates to Salesforce.
*/
class Mandate extends Common
{
use HashTrait;
/**
* @throws BadRequestException
* @throws BadResponseException
* @throws NotFoundException on missing campaign in a sandbox
* @throws GuzzleException
*
* @psalm-suppress LessSpecificReturnStatement
* @psalm-suppress MoreSpecificReturnType
*
* @return Salesforce18Id<RegularGivingMandate>
*/
public function createOrUpdate(MandateUpserted $message): Salesforce18Id
{
// We have both donations and mandates in the URI because in SF regular giving mandates
// are part of the donations API 'Site'. URI for a POST does not depend on content of mandate - mandate
// is identified by the URI in the request body.
$uri = $this->sfApiBaseUrl . '/donations/services/apexrest/v1.0/mandates/';
return $this->postUpdateToSalesforce(
$uri,
$message->jsonSnapshot,
$message->uuid,
'mandate',
);
}
}