Skip to content
Merged
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
68 changes: 68 additions & 0 deletions src/SoftwareLicence.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Spinen\Halo;

use Carbon\Carbon;
use Spinen\Halo\Support\Model;

/**
* Class SoftwareLicence
*
* @property ?Carbon $end_date
* @property ?Carbon $requested_quantity_date
* @property ?Carbon $start_date
* @property ?string $billing_cycle
* @property ?string $distributor
* @property ?string $manufacturer
* @property ?string $notes
* @property ?string $site_name
* @property ?string $snowid,
* @property ?string $supplier_name
* @property ?string $vendor
* @property bool $deleted
* @property bool $is_active
* @property float $monthly_cost
* @property float $monthly_price
* @property float $price
* @property float $purchase_price
* @property int $assigned_at_deletion
* @property int $azure_connection_id
* @property int $client_id
* @property int $count
* @property int $id
* @property int $licences_available
* @property int $licences_in_use
* @property int $licences_in_use_user
* @property int $parent_id
* @property int $requested_quantity
* @property int $site_id
* @property int $supplier_id
* @property int $type
* @property string $client_name
* @property string $licence_client_name
* @property string $name
* @property string $name_extra
*/
class SoftwareLicence extends Model
{
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'end_date' => 'datetime',
'requested_quantity_date' => 'datetime',
'start_date' => 'datetime',
];

/**
* Some of the responses have the data under a property
*/
protected ?string $responseKey = 'licences';

/**
* Path to API endpoint.
*/
protected string $path = '/softwarelicence';
}
62 changes: 33 additions & 29 deletions src/Support/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Spinen\Halo\Report;
use Spinen\Halo\Site;
use Spinen\Halo\Sla;
use Spinen\Halo\SoftwareLicence;
use Spinen\Halo\Status;
use Spinen\Halo\Supplier;
use Spinen\Halo\Team;
Expand All @@ -47,36 +48,37 @@
* Class Builder
*
* @property Agent $agent
* @property Collection $actions
* @property Collection $agents
* @property Collection $appointments
* @property Collection $articles
* @property Collection $assets
* @property Collection $asset_types
* @property Collection $attachments
* @property Collection $clients
* @property Collection $contracts
* @property Collection $invoices
* @property Collection $items
* @property Collection $opportunities
* @property Collection $organisations
* @property Collection $priorities
* @property Collection $projects
* @property Collection $quotes
* @property Collection $reports
* @property Collection $sites
* @property Collection $slas
* @property Collection $statuses
* @property Collection $suppliers
* @property Collection $teams
* @property Collection $ticket_types
* @property Collection $tickets
* @property Collection $users
* @property Collection $webhook_events
* @property Collection $webhooks
* @property Collection $workdays
* @property User $user
* @property Client $client
* @property Collection<int, Action> $actions
* @property Collection<int, Agent> $agents
* @property Collection<int, Appointment> $appointments
* @property Collection<int, Article> $articles
* @property Collection<int, AssetType> $asset_types
* @property Collection<int, Asset> $assets
* @property Collection<int, Attachment> $attachments
* @property Collection<int, Client> $clients
* @property Collection<int, Contract> $contracts
* @property Collection<int, Invoice> $invoices
* @property Collection<int, Item> $items
* @property Collection<int, Opportunity> $opportunities
* @property Collection<int, Organisation> $organisations
* @property Collection<int, Priority> $priorities
* @property Collection<int, Project> $projects
* @property Collection<int, Quote> $quotes
* @property Collection<int, Report> $reports
* @property Collection<int, Site> $sites
* @property Collection<int, Sla> $slas
* @property Collection<int, SoftwareLicence> $software_licences
* @property Collection<int, Status> $statuses
* @property Collection<int, Supplier> $suppliers
* @property Collection<int, Team> $teams
* @property Collection<int, TicketType> $ticket_types
* @property Collection<int, Ticket> $tickets
* @property Collection<int, User> $users
* @property Collection<int, WebhookEvent> $webhook_events
* @property Collection<int, Webhook> $webhooks
* @property Collection<int, Workday> $workdays
* @property User $user
*
* @method self actions()
* @method self agents()
Expand All @@ -99,6 +101,7 @@
* @method self search($for)
* @method self sites()
* @method self slas()
* @method self software_licences()
* @method self statuses()
* @method self suppliers()
* @method self teams()
Expand Down Expand Up @@ -160,6 +163,7 @@ class Builder
'reports' => Report::class,
'sites' => Site::class,
'slas' => Sla::class,
'software_licences' => SoftwareLicence::class,
'statuses' => Status::class,
'suppliers' => Supplier::class,
'teams' => Team::class,
Expand Down
3 changes: 3 additions & 0 deletions src/Support/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ public function newFromBuilder($attributes = []): self
{
$model = $this->newInstance([], true);

// TODO: Should we add a way to transform values?
// (i.e. SoftwareLicence gives 1899-12-30 00:00:00 for null date)

$model->setRawAttributes((array) $attributes, true);

return $model;
Expand Down
Loading