Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.
Open
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
8 changes: 8 additions & 0 deletions src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ public function invoice()
return new Connector\InvoiceConnector($this);
}

/**
* @return \Sminnee\WorkflowMax\Connector\CostConnector
*/
public function cost()
{
return new Connector\CostConnector($this);
}

/**
* Make an API call
* @param string $url The relative URL (e.g. 'jobs.api/list')
Expand Down
53 changes: 53 additions & 0 deletions src/Connector/CostConnector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Sminnee\WorkflowMax\Connector;

use Datetime;

use Sminnee\WorkflowMax\ApiClient;
use Sminnee\WorkflowMax\Model\Cost;

/**
* A sub-client responsible for accessing cost
*/
class CostConnector extends TypeConnector
{
protected $connector;

function __construct(ApiClient $connector) {
$this->connector = $connector;
}

/**
* Returns a cost byId cost number.
*
* @return Sminnee\WorkflowMax\Model\Cost
*/
function byId($cost) {
return new Cost($this->connector, $this->connector->apiCall(
"cost.api/get/$cost",
function($result) { return $result['Cost']; }
));
}


/**
* @param $stubData
*
* @return mixed
*/
function byStub($stubData) {
return $this->byId($stubData['ID'])->populate($stubData);
}

/**
* @param int $page
*
* @return mixed
*/
function all($page = 1) {
return $this->listFromApiCall($this->connector->apiCall('cost.api/list?page='.$page, function($result) {
return isset($result['Costs']['Cost']) ? $result['Costs']['Cost'] : [];
}));
}
}
26 changes: 26 additions & 0 deletions src/Model/Cost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Sminnee\WorkflowMax\Model;


/**
* Represents a single cost
*
* @property-read string $ID
* @property-read string $Description
* @property-read string $Cost
* @property-read string $Note
* @property-read string $UnitCost
* @property-read string $UnitPrice
* @property-read $Supplier
*/
class Cost
{
use ModelBase;


function processData($data) {

return $data;
}
}