Skip to content
Open
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
12 changes: 12 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset name="openapi-php-sdk">
<description>PSR-12 coding standard</description>

<file>src/</file>

<arg name="basepath" value="."/>
<arg name="colors"/>
<arg value="p"/>

<rule ref="PSR12"/>
</ruleset>
176 changes: 105 additions & 71 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,112 @@
{
"name": "openapi/openapi-sdk",
"description": "Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)",
"license": "MIT",
"authors": [
{
"name": "Altravia",
"email": "info@altravia.com",
"homepage": "https://www.altravia.com",
"role": "Maintainer"
},
{
"name": "Lorenzo Paderi",
"email": "l.paderi@altravia.com",
"homepage": "https://github.com/lpaderiAltravia",
"role": "Developer"
},
{
"name": "Mario Ugurcu",
"email": "mario.ugurcu@wum-studios.de",
"homepage": "https://github.com/Seraphim200001",
"role": "Contributor"
},
{
"name": "Francesco Bianco",
"email": "bianco@javanile.org",
"homepage": "https://github.com/francescobianco",
"role": "Contributor"
},
{
"name": "Claude Code (Anthropic)",
"email": "noreply@anthropic.com",
"homepage": "https://claude.ai/code",
"role": "AI Contributor"
}
],
"keywords": [
"api", "rest", "http", "client", "sdk", "oauth", "oauth2", "token",
"sms", "pec", "email", "geocoding", "company", "business-registry",
"italy", "italian", "imprese", "visure", "catasto",
"laravel", "symfony", "codeigniter", "yii", "slim", "lumen",
"cakephp", "phalcon", "laminas", "zend", "october", "wordpress",
"php", "php8", "curl", "psr-18", "http-client", "guzzle"
],
"minimum-stability": "stable",
"require": {
"php": ">=8.0.0",
"ext-curl": "*",
"ext-json": "*",
"psr/http-client": "^1.0"
"name": "openapi/openapi-sdk",
"description": "Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)",
"license": "MIT",
"authors": [
{
"name": "Altravia",
"email": "info@altravia.com",
"homepage": "https://www.altravia.com",
"role": "Maintainer"
},
"require-dev": {
"symfony/dotenv": "^5.3",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^2.1"
{
"name": "Lorenzo Paderi",
"email": "l.paderi@altravia.com",
"homepage": "https://github.com/lpaderiAltravia",
"role": "Developer"
},
"autoload": {
"psr-4": {
"Openapi\\": "src"
},
"files": [
"src/Bootstrap.php"
]
{
"name": "Mario Ugurcu",
"email": "mario.ugurcu@wum-studios.de",
"homepage": "https://github.com/Seraphim200001",
"role": "Contributor"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
{
"name": "Francesco Bianco",
"email": "bianco@javanile.org",
"homepage": "https://github.com/francescobianco",
"role": "Contributor"
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon",
"test": "phpunit tests/",
"test:unit": "phpunit tests/ --testsuite=unit",
"example:token": "php examples/token_generation.php",
"example:api": "php examples/api_calls.php",
"example:complete": "php examples/complete_workflow.php"
{
"name": "Claude Code (Anthropic)",
"email": "noreply@anthropic.com",
"homepage": "https://claude.ai/code",
"role": "AI Contributor"
}
],
"keywords": [
"api",
"rest",
"http",
"client",
"sdk",
"oauth",
"oauth2",
"token",
"sms",
"pec",
"email",
"geocoding",
"company",
"business-registry",
"italy",
"italian",
"imprese",
"visure",
"catasto",
"laravel",
"symfony",
"codeigniter",
"yii",
"slim",
"lumen",
"cakephp",
"phalcon",
"laminas",
"zend",
"october",
"wordpress",
"php",
"php8",
"curl",
"psr-18",
"http-client",
"guzzle"
],
"minimum-stability": "stable",
"require": {
"php": ">=8.0.0",
"ext-curl": "*",
"ext-json": "*",
"psr/http-client": "^1.0"
},
"require-dev": {
"symfony/dotenv": "^5.3",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^2.1",
"squizlabs/php_codesniffer": "^4.0"
},
"autoload": {
"psr-4": {
"Openapi\\": "src"
},
"files": [
"src/Bootstrap.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse -c phpstan.neon",
"test": "phpunit tests/",
"test:unit": "phpunit tests/ --testsuite=unit",
"example:token": "php examples/token_generation.php",
"example:api": "php examples/api_calls.php",
"example:complete": "php examples/complete_workflow.php",
"cs": "phpcs",
"cs-fix": "phpcbf"
}
}
8 changes: 6 additions & 2 deletions src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class ApiException extends \Exception
/**
* TODO: Utilize this method in Client and OauthClient to provide structured error context
*/
public function setServerResponse(mixed $response, mixed $headers = null, mixed $rawResponse = null, ?int $httpCode = null): void
{
public function setServerResponse(
mixed $response,
mixed $headers = null,
mixed $rawResponse = null,
?int $httpCode = null
): void {
$this->serverResponse = $response;
$this->headers = $headers;
$this->rawResponse = $rawResponse;
Expand Down
2 changes: 2 additions & 0 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols

declare(strict_types=1);

use Openapi\Environment\DotEnv;
Expand Down
6 changes: 3 additions & 3 deletions src/OauthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class OauthClient
private string $username;
private string $apikey;

const OAUTH_BASE_URL = 'https://oauth.openapi.it';
const TEST_OAUTH_BASE_URL = 'https://test.oauth.openapi.it';
public const OAUTH_BASE_URL = 'https://oauth.openapi.it';
public const TEST_OAUTH_BASE_URL = 'https://test.oauth.openapi.it';

public function __construct(?string $username = null, ?string $apikey = null, bool $test = false)
{
Expand Down Expand Up @@ -59,7 +59,7 @@ public function getCounters(string $period, string $date): string
return $this->request('GET', $this->url . '/counters/' . $period . '/' . $date);
}


/**
* @param array<string, mixed>|null $body
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Transports/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ final class CurlTransport implements HttpTransportInterface
{
public function __construct(
private ?string $token = null
) {}
) {
}

public function request(
string $method,
Expand Down