Skip to content

Commit 69f1c15

Browse files
committed
wip
1 parent 5180bea commit 69f1c15

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

.github/workflows/openapi.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
name: "OpenAPI"
44

55
on:
6-
schedule:
7-
# Update Monday
8-
- cron: "31 04 * * 1"
96
workflow_dispatch: null
107

118
permissions:
@@ -54,23 +51,17 @@ jobs:
5451
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
5552
-
5653
name: "Determine latest spec version"
57-
id: "billingo_spec"
54+
id: "simple_pay"
5855
run: |
5956
VERSION="$(
60-
wget -qO- "https://api.swaggerhub.com/apis/Billingo/Billingo/settings/default" \
61-
| jq -r '."version"'
57+
jq -r '."version"' ./openapi.json
6258
)"
6359
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
6460
-
6561
name: "Install OpenAPI"
6662
run: |
6763
wget -O "${{ runner.temp }}/openapi-generator-cli.jar" \
6864
"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"
7465
-
7566
name: "Clean up previously generated files"
7667
run: |
@@ -81,11 +72,11 @@ jobs:
8172
PHP_POST_PROCESS_FILE: "php-cs-fixer fix --allow-risky yes"
8273
run: |
8374
java -jar "${{ runner.temp }}/openapi-generator-cli.jar" generate \
84-
--input-spec "${{ runner.temp }}/spec.json" \
75+
--input-spec ./openapi.json \
8576
--generator-name php-nextgen \
8677
--output ./ \
8778
--enable-post-process-file \
88-
--additional-properties 'invokerPackage=Cone\Billingo,variableNamingConvention=camelCase,srcBasePath=src'
79+
--additional-properties 'invokerPackage=Cone\SimplePay,variableNamingConvention=camelCase,srcBasePath=src'
8980
-
9081
name: "Check difference to repository"
9182
run: |
@@ -100,7 +91,7 @@ jobs:
10091
add-paths: "./"
10192
branch: "php-client"
10293
commit-message: "Upgrade client"
103-
title: "Upgrade PHP client to ${{ steps.billingo_spec.outputs.version }}"
94+
title: "Upgrade PHP client to ${{ steps.simple_pay.outputs.version }}"
10495
body: |
10596
Automated changes by running `openapi-generator-cli.jar generate`.
10697
delete-branch: true

src/Client.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ class Client
1515
public function __construct(
1616
protected string $merchantId,
1717
protected string $secretKey,
18-
protected bool $sandbox = false
18+
protected ?Environment $env = null
1919
) {
20-
// $this->config()->setApiKey('X-API-KEY', $apiKey);
20+
$this->config()->setHost(match ($env) {
21+
$env::SANDBOX => 'https://sandbox.simplepay.hu/payment/v2',
22+
$env::SECURE => 'https://secure.simplepay.hu/payment/v2',
23+
default => 'https://secure.simplepay.hu/payment/v2'
24+
});
2125
}
2226

2327
/**

src/Environment.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Cone\SimplePay;
4+
5+
enum Environment: string
6+
{
7+
case SECURE = 'secure';
8+
case SANDBOX = 'sandbox';
9+
}

0 commit comments

Comments
 (0)