Skip to content

Commit

Permalink
Update generated code (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
silas authored Mar 12, 2024
1 parent 6002971 commit 2015686
Show file tree
Hide file tree
Showing 17 changed files with 430 additions and 33 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"require-dev": {
"donatj/mock-webserver": "^2.7",
"friendsofphp/php-cs-fixer": "^3.49",
"friendsofphp/php-cs-fixer": "3.49",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10"
},
Expand Down
27 changes: 18 additions & 9 deletions lib/AdminV1/CardPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ final class CardPaymentMethod implements \JsonSerializable, JsonUnserializable
*/
public string $brand;

/**
* The expiration date of the card.
*/
public null|CardPaymentMethodExpiration $expiration;

/**
* The last for digits of the card.
*/
Expand All @@ -33,25 +28,38 @@ final class CardPaymentMethod implements \JsonSerializable, JsonUnserializable
*/
public string $fundingType;

/**
* The expiration year.
*/
public int $expYear;

/**
* The expiration month.
*/
public int $expMonth;

public function __construct(
null|string $brand = null,
null|CardPaymentMethodExpiration $expiration = null,
null|string $last4 = null,
null|string $fundingType = null,
null|int $expYear = null,
null|int $expMonth = null,
) {
$this->brand = $brand ?? '';
$this->expiration = $expiration ?? null;
$this->last4 = $last4 ?? '';
$this->fundingType = $fundingType ?? '';
$this->expYear = $expYear ?? 0;
$this->expMonth = $expMonth ?? 0;
}

public function jsonSerialize(): mixed
{
return (object) [
'brand' => $this->brand ?? null,
'expiration' => $this->expiration ?? null,
'last4' => $this->last4 ?? null,
'fundingType' => $this->fundingType ?? null,
'expYear' => $this->expYear ?? null,
'expMonth' => $this->expMonth ?? null,
];
}

Expand All @@ -63,9 +71,10 @@ public static function jsonUnserialize(mixed $data): static

return new self(
$data->{'brand'} ?? null,
isset($data->{'expiration'}) ? CardPaymentMethodExpiration::jsonUnserialize($data->{'expiration'}) : null,
$data->{'last4'} ?? null,
$data->{'fundingType'} ?? null,
$data->{'expYear'} ?? null,
$data->{'expMonth'} ?? null,
);
}
}
9 changes: 9 additions & 0 deletions lib/AdminV1/JoinOrganizationFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ final class JoinOrganizationFlow implements \JsonSerializable, JsonUnserializabl
*/
public null|string $email;

/**
* The role to be assigned to the invitee.
*/
public null|Role $role;

public function __construct(
null|string $displayName = null,
null|string $email = null,
null|Role $role = null,
) {
$this->displayName = $displayName ?? null;
$this->email = $email ?? null;
$this->role = $role ?? null;
}

public function jsonSerialize(): mixed
{
return (object) [
'displayName' => $this->displayName ?? null,
'email' => $this->email ?? null,
'role' => $this->role ?? null,
];
}

Expand All @@ -48,6 +56,7 @@ public static function jsonUnserialize(mixed $data): static
return new self(
$data->{'displayName'} ?? null,
$data->{'email'} ?? null,
isset($data->{'role'}) ? Role::jsonUnserialize($data->{'role'}) : null,
);
}
}
13 changes: 13 additions & 0 deletions lib/AdminV1/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace UserHub\AdminV1;

use UserHub\ApiV1\Status;
use UserHub\CommonV1\Address;
use UserHub\Internal\JsonUnserializable;
use UserHub\Internal\Util;
Expand Down Expand Up @@ -63,6 +64,14 @@ final class PaymentMethod implements \JsonSerializable, JsonUnserializable
*/
public null|bool $default;

/**
* The last payment error.
*
* This will be unset if the payment method is updated
* or if a payment succeeds.
*/
public null|Status $lastPaymentError;

/**
* The last time the payment method was pulled from the connection.
*/
Expand Down Expand Up @@ -93,6 +102,7 @@ public function __construct(
null|string $fullName = null,
null|Address $address = null,
null|bool $default = null,
null|Status $lastPaymentError = null,
null|\DateTimeInterface $pullTime = null,
null|\DateTimeInterface $createTime = null,
null|\DateTimeInterface $updateTime = null,
Expand All @@ -107,6 +117,7 @@ public function __construct(
$this->fullName = $fullName ?? null;
$this->address = $address ?? null;
$this->default = $default ?? null;
$this->lastPaymentError = $lastPaymentError ?? null;
$this->pullTime = $pullTime ?? null;
$this->createTime = $createTime ?? Util::emptyDateTime();
$this->updateTime = $updateTime ?? Util::emptyDateTime();
Expand All @@ -125,6 +136,7 @@ public function jsonSerialize(): mixed
'fullName' => $this->fullName ?? null,
'address' => $this->address ?? null,
'default' => $this->default ?? null,
'lastPaymentError' => $this->lastPaymentError ?? null,
'pullTime' => isset($this->pullTime) ? Util::encodeDateTime($this->pullTime) : null,
'createTime' => isset($this->createTime) ? Util::encodeDateTime($this->createTime) : null,
'updateTime' => isset($this->updateTime) ? Util::encodeDateTime($this->updateTime) : null,
Expand All @@ -148,6 +160,7 @@ public static function jsonUnserialize(mixed $data): static
$data->{'fullName'} ?? null,
isset($data->{'address'}) ? Address::jsonUnserialize($data->{'address'}) : null,
$data->{'default'} ?? null,
isset($data->{'lastPaymentError'}) ? Status::jsonUnserialize($data->{'lastPaymentError'}) : null,
isset($data->{'pullTime'}) ? Util::decodeDateTime($data->{'pullTime'}) : null,
isset($data->{'createTime'}) ? Util::decodeDateTime($data->{'createTime'}) : null,
isset($data->{'updateTime'}) ? Util::decodeDateTime($data->{'updateTime'}) : null,
Expand Down
72 changes: 72 additions & 0 deletions lib/AdminV1/PaymentMethodInput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

// Code generated. DO NOT EDIT.

declare(strict_types=1);

namespace UserHub\AdminV1;

use UserHub\CommonV1\Address;
use UserHub\Internal\JsonUnserializable;

/**
* Payment method input parameters.
*/
final class PaymentMethodInput implements \JsonSerializable, JsonUnserializable
{
/**
* The full name of the owner of the payment method (e.g. `Jane Doe`).
*/
public null|string $fullName;

/**
* The address for the payment method.
*/
public null|Address $address;

/**
* The card expiration year (e.g. `2030`).
*/
public null|int $expYear;

/**
* The card expiration month (e.g. `12`).
*/
public null|int $expMonth;

public function __construct(
null|string $fullName = null,
null|Address $address = null,
null|int $expYear = null,
null|int $expMonth = null,
) {
$this->fullName = $fullName ?? null;
$this->address = $address ?? null;
$this->expYear = $expYear ?? null;
$this->expMonth = $expMonth ?? null;
}

public function jsonSerialize(): mixed
{
return (object) [
'fullName' => $this->fullName ?? null,
'address' => $this->address ?? null,
'expYear' => $this->expYear ?? null,
'expMonth' => $this->expMonth ?? null,
];
}

public static function jsonUnserialize(mixed $data): static
{
if (!\is_object($data)) {
throw new \TypeError('json data must be an object');
}

return new self(
$data->{'fullName'} ?? null,
isset($data->{'address'}) ? Address::jsonUnserialize($data->{'address'}) : null,
$data->{'expYear'} ?? null,
$data->{'expMonth'} ?? null,
);
}
}
4 changes: 2 additions & 2 deletions lib/Internal/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
abstract class Constants
{
public const API_BASE_URL = 'https://api.userhub.com';
public const USER_AGENT = 'UserHub-PHP/0.4.1';
public const VERSION = '0.4.1';
public const USER_AGENT = 'UserHub-PHP/0.5.0';
public const VERSION = '0.5.0';

public const AUTH_HEADER = 'Authorization';
public const API_KEY_HEADER = 'UserHub-Api-Key';
Expand Down
21 changes: 15 additions & 6 deletions lib/UserV1/CardPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ final class CardPaymentMethod implements \JsonSerializable, JsonUnserializable
public string $brand;

/**
* The expiration date of the card.
* The expiration year.
*/
public null|CardPaymentMethodExpiration $expiration;
public int $expYear;

/**
* The expiration month.
*/
public int $expMonth;

/**
* The last for digits of the card.
Expand All @@ -35,12 +40,14 @@ final class CardPaymentMethod implements \JsonSerializable, JsonUnserializable

public function __construct(
null|string $brand = null,
null|CardPaymentMethodExpiration $expiration = null,
null|int $expYear = null,
null|int $expMonth = null,
null|string $last4 = null,
null|string $fundingType = null,
) {
$this->brand = $brand ?? '';
$this->expiration = $expiration ?? null;
$this->expYear = $expYear ?? 0;
$this->expMonth = $expMonth ?? 0;
$this->last4 = $last4 ?? '';
$this->fundingType = $fundingType ?? '';
}
Expand All @@ -49,7 +56,8 @@ public function jsonSerialize(): mixed
{
return (object) [
'brand' => $this->brand ?? null,
'expiration' => $this->expiration ?? null,
'expYear' => $this->expYear ?? null,
'expMonth' => $this->expMonth ?? null,
'last4' => $this->last4 ?? null,
'fundingType' => $this->fundingType ?? null,
];
Expand All @@ -63,7 +71,8 @@ public static function jsonUnserialize(mixed $data): static

return new self(
$data->{'brand'} ?? null,
isset($data->{'expiration'}) ? CardPaymentMethodExpiration::jsonUnserialize($data->{'expiration'}) : null,
$data->{'expYear'} ?? null,
$data->{'expMonth'} ?? null,
$data->{'last4'} ?? null,
$data->{'fundingType'} ?? null,
);
Expand Down
9 changes: 9 additions & 0 deletions lib/UserV1/JoinOrganizationFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@ final class JoinOrganizationFlow implements \JsonSerializable, JsonUnserializabl
*/
public null|string $email;

/**
* The role to be assigned to the invitee.
*/
public null|Role $role;

public function __construct(
null|string $displayName = null,
null|string $email = null,
null|Role $role = null,
) {
$this->displayName = $displayName ?? null;
$this->email = $email ?? null;
$this->role = $role ?? null;
}

public function jsonSerialize(): mixed
{
return (object) [
'displayName' => $this->displayName ?? null,
'email' => $this->email ?? null,
'role' => $this->role ?? null,
];
}

Expand All @@ -51,6 +59,7 @@ public static function jsonUnserialize(mixed $data): static
return new self(
$data->{'displayName'} ?? null,
$data->{'email'} ?? null,
isset($data->{'role'}) ? Role::jsonUnserialize($data->{'role'}) : null,
);
}
}
Loading

0 comments on commit 2015686

Please sign in to comment.