1: <?php
2:
3: declare(strict_types=1);
4:
5: /*
6: * This file has been auto generated by Jane,
7: *
8: * Do no edit it directly.
9: */
10:
11: namespace NxSys\Library\Clients\Brex\API\Payments\Endpoint;
12:
13: class CreateTransfer extends \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\BaseEndpoint implements \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\Endpoint
14: {
15: use \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\EndpointTrait;
16:
17: /**
18: This endpoint creates a new transfer.
19:
20: Currently, the API can only create transfers for the following payment rails:
21: - ACH
22: - DOMESTIC_WIRE
23: - CHEQUE
24: - INTERNATIONAL_WIRES (For vendors already created through dashboard. Rate limited to 100/day - Please reach out to [email protected] if you need to do more)
25:
26: **Transaction Descriptions**
27: * For outgoing check payments, a successful transfer will return a response containing a description value with a format of `Check #<check number> to <recipient_name> - <external_memo>`.
28: * For book transfers (from one Brex Cash account to another), the recipient value will have a format of `<customer_account.dba_name> - <external_memo>` and the sender will have a format of `<target customer account's dba name> - <external_memo>`.
29: * For other payment rails, the format will be `<counterparty_name> - <external_memo>`, where Counterparty name is `payment_instrument.beneficiary_name` or `contact.name`.
30: For vendors created from the Payments API, the `counterparty_name` will be the `company_name` [field](/openapi/payments_api/#operation/createVendor!path=company_name&t=request).
31:
32: **Reminder**: You may not use the Brex API for any activity that requires a license or registration from any
33: *
34: * @param array $headerParameters {
35: *
36: * @var string $Idempotency-Key
37: * }
38: */
39: public function __construct(\NxSys\Library\Clients\Brex\API\Payments\Model\CreateTransferRequest $requestBody, array $headerParameters = [])
40: {
41: $this->body = $requestBody;
42: $this->headerParameters = $headerParameters;
43: }
44:
45: public function getMethod(): string
46: {
47: return 'POST';
48: }
49:
50: public function getUri(): string
51: {
52: return '/v1/transfers';
53: }
54:
55: public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
56: {
57: if ($this->body instanceof \NxSys\Library\Clients\Brex\API\Payments\Model\CreateTransferRequest) {
58: return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')];
59: }
60:
61: return [[], null];
62: }
63:
64: public function getExtraHeaders(): array
65: {
66: return ['Accept' => ['application/json']];
67: }
68:
69: protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
70: {
71: $optionsResolver = parent::getHeadersOptionsResolver();
72: $optionsResolver->setDefined(['Idempotency-Key']);
73: $optionsResolver->setRequired(['Idempotency-Key']);
74: $optionsResolver->setDefaults([]);
75: $optionsResolver->addAllowedTypes('Idempotency-Key', ['string']);
76:
77: return $optionsResolver;
78: }
79:
80: /**
81: * {@inheritdoc}
82: *
83: * @return \NxSys\Library\Clients\Brex\API\Payments\Model\Transfer|null
84: */
85: protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
86: {
87: $status = $response->getStatusCode();
88: $body = (string) $response->getBody();
89: if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
90: return $serializer->deserialize($body, 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\Transfer', 'json');
91: }
92: }
93:
94: public function getAuthenticationScopes(): array
95: {
96: return ['OAuth2'];
97: }
98: }
99: