Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WORKSOME_API_TOKEN=worksome-test-token
WORKSOME_BASE_URI=https://gateway.test
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* text=auto

# Ignore all test and documentation with "export-ignore".
/.env.example export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/composer.lock
/phpunit.xml
/phpstan.neon
.env
.php_cs
.php_cs.cache
.phpunit.cache
Expand Down
34 changes: 5 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ An object-oriented PHP wrapper for the Worksome API
## Requirements

- PHP >= 8.2
- A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation)
- A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation)

## Install

Via Composer

```shell
composer require worksome/sdk guzzlehttp/guzzle:^7.5 http-interop/http-factory-guzzle:^1.2
composer require worksome/sdk
```

We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io).

## Usage

#### Basic usage
Expand All @@ -32,8 +28,8 @@ We are decoupled from any HTTP messaging client with help by [HTTPlug](https://h
// Include the Composer autoloader
require_once __DIR__ . '/vendor/autoload.php';

$client = new \Worksome\Sdk\Client();
$repositories = $client->graph()->execute(<<<GQL
$client = new \Worksome\Sdk\Worksome();
$profile = $client->graph()->graphql(<<<GQL
query {
profile {
name
Expand All @@ -48,37 +44,17 @@ $repositories = $client->graph()->execute(<<<GQL
The Worksome SDK supports authenticating through an API token.

```php
$client = new \Worksome\Sdk\Client();
$client->authenticate($apiToken);
$client = new \Worksome\Sdk\Worksome($apiToken);
```

#### Using a different base URI

The Worksome SDK defaults to using the `https://api.worksome.com` URI, however if a custom URI is required, this can be passed to the constructor:

```php
$client = new \Worksome\Sdk\Client(baseUri: 'https://api.local');
```

#### Using a different HTTP client

Thanks to [HTTPlug](https://httplug.io), we support the use of many HTTP clients. For example, to use the Symfony HTTP
Client, first install the client and PSR-7 implementation.

```shell
composer require worksome/sdk symfony/http-client nyholm/psr7
$client = new \Worksome\Sdk\Worksome(baseUri: 'https://api.local');
```

Next, set up the Worksome client with this HTTP client:

```php
$client = \Worksome\SDK\Client::createWithHttpClient(
new \Symfony\Component\HttpClient\HttplugClient()
);
```

Alternatively, you can inject an HTTP client through the `Client` constructor.

## Change log

Please see [GitHub Releases](https://github.com/worksome/sdk-php/releases) for more information on what has changed recently.
Expand Down
18 changes: 4 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@
"license": "MIT",
"require": {
"php": "^8.3",
"php-http/client-common": "^2.7",
"php-http/discovery": "^1.20",
"php-http/httplug": "^2.4",
"php-http/multipart-stream-builder": "^1.4",
"psr/http-client-implementation": "^1.0",
"psr/http-factory-implementation": "^1.0",
"psr/http-message": "^1.1 || ^2.0"
"illuminate/collections": "^11.45 || ^12.22",
"saloonphp/saloon": "^3.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.9",
"guzzlehttp/psr7": "^2.7",
"http-interop/http-factory-guzzle": "^1.2",
"pestphp/pest": "^3.7",
"php-http/mock-client": "^1.6",
"php-http/vcr-plugin": "^1.2",
"phpstan/phpstan": "^2.1",
"symfony/var-dumper": "^7.2",
"vlucas/phpdotenv": "^5.6",
"worksome/coding-style": "^3.2"
},
"autoload": {
Expand Down Expand Up @@ -53,8 +44,7 @@
"allow-plugins": {
"pestphp/pest-plugin": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"worksome/coding-style": true,
"php-http/discovery": true
"worksome/coding-style": true
}
},
"minimum-stability": "dev",
Expand Down
72 changes: 3 additions & 69 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,73 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
message: '#^Method Worksome\\Sdk\\Exceptions\\GraphQL\\InvalidResponseException\:\:__construct\(\) has parameter \$response with generic class Worksome\\Sdk\\DTOs\\GraphQL but does not specify its types\: TData$#'
identifier: missingType.generics
count: 1
path: src/Exception/BadMethodCallException.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/Exception/ExceptionInterface.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/Exception/InvalidArgumentException.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/Exception/InvalidResponseException.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/Exception/MissingArgumentException.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/Exception/RuntimeException.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/HttpClient/Builder.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/HttpClient/Message/ResponseMediator.php

-
message: '#^Method Worksome\\Sdk\\HttpClient\\Plugin\\Authentication\:\:doHandleRequest\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
identifier: return.type
count: 1
path: src/HttpClient/Plugin/Authentication.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/HttpClient/Plugin/Authentication.php

-
message: '#^Method Worksome\\Sdk\\HttpClient\\Plugin\\PathPrepend\:\:doHandleRequest\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
identifier: return.type
count: 1
path: src/HttpClient/Plugin/PathPrepend.php

-
message: '#^PHP files should declare strict types\.$#'
identifier: worksome.declareStrictTypes
count: 1
path: src/HttpClient/Plugin/PathPrepend.php
path: src/Exceptions/GraphQL/InvalidResponseException.php
173 changes: 0 additions & 173 deletions src/Api/AbstractApi.php

This file was deleted.

Loading