Skip to content

Commit

Permalink
📝 Add SmartTags, correct typos, update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeorgel committed Sep 15, 2022
1 parent 003690a commit d18d546
Show file tree
Hide file tree
Showing 32 changed files with 124 additions and 80 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Thomas Georgel <thomas@hydrat.agency>
Copyright (c) Thomas Georgel <thomas@bluerocktel.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
- [License](#license)


⚠️ This client helps you query the Sellsy API V2.
If you're looking for a client for the API V1, checkout [TeknooSoftware/sellsy-client](https://github.com/TeknooSoftware/sellsy-client) instead.
⚠️ Warning: This client helps you query the Sellsy API V2 ONLY.
If you're looking to query V1, checkout [TeknooSoftware/sellsy-client](https://github.com/TeknooSoftware/sellsy-client) instead.

## Introduction
<a name="introduction"></a>
Expand All @@ -31,9 +31,9 @@ If you're looking for a client for the API V1, checkout [TeknooSoftware/sellsy-c
## Installation
<a name="installation"></a>

This library requires PHP >= `7.4`.
This library requires PHP `>= 7.4`.

Grab the library using composer :
Get the library using composer :

```
composer require bluerock/sellsy-client
Expand All @@ -45,11 +45,11 @@ composer require bluerock/sellsy-client
## Authenticate
<a name="usage_auth"></a>

This package only supports "Personnal" OAuth client credentials authentication.
> ℹ For now, this package only supports "Personnal" OAuth client credentials authentication.
Before calling any API class (or the Client helper), you MUST provide your credentials via the `Config` class :

```php
use Bluerock\Sellsy\Api\ContactsApi;
use Bluerock\Sellsy\Core\Client;
use Bluerock\Sellsy\Core\Config;

Expand All @@ -60,45 +60,43 @@ $config->set('url', 'https://api.sellsy.com/v2/') // optionnal, this is the defa
->set('client_secret', 'av8v94jx0ildsjje50sm9x1hnmjsg27bnqyryc0zgbmtxxmzpjzlw2vnj9aockwe');

$client = new Client();

$client->contacts()->index()->json(); // List contacts from API.
```

[Learn more](https://api.sellsy.com/doc/v2/#section/Authentication) about Sellsy API v2 credentials.

## Query the API
## Querying the API
<a name="usage_query"></a>

### The basics
<a name="usage_query_basic"></a>

The easiest way to start querying the API is to initialize the corresponding class and call the needed method(s) :
The easier way to start querying the API is by initializing the corresponding domain class :

```php
use Bluerock\Sellsy\Api\ContactsApi;

$contacts = new ContactsApi();

$contacts->index();
$contacts->show($contact_id);
```

You may also use the client helper that holds all API namespaces using methods.
The downside is that you would lose the editor documentation.
You may also use the Client helper that holds all API namespaces using methods.

```php
use Bluerock\Sellsy\Core\Client;

(new Client())->contacts()->show($contact_id);
# With instance...
$client = new Client();
$client->contacts()->show($contact_id);

# Or statically :
# ... or statically.
Client::contacts()->show($contact_id);
```

### Operations
### Operations & methods
<a name="usage_query_operations"></a>

ℹ️ To illustrate this part of the documentation, we will use the [ContactsApi](https://api.sellsy.com/doc/v2/#tag/Contacts) endpoint.

This client is using the CRUD operations keywords to name API methods :

| Client Keyword | Related operation |
Expand All @@ -116,13 +114,14 @@ Classic methods signatures :
```php
public function index(array $query = []): self;
public function show(string $id, array $query = []): self;
public function store(Contact $contact, array $query = []): self;
public function update(Contact $contact, array $query = []): self;
public function store(\Bluerock\Sellsy\Entities\Contact $contact, array $query = []): self;
public function update(\Bluerock\Sellsy\Entities\Contact $contact, array $query = []): self;
public function destroy(int $id): self;
```

When querying the API, you get back an API object containing a response. If something goes wrong, a `RequestException` will be thrown.
Most of the time, you only need to get the response entity sent back from the API. However, you can also make use of other available methods :
When issuing a request using one of these methods, you'll get back the api class object containing a response. If something goes wrong, a `RequestException` will be thrown.

Most of the time, you only need to retreive the instancied entity using `->entity()`method. However, you may also use one of other available methods :

```php
use Bluerock\Sellsy\Api\ContactsApi;
Expand Down Expand Up @@ -160,7 +159,7 @@ Under the hood, we are using the [spatie/data-transfer-object](https://github.co
#### List a resource
<a name="usage_query_list"></a>

To list a resource, we use the `index()` method. This method accept query parameters as only argument.
To list a resource, use the `index()` method. This method accept query parameters as only argument.

```php
$contacts = new ContactsApi();
Expand All @@ -174,7 +173,7 @@ $index->pagination(); // The pagination DTO
#### Show a resource
<a name="usage_query_show"></a>

To show a resource, we use the `show()` method. This method accept the resource id as first parameter :
To show a resource, use the `show()` method. This method accept the resource id as first parameter :

```php
$contacts = new ContactsApi();
Expand Down
2 changes: 1 addition & 1 deletion src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Use $connection->request($endpoint) to create a new authenticated request.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Api/CompaniesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The API client for the `companies` namespace.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ContactsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The API client for the `contacts` namespace.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Api/TaxesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The API client for the `companies` namespace.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/CompanyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* The Contact Entity collection.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/ContactCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* The Contact Entity collection.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/TaxCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* The Tax Entity collection.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/EntityCollectionContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* The Entity contract.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/EntityContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* The Entity contract.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The API client used for authentication.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* E.g: Show single contact address : Client::contacts()->addresses()->show($id).
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* The configuration helper.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The single connection instance, issuing prepared & authenticated requests.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* at class creation so we can alter the PendingRequest before submission.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The Contact Entity.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* The Address Entity.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
8 changes: 5 additions & 3 deletions src/Entities/Attributes/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace Bluerock\Sellsy\Entities\Attributes;

use Bluerock\Sellsy\Entities;

/**
* ACL Attributes.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
trait Acl
{
/**
* <READONLY> Company ACL.
* <READONLY> Entity ACL.
*/
public ?Acl $acl;
public ?Entities\Acl $acl;
}
10 changes: 5 additions & 5 deletions src/Entities/Attributes/Addresses.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
* Addresses Attributes.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
trait Addresses
{
/**
* <READONLY> Company invoicing address ID from Sellsy.
* <READONLY> Entity invoicing address ID from Sellsy.
*/
public ?int $invoicing_address_id;

/**
* <READONLY> Company delivery address ID from Sellsy.
* <READONLY> Entity delivery address ID from Sellsy.
*/
public ?int $delivery_address_id;

/**
* <READONLY> Company invoicing address entity.
* <READONLY> Entity invoicing address entity.
*/
public ?Address $invoicing_address;

/**
* <READONLY> Company delivery address entity.
* <READONLY> Entity delivery address entity.
*/
public ?Address $delivery_address;
}
2 changes: 1 addition & 1 deletion src/Entities/Attributes/ContactInfos.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ContactInfos Attributes.
*
* @package sellsy-connector
* @author Thomas <thomas@hydrat.agency>
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
Expand Down
21 changes: 21 additions & 0 deletions src/Entities/Attributes/SmartTags.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Bluerock\Sellsy\Entities\Attributes;

/**
* ACL Attributes.
*
* @package sellsy-connector
* @author Thomas <thomas@bluerocktel.com>
* @version 1.0
* @access public
*/
trait SmartTags
{
/**
* Entity Smart tags.
*
* \Bluerock\Sellsy\Entities\SmartTag[]
*/
public $smart_tags;
}
Loading

0 comments on commit d18d546

Please sign in to comment.