1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace nikserg\CRMCertificateAPI; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use nikserg\CRMCertificateAPI\models\request\PartnerStores as PartnerStoresRequest; |
7
|
|
|
use nikserg\CRMCertificateAPI\models\response\models\Store; |
8
|
|
|
use nikserg\CRMCertificateAPI\models\response\PartnerStores as PartnerStoresResponse; |
|
|
|
|
9
|
|
|
use nikserg\CRMCertificateAPI\models\Semantic; |
10
|
|
|
use nikserg\CRMCertificateAPI\models\data\Status; |
11
|
|
|
use nikserg\CRMCertificateAPI\models\PaymentModes; |
12
|
|
|
use nikserg\CRMCertificateAPI\models\request\ChangeStatus; |
13
|
|
|
use nikserg\CRMCertificateAPI\models\request\CheckPassport; |
14
|
|
|
use nikserg\CRMCertificateAPI\models\request\CheckSnils; |
15
|
|
|
use nikserg\CRMCertificateAPI\models\request\CustomerFormDocuments; |
16
|
|
|
use nikserg\CRMCertificateAPI\models\request\Egrul as EgrulRequest; |
17
|
|
|
use nikserg\CRMCertificateAPI\models\request\PartnerFullPrice as PartnerFullPriceRequest; |
18
|
|
|
use nikserg\CRMCertificateAPI\models\request\PartnerPlatforms as PartnerPlatformsRequest; |
19
|
|
|
use nikserg\CRMCertificateAPI\models\request\DetectPlatforms as DetectPlatformsRequest; |
20
|
|
|
use nikserg\CRMCertificateAPI\models\response\DetectPlatformVariant; |
21
|
|
|
use nikserg\CRMCertificateAPI\models\request\PartnerProducts as PartnerProductsRequest; |
22
|
|
|
use nikserg\CRMCertificateAPI\models\request\SendCheckRef; |
23
|
|
|
use nikserg\CRMCertificateAPI\models\request\SendCustomerForm as SendCustomerFormRequest; |
24
|
|
|
use nikserg\CRMCertificateAPI\models\request\SendCustomerFormData; |
25
|
|
|
use nikserg\CRMCertificateAPI\models\response\BooleanResponse; |
26
|
|
|
use nikserg\CRMCertificateAPI\models\response\GetCustomerForm; |
27
|
|
|
use nikserg\CRMCertificateAPI\models\response\GetOpportunity; |
28
|
|
|
use nikserg\CRMCertificateAPI\models\response\PassportCheck; |
29
|
|
|
use nikserg\CRMCertificateAPI\models\response\SnilsCheck; |
30
|
|
|
use nikserg\CRMCertificateAPI\models\response\models\DetectPlatformVariantPlatform; |
31
|
|
|
use nikserg\CRMCertificateAPI\models\response\models\PartnerPlatform; |
32
|
|
|
use nikserg\CRMCertificateAPI\models\response\models\PartnerProduct; |
33
|
|
|
use nikserg\CRMCertificateAPI\models\response\ReferralUser; |
34
|
|
|
use nikserg\CRMCertificateAPI\models\response\SendCustomerForm as SendCustomerFormResponse; |
35
|
|
|
use nikserg\CRMCertificateAPI\models\request\SendCustomerForm; |
36
|
|
|
use nikserg\CRMCertificateAPI\models\response\Esia\Egrul as EgrulResponse; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Тестовый клиент для связи с API CRM |
40
|
|
|
* |
41
|
|
|
* @package nikserg\CRMCertificateAPI |
42
|
|
|
*/ |
43
|
|
|
class MockClient extends Client |
44
|
|
|
{ |
45
|
|
|
// "Правильные" паспорта |
46
|
|
|
public const PASSPORTCHECK_VALID_SERIES = '1111'; |
47
|
|
|
public const PASSPORTCHECK_VALID_NUMBER = '111111'; |
48
|
|
|
// "Неправильные" паспорта |
49
|
|
|
public const PASSPORTCHECK_INVALID_SERIES = '2222'; |
50
|
|
|
public const PASSPORTCHECK_INVALID_NUMBER = '222222'; |
51
|
|
|
|
52
|
|
|
// Данные для запроса ЕГРЮЛ |
53
|
|
|
public const EGRUL_IP_KULSH = PHP_INT_MAX - 2; // Выписка для ИП Кулиш Янина Викторовна |
54
|
|
|
public const EGRUL_LEGAL_ITK = PHP_INT_MAX - 1; // Пыписка для юридического лица ООО "ИТК" |
55
|
|
|
|
56
|
|
|
private static $data; |
57
|
|
|
|
58
|
|
|
private static function getData() |
59
|
|
|
{ |
60
|
|
|
if (!empty(self::$data)) { |
61
|
|
|
return self::$data; |
62
|
|
|
} |
63
|
|
|
if (file_exists(__DIR__ . '/mock.runtime')) { |
64
|
|
|
self::$data = unserialize(file_get_contents(__DIR__ . '/mock.runtime')); |
65
|
|
|
} else { |
66
|
|
|
self::$data = [ |
67
|
|
|
'currentId' => 1, |
68
|
|
|
'currentStatus' => [ |
69
|
|
|
1 => 0, |
70
|
|
|
], |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
return self::$data; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
private static function flushData($data) |
77
|
|
|
{ |
78
|
|
|
self::$data = $data; |
79
|
|
|
file_put_contents(__DIR__ . '/mock.runtime', serialize(self::$data)); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function egrul(EgrulRequest $request) |
83
|
|
|
{ |
84
|
|
|
if ($request->customerForm == self::EGRUL_IP_KULSH) { |
85
|
|
|
return new EgrulResponse(json_decode('{ "id": 695854, "status": 2, "comment": "ok","data": { "organizationShortName": "ИП КУЛИШ ЯНИНА ВИКТОРОВНА", "OGRNIP": "306232719200028", "INN": "232702943100", "headLastName": "Кулиш", "headFirstName": "Янина", "headMiddleName": "Викторовна", "ownerGender": 2 }, "customerFormId": "559196" }')); |
86
|
|
|
} elseif ($request->customerForm == self::EGRUL_LEGAL_ITK) { |
87
|
|
|
return new EgrulResponse(json_decode('{ "id": 689373, "status": 2, "comment": "ok", "data": { "organizationShortName": "ООО \"ИТК\"", "organizationFullName": "ОБЩЕСТВО С ОГРАНИЧЕННОЙ ОТВЕТСТВЕННОСТЬЮ \"ИНТЕРНЕТ ТЕХНОЛОГИИ И КОММУНИКАЦИИ\"", "OGRN": "1112310000220", "INN": "2310152134", "KPP": "230801001", "fiasAddress": "КРАЙ КРАСНОДАРСКИЙ, ГОРОД КРАСНОДАР, УЛИЦА ДАЛЬНЯЯ, ДОМ 39\/3, ПОМЕЩЕНИЕ 140", "rawParticipators": [ " ", " ", " " ], "rawRegion": "КРАЙ КРАСНОДАРСКИЙ", "rawCity": "КРАСНОДАР", "rawOffice": "ПОМЕЩЕНИЕ 140", "rawHouse": "ДОМ 39\/3", "rawStreet": "УЛИЦА ДАЛЬНЯЯ", "postcode": "350051", "region": "23 Краснодарский край", "city": "Краснодар", "street": "УЛИЦА ДАЛЬНЯЯ, ДОМ 39\/3, ПОМЕЩЕНИЕ 140", "headLastName": "Сорокин", "headFirstName": "Дмитрий", "headMiddleName": "Викторович", "headPosition": "Генеральный директор" }, "customerFormId": "557436" }')); |
88
|
|
|
} |
89
|
|
|
return new EgrulResponse(json_decode('{"id":1,"status":2,"comment":"ok","data":{"organizationShortName":"ООО \"ИТК\"","organizationFullName":"ООО \"ИТК\"","OGRN":"1112310000220","INN":"2310152134","KPP":"12345678","region":"KRD","city":"Krasnodar","street":"One way st.","fiasAddress":"Krasnodar, One way st. 1337","headFirstName":"Дмитрий","headMiddleName":"Викторович","headLastName":"Сорокин","headPosition":"Генеральный директор"}}')); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getCustomerFormCertificateBlank($customerFormCrmId, $format = 'pdf') |
93
|
|
|
{ |
94
|
|
|
return base64_encode(file_get_contents(__DIR__ . '/data/blank.pdf')); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getCustomerFormClaim($customerFormCrmId, $format = 'pdf') |
98
|
|
|
{ |
99
|
|
|
return base64_encode(file_get_contents(__DIR__ . '/data/claim.pdf')); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function sendCustomerForm(SendCustomerFormRequest $customerForm) |
103
|
|
|
{ |
104
|
|
|
$response = new SendCustomerFormResponse(); |
105
|
|
|
if ($customerForm->id) { |
106
|
|
|
$response->id = $customerForm->id; |
107
|
|
|
} else { |
108
|
|
|
$data = self::getData(); |
109
|
|
|
$response->id = $data['currentId']; |
110
|
|
|
$data['currentStatus'][$response->id] = Status::INIT; |
111
|
|
|
$data['currentId'] = $response->id + 1; |
112
|
|
|
self::flushData($data); |
113
|
|
|
} |
114
|
|
|
$response->token = 'crmToken'; |
115
|
|
|
$response->generationToken = 'crmGenerateToken'; |
116
|
|
|
return $response; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getCustomerForm($customerFormCrmId) |
120
|
|
|
{ |
121
|
|
|
$response = new GetCustomerForm(); |
122
|
|
|
$data = self::getData(); |
123
|
|
|
$response->status = $data['currentStatus'][$customerFormCrmId]; |
124
|
|
|
$response->tokenCertificate = 'crmToken'; |
|
|
|
|
125
|
|
|
$response->token = 'token'; |
126
|
|
|
$response->opportunityId = 1; |
127
|
|
|
return $response; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getOpportunity($opportunityCrmId) |
131
|
|
|
{ |
132
|
|
|
$response = new GetOpportunity(); |
133
|
|
|
$response->isPay = true; |
|
|
|
|
134
|
|
|
$response->accountId = 1; |
135
|
|
|
$response->paymentToken = 'paymentToken'; |
|
|
|
|
136
|
|
|
return $response; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function changeStatus(ChangeStatus $changeStatus) |
140
|
|
|
{ |
141
|
|
|
$data = self::getData(); |
142
|
|
|
$data['currentStatus'][$changeStatus->id] = $changeStatus->status; |
143
|
|
|
self::flushData($data); |
144
|
|
|
$response = new BooleanResponse(); |
145
|
|
|
$response->status = true; |
146
|
|
|
return $response; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function deleteCustomerForm($customerFormCrmId) |
150
|
|
|
{ |
151
|
|
|
$response = new BooleanResponse(); |
152
|
|
|
$response->status = true; |
153
|
|
|
return $response; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function sendCustomerFormData($crmCustomerFormId, SendCustomerFormData $customerFormData) |
157
|
|
|
{ |
158
|
|
|
$response = new SendCustomerFormResponse(); |
159
|
|
|
$response->id = $crmCustomerFormId; |
160
|
|
|
$response->token = 'crmToken'; |
161
|
|
|
$response->generationToken = 'crmGenerateToken'; |
162
|
|
|
return $response; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function checkPassport(CheckPassport $request) |
166
|
|
|
{ |
167
|
|
|
$response = new PassportCheck(); |
168
|
|
|
if ($request->number == self::PASSPORTCHECK_INVALID_NUMBER) { |
169
|
|
|
$response->comment = 'Паспорт не существует (тест)'; |
170
|
|
|
$response->status = Semantic::NEGATIVE; |
171
|
|
|
} else { |
172
|
|
|
$response->comment = ''; |
173
|
|
|
$response->status = Semantic::POSITIVE; |
174
|
|
|
} |
175
|
|
|
return $response; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function checkSnils(CheckSnils $request) |
179
|
|
|
{ |
180
|
|
|
$response = new SnilsCheck(); |
181
|
|
|
$response->id = 1; |
182
|
|
|
$response->status = Semantic::POSITIVE; |
183
|
|
|
$response->comment = ''; |
184
|
|
|
$response->created = date("Y-m-d H:i:s"); |
185
|
|
|
return $response; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function getReferralUser(SendCheckRef $sendCheckRef) |
189
|
|
|
{ |
190
|
|
|
$response = new ReferralUser(); |
191
|
|
|
$response->id = 1; |
192
|
|
|
$response->paymentMode = PaymentModes::PAYMENT_UNLIMITED; |
193
|
|
|
$response->userName = 'username'; |
194
|
|
|
$response->email = '[email protected]'; |
195
|
|
|
$response->phone = 'hi :)'; |
196
|
|
|
$response->isOfd = true; |
197
|
|
|
$response->enablePlatformSelection = true; |
198
|
|
|
return $response; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function pushCustomerFormDocuments(CustomerFormDocuments $documents) |
202
|
|
|
{ |
203
|
|
|
return true; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
public function detectPlatforms(DetectPlatformsRequest $request) |
207
|
|
|
{ |
208
|
|
|
$known = [ |
209
|
|
|
"1.3.6.1.5.5.7.3.2", |
210
|
|
|
"1.3.6.1.5.5.7.3.4", |
211
|
|
|
"1.2.643.6.3.1.4.1", |
212
|
|
|
"1.2.643.6.3", |
213
|
|
|
"1.2.643.6.7", |
214
|
|
|
"1.2.643.6.3.1.1", |
215
|
|
|
"1.2.643.3.8.100.1.42", |
216
|
|
|
"1.2.643.100.113.1", |
217
|
|
|
"1.2.643.100.113.2", |
218
|
|
|
"1.2.643.2.2.34.6", |
219
|
|
|
"1.2.643.6.19.3", |
220
|
|
|
"1.2.643.6.3.1.4.3", |
221
|
|
|
"1.2.643.6.3.1.4.2", |
222
|
|
|
"1.2.643.6.3.1.3.1", |
223
|
|
|
"1.2.643.6.3.1.2.1", |
224
|
|
|
]; |
225
|
|
|
$unknown = array_diff($request->oids, $known); |
226
|
|
|
$variant = new DetectPlatformVariant(); |
227
|
|
|
$platform1 = new DetectPlatformVariantPlatform(); |
228
|
|
|
$platform1->value = 'AETP'; |
229
|
|
|
$platform1->name = 'АЭТП'; |
230
|
|
|
$platform2 = new DetectPlatformVariantPlatform(); |
231
|
|
|
$platform2->value = 'PROLONGATION_BIDDING_COMPLECT'; |
232
|
|
|
$platform2->name = 'Тариф «ЭП Торги-комплект»'; |
233
|
|
|
$variant->platforms = [$platform1, $platform2]; |
234
|
|
|
$variant->price = 5000; |
235
|
|
|
$variant->excluded = $unknown; |
236
|
|
|
return [$variant]; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
public function getPartnerPlatformsAll(PartnerPlatformsRequest $request) |
240
|
|
|
{ |
241
|
|
|
$json = /** @lang JSON */ |
242
|
|
|
'{ |
243
|
|
|
"platforms": [ |
244
|
|
|
{ |
245
|
|
|
"price": 2500, |
246
|
|
|
"description": "Описание EPGU", |
247
|
|
|
"name": "Имя EPGU", |
248
|
|
|
"platform": "EPGU" |
249
|
|
|
}, |
250
|
|
|
{ |
251
|
|
|
"price": 17600, |
252
|
|
|
"description": "Описание FABRIKANT", |
253
|
|
|
"name": "Имя FABRIKANT", |
254
|
|
|
"platform": "FABRIKANT" |
255
|
|
|
}, |
256
|
|
|
{ |
257
|
|
|
"price": 3500, |
258
|
|
|
"description": "Описание AETP_NEW_BASE", |
259
|
|
|
"name": "Имя AETP_NEW_BASE", |
260
|
|
|
"platform": "AETP_NEW_BASE" |
261
|
|
|
}, |
262
|
|
|
{ |
263
|
|
|
"price": 6900, |
264
|
|
|
"description": "Имя Описание B2B", |
265
|
|
|
"name": "Имя B2B", |
266
|
|
|
"platform": "B2B" |
267
|
|
|
}, |
268
|
|
|
{ |
269
|
|
|
"price": 1777, |
270
|
|
|
"description": "АЭТП", |
271
|
|
|
"name": "АЭТП", |
272
|
|
|
"platform": "AETP" |
273
|
|
|
}, |
274
|
|
|
{ |
275
|
|
|
"price": 1333, |
276
|
|
|
"description": "Тариф «ЭП Торги-комплект»", |
277
|
|
|
"name": "Тариф «ЭП Торги-комплект»", |
278
|
|
|
"platform": "PROLONGATION_BIDDING_COMPLECT" |
279
|
|
|
} |
280
|
|
|
] |
281
|
|
|
}'; |
282
|
|
|
$result = json_decode($json); |
283
|
|
|
$response = []; |
284
|
|
|
foreach ($result->platforms as $platform) { |
285
|
|
|
$partnerPlatform = new PartnerPlatform; |
286
|
|
|
$partnerPlatform->name = $platform->name; |
287
|
|
|
$partnerPlatform->group = "Группа"; |
288
|
|
|
$partnerPlatform->description = $platform->description; |
289
|
|
|
$partnerPlatform->platform = $platform->platform; |
290
|
|
|
$partnerPlatform->price = $platform->price; |
291
|
|
|
$response[] = $partnerPlatform; |
292
|
|
|
} |
293
|
|
|
return $response; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function getPartnerProductsAll(PartnerProductsRequest $request) |
297
|
|
|
{ |
298
|
|
|
$json = /** @lang JSON */ |
299
|
|
|
'{ |
300
|
|
|
"productInfo": [ |
301
|
|
|
{ |
302
|
|
|
"id": 981, |
303
|
|
|
"price": 1500, |
304
|
|
|
"name": "Сертифицированный защищенный носитель (Рутокен)", |
305
|
|
|
"description": "Рутокен — специальное сертифицированное защищённое USB-устройство, внешне похожее на флешку. Предназначено для хранения и использования электронной подписи (КЭП)." |
306
|
|
|
}, |
307
|
|
|
{ |
308
|
|
|
"id": 511, |
309
|
|
|
"price": 700, |
310
|
|
|
"name": "Лицензия на право использования СКЗИ КриптоПро CSP в составе сертификата ключа", |
311
|
|
|
"description": "КриптоПро - специальная программа криптозащиты.\\nОна используется для генерации ключа электронной подписи и работы с сертификатами. Без действующей лицензии СКЗИ КриптоПро CSP электронная подпись на вашем компьютере не сможет работать." |
312
|
|
|
}, |
313
|
|
|
{ |
314
|
|
|
"id": 127, |
315
|
|
|
"price": 1000, |
316
|
|
|
"name": "Установка СКЗИ КриптоПро CSP и КЭП", |
317
|
|
|
"description": "Процесс установки СКЗИ «КриптоПро» и настройки рабочего места для корректной работы электронной подписи — весьма трудоёмкий и требует специальных знаний. Чтобы облегчить и ускорить этот процесс, закажите его у специалистов технической поддержки." |
318
|
|
|
} |
319
|
|
|
] |
320
|
|
|
}'; |
321
|
|
|
$result = json_decode($json); |
322
|
|
|
$response = []; |
323
|
|
|
foreach ($result->productInfo as $product) { |
324
|
|
|
$partnerPlatform = new PartnerProduct(); |
325
|
|
|
$partnerPlatform->name = $product->name; |
326
|
|
|
$partnerPlatform->description = $product->description; |
327
|
|
|
$partnerPlatform->id = $product->id; |
328
|
|
|
$partnerPlatform->price = $product->price; |
329
|
|
|
$response[] = $partnerPlatform; |
330
|
|
|
} |
331
|
|
|
return $response; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
public function getPartnerFullPrice(PartnerFullPriceRequest $fullPriceRequest) |
335
|
|
|
{ |
336
|
|
|
return 666; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
public function getPartnerStores(PartnerStoresRequest $partnerStores) |
340
|
|
|
{ |
341
|
|
|
$json = /** @lang JSON */ |
342
|
|
|
'{ |
343
|
|
|
"stores": [ |
344
|
|
|
{ |
345
|
|
|
"id": 3195, |
346
|
|
|
"title": "ИП Глумова Татьяна Борисовна", |
347
|
|
|
"address": "656002, Алтайский край, Барнаул г, Сизова ул, дом № 14Б", |
348
|
|
|
"phone": "", |
349
|
|
|
"lat": "53.280205", |
350
|
|
|
"lng": "83.761495" |
351
|
|
|
}, |
352
|
|
|
{ |
353
|
|
|
"id": 3225, |
354
|
|
|
"title": "ООО БРАВО", |
355
|
|
|
"address": "659319, Алтайский край, Бийск г, Петра Мерлина ул, дом № 58, кв 311", |
356
|
|
|
"phone": "", |
357
|
|
|
"lat": "52.530544", |
358
|
|
|
"lng": "85.16064800000004" |
359
|
|
|
}, |
360
|
|
|
{ |
361
|
|
|
"id": 3049, |
362
|
|
|
"title": "ИП Лапина Ирина Анатольевна", |
363
|
|
|
"address": "453431, Башкортостан респ, Благовещенский р-н, Благовещенск г, Седова ул, дом № 110", |
364
|
|
|
"phone": "", |
365
|
|
|
"lat": "55.049091", |
366
|
|
|
"lng": "55.95632899999998" |
367
|
|
|
} |
368
|
|
|
] |
369
|
|
|
}'; |
370
|
|
|
$result = json_decode($json); |
371
|
|
|
return $this->fillList(Store::class, $result->stores); |
372
|
|
|
} |
373
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths