Skip to content

Commit 1dded97

Browse files
committed
feat: migrate to Saloon
1 parent 7bb996e commit 1dded97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+581
-984
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WORKSOME_API_TOKEN=worksome-test-token
2+
WORKSOME_BASE_URI=https://gateway.test

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* text=auto
44

55
# Ignore all test and documentation with "export-ignore".
6+
/.env.example export-ignore
67
/.github export-ignore
78
/.gitattributes export-ignore
89
/.gitignore export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/composer.lock
66
/phpunit.xml
77
/phpstan.neon
8+
.env
89
.php_cs
910
.php_cs.cache
1011
.phpunit.cache

README.md

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ An object-oriented PHP wrapper for the Worksome API
1111
## Requirements
1212

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

1715
## Install
1816

1917
Via Composer
2018

2119
```shell
22-
composer require worksome/sdk guzzlehttp/guzzle:^7.5 http-interop/http-factory-guzzle:^1.2
20+
composer require worksome/sdk
2321
```
2422

25-
We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io).
26-
2723
## Usage
2824

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

35-
$client = new \Worksome\Sdk\Client();
36-
$repositories = $client->graph()->execute(<<<GQL
31+
$client = new \Worksome\Sdk\Worksome();
32+
$profile = $client->graph()->graphql(<<<GQL
3733
query {
3834
profile {
3935
name
@@ -48,37 +44,17 @@ $repositories = $client->graph()->execute(<<<GQL
4844
The Worksome SDK supports authenticating through an API token.
4945

5046
```php
51-
$client = new \Worksome\Sdk\Client();
52-
$client->authenticate($apiToken);
47+
$client = new \Worksome\Sdk\Worksome($apiToken);
5348
```
5449

5550
#### Using a different base URI
5651

5752
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:
5853

5954
```php
60-
$client = new \Worksome\Sdk\Client(baseUri: 'https://api.local');
61-
```
62-
63-
#### Using a different HTTP client
64-
65-
Thanks to [HTTPlug](https://httplug.io), we support the use of many HTTP clients. For example, to use the Symfony HTTP
66-
Client, first install the client and PSR-7 implementation.
67-
68-
```shell
69-
composer require worksome/sdk symfony/http-client nyholm/psr7
55+
$client = new \Worksome\Sdk\Worksome(tokenbaseUri: 'https://api.local');
7056
```
7157

72-
Next, set up the Worksome client with this HTTP client:
73-
74-
```php
75-
$client = \Worksome\SDK\Client::createWithHttpClient(
76-
new \Symfony\Component\HttpClient\HttplugClient()
77-
);
78-
```
79-
80-
Alternatively, you can inject an HTTP client through the `Client` constructor.
81-
8258
## Change log
8359

8460
Please see [GitHub Releases](https://github.com/worksome/sdk-php/releases) for more information on what has changed recently.

composer.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@
55
"license": "MIT",
66
"require": {
77
"php": "^8.3",
8-
"php-http/client-common": "^2.7",
9-
"php-http/discovery": "^1.20",
10-
"php-http/httplug": "^2.4",
11-
"php-http/multipart-stream-builder": "^1.4",
12-
"psr/http-client-implementation": "^1.0",
13-
"psr/http-factory-implementation": "^1.0",
14-
"psr/http-message": "^1.1 || ^2.0"
8+
"illuminate/collections": "^12.22",
9+
"saloonphp/saloon": "^3.0"
1510
},
1611
"require-dev": {
17-
"guzzlehttp/guzzle": "^7.9",
18-
"guzzlehttp/psr7": "^2.7",
19-
"http-interop/http-factory-guzzle": "^1.2",
2012
"pestphp/pest": "^3.7",
21-
"php-http/mock-client": "^1.6",
22-
"php-http/vcr-plugin": "^1.2",
2313
"phpstan/phpstan": "^2.1",
2414
"symfony/var-dumper": "^7.2",
15+
"vlucas/phpdotenv": "^5.6",
2516
"worksome/coding-style": "^3.2"
2617
},
2718
"autoload": {
@@ -53,8 +44,7 @@
5344
"allow-plugins": {
5445
"pestphp/pest-plugin": true,
5546
"dealerdirect/phpcodesniffer-composer-installer": true,
56-
"worksome/coding-style": true,
57-
"php-http/discovery": true
47+
"worksome/coding-style": true
5848
}
5949
},
6050
"minimum-stability": "dev",

phpstan-baseline.neon

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,7 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: '#^PHP files should declare strict types\.$#'
5-
identifier: worksome.declareStrictTypes
4+
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$#'
5+
identifier: missingType.generics
66
count: 1
7-
path: src/Exception/BadMethodCallException.php
8-
9-
-
10-
message: '#^PHP files should declare strict types\.$#'
11-
identifier: worksome.declareStrictTypes
12-
count: 1
13-
path: src/Exception/ExceptionInterface.php
14-
15-
-
16-
message: '#^PHP files should declare strict types\.$#'
17-
identifier: worksome.declareStrictTypes
18-
count: 1
19-
path: src/Exception/InvalidArgumentException.php
20-
21-
-
22-
message: '#^PHP files should declare strict types\.$#'
23-
identifier: worksome.declareStrictTypes
24-
count: 1
25-
path: src/Exception/InvalidResponseException.php
26-
27-
-
28-
message: '#^PHP files should declare strict types\.$#'
29-
identifier: worksome.declareStrictTypes
30-
count: 1
31-
path: src/Exception/MissingArgumentException.php
32-
33-
-
34-
message: '#^PHP files should declare strict types\.$#'
35-
identifier: worksome.declareStrictTypes
36-
count: 1
37-
path: src/Exception/RuntimeException.php
38-
39-
-
40-
message: '#^PHP files should declare strict types\.$#'
41-
identifier: worksome.declareStrictTypes
42-
count: 1
43-
path: src/HttpClient/Builder.php
44-
45-
-
46-
message: '#^PHP files should declare strict types\.$#'
47-
identifier: worksome.declareStrictTypes
48-
count: 1
49-
path: src/HttpClient/Message/ResponseMediator.php
50-
51-
-
52-
message: '#^Method Worksome\\Sdk\\HttpClient\\Plugin\\Authentication\:\:doHandleRequest\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
53-
identifier: return.type
54-
count: 1
55-
path: src/HttpClient/Plugin/Authentication.php
56-
57-
-
58-
message: '#^PHP files should declare strict types\.$#'
59-
identifier: worksome.declareStrictTypes
60-
count: 1
61-
path: src/HttpClient/Plugin/Authentication.php
62-
63-
-
64-
message: '#^Method Worksome\\Sdk\\HttpClient\\Plugin\\PathPrepend\:\:doHandleRequest\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
65-
identifier: return.type
66-
count: 1
67-
path: src/HttpClient/Plugin/PathPrepend.php
68-
69-
-
70-
message: '#^PHP files should declare strict types\.$#'
71-
identifier: worksome.declareStrictTypes
72-
count: 1
73-
path: src/HttpClient/Plugin/PathPrepend.php
7+
path: src/Exceptions/GraphQL/InvalidResponseException.php

src/Api/AbstractApi.php

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)