Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit f603c80

Browse files
author
Artem Sokolovsky
committed
Перенос репозитория
0 parents  commit f603c80

File tree

7 files changed

+559
-0
lines changed

7 files changed

+559
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, Individual entrepreneur Sokolovsky Artem Sergeevich
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Пакет для интеграции с партнерским кабинетом банка Открытие с помощью API.
2+
3+
[![Latest Stable Version](https://poser.pugx.org/iesokolovskyartem/yii_openbank_partners/v)](//packagist.org/packages/iesokolovskyartem/yii_openbank_partners)
4+
[![Latest Unstable Version](https://poser.pugx.org/iesokolovskyartem/yii_openbank_partners/v/unstable)](//packagist.org/packages/iesokolovskyartem/yii_openbank_partners)
5+
[![Total Downloads](https://poser.pugx.org/iesokolovskyartem/yii_openbank_partners/downloads)](//packagist.org/packages/iesokolovskyartem/yii_openbank_partners)
6+
[![License](https://poser.pugx.org/iesokolovskyartem/yii_openbank_partners/license)](//packagist.org/packages/iesokolovskyartem/yii_openbank_partners)
7+
8+
Этот пакет написан не разработчиком банка Открытия, разработан для [Framework yii2](https://www.yiiframework.com/).
9+
Документацию по пакету можно найти в [WiKi страницах](https://github.com/iesokolovskyartem/yii_openbank_partners/wiki), техническую поддержку можно получить написав
10+
на почту [[email protected]](mailto:[email protected]) или в [Issues](https://github.com/iesokolovskyartem/yii_openbank_partners/issues/new).
11+
12+
### Установка
13+
Установить можете с помощью composer
14+
15+
```
16+
composer require iesokolovskyartem/yii_openbank_partners
17+
```
18+
19+
либо указать в composer.json
20+
21+
```
22+
"iesokolovskyartem/yii_openbank_partners": "^1.0"
23+
```
24+
25+
### Зависимости:
26+
PHP >= 7.0
27+
28+
[yiisoft/yii2-httpclient](https://github.com/yiisoft/yii2-httpclient) ~2.0.0
29+
30+
### Возможности:
31+
1. Добавление заявки.
32+
2. Получение статуса заявки.
33+
3. Проверка ИНН на дублирование.
34+
4. Получение результата проверки ИНН на дублирование.
35+
5. Получение словарей (список городов и акций).

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "iesokolovskyartem/yii_openbank_partners",
3+
"description": "Пакет для интеграции с партнерским кабинетом банка Открытие.",
4+
"type": "package",
5+
"require": {
6+
"php": ">=7.0",
7+
"yiisoft/yii2-httpclient": "~2.0.0"
8+
},
9+
"license": "BSD-3-Clause",
10+
"authors": [
11+
{
12+
"name": "Artem Sokolovsky",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"minimum-stability": "stable",
17+
"autoload": {
18+
"psr-4": {
19+
"yii\\iesokolovskyartem\\yii_openbank_partners\\": "src"
20+
}
21+
}
22+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
4+
namespace yii\c7v\yii_openbank_partners\dictionaries;
5+
6+
use http\Client\Request;
7+
use http\Client\Response;
8+
use yii\httpclient\Client;
9+
use yii\helpers\ArrayHelper;
10+
use yii\base\Component;
11+
12+
/**
13+
* Class CityAndPromotion
14+
* @package yii\c7v\openpartners\dictionaries
15+
*/
16+
class CityAndPromotion extends Component
17+
{
18+
const BASE_URL = 'https://openpartners.ru/api/v2/dictionaries/';
19+
20+
/**
21+
* @var string
22+
*/
23+
public $x_auth_token;
24+
/**
25+
* @var boolean
26+
*/
27+
private $test;
28+
29+
/**
30+
* @var Client
31+
*/
32+
public $client;
33+
/**
34+
* @var Request
35+
*/
36+
public $request;
37+
/**
38+
* @var Response
39+
*/
40+
public $response;
41+
42+
/**
43+
* CityAndPromotion constructor.
44+
* @param array $config
45+
*/
46+
public function __construct($config = [])
47+
{
48+
if (!empty($config['X-Auth-Token'])){
49+
$this->x_auth_token = $config['X-Auth-Token'];
50+
}else{
51+
if (!empty(\Yii::$app->params['X-Auth-Token'])){
52+
$this->x_auth_token = \Yii::$app->params['X-Auth-Token'];
53+
}else{
54+
throw new \Exception("Не установлен X-Auth-Token", 102);
55+
}
56+
}
57+
$this->test = false;
58+
if (!empty($config['test'])){
59+
$this->test = $config['test'];
60+
}
61+
$this->client = new Client([
62+
'baseUrl' => self::BASE_URL,
63+
]);
64+
$this->request = $this->client->createRequest()->setFormat(Client::FORMAT_JSON)->setHeaders([
65+
'X-Auth-Token' => $this->x_auth_token,
66+
]);
67+
}
68+
69+
/**
70+
* @param bool $list
71+
* @return bool|mixed|null
72+
* @throws \yii\httpclient\Exception
73+
*/
74+
public function getCity($list = false){
75+
$this->response = $this->request->setMethod("GET")->setUrl('city')->send();
76+
if ($this->response->isOk){
77+
$data = $this->response->getData();
78+
return $list==true ? ArrayHelper::map($data, 'city', 'city') : $data;
79+
}
80+
return false;
81+
}
82+
83+
/**
84+
* @param bool $list
85+
* @return bool|mixed|null
86+
* @throws \yii\httpclient\Exception
87+
*/
88+
public function getPromotion($list = false){
89+
$this->response = $this->request->setMethod("GET")->setUrl('promotion')->send();
90+
if ($this->response->isOk){
91+
$data = $this->response->getData()['promotions'];
92+
if (!empty($data)){
93+
return $list==true ? ArrayHelper::map($data, 'id', 'name') : $data;
94+
}
95+
return null;
96+
}
97+
return false;
98+
}
99+
}

0 commit comments

Comments
 (0)