Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "Checlbox",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/php"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
59 changes: 33 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
name: PHP Composer
name: CI

on:
push:
branches:
- '*'
pull_request:
branches: [ "main" ]
branches: [main]
workflow_call:

permissions:
contents: read

jobs:
test:
strategy:
matrix:
php: [ 8.2, 8.3]
php: [8.3, 8.4, 8.5]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}
- name: Install dependencies
run: |
composer install --prefer-dist --no-progress
- name: Run test suite
run: composer run-script test
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test

- name: Check code style
run: composer run-script cs-check
47 changes: 11 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,22 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.3, 8.4]
steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Cache Composer packages
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test
uses: ./.github/workflows/ci.yml

release:
release-please:
needs: test
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: go-semantic-release/action@v1
- uses: googleapis/release-please-action@v4
id: release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
changelog-file: CHANGELOG.md
changelog-generator-opt: "emojis=true"
allow-initial-development-versions: true
prepend: true
release-type: simple
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@

# About
Checkbox.ua have OpenAPI specification (https://api.checkbox.in.ua/api/openapi.json)
that is incorrectly described in many places.
For example, lack of nullable union types and different datetime format for the semantically same type of field.
That causes generated client libraries to throw unexpected error.

Initial library code was generated by [JanePHP](https://github.com/janephp/janephp) (Thanks, for a great project!)
Checkbox.ua has an OpenAPI specification (https://api.checkbox.in.ua/api/openapi.json) that is incorrectly described in many places. For example, lack of nullable union types and different datetime formats for semantically same fields. This causes generated client libraries to throw unexpected errors.

That code was modified manually, nullables was added and a specific date format used for different fields.
Initial library code was generated by [JanePHP](https://github.com/janephp/janephp). That code was modified manually to add nullables and handle specific date formats for different fields.

General logic is still handled by [JanePHP runtime](https://github.com/janephp/janephp)
General logic is still handled by [JanePHP runtime](https://github.com/janephp/janephp).

## Installation

```bash
composer install revotale/checkbox-ua
composer require revotale/checkbox-ua
```

## Usage
Example with [signing in cashier with pin code and licence key](https://api.checkbox.in.ua/api/docs#/Касир/sign_in_cashier_api_v1_cashier_signin_post).

Example with [signing in cashier with pin code and licence key](https://api.checkbox.in.ua/api/docs#/Касир/sign_in_cashier_api_v1_cashier_signin_post):

```php
<?php
declare(strict_types=1)

declare(strict_types=1);

use RevoTale\CheckboxUA\ClientFactory;
use RevoTale\CheckboxUA\Model\CashierSignInPinCode;
$client = ClientFactory::createClient();//You can provide a token in case of secure API endpoint

$client = ClientFactory::createClient(
clientName: 'MyApp',
clientVersion: '1.0.0',
token: $token // optional, for secure API endpoints
);

$payload = new CashierSignInPinCode();
$payload->setPinCode($pinCode);
$client->signInCashierApiV1CashierSigninPost()

$response = $client->signInCashierApiV1CashierSigninPost($payload);
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
],
"scripts": {
"test": "vendor/bin/phpstan analyse --memory-limit=1G -c phpstan.neon",
"fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
"fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"cs-check": "vendor/bin/php-cs-fixer check --allow-risky=yes"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 1
level: 0

paths:
- src
Loading