From 6cae1c3052fb96e1d97515559d6e3302fc8f95de Mon Sep 17 00:00:00 2001 From: Eric Viana Date: Tue, 4 Aug 2026 16:55:21 -0300 Subject: [PATCH] feat(types): widen 99 nullable response fields, v3.4.0 The spec marks these fields nullable but the SDK typed them as non-nullable, so decoding a null crashed or type checks rejected valid handling. Mechanical widening following the codebase's existing nullable idioms; audit nullability count goes 99 to 0. Claude-Session: https://claude.ai/code/session_01F1stiNzuNtJXoXtiW9ZCbs --- src/BlindPay.php | 2 +- src/Resources/BankAccounts/BankAccounts.php | 6 +- .../CustodialWallets/CustodialWallets.php | 10 ++- src/Resources/Customers/Customers.php | 38 +++++---- src/Resources/Payins/Payins.php | 70 ++++++++-------- src/Resources/Payins/Quotes.php | 28 +++---- src/Resources/Payouts/Payouts.php | 84 ++++++++++--------- src/Resources/Quotes/Quotes.php | 38 ++++----- src/Resources/Transfers/Transfers.php | 16 ++-- .../VirtualAccounts/VirtualAccounts.php | 36 ++++---- src/Resources/Wallets/BlockchainWallets.php | 12 +-- src/Resources/Wallets/OfframpWallets.php | 16 ++-- src/Resources/Webhooks/Webhooks.php | 16 ++-- src/Types/TrackingComplete.php | 4 +- src/Types/TrackingLiquidity.php | 4 +- src/Types/TrackingTransaction.php | 4 +- 16 files changed, 206 insertions(+), 178 deletions(-) diff --git a/src/BlindPay.php b/src/BlindPay.php index 0cbd465..16f58ed 100644 --- a/src/BlindPay.php +++ b/src/BlindPay.php @@ -39,7 +39,7 @@ class BlindPay implements ApiClientInterface { private const BASE_URL = 'https://api.blindpay.com/v1/'; - private const VERSION = '3.3.0'; + private const VERSION = '3.4.0'; private Client $httpClient; diff --git a/src/Resources/BankAccounts/BankAccounts.php b/src/Resources/BankAccounts/BankAccounts.php index 23dece0..05938ab 100644 --- a/src/Resources/BankAccounts/BankAccounts.php +++ b/src/Resources/BankAccounts/BankAccounts.php @@ -93,7 +93,7 @@ public function __construct( public ?Country $swiftIntermediaryBankCountry, public ?string $tronWalletHash, public ?array $offrampWallets, - public DateTimeImmutable $createdAt, + public ?DateTimeImmutable $createdAt, public ?string $tedBankCode = null, public ?string $tedBranchCode = null, public ?string $tedCpfCnpj = null, @@ -152,7 +152,9 @@ public static function fromArray(array $data): self swiftIntermediaryBankCountry: isset($data['swift_intermediary_bank_country']) ? Country::from($data['swift_intermediary_bank_country']) : null, tronWalletHash: $data['tron_wallet_hash'] ?? null, offrampWallets: $data['offramp_wallets'] ?? null, - createdAt: new DateTimeImmutable($data['created_at']), + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, tedBankCode: $data['ted_bank_code'] ?? null, tedBranchCode: $data['ted_branch_code'] ?? null, tedCpfCnpj: $data['ted_cpf_cnpj'] ?? null, diff --git a/src/Resources/CustodialWallets/CustodialWallets.php b/src/Resources/CustodialWallets/CustodialWallets.php index 26e1a84..56ee5e1 100644 --- a/src/Resources/CustodialWallets/CustodialWallets.php +++ b/src/Resources/CustodialWallets/CustodialWallets.php @@ -16,8 +16,8 @@ public function __construct( public string $customerId, public string $instanceId, public Network $network, - public string $address, - public DateTimeImmutable $createdAt + public ?string $address, + public ?DateTimeImmutable $createdAt ) {} public static function fromArray(array $data): self @@ -27,8 +27,10 @@ public static function fromArray(array $data): self customerId: $data['customer_id'], instanceId: $data['instance_id'], network: Network::from($data['network']), - address: $data['address'], - createdAt: new DateTimeImmutable($data['created_at']) + address: $data['address'] ?? null, + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null ); } } diff --git a/src/Resources/Customers/Customers.php b/src/Resources/Customers/Customers.php index 410fe5b..7069372 100644 --- a/src/Resources/Customers/Customers.php +++ b/src/Resources/Customers/Customers.php @@ -1185,13 +1185,13 @@ public function __construct( public string $id, public string $customerId, public LimitIncreaseRequestStatus $status, - public float $daily, - public float $monthly, - public float $perTransaction, - public string $supportingDocumentFile, - public LimitIncreaseRequestSupportingDocumentType $supportingDocumentType, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt, + public ?float $daily, + public ?float $monthly, + public ?float $perTransaction, + public ?string $supportingDocumentFile, + public ?LimitIncreaseRequestSupportingDocumentType $supportingDocumentType, + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt, public ?int $approvedPerTransaction = null, public ?int $approvedDaily = null, public ?int $approvedMonthly = null @@ -1203,13 +1203,17 @@ public static function fromArray(array $data): self id: $data['id'], customerId: $data['customer_id'], status: LimitIncreaseRequestStatus::from($data['status']), - daily: (float) $data['daily'], - monthly: (float) $data['monthly'], - perTransaction: (float) $data['per_transaction'], - supportingDocumentFile: $data['supporting_document_file'], - supportingDocumentType: LimitIncreaseRequestSupportingDocumentType::from($data['supporting_document_type']), - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']), + daily: isset($data['daily']) ? (float) $data['daily'] : null, + monthly: isset($data['monthly']) ? (float) $data['monthly'] : null, + perTransaction: isset($data['per_transaction']) ? (float) $data['per_transaction'] : null, + supportingDocumentFile: $data['supporting_document_file'] ?? null, + supportingDocumentType: isset($data['supporting_document_type']) ? LimitIncreaseRequestSupportingDocumentType::from($data['supporting_document_type']) : null, + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null, approvedPerTransaction: isset($data['approved_per_transaction']) ? (int) $data['approved_per_transaction'] : null, approvedDaily: isset($data['approved_daily']) ? (int) $data['approved_daily'] : null, approvedMonthly: isset($data['approved_monthly']) ? (int) $data['approved_monthly'] : null @@ -1221,9 +1225,9 @@ public static function fromArray(array $data): self { public function __construct( public string $customerId, - public float $daily, - public float $monthly, - public float $perTransaction, + public ?float $daily, + public ?float $monthly, + public ?float $perTransaction, public string $supportingDocumentFile, public LimitIncreaseRequestSupportingDocumentType $supportingDocumentType ) {} diff --git a/src/Resources/Payins/Payins.php b/src/Resources/Payins/Payins.php index f3d3409..83620d2 100644 --- a/src/Resources/Payins/Payins.php +++ b/src/Resources/Payins/Payins.php @@ -149,10 +149,10 @@ public function __construct( public string $routingNumber, public string $accountNumber, public string $accountType, - public string $swiftBicCode, - public BankAch $ach, - public BankWire $wire, - public BankRtp $rtp, + public ?string $swiftBicCode, + public ?BankAch $ach, + public ?BankWire $wire, + public ?BankRtp $rtp, public BankBeneficiary $beneficiary, public BankReceivingBank $receivingBank, public ?string $swiftAccountNumber = null, @@ -165,10 +165,10 @@ public static function fromArray(array $data): self routingNumber: $data['routing_number'], accountNumber: $data['account_number'], accountType: $data['account_type'], - swiftBicCode: $data['swift_bic_code'], - ach: BankAch::fromArray($data['ach']), - wire: BankWire::fromArray($data['wire']), - rtp: BankRtp::fromArray($data['rtp']), + swiftBicCode: $data['swift_bic_code'] ?? null, + ach: isset($data['ach']) ? BankAch::fromArray($data['ach']) : null, + wire: isset($data['wire']) ? BankWire::fromArray($data['wire']) : null, + rtp: isset($data['rtp']) ? BankRtp::fromArray($data['rtp']) : null, beneficiary: BankBeneficiary::fromArray($data['beneficiary']), receivingBank: BankReceivingBank::fromArray($data['receiving_bank']), swiftAccountNumber: $data['swift_account_number'] ?? null, @@ -183,9 +183,9 @@ public function toArray(): array 'account_number' => $this->accountNumber, 'account_type' => $this->accountType, 'swift_bic_code' => $this->swiftBicCode, - 'ach' => $this->ach->toArray(), - 'wire' => $this->wire->toArray(), - 'rtp' => $this->rtp->toArray(), + 'ach' => $this->ach?->toArray(), + 'wire' => $this->wire?->toArray(), + 'rtp' => $this->rtp?->toArray(), 'beneficiary' => $this->beneficiary->toArray(), 'receiving_bank' => $this->receivingBank->toArray(), 'swift_account_number' => $this->swiftAccountNumber, @@ -202,21 +202,21 @@ public function __construct( public TransactionStatus $status, public string $payinQuoteId, public string $instanceId, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt, + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt, public string $type, public string $paymentMethod, - public float $senderAmount, - public float $receiverAmount, + public ?float $senderAmount, + public ?float $receiverAmount, public StablecoinToken $token, - public float $partnerFeeAmount, - public float $totalFeeAmount, - public float $commercialQuotation, - public float $blindpayQuotation, + public ?float $partnerFeeAmount, + public ?float $totalFeeAmount, + public ?float $commercialQuotation, + public ?float $blindpayQuotation, public string $currency, public float $billingFee, public string $name, - public string $address, + public ?string $address, public Network $network, public BankDetails $BankDetails, public ?string $pixCode = null, @@ -248,21 +248,25 @@ public static function fromArray(array $data): self status: TransactionStatus::from($data['status']), payinQuoteId: $data['payin_quote_id'], instanceId: $data['instance_id'], - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']), + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null, type: $data['type'], paymentMethod: $data['payment_method'], - senderAmount: (float) $data['sender_amount'], - receiverAmount: (float) $data['receiver_amount'], + senderAmount: isset($data['sender_amount']) ? (float) $data['sender_amount'] : null, + receiverAmount: isset($data['receiver_amount']) ? (float) $data['receiver_amount'] : null, token: StablecoinToken::from($data['token']), - partnerFeeAmount: (float) $data['partner_fee_amount'], - totalFeeAmount: (float) $data['total_fee_amount'], - commercialQuotation: (float) $data['commercial_quotation'], - blindpayQuotation: (float) $data['blindpay_quotation'], + partnerFeeAmount: isset($data['partner_fee_amount']) ? (float) $data['partner_fee_amount'] : null, + totalFeeAmount: isset($data['total_fee_amount']) ? (float) $data['total_fee_amount'] : null, + commercialQuotation: isset($data['commercial_quotation']) ? (float) $data['commercial_quotation'] : null, + blindpayQuotation: isset($data['blindpay_quotation']) ? (float) $data['blindpay_quotation'] : null, currency: $data['currency'], billingFee: (float) $data['billing_fee'], name: $data['name'], - address: $data['address'], + address: $data['address'] ?? null, network: Network::from($data['network']), BankDetails: BankDetails::fromArray($data['blindpay_bank_details']), pixCode: $data['pix_code'] ?? null, @@ -372,8 +376,8 @@ public function toQueryString(): string public function __construct( public string $id, public TransactionStatus $status, - public string $customerId, - public float $receiverAmount, + public ?string $customerId, + public ?float $receiverAmount, public BankDetails $BankDetails, public ?string $pixCode = null, public ?string $memoCode = null, @@ -389,8 +393,8 @@ public static function fromArray(array $data): self return new self( id: $data['id'], status: TransactionStatus::from($data['status']), - customerId: $data['customer_id'], - receiverAmount: (float) $data['receiver_amount'], + customerId: $data['customer_id'] ?? null, + receiverAmount: isset($data['receiver_amount']) ? (float) $data['receiver_amount'] : null, BankDetails: BankDetails::fromArray($data['blindpay_bank_details']), pixCode: $data['pix_code'] ?? null, memoCode: $data['memo_code'] ?? null, diff --git a/src/Resources/Payins/Quotes.php b/src/Resources/Payins/Quotes.php index 5a9ff96..9bd50dc 100644 --- a/src/Resources/Payins/Quotes.php +++ b/src/Resources/Payins/Quotes.php @@ -21,7 +21,7 @@ enum PaymentMethod: string readonly class PayerRules { public function __construct( - public array $pixAllowedTaxIds, + public ?array $pixAllowedTaxIds, public ?string $transfersAllowedTaxId = null, public ?array $pseAllowedTaxIds = null, public ?string $pseFullName = null, @@ -50,7 +50,7 @@ public function toArray(): array public static function fromArray(array $data): self { return new self( - pixAllowedTaxIds: $data['pix_allowed_tax_ids'] ?? [], + pixAllowedTaxIds: $data['pix_allowed_tax_ids'] ?? null, transfersAllowedTaxId: $data['transfers_allowed_tax_id'] ?? null, pseAllowedTaxIds: $data['pse_allowed_tax_ids'] ?? null, pseFullName: $data['pse_full_name'] ?? null, @@ -66,13 +66,13 @@ public static function fromArray(array $data): self readonly class CreatePayinQuoteInput { public function __construct( - public string $blockchainWalletId, + public ?string $blockchainWalletId, public CurrencyType $currencyType, public PaymentMethod $paymentMethod, public float $requestAmount, public StablecoinToken $token, - public bool $coverFees, - public PayerRules $payerRules, + public ?bool $coverFees, + public ?PayerRules $payerRules, public ?string $partnerFeeId = null, public ?bool $isOtc = null, public ?string $walletId = null @@ -87,7 +87,7 @@ public function toArray(): array 'request_amount' => $this->requestAmount, 'token' => $this->token->value, 'cover_fees' => $this->coverFees, - 'payer_rules' => $this->payerRules->toArray(), + 'payer_rules' => $this->payerRules?->toArray(), ]; if ($this->partnerFeeId !== null) { @@ -111,10 +111,10 @@ public function toArray(): array public function __construct( public string $id, public int $expiresAt, - public float $commercialQuotation, - public float $blindpayQuotation, - public float $receiverAmount, - public float $senderAmount, + public ?float $commercialQuotation, + public ?float $blindpayQuotation, + public ?float $receiverAmount, + public ?float $senderAmount, public ?float $partnerFeeAmount = null, public ?float $flatFee = null ) {} @@ -124,10 +124,10 @@ public static function fromArray(array $data): self return new self( id: $data['id'], expiresAt: (int) $data['expires_at'], - commercialQuotation: (float) $data['commercial_quotation'], - blindpayQuotation: (float) $data['blindpay_quotation'], - receiverAmount: (float) $data['receiver_amount'], - senderAmount: (float) $data['sender_amount'], + commercialQuotation: isset($data['commercial_quotation']) ? (float) $data['commercial_quotation'] : null, + blindpayQuotation: isset($data['blindpay_quotation']) ? (float) $data['blindpay_quotation'] : null, + receiverAmount: isset($data['receiver_amount']) ? (float) $data['receiver_amount'] : null, + senderAmount: isset($data['sender_amount']) ? (float) $data['sender_amount'] : null, partnerFeeAmount: isset($data['partner_fee_amount']) ? (float) $data['partner_fee_amount'] : null, flatFee: isset($data['flat_fee']) ? (float) $data['flat_fee'] : null ); diff --git a/src/Resources/Payouts/Payouts.php b/src/Resources/Payouts/Payouts.php index c2d19aa..9363b90 100644 --- a/src/Resources/Payouts/Payouts.php +++ b/src/Resources/Payouts/Payouts.php @@ -44,34 +44,34 @@ public function __construct( public string $id, public TransactionStatus $status, public string $senderWalletAddress, - public string $signedTransaction, + public ?string $signedTransaction, public string $quoteId, public string $instanceId, public TrackingTransaction $trackingTransaction, public PayoutTrackingPayment $trackingPayment, - public TrackingLiquidity $trackingLiquidity, + public ?TrackingLiquidity $trackingLiquidity, public TrackingComplete $trackingComplete, public TrackingPartnerFee $trackingPartnerFee, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt, - public string $imageUrl, - public string $firstName, - public string $lastName, - public string $legalName, + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt, + public ?string $imageUrl, + public ?string $firstName, + public ?string $lastName, + public ?string $legalName, public Network $network, public StablecoinToken $token, - public string $description, - public float $senderAmount, - public float $receiverAmount, - public float $partnerFeeAmount, - public float $commercialQuotation, - public float $blindpayQuotation, - public float $totalFeeAmount, - public float $customerLocalAmount, + public ?string $description, + public ?float $senderAmount, + public ?float $receiverAmount, + public ?float $partnerFeeAmount, + public ?float $commercialQuotation, + public ?float $blindpayQuotation, + public ?float $totalFeeAmount, + public ?float $customerLocalAmount, public Currency $currency, - public string $transactionDocumentFile, - public TransactionDocumentType $transactionDocumentType, - public string $transactionDocumentId, + public ?string $transactionDocumentFile, + public ?TransactionDocumentType $transactionDocumentType, + public ?string $transactionDocumentId, public string $name, public Rail $type, public ?string $pixKey, @@ -102,7 +102,7 @@ public function __construct( public ?string $swiftAccountNumberIban, public ?string $transfersAccount, public ?ArgentinaTransferType $transfersType, - public bool $hasVirtualAccount, + public ?bool $hasVirtualAccount, public ?string $partnerFeeId = null, public ?string $tedBankCode = null, public ?string $tedBranchCode = null, @@ -119,34 +119,38 @@ public static function fromArray(array $data): self id: $data['id'], status: TransactionStatus::from($data['status']), senderWalletAddress: $data['sender_wallet_address'], - signedTransaction: $data['signed_transaction'], + signedTransaction: $data['signed_transaction'] ?? null, quoteId: $data['quote_id'], instanceId: $data['instance_id'], trackingTransaction: TrackingTransaction::fromArray($data['tracking_transaction']), trackingPayment: PayoutTrackingPayment::fromArray($data['tracking_payment']), - trackingLiquidity: TrackingLiquidity::fromArray($data['tracking_liquidity']), + trackingLiquidity: isset($data['tracking_liquidity']) ? TrackingLiquidity::fromArray($data['tracking_liquidity']) : null, trackingComplete: TrackingComplete::fromArray($data['tracking_complete']), trackingPartnerFee: TrackingPartnerFee::fromArray($data['tracking_partner_fee']), - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']), - imageUrl: $data['image_url'], - firstName: $data['first_name'], - lastName: $data['last_name'], - legalName: $data['legal_name'], + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null, + imageUrl: $data['image_url'] ?? null, + firstName: $data['first_name'] ?? null, + lastName: $data['last_name'] ?? null, + legalName: $data['legal_name'] ?? null, network: Network::from($data['network']), token: StablecoinToken::from($data['token']), - description: $data['description'], - senderAmount: (float) $data['sender_amount'], - receiverAmount: (float) $data['receiver_amount'], - partnerFeeAmount: (float) $data['partner_fee_amount'], - commercialQuotation: (float) $data['commercial_quotation'], - blindpayQuotation: (float) $data['blindpay_quotation'], - totalFeeAmount: (float) $data['total_fee_amount'], - customerLocalAmount: (float) $data['customer_local_amount'], + description: $data['description'] ?? null, + senderAmount: isset($data['sender_amount']) ? (float) $data['sender_amount'] : null, + receiverAmount: isset($data['receiver_amount']) ? (float) $data['receiver_amount'] : null, + partnerFeeAmount: isset($data['partner_fee_amount']) ? (float) $data['partner_fee_amount'] : null, + commercialQuotation: isset($data['commercial_quotation']) ? (float) $data['commercial_quotation'] : null, + blindpayQuotation: isset($data['blindpay_quotation']) ? (float) $data['blindpay_quotation'] : null, + totalFeeAmount: isset($data['total_fee_amount']) ? (float) $data['total_fee_amount'] : null, + customerLocalAmount: isset($data['customer_local_amount']) ? (float) $data['customer_local_amount'] : null, currency: Currency::from($data['currency']), - transactionDocumentFile: $data['transaction_document_file'], - transactionDocumentType: TransactionDocumentType::from($data['transaction_document_type']), - transactionDocumentId: $data['transaction_document_id'], + transactionDocumentFile: $data['transaction_document_file'] ?? null, + transactionDocumentType: isset($data['transaction_document_type']) ? TransactionDocumentType::from($data['transaction_document_type']) : null, + transactionDocumentId: $data['transaction_document_id'] ?? null, name: $data['name'], type: Rail::from($data['type']), pixKey: $data['pix_key'] ?? null, @@ -177,7 +181,7 @@ public static function fromArray(array $data): self swiftAccountNumberIban: $data['swift_account_number_iban'] ?? null, transfersAccount: $data['transfers_account'] ?? null, transfersType: isset($data['transfers_type']) ? ArgentinaTransferType::from($data['transfers_type']) : null, - hasVirtualAccount: $data['has_virtual_account'], + hasVirtualAccount: $data['has_virtual_account'] ?? null, partnerFeeId: $data['partner_fee_id'] ?? null, tedBankCode: $data['ted_bank_code'] ?? null, tedBranchCode: $data['ted_branch_code'] ?? null, diff --git a/src/Resources/Quotes/Quotes.php b/src/Resources/Quotes/Quotes.php index da98c3a..8ae8dd7 100644 --- a/src/Resources/Quotes/Quotes.php +++ b/src/Resources/Quotes/Quotes.php @@ -116,15 +116,15 @@ public function toArray(): array public function __construct( public string $id, public int $expiresAt, - public float $commercialQuotation, - public float $blindpayQuotation, - public float $receiverAmount, - public float $senderAmount, - public float $partnerFeeAmount, - public float $flatFee, - public QuoteContract $contract, - public float $customerLocalAmount, - public string $description + public ?float $commercialQuotation, + public ?float $blindpayQuotation, + public ?float $receiverAmount, + public ?float $senderAmount, + public ?float $partnerFeeAmount, + public ?float $flatFee, + public ?QuoteContract $contract, + public ?float $customerLocalAmount, + public ?string $description ) {} public static function fromArray(array $data): self @@ -132,15 +132,15 @@ public static function fromArray(array $data): self return new self( id: $data['id'], expiresAt: $data['expires_at'], - commercialQuotation: (float) $data['commercial_quotation'], - blindpayQuotation: (float) $data['blindpay_quotation'], - receiverAmount: (float) $data['receiver_amount'], - senderAmount: (float) $data['sender_amount'], - partnerFeeAmount: (float) $data['partner_fee_amount'], - flatFee: (float) $data['flat_fee'], - contract: QuoteContract::fromArray($data['contract']), - customerLocalAmount: (float) $data['customer_local_amount'], - description: $data['description'] + commercialQuotation: isset($data['commercial_quotation']) ? (float) $data['commercial_quotation'] : null, + blindpayQuotation: isset($data['blindpay_quotation']) ? (float) $data['blindpay_quotation'] : null, + receiverAmount: isset($data['receiver_amount']) ? (float) $data['receiver_amount'] : null, + senderAmount: isset($data['sender_amount']) ? (float) $data['sender_amount'] : null, + partnerFeeAmount: isset($data['partner_fee_amount']) ? (float) $data['partner_fee_amount'] : null, + flatFee: isset($data['flat_fee']) ? (float) $data['flat_fee'] : null, + contract: isset($data['contract']) ? QuoteContract::fromArray($data['contract']) : null, + customerLocalAmount: isset($data['customer_local_amount']) ? (float) $data['customer_local_amount'] : null, + description: $data['description'] ?? null ); } @@ -155,7 +155,7 @@ public function toArray(): array 'sender_amount' => $this->senderAmount, 'partner_fee_amount' => $this->partnerFeeAmount, 'flat_fee' => $this->flatFee, - 'contract' => $this->contract->toArray(), + 'contract' => $this->contract?->toArray(), 'customer_local_amount' => $this->customerLocalAmount, 'description' => $this->description, ]; diff --git a/src/Resources/Transfers/Transfers.php b/src/Resources/Transfers/Transfers.php index 474825e..1fe79fe 100644 --- a/src/Resources/Transfers/Transfers.php +++ b/src/Resources/Transfers/Transfers.php @@ -220,15 +220,15 @@ public function __construct( public Network $customerNetwork, public string $customerWalletAddress, public string $customerId, - public string $address, + public ?string $address, public Network $network, public TransferTrackingTransactionMonitoring $trackingTransactionMonitoring, public TransferTrackingPaymaster $trackingPaymaster, public TransferTrackingBridgeSwap $trackingBridgeSwap, public TrackingComplete $trackingComplete, public TrackingPartnerFee $trackingPartnerFee, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt, + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt, public ?string $imageUrl = null, public ?string $firstName = null, public ?string $lastName = null, @@ -252,15 +252,19 @@ public static function fromArray(array $data): self customerNetwork: Network::from($data['customer_network']), customerWalletAddress: $data['customer_wallet_address'], customerId: $data['customer_id'], - address: $data['address'], + address: $data['address'] ?? null, network: Network::from($data['network']), trackingTransactionMonitoring: TransferTrackingTransactionMonitoring::fromArray($data['tracking_transaction_monitoring']), trackingPaymaster: TransferTrackingPaymaster::fromArray($data['tracking_paymaster']), trackingBridgeSwap: TransferTrackingBridgeSwap::fromArray($data['tracking_bridge_swap']), trackingComplete: TrackingComplete::fromArray($data['tracking_complete']), trackingPartnerFee: TrackingPartnerFee::fromArray($data['tracking_partner_fee']), - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']), + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null, imageUrl: $data['image_url'] ?? null, firstName: $data['first_name'] ?? null, lastName: $data['last_name'] ?? null, diff --git a/src/Resources/VirtualAccounts/VirtualAccounts.php b/src/Resources/VirtualAccounts/VirtualAccounts.php index d66a645..4ea9f17 100644 --- a/src/Resources/VirtualAccounts/VirtualAccounts.php +++ b/src/Resources/VirtualAccounts/VirtualAccounts.php @@ -13,13 +13,13 @@ readonly class VirtualAccountUsDetails { public function __construct( - public VirtualAccountUsAch $ach, + public ?VirtualAccountUsAch $ach, public VirtualAccountUsWire $wire, - public VirtualAccountUsRtp $rtp, - public string $swiftBicCode, + public ?VirtualAccountUsRtp $rtp, + public ?string $swiftBicCode, public string $accountType, - public VirtualAccountBeneficiary $beneficiary, - public VirtualAccountReceivingBank $receivingBank, + public ?VirtualAccountBeneficiary $beneficiary, + public ?VirtualAccountReceivingBank $receivingBank, public ?string $swiftAccountNumber = null, public ?VirtualAccountSwiftReceivingBank $swiftReceivingBank = null, public ?array $swiftIntermediaryBank = null @@ -28,13 +28,13 @@ public function __construct( public static function fromArray(array $data): self { return new self( - ach: VirtualAccountUsAch::fromArray($data['ach']), + ach: isset($data['ach']) ? VirtualAccountUsAch::fromArray($data['ach']) : null, wire: VirtualAccountUsWire::fromArray($data['wire']), - rtp: VirtualAccountUsRtp::fromArray($data['rtp']), - swiftBicCode: $data['swift_bic_code'], + rtp: isset($data['rtp']) ? VirtualAccountUsRtp::fromArray($data['rtp']) : null, + swiftBicCode: $data['swift_bic_code'] ?? null, accountType: $data['account_type'], - beneficiary: VirtualAccountBeneficiary::fromArray($data['beneficiary']), - receivingBank: VirtualAccountReceivingBank::fromArray($data['receiving_bank']), + beneficiary: isset($data['beneficiary']) ? VirtualAccountBeneficiary::fromArray($data['beneficiary']) : null, + receivingBank: isset($data['receiving_bank']) ? VirtualAccountReceivingBank::fromArray($data['receiving_bank']) : null, swiftAccountNumber: $data['swift_account_number'] ?? null, swiftReceivingBank: isset($data['swift_receiving_bank']) ? VirtualAccountSwiftReceivingBank::fromArray($data['swift_receiving_bank']) : null, swiftIntermediaryBank: $data['swift_intermediary_bank'] ?? null @@ -44,13 +44,13 @@ public static function fromArray(array $data): self public function toArray(): array { $data = [ - 'ach' => $this->ach->toArray(), + 'ach' => $this->ach?->toArray(), 'wire' => $this->wire->toArray(), - 'rtp' => $this->rtp->toArray(), + 'rtp' => $this->rtp?->toArray(), 'swift_bic_code' => $this->swiftBicCode, 'account_type' => $this->accountType, - 'beneficiary' => $this->beneficiary->toArray(), - 'receiving_bank' => $this->receivingBank->toArray(), + 'beneficiary' => $this->beneficiary?->toArray(), + 'receiving_bank' => $this->receivingBank?->toArray(), ]; if ($this->swiftAccountNumber !== null) { @@ -173,7 +173,7 @@ public function toArray(): array public function __construct( public string $name, public string $addressLine1, - public string $addressLine2 + public ?string $addressLine2 ) {} public static function fromArray(array $data): self @@ -181,7 +181,7 @@ public static function fromArray(array $data): self return new self( name: $data['name'], addressLine1: $data['address_line_1'], - addressLine2: $data['address_line_2'] + addressLine2: $data['address_line_2'] ?? null ); } @@ -228,7 +228,7 @@ public function __construct( public string $id, public VirtualAccountUsDetails $us, public StablecoinToken $token, - public string $blockchainWalletId, + public ?string $blockchainWalletId, public ?BankingPartner $bankingPartner = null, public ?string $kycStatus = null ) {} @@ -239,7 +239,7 @@ public static function fromArray(array $data): self id: $data['id'], us: VirtualAccountUsDetails::fromArray($data['us']), token: StablecoinToken::from($data['token']), - blockchainWalletId: $data['blockchain_wallet_id'], + blockchainWalletId: $data['blockchain_wallet_id'] ?? null, bankingPartner: isset($data['banking_partner']) ? BankingPartner::from($data['banking_partner']) : null, kycStatus: $data['kyc_status'] ?? null ); diff --git a/src/Resources/Wallets/BlockchainWallets.php b/src/Resources/Wallets/BlockchainWallets.php index 910dcf9..5a7674c 100644 --- a/src/Resources/Wallets/BlockchainWallets.php +++ b/src/Resources/Wallets/BlockchainWallets.php @@ -12,9 +12,9 @@ { public function __construct( public string $id, - public string $name, - public Network $network, - public bool $isAccountAbstraction, + public ?string $name, + public ?Network $network, + public ?bool $isAccountAbstraction, public string $customerId, public ?string $address = null, public ?string $signatureTxHash = null @@ -24,9 +24,9 @@ public static function fromArray(array $data): self { return new self( id: $data['id'], - name: $data['name'], - network: Network::from($data['network']), - isAccountAbstraction: $data['is_account_abstraction'], + name: $data['name'] ?? null, + network: isset($data['network']) ? Network::from($data['network']) : null, + isAccountAbstraction: $data['is_account_abstraction'] ?? null, customerId: $data['customer_id'], address: $data['address'] ?? null, signatureTxHash: $data['signature_tx_hash'] ?? null diff --git a/src/Resources/Wallets/OfframpWallets.php b/src/Resources/Wallets/OfframpWallets.php index bfc5211..98c0339 100644 --- a/src/Resources/Wallets/OfframpWallets.php +++ b/src/Resources/Wallets/OfframpWallets.php @@ -12,14 +12,14 @@ { public function __construct( public string $id, - public string $externalId, + public ?string $externalId, public string $instanceId, public string $customerId, public string $bankAccountId, public string $network, public string $address, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt, + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt, public ?string $circleWalletId = null ) {} @@ -27,14 +27,18 @@ public static function fromArray(array $data): self { return new self( id: $data['id'], - externalId: $data['external_id'], + externalId: $data['external_id'] ?? null, instanceId: $data['instance_id'], customerId: $data['customer_id'], bankAccountId: $data['bank_account_id'], network: $data['network'], address: $data['address'], - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']), + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null, circleWalletId: $data['circle_wallet_id'] ?? null ); } diff --git a/src/Resources/Webhooks/Webhooks.php b/src/Resources/Webhooks/Webhooks.php index 54973cf..a117196 100644 --- a/src/Resources/Webhooks/Webhooks.php +++ b/src/Resources/Webhooks/Webhooks.php @@ -46,8 +46,8 @@ public function __construct( public array $events, public string $lastEventAt, public string $instanceId, - public DateTimeImmutable $createdAt, - public DateTimeImmutable $updatedAt + public ?DateTimeImmutable $createdAt, + public ?DateTimeImmutable $updatedAt ) {} public static function fromArray(array $data): self @@ -61,8 +61,12 @@ public static function fromArray(array $data): self ), lastEventAt: $data['last_event_at'], instanceId: $data['instance_id'], - createdAt: new DateTimeImmutable($data['created_at']), - updatedAt: new DateTimeImmutable($data['updated_at']) + createdAt: isset($data['created_at']) + ? new DateTimeImmutable($data['created_at']) + : null, + updatedAt: isset($data['updated_at']) + ? new DateTimeImmutable($data['updated_at']) + : null ); } @@ -77,8 +81,8 @@ public function toArray(): array ), 'last_event_at' => $this->lastEventAt, 'instance_id' => $this->instanceId, - 'created_at' => $this->createdAt->format(\DateTimeInterface::ATOM), - 'updated_at' => $this->updatedAt->format(\DateTimeInterface::ATOM), + 'created_at' => $this->createdAt?->format(\DateTimeInterface::ATOM), + 'updated_at' => $this->updatedAt?->format(\DateTimeInterface::ATOM), ]; } } diff --git a/src/Types/TrackingComplete.php b/src/Types/TrackingComplete.php index bdc694a..d27540a 100644 --- a/src/Types/TrackingComplete.php +++ b/src/Types/TrackingComplete.php @@ -11,7 +11,7 @@ public function __construct( string $step, public string $status, - public string $transactionHash, + public ?string $transactionHash, public ?string $providerTransactionId = null, public ?string $refundReason = null, public ?string $gasFee = null, @@ -26,7 +26,7 @@ public static function fromArray(array $data): self return new self( step: $data['step'], status: $data['status'], - transactionHash: $data['transaction_hash'], + transactionHash: $data['transaction_hash'] ?? null, providerTransactionId: $data['provider_transaction_id'] ?? null, refundReason: $data['refund_reason'] ?? null, gasFee: $data['gas_fee'] ?? null, diff --git a/src/Types/TrackingLiquidity.php b/src/Types/TrackingLiquidity.php index 8e505cb..1c1deac 100644 --- a/src/Types/TrackingLiquidity.php +++ b/src/Types/TrackingLiquidity.php @@ -10,7 +10,7 @@ { public function __construct( string $step, - public string $providerTransactionId, + public ?string $providerTransactionId, public string $providerStatus, public string $estimatedTimeOfArrival, ?DateTimeImmutable $completedAt @@ -22,7 +22,7 @@ public static function fromArray(array $data): self { return new self( step: $data['step'], - providerTransactionId: $data['provider_transaction_id'], + providerTransactionId: $data['provider_transaction_id'] ?? null, providerStatus: $data['provider_status'], estimatedTimeOfArrival: $data['estimated_time_of_arrival'], completedAt: isset($data['completed_at']) diff --git a/src/Types/TrackingTransaction.php b/src/Types/TrackingTransaction.php index 5a6b116..1ce7b66 100644 --- a/src/Types/TrackingTransaction.php +++ b/src/Types/TrackingTransaction.php @@ -11,7 +11,7 @@ public function __construct( string $step, public string $status, - public string $transactionHash, + public ?string $transactionHash, public ?string $externalId = null, public ?string $providerName = null, public ?string $providerTransactionId = null, @@ -40,7 +40,7 @@ public static function fromArray(array $data): self return new self( step: $data['step'], status: $data['status'], - transactionHash: $data['transaction_hash'], + transactionHash: $data['transaction_hash'] ?? null, externalId: $data['external_id'] ?? null, providerName: $data['provider_name'] ?? null, providerTransactionId: $data['provider_transaction_id'] ?? null,