-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642c2b3
commit dd890cf
Showing
17 changed files
with
2,065 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Unit tests and checkstyle | ||
on: [push] | ||
jobs: | ||
phpunit: | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
operating-system: ['ubuntu-latest'] | ||
php-versions: ['8.2', '8.3'] | ||
phpunit-versions: ['latest'] | ||
include: | ||
- operating-system: 'ubuntu-latest' | ||
php-versions: '8.2' | ||
phpunit-versions: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: mbstring | ||
coverage: xdebug | ||
tools: composer:v2, php-cs-fixer, phpunit:${{ matrix.phpunit-versions }} | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist | ||
|
||
- name: Run PHPCS | ||
run: ./vendor/bin/phpcs src tests -v --standard=PSR2 | ||
|
||
- name: Run Psalm | ||
run: ./vendor/bin/psalm --show-info=true | ||
|
||
- name: Run PHPStan | ||
run: ./vendor/bin/phpstan analyse --level=5 src tests | ||
|
||
- name: Run PHPUnit | ||
run: ./vendor/bin/phpunit --coverage-text --colors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# IDE | ||
/.idea/ | ||
|
||
# PHP Unit | ||
.phpunit.cache | ||
.phpunit.result.cache | ||
|
||
# Composer | ||
composer.lock | ||
composer.phar | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Requirements | ||
[![PHP Version Require](http://poser.pugx.org/inserve/also-cloud-marketplace-api-php/require/php)](https://packagist.org/packages/inserve/also-cloud-marketplace-api-php) | ||
|
||
## Installation | ||
`composer require inserve/also-cloud-marketplace-api-php` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "inserve/also-cloud-marketplace-api-php", | ||
"description": "A PHP wrapper ALSO Cloud Marketplace", | ||
"license": "MIT", | ||
"type": "library", | ||
"require": { | ||
"php": "^8.2", | ||
"guzzlehttp/guzzle": "^7.7", | ||
"symfony/serializer": "^6.3|^7", | ||
"symfony/property-access": "^6.3|^7", | ||
"psr/log": "^3.0", | ||
"phpdocumentor/reflection-docblock": "^5.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^10.2", | ||
"squizlabs/php_codesniffer": "^3.7", | ||
"phpstan/phpstan": "^1.10", | ||
"vimeo/psalm": "^5.22" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Inserve\\ALSOCloudMarketplaceAPI\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Inserve\\ALSOCloudMarketplaceAPI\\Tests\\": "tests/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Inserve", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "stable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" | ||
backupGlobals="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false" | ||
> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true"> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="3" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
findUnusedBaselineEntry="true" | ||
findUnusedCode="false" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
<directory name="tests" /> | ||
<ignoreFiles> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
</psalm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Inserve\ALSOCloudMarketplaceAPI\API; | ||
|
||
use Inserve\ALSOCloudMarketplaceAPI\Client\APIClient; | ||
|
||
/** | ||
* | ||
*/ | ||
abstract class AbstractAPIClient | ||
{ | ||
/** | ||
* @param APIClient $apiClient | ||
*/ | ||
public function __construct(#[\SensitiveParameter] protected APIClient $apiClient) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Inserve\ALSOCloudMarketplaceAPI\API; | ||
|
||
use Inserve\ALSOCloudMarketplaceAPI\Exception\MarketplaceAPIException; | ||
use Inserve\ALSOCloudMarketplaceAPI\Model\Company; | ||
use Symfony\Component\Serializer\Exception\ExceptionInterface; | ||
|
||
/** | ||
* | ||
*/ | ||
class CompanyAPI extends AbstractAPIClient | ||
{ | ||
/** | ||
* @param int $accountId | ||
* | ||
* @return Company|null | ||
* | ||
* @throws MarketplaceAPIException|ExceptionInterface | ||
*/ | ||
public function get(int $accountId): ?Company | ||
{ | ||
$response = $this->apiClient->call( | ||
'/GetCompany', | ||
json_encode(compact('accountId')) | ||
); | ||
|
||
return $this->apiClient->denormalize($response, Company::class); | ||
} | ||
|
||
/** | ||
* @param int $parentAccountId | ||
* | ||
* @return Company[] | ||
* | ||
* @throws MarketplaceAPIException|ExceptionInterface | ||
*/ | ||
public function list(int $parentAccountId): array | ||
{ | ||
$response = $this->apiClient->call( | ||
'/GetCompanies', | ||
json_encode(compact('parentAccountId')) | ||
); | ||
|
||
$companies = []; | ||
foreach ($response as $item) { | ||
$companies[] = $this->apiClient->denormalize($item, Company::class); | ||
} | ||
|
||
return $companies; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Inserve\ALSOCloudMarketplaceAPI\API; | ||
|
||
use Inserve\ALSOCloudMarketplaceAPI\Exception\MarketplaceAPIException; | ||
use Inserve\ALSOCloudMarketplaceAPI\Model\Subscription; | ||
use Symfony\Component\Serializer\Exception\ExceptionInterface; | ||
|
||
/** | ||
* | ||
*/ | ||
class SubscriptionsAPI extends AbstractAPIClient | ||
{ | ||
/** | ||
* @param int $accountId | ||
* | ||
* @return Subscription|null | ||
* | ||
* @throws MarketplaceAPIException|ExceptionInterface | ||
*/ | ||
public function get(int $accountId): ?Subscription | ||
{ | ||
$response = $this->apiClient->call( | ||
'/GetSubscription', | ||
json_encode(compact('accountId')) | ||
); | ||
|
||
return $this->apiClient->denormalize($response, Subscription::class); | ||
} | ||
|
||
/** | ||
* @param int $parentAccountId | ||
* @param bool $excludeUserLevel | ||
* | ||
* @return Subscription[] | ||
* | ||
* @throws MarketplaceAPIException|ExceptionInterface | ||
*/ | ||
public function list(int $parentAccountId, bool $excludeUserLevel = false): array | ||
{ | ||
$response = $this->apiClient->call( | ||
'/GetSubscriptions', | ||
json_encode(compact('parentAccountId', 'excludeUserLevel')) | ||
); | ||
|
||
$subscriptions = []; | ||
foreach ($response as $item) { | ||
$subscriptions[] = $this->apiClient->denormalize($item, Subscription::class); | ||
} | ||
|
||
return $subscriptions; | ||
} | ||
} |
Oops, something went wrong.