generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement ability to load client custom fields
- Loading branch information
1 parent
3424f83
commit e2f242a
Showing
9 changed files
with
278 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Objects\Client; | ||
|
||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractResponse; | ||
|
||
class ClientCustomFieldData extends AbstractResponse | ||
{ | ||
|
||
public ?string $UUID = null; | ||
public ?string $Name = null; | ||
|
||
public ?string $Text = null; | ||
public ?string $Date = null; | ||
public ?string $Number = null; | ||
public ?string $Decimal = null; | ||
public ?bool $Boolean = null; | ||
|
||
public function getUUID(): ?string | ||
{ | ||
return $this->UUID; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->Name; | ||
} | ||
|
||
public function getText(): ?string | ||
{ | ||
return $this->Text; | ||
} | ||
|
||
public function getDate(): ?string | ||
{ | ||
return $this->Date; | ||
} | ||
|
||
public function getNumber(): ?string | ||
{ | ||
return $this->Number; | ||
} | ||
|
||
public function getDecimal(): ?string | ||
{ | ||
return $this->Decimal; | ||
} | ||
|
||
public function getBoolean(): ?bool | ||
{ | ||
return $this->Boolean; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Objects; | ||
|
||
use Spatie\LaravelData\DataCollection; | ||
use Spatie\LaravelData\Attributes\DataCollectionOf; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractResponse; | ||
|
||
class CustomFieldData extends AbstractResponse | ||
{ | ||
|
||
public ?string $UUID = null; | ||
public ?string $Name = null; | ||
public ?string $Type = null; | ||
public ?string $LinkUrl = null; | ||
public ?string $Options = null; | ||
public ?bool $UseClient = null; | ||
public ?bool $UseContact = null; | ||
public ?bool $UseJob = null; | ||
public ?bool $UseJobTask = null; | ||
public ?bool $UseJobCost = null; | ||
public ?bool $UseJobTime = null; | ||
public ?string $ValueElement = null; | ||
|
||
public function getUUID(): ?string | ||
{ | ||
return $this->UUID; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->Name; | ||
} | ||
|
||
public function getType(): ?string | ||
{ | ||
return $this->Type; | ||
} | ||
|
||
public function getLinkUrl(): ?string | ||
{ | ||
return $this->LinkUrl; | ||
} | ||
|
||
public function getOptions(): ?string | ||
{ | ||
return $this->Options; | ||
} | ||
|
||
public function getUseClient(): ?bool | ||
{ | ||
return $this->UseClient; | ||
} | ||
|
||
public function getUseContact(): ?bool | ||
{ | ||
return $this->UseContact; | ||
} | ||
|
||
public function getUseJob(): ?bool | ||
{ | ||
return $this->UseJob; | ||
} | ||
|
||
public function getUseJobTask(): ?bool | ||
{ | ||
return $this->UseJobTask; | ||
} | ||
|
||
public function getUseJobCost(): ?bool | ||
{ | ||
return $this->UseJobCost; | ||
} | ||
|
||
public function getUseJobTime(): ?bool | ||
{ | ||
return $this->UseJobTime; | ||
} | ||
|
||
public function getValueElement(): ?string | ||
{ | ||
return $this->ValueElement; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Resources\Clients; | ||
|
||
use Saloon\Enums\Method; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractRequest; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\XeroPracticeManagerConnector; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Objects\Client\ClientCustomFieldData; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Responses\ClientCustomFieldsCollectionResponse; | ||
|
||
class ClientGetCustomFieldsRequest extends AbstractRequest | ||
{ | ||
protected Method $method = Method::GET; | ||
|
||
protected ?string $responseModel = ClientCustomFieldsCollectionResponse::class; | ||
|
||
public function __construct(XeroPracticeManagerConnector $connector, private readonly string $xeroId) | ||
{ | ||
parent::__construct($connector); | ||
} | ||
|
||
public function resolveEndpoint(): string | ||
{ | ||
return '/client.api/get/' . $this->xeroId . '/customfield'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Resources\CustomFields; | ||
|
||
use Saloon\Enums\Method; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractRequest; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\XeroPracticeManagerConnector; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Responses\CustomFieldCollectionResponse; | ||
|
||
class CustomFieldsListRequest extends AbstractRequest | ||
{ | ||
protected Method $method = Method::GET; | ||
|
||
protected ?string $responseModel = CustomFieldCollectionResponse::class; | ||
protected string $collectionKey = 'CustomFieldDefinitions'; | ||
|
||
public function __construct( | ||
XeroPracticeManagerConnector $connector, | ||
) { | ||
parent::__construct($connector); | ||
} | ||
|
||
public function resolveEndpoint(): string | ||
{ | ||
return '/customfield.api/definition'; | ||
} | ||
|
||
protected function defaultQuery(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Resources\CustomFields; | ||
|
||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractResource; | ||
|
||
class CustomFieldsResource extends AbstractResource | ||
{ | ||
public function list(): CustomFieldsListRequest | ||
{ | ||
return new CustomFieldsListRequest($this->connector); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Responses; | ||
|
||
use Spatie\LaravelData\DataCollection; | ||
use Spatie\LaravelData\Attributes\DataCollectionOf; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Objects\Client\ClientCustomFieldData; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractResponse; | ||
|
||
class ClientCustomFieldsCollectionResponse extends AbstractResponse | ||
{ | ||
/** | ||
* @var null|DataCollection<int, ClientCustomFieldData> | ||
*/ | ||
#[DataCollectionOf(ClientCustomFieldData::class)] | ||
public ?DataCollection $CustomFields = null; | ||
|
||
public static array $relations = ['CustomFields']; | ||
|
||
/** | ||
* @return DataCollection<int, ClientCustomFieldData> | ||
*/ | ||
public function getCustomFields(): DataCollection | ||
{ | ||
return $this->CustomFields ?: ClientCustomFieldData::collection([]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace BuckhamDuffy\LaravelXeroPracticeManager\Responses; | ||
|
||
use Spatie\LaravelData\DataCollection; | ||
use Spatie\LaravelData\Attributes\DataCollectionOf; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Objects\CustomFieldData; | ||
use BuckhamDuffy\LaravelXeroPracticeManager\Support\AbstractResponse; | ||
|
||
class CustomFieldCollectionResponse extends AbstractResponse | ||
{ | ||
/** | ||
* @var null|DataCollection<int, CustomFieldData> | ||
*/ | ||
#[DataCollectionOf(CustomFieldData::class)] | ||
public ?DataCollection $CustomFieldDefinitions = null; | ||
|
||
public static array $relations = ['CustomFieldDefinitions']; | ||
|
||
/** | ||
* @return DataCollection<int, CustomFieldData> | ||
*/ | ||
public function getCustomFields(): DataCollection | ||
{ | ||
return $this->CustomFieldDefinitions ?: CustomFieldData::collection([]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters