Skip to content

Commit be78850

Browse files
author
vfarylevych
committed
Initial
0 parents  commit be78850

18 files changed

+7226
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitattributes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
*.md diff=markdown
4+
*.php diff=php
5+
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
.styleci.yml export-ignore
10+
CHANGELOG.md export-ignore
11+
UPGRADE.md

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea
2+
/vendor

.styleci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Release Notes
2+
3+
## [1.0.0 (2021-09-01)]
4+
5+
### Added
6+
- Everything

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Volodymyr Farylevych
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Laravel-Ubki
2+
3+
<p align="center">
4+
<a href="https://github.styleci.io/repos/000000000"><img src="https://github.styleci.io/repos/000000000/shield?style=flat" alt="StyleCI Status"></a>
5+
<a href="https://packagist.org/packages/arttiger/laravel-ubki"><img src="https://img.shields.io/packagist/dt/arttiger/laravel-ubki?style=flat" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/arttiger/laravel-ubki"><img src="https://img.shields.io/packagist/v/arttiger/laravel-ubki?style=flat" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/arttiger/laravel-ubki"><img src="https://img.shields.io/packagist/l/arttiger/laravel-ubki?style=flat" alt="License"></a>
8+
</p>
9+
10+
[Украинское бюро кредитных историй (УБКИ)][link-ubki] занимается сбором, хранением, обработкой и предоставлением кредитных историй. УБКИ получает информацию о заемщиках от банков, страховых компаний, лизинговых компаний, кредитных союзов и других финансовых институтов. Информация передается на добровольной основе и только при наличии письменного согласия заемщика.
11+
12+
Для автоматизации взаимодействия с УБКИ существует [web-сервис][link-ubki-api], который принимает запросы, обрабатывает и выдает ответ в зависимости от типа запроса.
13+
14+
This package allows you to simply and easily work with the web-service UBKI.
15+
16+
## Installation
17+
18+
Install the package via composer:
19+
20+
``` bash
21+
$ composer require arttiger/laravel-ubki
22+
```
23+
24+
Next, you need to run migrations:
25+
```bash
26+
$ php artisan migrate
27+
```
28+
29+
### Configuration
30+
31+
In order to edit the default configuration you may execute:
32+
```
33+
php artisan vendor:publish --provider="Arttiger\Ubki\UbkiServiceProvider"
34+
```
35+
36+
After that, `config/ubki.php` will be created.
37+
38+
### Environment
39+
40+
Set environment variable (`.env`)
41+
```
42+
UBKI_TEST_MODE=true
43+
UBKI_ACCOUNT_LOGIN=
44+
UBKI_ACCOUNT_PASSWORD=
45+
UBKI_AUTH_URL=https://secure.ubki.ua/b2_api_xml/ubki/auth
46+
UBKI_REQUEST_URL=https://secure.ubki.ua/b2_api_xml/ubki/xml
47+
UBKI_UPLOAD_URL=https://secure.ubki.ua/upload/data/xml
48+
UBKI_TEST_AUTH_URL=https://secure.ubki.ua:4040/b2_api_xml/ubki/auth
49+
UBKI_TEST_REQUEST_URL=https://secure.ubki.ua:4040/b2_api_xml/ubki/xml
50+
UBKI_TEST_UPLOAD_URL=https://secure.ubki.ua:4040/upload/data/xml
51+
```
52+
53+
## Usage
54+
Add `IntegratorUbki`-trait to the model with client data:
55+
```
56+
use Arttiger\Ubki\Traits\IntegratorUbki;
57+
58+
class Loan extends Model
59+
{
60+
use IntegratorUbki;
61+
...
62+
}
63+
```
64+
65+
Set the necessary the mapping variables in `config/ubki.php`:
66+
67+
```
68+
'model_data' => [
69+
'okpo' => 'inn', // ИНН
70+
'lname' => 'lastName', // Фамилия
71+
'fname' => 'firstName', // Имя
72+
'mname' => 'middleName', // Отчество
73+
'bdate' => 'birth_date', // Дата рождения (гггг-мм-дд)
74+
'dtype' => 'passport_type', // Тип паспорта (см. справочник "Тип документа")
75+
'dser' => 'passport_ser', // Серия паспорта или номер записи ID-карты
76+
'dnom' => 'passport_num', // Номер паспорта или номер ID-карты
77+
'ctype' => 'contact_type', // Тип контакта (см. справочник "Тип контакта")
78+
'cval' => 'contact_val', // Значение контакта (например - "+380951111111")
79+
'foto' => 'foto', // <base64(Фото)>
80+
],
81+
```
82+
This map establishes the correspondence between the attributes of your model and the required query fields in UBKI.
83+
84+
Add a new method `ubkiAttributes()` to the class to add the necessary attributes and fill them with data:
85+
86+
```
87+
use Arttiger\Ubki\Traits\IntegratorUbki;
88+
89+
class Loan extends Model
90+
{
91+
use IntegratorUbki;
92+
...
93+
94+
public function ubkiAttributes($params = [])
95+
{
96+
$client_data = json_decode($this->attributes['client_data']);
97+
$this->attributes['inn'] = trim($client_data->code);
98+
$this->attributes['lastName'] = trim($client_data->lastName);
99+
...
100+
}
101+
}
102+
```
103+
You can use other ways to create custom attributes that you specified in `'model_data'` (`config/ubki.php`).
104+
105+
Now, you can get data from UBKI:
106+
```php
107+
$loan = Loan::find(1);
108+
$result = $loan->ubki();
109+
```
110+
`$result['response']` - xml response from UBKI (standard report).
111+
112+
You can also pass parameters:
113+
```php
114+
$result = $loan->ubki($params);
115+
```
116+
- `$params['report']` - report alias, if you need other reports;
117+
- `$params['request_id']` - your request ID (if necessary);
118+
- `$params['lang']` - search language;
119+
- `$params['delete_all_history']` - set true if you want delete all history;
120+
121+
You can send the loan data to UBKI:
122+
```php
123+
$result = $loan->ubki_upload($params);
124+
```
125+
`$params` - will be passed to the ubkiAttributes() method in the model.
126+
127+
For switching between accounts you should add to params:
128+
- to select second account
129+
```php
130+
$params = [
131+
'test' => false,
132+
'use_second_account_login' => true
133+
];
134+
```
135+
136+
- to select main account
137+
```php
138+
$params = [
139+
'test' => false,
140+
'use_second_account_login' => false
141+
];
142+
```
143+
144+
if you not select what account to use, last used account will be executed.
145+
146+
## Change log
147+
148+
Please see the [changelog](CHANGELOG.md) for more information on what has changed recently.
149+
150+
## Security
151+
152+
If you discover any security related issues, please email author email instead of using the issue tracker.
153+
154+
## Credits
155+
156+
[Volodymyr Farylevych](https://github.com/arttiger)
157+
158+
## License
159+
160+
Please see the [license file](LICENSE.md) for more information.
161+
162+
[link-ubki]: https://www.ubki.ua/
163+
[link-ubki-api]: https://sites.google.com/ubki.ua/doc/%D0%BE%D0%B1%D1%89%D0%B8%D0%B5-%D0%BF%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF%D1%8B-%D0%B2%D0%B7%D0%B0%D0%B8%D0%BC%D0%BE%D0%B4%D0%B5%D0%B9%D1%81%D1%82%D0%B2%D0%B8%D1%8F
164+

codecov.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
parsers:
10+
gcov:
11+
branch_detection:
12+
conditional: yes
13+
loop: yes
14+
method: no
15+
macro: no
16+
17+
comment:
18+
layout: "reach,diff,flags,files,footer"
19+
behavior: default
20+
require_changes: no

composer.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "arttiger/laravel-ubki",
3+
"description": "Laravel package for integration with UBKI",
4+
"keywords": [
5+
"Laravel",
6+
"Ubki"
7+
],
8+
"homepage": "https://github.com/arttiger/laravel-ubki",
9+
"license": "MIT",
10+
"type": "library",
11+
"authors": [
12+
{
13+
"name": "Volodymyr Farylevych",
14+
"email": "[email protected]",
15+
"homepage": "https://farylevych.com",
16+
"role": "Developer"
17+
}
18+
],
19+
"support": {
20+
"email": "[email protected]",
21+
"irc": "irc://irc.freenode.org/composer"
22+
},
23+
"require": {
24+
"illuminate/support": "5.6.39|5.7.*|5.8.*|^6.0|^7.0|^8.0"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "^7.5",
28+
"mockery/mockery": "^1.1",
29+
"orchestra/testbench": "~3.0",
30+
"sempro/phpunit-pretty-print": "^1.0",
31+
"styleci/cli": "^1.1"
32+
},
33+
"autoload": {
34+
"psr-4": {
35+
"Arttiger\\Ubki\\": "src/"
36+
}
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"Arttiger\\Ubki\\Tests\\": "tests"
41+
}
42+
},
43+
"scripts": {
44+
"test": "vendor/bin/phpunit",
45+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
46+
47+
},
48+
"extra": {
49+
"laravel": {
50+
"providers": [
51+
"Arttiger\\Ubki\\UbkiServiceProvider"
52+
],
53+
"aliases": {
54+
"Ubki": "Arttiger\\Ubki\\Facades\\Ubki"
55+
}
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)