Skip to content

Commit

Permalink
Merge pull request #3 from mihajlstje/main
Browse files Browse the repository at this point in the history
add SalesOffer resource
  • Loading branch information
leventcz authored Aug 30, 2024
2 parents 55a1492 + e833ef8 commit 2dc5428
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Leventcz\Parasut\Resources\TrackableJob;
use Leventcz\Parasut\Resources\Transaction;
use Leventcz\Parasut\Resources\WareHouse;
use Leventcz\Parasut\Resources\SalesOffer;

readonly class Client
{
Expand Down Expand Up @@ -203,4 +204,12 @@ public function trackableJob(): TrackableJob
{
return new TrackableJob($this->httpClient);
}

/**
* @return SalesOffer
*/
public function salesOffer(): SalesOffer
{
return new SalesOffer($this->httpClient);
}
}
82 changes: 82 additions & 0 deletions src/Resources/SalesOffer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace Leventcz\Parasut\Resources;

use Leventcz\Parasut\Exceptions\ClientException;
use Leventcz\Parasut\Resources\Concerns\ArchivesResource;
use Leventcz\Parasut\Resources\Concerns\CreatesResource;
use Leventcz\Parasut\Resources\Concerns\DeletesResource;
use Leventcz\Parasut\Resources\Concerns\EditsResource;
use Leventcz\Parasut\Resources\Concerns\IndexesResources;
use Leventcz\Parasut\Resources\Concerns\ShowsResource;
use Leventcz\Parasut\Resources\Concerns\UnArchivesResource;
use Leventcz\Parasut\ValueObjects\Method;

class SalesOffer extends ApiResource
{
use IndexesResources;
use CreatesResource;
use ShowsResource;
use EditsResource;
use DeletesResource;
use ArchivesResource;
use UnArchivesResource;

/**
* @var string
*/
protected string $resource = 'sales_offers';

/**
* @param string $id
* @return array<mixed>|null
* @throws ClientException
*/
public function pdf(string $id): ?array
{
return $this
->getHttpClient()
->authenticatedRequest(
method: Method::POST,
uri: "{$this->getResource()}/$id/pdf"
);
}

/**
* @param string $id
* @param array<string, string|array<string, string>> $query
* @return array<mixed>|null
* @throws ClientException
*/
public function details(string $id, array $query = []): ?array
{
return $this
->getHttpClient()
->authenticatedRequest(
method: Method::GET,
uri: "{$this->getResource()}/$id/details",
query: $query
);
}

/**
* @param string $id
* @param array<string, string|array<string, string>> $query
* @param array<string, string|array<string, string>> $body
* @return array<mixed>|null
* @throws ClientException
*/
public function updateStatus(string $id, array $query = [], array $body = []): ?array
{
return $this
->getHttpClient()
->authenticatedRequest(
method: Method::PATCH,
uri: "{$this->getResource()}/$id/update_status",
query: $query,
body: $body
);
}
}

0 comments on commit 2dc5428

Please sign in to comment.