Skip to content

Commit 876d197

Browse files
committed
wip
1 parent 982c37e commit 876d197

8 files changed

Lines changed: 408 additions & 0 deletions

File tree

.github/workflows/openapi.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: "OpenAPI"
4+
5+
on:
6+
schedule:
7+
# Update Monday
8+
- cron: "31 04 * * 1"
9+
workflow_dispatch: null
10+
11+
permissions:
12+
contents: "write"
13+
pull-requests: "write"
14+
15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.ref }}"
17+
cancel-in-progress: true
18+
19+
jobs:
20+
generate:
21+
name: "Generate PHP client"
22+
runs-on: "ubuntu-22.04"
23+
timeout-minutes: 5
24+
steps:
25+
-
26+
name: "Checkout repository"
27+
uses: "actions/checkout@v4"
28+
-
29+
name: "Set up Java"
30+
uses: "actions/setup-java@v4"
31+
with:
32+
distribution: "temurin"
33+
java-version: "17"
34+
-
35+
name: "Install xmlstarlet"
36+
run: |
37+
sudo -- apt-get update
38+
sudo -- apt-get install -y xmlstarlet
39+
-
40+
name: "Set up PHP"
41+
uses: "shivammathur/setup-php@v2"
42+
with:
43+
php-version: "8.1"
44+
tools: "php-cs-fixer"
45+
coverage: "none"
46+
-
47+
name: "Determine OpenAPI CLI version"
48+
id: "openapi_cli"
49+
run: |
50+
VERSION="$(
51+
wget -qO- "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml" \
52+
| xmlstarlet sel -t -v '//metadata/versioning/versions/version[last()]'
53+
)"
54+
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
55+
-
56+
name: "Determine latest spec version"
57+
id: "billingo_spec"
58+
run: |
59+
VERSION="$(
60+
wget -qO- "https://api.swaggerhub.com/apis/Billingo/Billingo/settings/default" \
61+
| jq -r '."version"'
62+
)"
63+
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
64+
-
65+
name: "Install OpenAPI"
66+
run: |
67+
wget -O "${{ runner.temp }}/openapi-generator-cli.jar" \
68+
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ steps.openapi_cli.outputs.version }}/openapi-generator-cli-${{ steps.openapi_cli.outputs.version }}.jar"
69+
-
70+
name: "Download spec"
71+
run: |
72+
wget -O "${{ runner.temp }}/spec.json" \
73+
"https://api.swaggerhub.com/apis/Billingo/Billingo/${{ steps.billingo_spec.outputs.version }}?resolved=false&flatten=false"
74+
-
75+
name: "Clean up previously generated files"
76+
run: |
77+
cat .openapi-generator/FILES | xargs -- rm -f -r
78+
-
79+
name: "Generate client"
80+
env:
81+
PHP_POST_PROCESS_FILE: "php-cs-fixer fix --allow-risky yes"
82+
run: |
83+
java -jar "${{ runner.temp }}/openapi-generator-cli.jar" generate \
84+
--input-spec "${{ runner.temp }}/spec.json" \
85+
--generator-name php-nextgen \
86+
--output ./ \
87+
--enable-post-process-file \
88+
--additional-properties 'invokerPackage=Cone\Billingo,variableNamingConvention=camelCase,srcBasePath=src'
89+
-
90+
name: "Check difference to repository"
91+
run: |
92+
if [ -z "$(git status --porcelain)" ]; then
93+
echo "No changes!"
94+
exit 10
95+
fi
96+
-
97+
name: "Create pull request"
98+
uses: "peter-evans/create-pull-request@v5"
99+
with:
100+
add-paths: "./"
101+
branch: "php-client"
102+
commit-message: "Upgrade client"
103+
title: "Upgrade PHP client to ${{ steps.billingo_spec.outputs.version }}"
104+
body: |
105+
Automated changes by running `openapi-generator-cli.jar generate`.
106+
delete-branch: true

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
composer.phar
2+
/composer.lock
3+
/vendor/
4+
5+
# php-cs-fixer cache
6+
.php_cs.cache
7+
.php-cs-fixer.cache
8+
9+
# PHPUnit cache
10+
.phpunit.result.cache
11+
.phpunit.cache/

.openapi-generator-ignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.gitignore
2+
/.php-cs-fixer.dist.php
3+
/.travis.yml
4+
/git_push.sh
5+
/composer.json
6+
/README.md
7+
/test/
8+
/docs/
9+
/phpunit.xml.dist

.php-cs-fixer.dist.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/**
4+
* @generated
5+
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
6+
*/
7+
$finder = PhpCsFixer\Finder::create()
8+
->in(__DIR__)
9+
->exclude('vendor')
10+
->exclude('test')
11+
->exclude('tests')
12+
;
13+
14+
$config = new PhpCsFixer\Config();
15+
return $config->setRules([
16+
'@PSR12' => true,
17+
'phpdoc_order' => true,
18+
'array_syntax' => [ 'syntax' => 'short' ],
19+
'single_line_comment_style' => [ 'comment_types' => [ 'hash' ] ],
20+
'strict_comparison' => true,
21+
'strict_param' => true,
22+
'phpdoc_indent' => true,
23+
'phpdoc_no_package' => true,
24+
'phpdoc_scalar' => true,
25+
'trailing_comma_in_multiline' => [ 'elements' => [ 'arrays' ] ],
26+
])
27+
->setFinder($finder)
28+
;

.phplint.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
path:
2+
- ./src
3+
- ./tests
4+
jobs: 10
5+
extensions:
6+
- php
7+
exclude:
8+
- vendor
9+
warning: true
10+
memory-limit: -1
11+
no-cache: true

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "conedevelopment/simplepay-client",
3+
"description": "The SimplePay PHP Client.",
4+
"keywords": [
5+
"openapi",
6+
"php",
7+
"sdk",
8+
"api"
9+
],
10+
"homepage": "https://conedevelopment.com",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Cone Development",
15+
"homepage": "https://conedevelopment.com"
16+
},
17+
{
18+
"name": "Szépe Viktor",
19+
"homepage": "https://www.szepe.net"
20+
}
21+
],
22+
"require": {
23+
"php": "^8.1",
24+
"ext-curl": "*",
25+
"ext-json": "*",
26+
"ext-mbstring": "*",
27+
"guzzlehttp/guzzle": "^7.3",
28+
"guzzlehttp/psr7": "^2.0"
29+
},
30+
"require-dev": {
31+
"friendsofphp/php-cs-fixer": "^3.5"
32+
},
33+
"autoload": {
34+
"psr-4": {
35+
"Cone\\SimplePay\\" : "src/"
36+
}
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"Cone\\SimplePay\\Test\\" : "test/"
41+
}
42+
}
43+
}

openapi.json

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "SimplePay API v2",
5+
"description": "This is a SimplePay API v2 documentation.",
6+
"termsOfService": "#",
7+
"contact": {
8+
"name": "Cone Development",
9+
"url": "https://conedevelopment.com",
10+
"email": "hello@conedevelopment.com"
11+
},
12+
"version": "2.0.0"
13+
},
14+
"servers": [
15+
{
16+
"url": "https://secure.simplepay.hu/payment/v2",
17+
"description": "The Production SimplePay API"
18+
},
19+
{
20+
"url": "sandbox://sandbox.simplepay.hu/payment/v2",
21+
"description": "The Test SimplePay API"
22+
}
23+
],
24+
"paths": {
25+
"/start": {
26+
"post": {
27+
"tags": [
28+
"Transaction"
29+
],
30+
"summary": "Start a transaction",
31+
"description": "Start a transaction using the given parameters",
32+
"operationId": "ListBankAccount",
33+
"parameters": [
34+
{
35+
"name": "page",
36+
"in": "query",
37+
"required": false,
38+
"schema": {
39+
"type": "integer",
40+
"default": "1"
41+
}
42+
}
43+
],
44+
"requestBody": {
45+
"description": "The transaction object you would like to start.",
46+
"required": true,
47+
"content": {
48+
"application/json": {
49+
"schema": {
50+
"$ref": "#/components/schemas/BankAccount"
51+
}
52+
}
53+
}
54+
},
55+
"responses": {
56+
"200": {
57+
"description": "Success response",
58+
"headers": {
59+
"Signature": {
60+
"description": "Request limit per minute.",
61+
"schema": {
62+
"type": "integer",
63+
"format": "int32"
64+
}
65+
}
66+
},
67+
"content": {
68+
"application/json": {
69+
"schema": {
70+
"$ref": "#/components/schemas/BankAccountList"
71+
}
72+
}
73+
}
74+
},
75+
"400": {
76+
"$ref": "#/components/responses/BadRequest"
77+
},
78+
"401": {
79+
"$ref": "#/components/responses/Unauthorized"
80+
},
81+
"402": {
82+
"$ref": "#/components/responses/PaymentRequired"
83+
},
84+
"422": {
85+
"$ref": "#/components/responses/UnprocessableEntity"
86+
},
87+
"429": {
88+
"$ref": "#/components/responses/TooManyRequests"
89+
},
90+
"500": {
91+
"$ref": "#/components/responses/ServerError"
92+
}
93+
}
94+
}
95+
}
96+
},
97+
"components": {
98+
"schemas": {
99+
"Transaction": {
100+
"required": [
101+
"currency"
102+
],
103+
"properties": {
104+
"customer": {
105+
"type": "string"
106+
},
107+
"customerEmail": {
108+
"type": "string",
109+
"format": "email"
110+
},
111+
"currency": {
112+
"$ref": "#/components/schemas/Currency"
113+
},
114+
"maySelectInvoice": {
115+
"type": "boolean",
116+
"default": false
117+
},
118+
"twoStep": {
119+
"type": "boolean",
120+
"default": false
121+
},
122+
"onlyCardReg": {
123+
"type": "boolean",
124+
"default": false
125+
},
126+
"url": {
127+
"type": "string"
128+
},
129+
"language": {
130+
"type": "string"
131+
},
132+
"discount": {
133+
"type": "number",
134+
"default": 0
135+
},
136+
"shippingCost": {
137+
"type": "number",
138+
"default": 0
139+
},
140+
"total": {
141+
"type": "number",
142+
"default": 0
143+
},
144+
"delivery": {
145+
"type": "object",
146+
"properties": {}
147+
},
148+
"invoice": {
149+
"type": "object",
150+
"properties": {}
151+
},
152+
"items": {
153+
"type": "array",
154+
"items": {}
155+
},
156+
"methods": {
157+
"type": "array",
158+
"description": "Possible valies: CARD, WIRE or EAM."
159+
},
160+
"timeout": {
161+
"type": "string",
162+
"description": "The ISO 8601 format of the timeout date.",
163+
"example": "2004-02-12T15:19:21+00:00"
164+
}
165+
},
166+
"type": "object"
167+
},
168+
"Currency": {
169+
"type": "string",
170+
"enum": [
171+
"EUR",
172+
"HUF",
173+
"USD"
174+
]
175+
}
176+
}
177+
}
178+
}

0 commit comments

Comments
 (0)