Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 258
openapi_spec_hash: a0b4ea6e95b4d03425ddbbf38709d16d
openapi_spec_hash: 4f5195a915a02f30162c38f88ecfaa14
config_hash: b0e46656e84a8c26907fbe6dc8116a3d
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

34 changes: 32 additions & 2 deletions src/CardPayments/CardPayment/Element/CardRefund/Interchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Increase\CardPayments\CardPayment\Element\CardRefund;

use Increase\CardPayments\CardPayment\Element\CardRefund\Interchange\Adjustment;
use Increase\CardPayments\CardPayment\Element\CardRefund\Interchange\Currency;
use Increase\Core\Attributes\Required;
use Increase\Core\Concerns\SdkModel;
Expand All @@ -12,7 +13,10 @@
/**
* Interchange assessed as a part of this transaction.
*
* @phpstan-import-type AdjustmentShape from \Increase\CardPayments\CardPayment\Element\CardRefund\Interchange\Adjustment
*
* @phpstan-type InterchangeShape = array{
* adjustment: null|Adjustment|AdjustmentShape,
* amount: string,
* code: string|null,
* currency: \Increase\CardPayments\CardPayment\Element\CardRefund\Interchange\Currency|value-of<\Increase\CardPayments\CardPayment\Element\CardRefund\Interchange\Currency>,
Expand All @@ -23,6 +27,12 @@ final class Interchange implements BaseModel
/** @use SdkModel<InterchangeShape> */
use SdkModel;

/**
* An adjustment the card network made to the interchange after this transaction cleared, if any.
*/
#[Required]
public ?Adjustment $adjustment;

/**
* The interchange amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase (e.g., settlements) and a negative number if it is debited (e.g., refunds).
*/
Expand Down Expand Up @@ -50,13 +60,17 @@ enum: Currency::class,
*
* To enforce required parameters use
* ```
* Interchange::with(amount: ..., code: ..., currency: ...)
* Interchange::with(adjustment: ..., amount: ..., code: ..., currency: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Interchange)->withAmount(...)->withCode(...)->withCurrency(...)
* (new Interchange)
* ->withAdjustment(...)
* ->withAmount(...)
* ->withCode(...)
* ->withCurrency(...)
* ```
*/
public function __construct()
Expand All @@ -69,22 +83,38 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Adjustment|AdjustmentShape|null $adjustment
* @param Currency|value-of<Currency> $currency
*/
public static function with(
Adjustment|array|null $adjustment,
string $amount,
?string $code,
Currency|string $currency,
): self {
$self = new self;

$self['adjustment'] = $adjustment;
$self['amount'] = $amount;
$self['code'] = $code;
$self['currency'] = $currency;

return $self;
}

/**
* An adjustment the card network made to the interchange after this transaction cleared, if any.
*
* @param Adjustment|AdjustmentShape|null $adjustment
*/
public function withAdjustment(Adjustment|array|null $adjustment): self
{
$self = clone $this;
$self['adjustment'] = $adjustment;

return $self;
}

