Skip to content

Commit

Permalink
Release 3.0 (#20)
Browse files Browse the repository at this point in the history
- Added php 7.4+ support
- Added strict types and codestyle fixes
  • Loading branch information
m1x0n authored Apr 10, 2022
1 parent 8730077 commit 682081e
Show file tree
Hide file tree
Showing 46 changed files with 1,740 additions and 2,668 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.4']
php-versions: ['7.4', '8.0']
name: PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
Expand All @@ -32,5 +32,11 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist

- name: Run phpcs
run: vendor/bin/phpcs src tests --standard=PSR12

- name: Run phpstan
run: vendor/bin/phpstan analyse

- name: Run phpunit
run: vendor/bin/phpunit
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.0
**Breaking change**: Now package requires **php 7.4+**

### 2.0
**Breaking change**: Now package requires **php 7.3+**
* Updated Guzzle and PHPUnit
Expand Down
77 changes: 19 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@ Inspired and followed by original [https://github.com/helpscout/helpscout-api-ph

Requirements
---------------------
* PHP >= 7.3.0
* PHP >= 7.4.0

Installation
--------------------
This will install latest `2.*` version:
This will install latest `3.*` version:
```
composer require m1x0n/helpscout-docs-api-php
```

Previous versions for `"php":">= 5.5"` are also available and could be installed in following way:
Package version | PHP version
------------- | -------------
`1.*` | `>= 5.5`
`2.*` | `>= 7.3`
`3.*` | `>= 7.4`


Previous versions are also available and could be installed in following way:
```
composer require m1x0n/helpscout-docs-api-php:^1
composer require m1x0n/helpscout-docs-api-php:^2
```

Example Usage:
Expand All @@ -29,68 +36,22 @@ require_once __DIR__ . '/../vendor/autoload.php';

use HelpScoutDocs\DocsApiClient;

$docsApiClient = new DocsApiClient();
$docsApiClient->setApiKey('your-api-key');
// Initialize client
$docsApiClient = new DocsApiClient('your-api-key');

// Get all collections
$collections = $docsApiClient->getCollections();

```

[More examples](https://github.com/m1x0n/helpscout-docs-api-php/tree/master/examples)
--------------------
[Changelog](https://github.com/m1x0n/helpscout-docs-api-php/tree/master/CHANGELOG.md)
--------------------

Docs API Client Endpoints Methods
[Covered Docs API methods](https://github.com/m1x0n/helpscout-docs-api-php/tree/master/REFERENCE.md)
--------------------

### Collections
* getCollections($page = 1, $siteId = '', $visibility = 'all', $sort = 'order', $order = 'asc')
* getCollection($collectionIdOrNumber)
* createCollection(Collection $collection, $reload = false)
* updateCollection(Collection $collection, $reload = false)
* deleteCollection($collectionId)

### Categories
* getCategories($collectionId, $page = 1, $sort = 'order', $order = 'asc')
* getCategory($categoryIdOrNumber)
* createCategory(Category $category, $reload = false)
* updateCategory(Category $category, $reload = false)
* updateCategoryOrder($collectionId, array $categories)
* deleteCategory($categoryId)

### Articles
* ~~getArticles($categoryId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)~~ Deprecated. Will be removed soon.
* getArticlesForCategory($categoryId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)
* getArticlesForCollection($collectionId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)
* searchArticles($query = '*', $page = 1, $collectionId = '', $status = 'all', $visibility = 'all')
* getRelatedArticles($articleId, $page = 1, $status = 'all', $sort = 'order', $order = 'desc')
* getRevisions($articleId, $page = 1)
* getArticle($articleIdOrNumber, $draft = false)
* getRevision($revisionId)
* createArticle(Article $article, $reload = false)
* updateArticle(Article $article, $reload = false)
* uploadArticle(UploadArticle $uploadArticle, $reload = false)
* updateViewCount($articleId, $count = 1)
* deleteArticle($articleId)
* saveArticleDraft($articleId, $text)
* deleteArticleDraft($articleId)

### Sites
* getSites($page = 1)
* getSite($siteId)
* createSite(Site $site, $reload = false)
* updateSite(Site $site, $reload = false)
* deleteSite($siteId)

### Assets
* createArticleAsset(ArticleAsset $articleAsset)
* createSettingsAsset(SettingsAsset $settingsAsset)
Contributions
---------------------
Contributions are highly appreciated.

### Redirects
* getRedirects($siteId)
* getRedirect($redirectId)
* findRedirect($url, $siteId)
* createRedirect(Redirect $redirect, $reload = false)
* updateRedirect(Redirect $redirect, $reload = false)
* deleteRedirect($redirectId)
Feel free to file an issue, send a PR, make a suggestion etc.
53 changes: 53 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Docs API Client Endpoints Methods
--------------------

### Collections
* getCollections($page = 1, $siteId = '', $visibility = 'all', $sort = 'order', $order = 'asc')
* getCollection($collectionIdOrNumber)
* createCollection(Collection $collection, $reload = false)
* updateCollection(Collection $collection, $reload = false)
* deleteCollection($collectionId)

### Categories
* getCategories($collectionId, $page = 1, $sort = 'order', $order = 'asc')
* getCategory($categoryIdOrNumber)
* createCategory(Category $category, $reload = false)
* updateCategory(Category $category, $reload = false)
* updateCategoryOrder($collectionId, array $categories)
* deleteCategory($categoryId)

### Articles
* ~~getArticles($categoryId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)~~ Deprecated. Will be removed soon.
* getArticlesForCategory($categoryId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)
* getArticlesForCollection($collectionId, $page = 1, $status = 'all', $sort = 'order', $order = 'asc', $pageSize = 50)
* searchArticles($query = '*', $page = 1, $collectionId = '', $status = 'all', $visibility = 'all')
* getRelatedArticles($articleId, $page = 1, $status = 'all', $sort = 'order', $order = 'desc')
* getRevisions($articleId, $page = 1)
* getArticle($articleIdOrNumber, $draft = false)
* getRevision($revisionId)
* createArticle(Article $article, $reload = false)
* updateArticle(Article $article, $reload = false)
* uploadArticle(UploadArticle $uploadArticle, $reload = false)
* updateViewCount($articleId, $count = 1)
* deleteArticle($articleId)
* saveArticleDraft($articleId, $text)
* deleteArticleDraft($articleId)

### Sites
* getSites($page = 1)
* getSite($siteId)
* createSite(Site $site, $reload = false)
* updateSite(Site $site, $reload = false)
* deleteSite($siteId)

### Assets
* createArticleAsset(ArticleAsset $articleAsset)
* createSettingsAsset(SettingsAsset $settingsAsset)

### Redirects
* getRedirects($siteId)
* getRedirect($redirectId)
* findRedirect($url, $siteId)
* createRedirect(Redirect $redirect, $reload = false)
* updateRedirect(Redirect $redirect, $reload = false)
* deleteRedirect($redirectId)
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
},
"minimum-stability": "stable",
"require": {
"php": ">=7.3.0",
"php": ">=7.4.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0.1"
},
"autoload": {
Expand All @@ -42,7 +43,9 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.6",
"phpstan/phpstan": "^0.12.98"
},
"autoload-dev": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions examples/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

require_once __DIR__ . '/../vendor/autoload.php';

$docsClient = new DocsApiClient();
$docsClient->setApiKey('API_KEY');
$docsClient = new DocsApiClient('my_key');

// Create article asset
$articleAsset = new ArticleAsset();
Expand Down
3 changes: 1 addition & 2 deletions examples/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use HelpScoutDocs\DocsApiClient;

// Initialize client
$docsApiClient = new DocsApiClient();
$docsApiClient->setApiKey('your-api-key');
$docsApiClient = new DocsApiClient('your-api-key');

// Get all collections
$collections = $docsApiClient->getCollections();
Expand Down
6 changes: 3 additions & 3 deletions examples/upload-article.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

require_once __DIR__ . '/../vendor/autoload.php';

$docsClient = new DocsApiClient();
$docsClient = new DocsApiClient('your-api-key');
$docsClient->setApiKey('API_KEY');

$upload = new UploadArticle();
$upload->setCollectionId('COLLECTION_ID');
$upload->setName(uniqid('Uploaded Article '));
$upload->setName(uniqid('Uploaded Article ', true));
$upload->setFile('REAL_PATH_TO_FILE');

$article = $docsClient->uploadArticle($upload, true);
$article = $docsClient->uploadArticleAndReturnUploaded($upload);
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: 7
paths:
- src
- tests
checkGenericClassInNonGenericObjectType: false
36 changes: 20 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="./tests/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/HelpScoutDocs/</directory>
</include>
<exclude>
<directory suffix=".php">src/HelpScoutDocs/Models/</directory>
<file>src/HelpScoutDocs/ResourceCollection.php</file>
<file>src/HelpScoutDocs/ApiException.php</file>
</exclude>
</coverage>
<testsuites>
<testsuite name="HelpScout Docs Api Test Suite">
<directory>./tests/HelpScoutDocs/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false"
colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false"
stopOnFailure="false" beStrictAboutTestsThatDoNotTestAnything="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/HelpScoutDocs/</directory>
</include>
<exclude>
<directory suffix=".php">src/HelpScoutDocs/Models/</directory>
<file>src/HelpScoutDocs/ResourceCollection.php</file>
<file>src/HelpScoutDocs/ApiException.php</file>
</exclude>
</coverage>
<testsuites>
<testsuite name="HelpScout Docs Api Test Suite">
<directory>./tests/HelpScoutDocs/</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 682081e

Please sign in to comment.