| 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; |
| 12: | |
| 13: | class Client extends \NxSys\Library\Clients\Brex\API\Payments\Runtime\Client\Client |
| 14: | { |
| 15: | /** |
| 16: | This endpoint creates a new incoming transfer. You may use use any eligible bank account connection to fund (ACH Debit) |
| 17: | any active Brex cash account. |
| 18: | |
| 19: | **Reminder**: You may not use the Brex API for any activity that requires a license or registration from any. |
| 20: | * |
| 21: | * @param \NxSys\Library\Clients\Brex\API\Payments\Model\CreateIncomingTransferRequest $requestBody |
| 22: | * @param array $headerParameters { |
| 23: | * |
| 24: | * @var string $Idempotency-Key |
| 25: | * } |
| 26: | * |
| 27: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 28: | * |
| 29: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\Transfer|\Psr\Http\Message\ResponseInterface|null |
| 30: | */ |
| 31: | public function createIncomingTransfer(Model\CreateIncomingTransferRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
| 32: | { |
| 33: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\CreateIncomingTransfer($requestBody, $headerParameters), $fetch); |
| 34: | } |
| 35: | |
| 36: | /** |
| 37: | This endpoint lists all bank connections that are eligible to make ACH transfers to Brex cash account |
| 38: | |
| 39: | * |
| 40: | * @param array $queryParameters { |
| 41: | * |
| 42: | * @var string $cursor |
| 43: | * @var int $limit |
| 44: | * } |
| 45: | * |
| 46: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 47: | * |
| 48: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\PageBankConnection|\Psr\Http\Message\ResponseInterface|null |
| 49: | * |
| 50: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListLinkedAccountsBadRequestException |
| 51: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListLinkedAccountsUnauthorizedException |
| 52: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListLinkedAccountsForbiddenException |
| 53: | */ |
| 54: | public function listLinkedAccounts(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
| 55: | { |
| 56: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\ListLinkedAccounts($queryParameters), $fetch); |
| 57: | } |
| 58: | |
| 59: | /** |
| 60: | This endpoint lists existing transfers for an account. |
| 61: | |
| 62: | Currently, the API can only return transfers for the following payment rails: |
| 63: | - ACH |
| 64: | - DOMESTIC_WIRE |
| 65: | - CHEQUE |
| 66: | - INTERNATIONAL_WIRE |
| 67: | |
| 68: | * |
| 69: | * @param array $queryParameters { |
| 70: | * |
| 71: | * @var string $cursor |
| 72: | * @var int $limit |
| 73: | * } |
| 74: | * |
| 75: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 76: | * |
| 77: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\PageTransfer|\Psr\Http\Message\ResponseInterface|null |
| 78: | * |
| 79: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersBadRequestException |
| 80: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersUnauthorizedException |
| 81: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersForbiddenException |
| 82: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListTransfersInternalServerErrorException |
| 83: | */ |
| 84: | public function listTransfers(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
| 85: | { |
| 86: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\ListTransfers($queryParameters), $fetch); |
| 87: | } |
| 88: | |
| 89: | /** |
| 90: | This endpoint creates a new transfer. |
| 91: | |
| 92: | Currently, the API can only create transfers for the following payment rails: |
| 93: | - ACH |
| 94: | - DOMESTIC_WIRE |
| 95: | - CHEQUE |
| 96: | - 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) |
| 97: | |
| 98: | **Transaction Descriptions** |
| 99: | * 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>`. |
| 100: | * 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>`. |
| 101: | * For other payment rails, the format will be `<counterparty_name> - <external_memo>`, where Counterparty name is `payment_instrument.beneficiary_name` or `contact.name`. |
| 102: | 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). |
| 103: | |
| 104: | **Reminder**: You may not use the Brex API for any activity that requires a license or registration from any |
| 105: | * |
| 106: | * @param \NxSys\Library\Clients\Brex\API\Payments\Model\CreateTransferRequest $requestBody |
| 107: | * @param array $headerParameters { |
| 108: | * |
| 109: | * @var string $Idempotency-Key |
| 110: | * } |
| 111: | * |
| 112: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 113: | * |
| 114: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\Transfer|\Psr\Http\Message\ResponseInterface|null |
| 115: | */ |
| 116: | public function createTransfer(Model\CreateTransferRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
| 117: | { |
| 118: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\CreateTransfer($requestBody, $headerParameters), $fetch); |
| 119: | } |
| 120: | |
| 121: | /** |
| 122: | This endpoint gets a transfer by ID. |
| 123: | |
| 124: | * |
| 125: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 126: | * |
| 127: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\Transfer|\Psr\Http\Message\ResponseInterface|null |
| 128: | * |
| 129: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetTransfersByIdBadRequestException |
| 130: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetTransfersByIdUnauthorizedException |
| 131: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetTransfersByIdForbiddenException |
| 132: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetTransfersByIdInternalServerErrorException |
| 133: | */ |
| 134: | public function getTransfersById(string $id, string $fetch = self::FETCH_OBJECT) |
| 135: | { |
| 136: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\GetTransfersById($id), $fetch); |
| 137: | } |
| 138: | |
| 139: | /** |
| 140: | This endpoint lists all existing vendors for an account. |
| 141: | Takes an optional parameter to match by vendor name. |
| 142: | |
| 143: | * |
| 144: | * @param array $queryParameters { |
| 145: | * |
| 146: | * @var string $cursor |
| 147: | * @var int $limit |
| 148: | * @var string $name |
| 149: | * } |
| 150: | * |
| 151: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 152: | * |
| 153: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\PageVendorResponse|\Psr\Http\Message\ResponseInterface|null |
| 154: | * |
| 155: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListVendorsBadRequestException |
| 156: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListVendorsUnauthorizedException |
| 157: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\ListVendorsForbiddenException |
| 158: | */ |
| 159: | public function listVendors(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
| 160: | { |
| 161: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\ListVendors($queryParameters), $fetch); |
| 162: | } |
| 163: | |
| 164: | /** |
| 165: | This endpoint creates a new vendor. |
| 166: | |
| 167: | * |
| 168: | * @param \NxSys\Library\Clients\Brex\API\Payments\Model\CreateVendorRequest $requestBody |
| 169: | * @param array $headerParameters { |
| 170: | * |
| 171: | * @var string $Idempotency-Key |
| 172: | * } |
| 173: | * |
| 174: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 175: | * |
| 176: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\VendorResponse|\Psr\Http\Message\ResponseInterface|null |
| 177: | */ |
| 178: | public function createVendor(Model\CreateVendorRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
| 179: | { |
| 180: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\CreateVendor($requestBody, $headerParameters), $fetch); |
| 181: | } |
| 182: | |
| 183: | /** |
| 184: | This endpoint deletes a vendor by ID. |
| 185: | |
| 186: | * |
| 187: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 188: | * |
| 189: | * @return \Psr\Http\Message\ResponseInterface|null |
| 190: | */ |
| 191: | public function deleteVendor(string $id, string $fetch = self::FETCH_OBJECT) |
| 192: | { |
| 193: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\DeleteVendor($id), $fetch); |
| 194: | } |
| 195: | |
| 196: | /** |
| 197: | This endpoint gets a vendor by ID. |
| 198: | |
| 199: | * |
| 200: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 201: | * |
| 202: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\VendorResponse|\Psr\Http\Message\ResponseInterface|null |
| 203: | * |
| 204: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdBadRequestException |
| 205: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdUnauthorizedException |
| 206: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdForbiddenException |
| 207: | * @throws \NxSys\Library\Clients\Brex\API\Payments\Exception\GetVendorByIdInternalServerErrorException |
| 208: | */ |
| 209: | public function getVendorById(string $id, string $fetch = self::FETCH_OBJECT) |
| 210: | { |
| 211: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\GetVendorById($id), $fetch); |
| 212: | } |
| 213: | |
| 214: | /** |
| 215: | Updates an existing vendor by ID. |
| 216: | |
| 217: | * |
| 218: | * @param \NxSys\Library\Clients\Brex\API\Payments\Model\UpdateVendorRequest $requestBody |
| 219: | * @param array $headerParameters { |
| 220: | * |
| 221: | * @var string $Idempotency-Key |
| 222: | * } |
| 223: | * |
| 224: | * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) |
| 225: | * |
| 226: | * @return \NxSys\Library\Clients\Brex\API\Payments\Model\VendorResponse|\Psr\Http\Message\ResponseInterface|null |
| 227: | */ |
| 228: | public function updateVendor(string $id, Model\UpdateVendorRequest $requestBody, array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
| 229: | { |
| 230: | return $this->executeEndpoint(new \NxSys\Library\Clients\Brex\API\Payments\Endpoint\UpdateVendor($id, $requestBody, $headerParameters), $fetch); |
| 231: | } |
| 232: | |
| 233: | public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) |
| 234: | { |
| 235: | if (null === $httpClient) { |
| 236: | $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); |
| 237: | $plugins = []; |
| 238: | $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://platform.brexapis.com'); |
| 239: | $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); |
| 240: | if (count($additionalPlugins) > 0) { |
| 241: | $plugins = array_merge($plugins, $additionalPlugins); |
| 242: | } |
| 243: | $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); |
| 244: | } |
| 245: | $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); |
| 246: | $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); |
| 247: | $normalizers = [new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \NxSys\Library\Clients\Brex\API\Payments\Normalizer\JaneObjectNormalizer()]; |
| 248: | if (count($additionalNormalizers) > 0) { |
| 249: | $normalizers = array_merge($normalizers, $additionalNormalizers); |
| 250: | } |
| 251: | $serializer = new \Symfony\Component\Serializer\Serializer($normalizers, [new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(['json_decode_associative' => true]))]); |
| 252: | |
| 253: | return new static($httpClient, $requestFactory, $serializer, $streamFactory); |
| 254: | } |
| 255: | } |
| 256: |