/**
* The interchange amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase (e.g., settlements) and a negative number if it is debited (e.g., refunds).
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

declare(strict_types=1);

namespace Increase\CardPayments\CardPayment\Element\CardRefund\Interchange;

use Increase\Core\Attributes\Required;
use Increase\Core\Concerns\SdkModel;
use Increase\Core\Contracts\BaseModel;

/**
* An adjustment the card network made to the interchange after this transaction cleared, if any.
*
* @phpstan-type AdjustmentShape = array{
* adjustedAt: \DateTimeInterface, amount: string, code: string
* }
*/
final class Adjustment implements BaseModel
{
/** @use SdkModel<AdjustmentShape> */
use SdkModel;

/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the interchange was adjusted.
*/
#[Required('adjusted_at')]
public \DateTimeInterface $adjustedAt;

/**
* The adjustment amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase and a negative number if it is debited.
*/
#[Required]
public string $amount;

/**
* The card network specific interchange code that applies after the adjustment.
*/
#[Required]
public string $code;

/**
* `new Adjustment()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* Adjustment::with(adjustedAt: ..., amount: ..., code: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Adjustment)->withAdjustedAt(...)->withAmount(...)->withCode(...)
* ```
*/
public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*/
public static function with(
\DateTimeInterface $adjustedAt,
string $amount,
string $code
): self {
$self = new self;

$self['adjustedAt'] = $adjustedAt;
$self['amount'] = $amount;
$self['code'] = $code;

return $self;
}

/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the interchange was adjusted.
*/
public function withAdjustedAt(\DateTimeInterface $adjustedAt): self
{
$self = clone $this;
$self['adjustedAt'] = $adjustedAt;

return $self;
}

/**
* The adjustment amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase and a negative number if it is debited.
*/
public function withAmount(string $amount): self
{
$self = clone $this;
$self['amount'] = $amount;

return $self;
}

/**
* The card network specific interchange code that applies after the adjustment.
*/
public function withCode(string $code): self
{
$self = clone $this;
$self['code'] = $code;

return $self;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Increase\CardPayments\CardPayment\Element\CardSettlement;

use Increase\CardPayments\CardPayment\Element\CardSettlement\Interchange\Adjustment;
use Increase\CardPayments\CardPayment\Element\CardSettlement\Interchange\Currency;
use Increase\Core\Attributes\Required;
use Increase\Core\Concerns\SdkModel;
Expand All @@ -12,7 +13,10 @@
/**
* Interchange assessed as a part of this transaction.
*
* @phpstan-import-type AdjustmentShape from \Increase\CardPayments\CardPayment\Element\CardSettlement\Interchange\Adjustment
*
* @phpstan-type InterchangeShape = array{
* adjustment: null|Adjustment|AdjustmentShape,
* amount: string,
* code: string|null,
* currency: \Increase\CardPayments\CardPayment\Element\CardSettlement\Interchange\Currency|value-of<\Increase\CardPayments\CardPayment\Element\CardSettlement\Interchange\Currency>,
Expand All @@ -23,6 +27,12 @@ final class Interchange implements BaseModel
/** @use SdkModel<InterchangeShape> */
use SdkModel;

/**
* An adjustment the card network made to the interchange after this transaction cleared, if any.
*/
#[Required]
public ?Adjustment $adjustment;

/**
* The interchange amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase (e.g., settlements) and a negative number if it is debited (e.g., refunds).
*/
Expand Down Expand Up @@ -50,13 +60,17 @@ enum: Currency::class,
*
* To enforce required parameters use
* ```
* Interchange::with(amount: ..., code: ..., currency: ...)
* Interchange::with(adjustment: ..., amount: ..., code: ..., currency: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Interchange)->withAmount(...)->withCode(...)->withCurrency(...)
* (new Interchange)
* ->withAdjustment(...)
* ->withAmount(...)
* ->withCode(...)
* ->withCurrency(...)
* ```
*/
public function __construct()
Expand All @@ -69,22 +83,38 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Adjustment|AdjustmentShape|null $adjustment
* @param Currency|value-of<Currency> $currency
*/
public static function with(
Adjustment|array|null $adjustment,
string $amount,
?string $code,
Currency|string $currency,
): self {
$self = new self;

$self['adjustment'] = $adjustment;
$self['amount'] = $amount;
$self['code'] = $code;
$self['currency'] = $currency;

return $self;
}

/**
* An adjustment the card network made to the interchange after this transaction cleared, if any.
*
* @param Adjustment|AdjustmentShape|null $adjustment
*/
public function withAdjustment(Adjustment|array|null $adjustment): self
{
$self = clone $this;
$self['adjustment'] = $adjustment;

return $self;
}

/**
* The interchange amount given as a string containing a decimal number in major units (so e.g., "3.14" for $3.14). The amount is a positive number if it is credited to Increase (e.g., settlements) and a negative number if it is debited (e.g., refunds).
*/
Expand Down
Loading
Loading