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
4 changes: 2 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG PHP_VERSION=7.4
ARG COMPOSER_VERSION=2.7.9
ARG COMPOSER_VERSION=2.8.12

FROM composer:${COMPOSER_VERSION} AS composer
FROM php:${PHP_VERSION}-fpm-alpine

COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /app
WORKDIR /app
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{yml,yaml}]
indent_size = 2
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pashamesh
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on: [ push ]

jobs:
php-test-unit:
name: Unit tests
runs-on: ubuntu-latest

strategy:
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3", "8.4" ]

steps:
- uses: actions/checkout@v4

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('*/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-

- uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php }}

- name: Run tests
run: ./vendor/bin/phpunit tests --do-not-cache-result
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/vendor/
/nbproject/
.idea
.DS_Store
composer.lock
composer.lock
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

all: test

.PHONY: shell sh
shell sh:
docker compose run --rm shell sh

.PHONY: test
test:
docker compose run --rm shell ./vendor/bin/phpunit tests

.PHONY: test-legacy
test-legacy:
docker compose run --rm test

.PHONY: build
build:
docker compose build
docker compose build
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CoMagic php client for:
- Rest API https://www.comagic.ru/support/api/
- Call API

## Requirements
This package requires PHP 7.4 or above.

## Installation
To get started, install package via the Composer package manager:

Expand Down Expand Up @@ -48,18 +51,22 @@ use CoMagic\RestApiClient;

$restApi = new RestApiClient($config);
var_dump(
$restApi->call(['date_from' => '2017-01-10', 'date_till' => '2017-01-13'])
$restApi->call(['date_from' => '2025-01-10', 'date_till' => '2025-01-13'])
);
```

### Call API
API Methods names need to be specified in CamelCase
```php
use CoMagic\CallApiConfig;
use CoMagic\CallApiClient;

$config = new CallApiConfig('login', 'password', 'access_token');
$callApi = new CallApiClient($config);
var_dump($callApi->listCalls());
```

It's possible to get response metadata after API request is made
```php
var_dump($callApi->metadata());
```
```
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "pashamesh/comagic-api",
"description": "php binding for CoMagic API",
"description": "php binding for UIScom and CoMagic API",
"type": "library",
"require": {
"php": ">=7.4",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.2|^7.0"
},
Expand All @@ -16,5 +17,8 @@
"name": "Pasha Mesh",
"email": "pasha.mesh@gmail.com"
}
]
],
"require-dev": {
"phpunit/phpunit": "^9.6"
}
}
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
services:
shell:
build: .docker
image: comagic-api-dev
pull_policy: never
volumes:
- .:/app

test:
build: .docker
image: comagic-api-dev
pull_policy: never
volumes:
- .:/app
command: [
Expand Down
Loading