-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDonation.php
More file actions
46 lines (40 loc) · 1.16 KB
/
Donation.php
File metadata and controls
46 lines (40 loc) · 1.16 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
45
46
<?php
declare(strict_types=1);
namespace MatchBot\Client;
use GuzzleHttp\Exception\GuzzleException;
use MatchBot\Application\Messenger\DonationUpserted;
use MatchBot\Domain\Salesforce18Id;
/**
* Client to push / upsert copies of donations to Salesforce.
*/
class Donation extends Common
{
/**
* @return Salesforce18Id<\MatchBot\Domain\Donation>|null
* @throws BadResponseException
* @throws NotFoundException on missing campaign in a sandbox
* @throws GuzzleException
*
* @psalm-suppress LessSpecificReturnStatement
* @psalm-suppress MoreSpecificReturnType
*
* @throws BadRequestException
*/
public function createOrUpdate(DonationUpserted $message): ?Salesforce18Id
{
$jsonSnapshot = $message->jsonSnapshot;
if ($jsonSnapshot === null) {
return null;
}
return $this->postUpdateToSalesforce(
$this->baseUri() . '/' . $message->uuid,
$jsonSnapshot,
$message->uuid,
'donation',
);
}
private function baseUri(): string
{
return $this->sfApiBaseUrl . '/donations/services/apexrest/v2.0/donations';
}
}