Completed
Push — master ( 07cb44...4bf17b )
by
unknown
17s queued 13s
created

Builder::addProfileData()   F

Complexity

Conditions 184
Paths 94

Size

Total Lines 563

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 563
rs 3.3333
c 0
b 0
f 0
cc 184
nc 94
nop 93

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Covery\Client\Envelopes;
4
5
use Covery\Client\EnvelopeInterface;
6
use Covery\Client\IdentityNodeInterface;
7
8
class Builder
9
{
10
    const EVENT_PROFILE_UPDATE = 'profile_update';
11
12
    /**
13
     * @var string
14
     */
15
    private $type;
16
    /**
17
     * @var string
18
     */
19
    private $sequenceId;
20
    /**
21
     * @var IdentityNodeInterface[]
22
     */
23
    private $identities = array();
24
    /**
25
     * @var array
26
     */
27
    private $data = array();
28
29
    /**
30
     * Returns builder for confirmation event
31
     *
32
     * @param string $sequenceId
33
     * @param string $userId
34
     * @param int|null $timestamp If null provided, takes current time
35
     * @param bool|null $isEmailConfirmed
36
     * @param bool|null $idPhoneConfirmed
37
     * @param string|null $email
38
     * @param string|null $phone
39
     * @param string|null $groupId
40
     *
41
     * @return Builder
42
     */
43
    public static function confirmationEvent(
44
        $sequenceId,
45
        $userId,
46
        $timestamp = null,
47
        $isEmailConfirmed = null,
48
        $idPhoneConfirmed = null,
49
        $email = null,
50
        $phone = null,
51
        $groupId = null
52
    ) {
53
        $builder = new self('confirmation', $sequenceId);
54
        if ($timestamp === null) {
55
            $timestamp = time();
56
        }
57
58
        return $builder->addUserData(
59
            $email,
60
            $userId,
61
            $phone,
62
            null,
63
            null,
64
            null,
65
            null,
66
            null,
67
            null,
68
            null,
69
            null,
70
            null,
71
            $timestamp,
72
            $isEmailConfirmed,
73
            $idPhoneConfirmed,
74
            null
75
        )->addGroupId($groupId);
76
    }
77
78
    /**
79
     * Returns builder for login event
80
     *
81
     * @param string $sequenceId
82
     * @param string $userId
83
     * @param int|null $timestamp
84
     * @param string|null $email
85
     * @param bool|null $failed
86
     * @param string|null $gender
87
     * @param string|null $trafficSource
88
     * @param string|null $affiliateId
89
     * @param string|null $password
90
     * @param string|null $campaign
91
     * @param string|null $groupId
92
     *
93
     * @return Builder
94
     */
95
    public static function loginEvent(
96
        $sequenceId,
97
        $userId,
98
        $timestamp = null,
99
        $email = null,
100
        $failed = null,
101
        $gender = null,
102
        $trafficSource = null,
103
        $affiliateId = null,
104
        $password = null,
105
        $campaign = null,
106
        $groupId = null
107
    ) {
108
        $builder = new self('login', $sequenceId);
109
        if ($timestamp === null) {
110
            $timestamp = time();
111
        }
112
113
        return $builder->addUserData(
114
            $email,
115
            $userId,
116
            null,
117
            null,
118
            null,
119
            null,
120
            $gender,
121
            null,
122
            null,
123
            null,
124
            null,
125
            $timestamp,
126
            null,
127
            null,
128
            null,
129
            $failed,
130
            null,
131
            null,
132
            null,
133
            null,
134
            null,
135
            null,
136
            $password
137
        )->addWebsiteData(null, $trafficSource, $affiliateId, $campaign)->addGroupId($groupId);
138
    }
139
140
    /**
141
     * Returns builder for registration event
142
     *
143
     * @param string $sequenceId
144
     * @param string $userId
145
     * @param int|null $timestamp
146
     * @param string|null $email
147
     * @param string|null $userName
148
     * @param string|null $firstName
149
     * @param string|null $lastName
150
     * @param int|null $age
151
     * @param string|null $gender
152
     * @param string|null $phone
153
     * @param string|null $country
154
     * @param string|null $socialType
155
     * @param string|null $websiteUrl
156
     * @param string|null $trafficSource
157
     * @param string|null $affiliateId
158
     * @param string|null $password
159
     * @param string|null $campaign
160
     * @param string|null $groupId
161
     *
162
     * @return Builder
163
     */
164
    public static function registrationEvent(
165
        $sequenceId,
166
        $userId,
167
        $timestamp = null,
168
        $email = null,
169
        $userName = null,
170
        $firstName = null,
171
        $lastName = null,
172
        $age = null,
173
        $gender = null,
174
        $phone = null,
175
        $country = null,
176
        $socialType = null,
177
        $websiteUrl = null,
178
        $trafficSource = null,
179
        $affiliateId = null,
180
        $password = null,
181
        $campaign = null,
182
        $groupId = null
183
    ) {
184
        $builder = new self('registration', $sequenceId);
185
        if ($timestamp === null) {
186
            $timestamp = time();
187
        }
188
189
        return $builder->addWebsiteData(
190
            $websiteUrl,
191
            $trafficSource,
192
            $affiliateId,
193
            $campaign
194
        )->addUserData(
195
            $email,
196
            $userId,
197
            $phone,
198
            $userName,
199
            $firstName,
200
            $lastName,
201
            $gender,
202
            $age,
203
            $country,
204
            $socialType,
205
            $timestamp,
206
            null,
207
            null,
208
            null,
209
            null,
210
            null,
211
            null,
212
            null,
213
            null,
214
            null,
215
            null,
216
            null,
217
            $password
218
        )-> addGroupId($groupId);
219
    }
220
221
    /**
222
     * Returns builder for payout request
223
     *
224
     * @param string $sequenceId
225
     * @param string $userId
226
     * @param string $payoutId
227
     * @param string $currency
228
     * @param int|float $amount
229
     * @param int|null $payoutTimestamp
230
     * @param string|null $cardId
231
     * @param string|null $accountId
232
     * @param string|null $method
233
     * @param string|null $system
234
     * @param string|null $mid
235
     * @param int|float $amountConverted
236
     * @param string|null $firstName
237
     * @param string|null $lastName
238
     * @param string|null $country
239
     * @param string|null $email
240
     * @param string|null $phone
241
     * @param int|null $cardBin
242
     * @param string|null $cardLast4
243
     * @param int|null $cardExpirationMonth
244
     * @param int|null $cardExpirationYear
245
     * @param string|null $groupId
246
     *
247
     * @return Builder
248
     */
249
    public static function payoutEvent(
250
        $sequenceId,
251
        $userId,
252
        $payoutId,
253
        $currency,
254
        $amount,
255
        $payoutTimestamp = null,
256
        $cardId = null,
257
        $accountId = null,
258
        $method = null,
259
        $system = null,
260
        $mid = null,
261
        $amountConverted = null,
262
        $firstName = null,
263
        $lastName = null,
264
        $country = null,
265
        $email = null,
266
        $phone = null,
267
        $cardBin = null,
268
        $cardLast4 = null,
269
        $cardExpirationMonth = null,
270
        $cardExpirationYear = null,
271
        $groupId = null
272
    ) {
273
        $builder = new self('payout', $sequenceId);
274
        if ($payoutTimestamp === null) {
275
            $payoutTimestamp = time();
276
        }
277
        return $builder->addPayoutData(
278
            $payoutId,
279
            $payoutTimestamp,
280
            $amount,
281
            $currency,
282
            $cardId,
283
            $accountId,
284
            $method,
285
            $system,
286
            $mid,
287
            $amountConverted,
288
            $cardBin,
289
            $cardLast4,
290
            $cardExpirationMonth,
291
            $cardExpirationYear
292
        )->addShortUserData($email, $userId, $phone, $firstName, $lastName, $country)->addGroupId($groupId);
293
    }
294
295
    /**
296
     * Returns builder for transaction request
297
     *
298
     * @param string $sequenceId
299
     * @param string $userId
300
     * @param string $transactionId
301
     * @param int|float $transactionAmount
302
     * @param string $transactionCurrency
303
     * @param int|null $transactionTimestamp
304
     * @param string|null $transactionMode
305
     * @param string|null $transactionType
306
     * @param int|null $cardBin
307
     * @param string|null $cardId
308
     * @param string|null $cardLast4
309
     * @param int|null $expirationMonth
310
     * @param int|null $expirationYear
311
     * @param int|null $age
312
     * @param string|null $country
313
     * @param string|null $email
314
     * @param string|null $gender
315
     * @param string|null $firstName
316
     * @param string|null $lastName
317
     * @param string|null $phone
318
     * @param string|null $userName
319
     * @param string|null $paymentAccountId
320
     * @param string|null $paymentMethod
321
     * @param string|null $paymentMidName
322
     * @param string|null $paymentSystem
323
     * @param int|float|null $transactionAmountConverted
324
     * @param string|null $transactionSource
325
     * @param string|null $billingAddress
326
     * @param string|null $billingCity
327
     * @param string|null $billingCountry
328
     * @param string|null $billingFirstName
329
     * @param string|null $billingLastName
330
     * @param string|null $billingFullName
331
     * @param string|null $billingState
332
     * @param string|null $billingZip
333
     * @param string|null $productDescription
334
     * @param string|null $productName
335
     * @param int|float|null $productQuantity
336
     * @param string|null $websiteUrl
337
     * @param string|null $merchantIp
338
     * @param string|null $affiliateId
339
     * @param string|null $campaign
340
     * @param string|null $merchantCountry
341
     * @param string|null $mcc
342
     * @param string|null $acquirerMerchantId
343
     * @param string|null $groupId
344
     *
345
     * @return Builder
346
     */
347
    public static function transactionEvent(
348
        $sequenceId,
349
        $userId,
350
        $transactionId,
351
        $transactionAmount,
352
        $transactionCurrency,
353
        $transactionTimestamp = null,
354
        $transactionMode = null,
355
        $transactionType = null,
356
        $cardBin = null,
357
        $cardId = null,
358
        $cardLast4 = null,
359
        $expirationMonth = null,
360
        $expirationYear = null,
361
        $age = null,
362
        $country = null,
363
        $email = null,
364
        $gender = null,
365
        $firstName = null,
366
        $lastName = null,
367
        $phone = null,
368
        $userName = null,
369
        $paymentAccountId = null,
370
        $paymentMethod = null,
371
        $paymentMidName = null,
372
        $paymentSystem = null,
373
        $transactionAmountConverted = null,
374
        $transactionSource = null,
375
        $billingAddress = null,
376
        $billingCity = null,
377
        $billingCountry = null,
378
        $billingFirstName = null,
379
        $billingLastName = null,
380
        $billingFullName = null,
381
        $billingState = null,
382
        $billingZip = null,
383
        $productDescription = null,
384
        $productName = null,
385
        $productQuantity = null,
386
        $websiteUrl = null,
387
        $merchantIp = null,
388
        $affiliateId = null,
389
        $campaign = null,
390
        $merchantCountry = null,
391
        $mcc = null,
392
        $acquirerMerchantId = null,
393
        $groupId = null
394
    ) {
395
        $builder = new self('transaction', $sequenceId);
396
        if ($transactionTimestamp === null) {
397
            $transactionTimestamp = time();
398
        }
399
400
        return $builder
401
            ->addCCTransactionData(
402
                $transactionId,
403
                $transactionSource,
404
                $transactionType,
405
                $transactionMode,
406
                $transactionTimestamp,
407
                $transactionCurrency,
408
                $transactionAmount,
409
                $transactionAmountConverted,
410
                $paymentMethod,
411
                $paymentSystem,
412
                $paymentMidName,
413
                $paymentAccountId,
414
                $merchantCountry,
415
                $mcc,
416
                $acquirerMerchantId
417
            )
418
            ->addBillingData(
419
                $billingFirstName,
420
                $billingLastName,
421
                $billingFullName,
422
                $billingCountry,
423
                $billingState,
424
                $billingCity,
425
                $billingAddress,
426
                $billingZip
427
            )
428
            ->addCardData($cardBin, $cardLast4, $expirationMonth, $expirationYear, $cardId)
429
            ->addUserData(
430
                $email,
431
                $userId,
432
                $phone,
433
                $userName,
434
                $firstName,
435
                $lastName,
436
                $gender,
437
                $age,
438
                $country
439
            )
440
            ->addProductData($productQuantity, $productName, $productDescription)
441
            ->addWebsiteData($websiteUrl, null, $affiliateId, $campaign)
442
            ->addIpData(null, null, $merchantIp)
443
            ->addGroupId($groupId);
444
445
    }
446
447
    /**
448
     * Returns builder for install request
449
     *
450
     * @param string $sequenceId
451
     * @param string|null $userId
452
     * @param int|null $installTimestamp
453
     * @param string|null $country
454
     * @param string|null $websiteUrl
455
     * @param string|null $trafficSource
456
     * @param string|null $affiliateId
457
     * @param string|null $campaign
458
     * @param string|null $groupId
459
     * @return Builder
460
     */
461
    public static function installEvent(
462
        $sequenceId,
463
        $userId = null,
464
        $installTimestamp = null,
465
        $country = null,
466
        $websiteUrl = null,
467
        $trafficSource = null,
468
        $affiliateId = null,
469
        $campaign = null,
470
        $groupId = null
471
    ) {
472
        $builder = new self('install', $sequenceId);
473
        if ($installTimestamp === null) {
474
            $installTimestamp = time();
475
        }
476
477
        return $builder->addInstallData(
478
            $installTimestamp
479
        )->addWebsiteData($websiteUrl, $trafficSource, $affiliateId, $campaign)
480
        ->addShortUserData(null, $userId, null, null, null, $country)
481
        ->addGroupId($groupId);
482
    }
483
484
    /**
485
     * Returns builder for refund request
486
     *
487
     * @param string $sequenceId
488
     * @param string $refundId
489
     * @param int|float $refundAmount
490
     * @param string $refundCurrency
491
     * @param int|null $refundTimestamp
492
     * @param int|float|null $refundAmountConverted
493
     * @param string|null $refundSource
494
     * @param string|null $refundType
495
     * @param string|null $refundCode
496
     * @param string|null $refundReason
497
     * @param string|null $agentId
498
     * @param string|null $refundMethod
499
     * @param string|null $refundSystem
500
     * @param string|null $refundMid
501
     * @param string|null $email
502
     * @param string|null $phone
503
     * @param string|null $userId
504
     * @param string|null $groupId
505
     *
506
     * @return Builder
507
     */
508
    public static function refundEvent(
509
        $sequenceId,
510
        $refundId,
511
        $refundAmount,
512
        $refundCurrency,
513
        $refundTimestamp = null,
514
        $refundAmountConverted = null,
515
        $refundSource = null,
516
        $refundType = null,
517
        $refundCode = null,
518
        $refundReason = null,
519
        $agentId = null,
520
        $refundMethod = null,
521
        $refundSystem = null,
522
        $refundMid = null,
523
        $email = null,
524
        $phone = null,
525
        $userId = null,
526
        $groupId = null
527
    ) {
528
        $builder = new self('refund', $sequenceId);
529
        if ($refundTimestamp === null) {
530
            $refundTimestamp = time();
531
        }
532
533
        return $builder->addRefundData(
534
            $refundId,
535
            $refundTimestamp,
536
            $refundAmount,
537
            $refundCurrency,
538
            $refundAmountConverted,
539
            $refundSource,
540
            $refundType,
541
            $refundCode,
542
            $refundReason,
543
            $agentId,
544
            $refundMethod,
545
            $refundSystem,
546
            $refundMid
547
        )->addUserData($email, $userId, $phone)->addGroupId($groupId);
548
    }
549
550
    /**
551
     * Returns builder for transfer request
552
     *
553
     * @param string $sequenceId
554
     * @param string $eventId
555
     * @param float $amount
556
     * @param string $currency
557
     * @param string $userId
558
     * @param string $accountId
559
     * @param string $secondAccountId
560
     * @param string $accountSystem
561
     * @param string|null $method
562
     * @param int|null $eventTimestamp
563
     * @param float|null $amountConverted
564
     * @param string|null $email
565
     * @param string|null $phone
566
     * @param int|null $birthDate
567
     * @param string|null $firstname
568
     * @param string|null $lastname
569
     * @param string|null $fullname
570
     * @param string|null $state
571
     * @param string|null $city
572
     * @param string|null $address
573
     * @param string|null $zip
574
     * @param string|null $gender
575
     * @param string|null $country
576
     * @param string|null $operation
577
     * @param string|null $secondEmail
578
     * @param string|null $secondPhone
579
     * @param int|null $secondBirthDate
580
     * @param string|null $secondFirstname
581
     * @param string|null $secondLastname
582
     * @param string|null $secondFullname
583
     * @param string|null $secondState
584
     * @param string|null $secondCity
585
     * @param string|null $secondAddress
586
     * @param string|null $secondZip
587
     * @param string|null $secondGender
588
     * @param string|null $secondCountry
589
     * @param string|null $productDescription
590
     * @param string|null $productName
591
     * @param int|float|null $productQuantity
592
     * @param string|null $iban
593
     * @param string|null $secondIban
594
     * @param string|null $bic
595
     * @param string|null $source
596
     * @param string|null $groupId
597
     * @param string|null $secondUserMerchantId
598
     *
599
     * @return Builder
600
     */
601
    public static function transferEvent(
602
        $sequenceId,
603
        $eventId,
604
        $amount,
605
        $currency,
606
        $userId,
607
        $accountId = null,
608
        $secondAccountId = null,
609
        $accountSystem = null,
610
        $method = null,
611
        $eventTimestamp = null,
612
        $amountConverted = null,
613
        $email = null,
614
        $phone = null,
615
        $birthDate = null,
616
        $firstname = null,
617
        $lastname = null,
618
        $fullname = null,
619
        $state = null,
620
        $city = null,
621
        $address = null,
622
        $zip = null,
623
        $gender = null,
624
        $country = null,
625
        $operation = null,
626
        $secondEmail = null,
627
        $secondPhone = null,
628
        $secondBirthDate = null,
629
        $secondFirstname = null,
630
        $secondLastname = null,
631
        $secondFullname = null,
632
        $secondState = null,
633
        $secondCity = null,
634
        $secondAddress = null,
635
        $secondZip = null,
636
        $secondGender = null,
637
        $secondCountry = null,
638
        $productDescription = null,
639
        $productName = null,
640
        $productQuantity = null,
641
        $iban = null,
642
        $secondIban = null,
643
        $bic = null,
644
        $source = null,
645
        $groupId = null,
646
        $secondUserMerchantId = null
647
    ) {
648
        $builder = new self('transfer', $sequenceId);
649
        if ($eventTimestamp === null) {
650
            $eventTimestamp = time();
651
        }
652
653
        return $builder
654
            ->addTransferData(
655
               $eventId,
656
               $eventTimestamp,
657
               $amount,
658
               $currency,
659
               $accountId,
660
               $secondAccountId,
661
               $accountSystem,
662
               $amountConverted,
663
               $method,
664
               $operation,
665
               $secondEmail,
666
               $secondPhone,
667
               $secondBirthDate,
668
               $secondFirstname,
669
               $secondLastname,
670
               $secondFullname,
671
               $secondState,
672
               $secondCity,
673
               $secondAddress,
674
               $secondZip,
675
               $secondGender,
676
               $secondCountry,
677
               $iban,
678
               $secondIban,
679
               $bic,
680
               $source,
681
               $secondUserMerchantId
682
            )
683
            ->addUserData(
684
                $email,
685
                $userId,
686
                $phone,
687
                null,
688
                $firstname,
689
                $lastname,
690
                $gender,
691
                null,
692
                $country,
693
                null,
694
                null,
695
                null,
696
                null,
697
                null,
698
                null,
699
                null,
700
                $birthDate,
701
                $fullname,
702
                $state,
703
                $city,
704
                $address,
705
                $zip,
706
                null
707
            )
708
            ->addProductData($productQuantity, $productName, $productDescription)->addGroupId($groupId);
709
    }
710
711
    /**
712
     * Returns builder for kyc_profile request
713
     *
714
     * @param string $sequenceId
715
     * @param string $eventId
716
     * @param string $userId
717
     * @param int|null $eventTimestamp
718
     * @param string|null $groupId
719
     * @param string|null $status
720
     * @param string|null $code
721
     * @param string|null $reason
722
     * @param string|null $providerResult
723
     * @param string|null $providerCode
724
     * @param string|null $providerReason
725
     * @param string|null $profileId
726
     * @param string|null $profileType
727
     * @param string|null $profileSubType
728
     * @param string|null $firstName
729
     * @param string|null $lastName
730
     * @param string|null $fullName
731
     * @param string|null $industry
732
     * @param string|null $websiteUrl
733
     * @param string|null $description
734
     * @param int|null $birthDate
735
     * @param int|null $regDate
736
     * @param string|null $regNumber
737
     * @param string|null $vatNumber
738
     * @param string|null $email
739
     * @param bool|null $emailConfirmed
740
     * @param string|null $phone
741
     * @param bool|null $phoneConfirmed
742
     * @param string|null $country
743
     * @param string|null $state
744
     * @param string|null $city
745
     * @param string|null $address
746
     * @param string|null $zip
747
     * @param string|null $secondCountry
748
     * @param string|null $secondState
749
     * @param string|null $secondCity
750
     * @param string|null $secondAddress
751
     * @param string|null $secondZip
752
     * @param string|null $providerId
753
     * @param string|null $contactEmail
754
     * @param string|null $contactPhone
755
     * @param string|null $walletType
756
     * @param string|null $nationality
757
     * @param bool|null $finalBeneficiary
758
     * @param string|null $employmentStatus
759
     * @param string|null $sourceOfFunds
760
     * @param int|null $issueDate
761
     * @param int|null $expiryDate
762
     * @param string|null $gender
763
     * @return Builder
764
     */
765
    public static function kycProfileEvent(
766
        $sequenceId,
767
        $eventId,
768
        $userId,
769
        $eventTimestamp = null,
770
        $groupId = null,
771
        $status = null,
772
        $code = null,
773
        $reason = null,
774
        $providerResult = null,
775
        $providerCode = null,
776
        $providerReason = null,
777
        $profileId = null,
778
        $profileType = null,
779
        $profileSubType = null,
780
        $firstName = null,
781
        $lastName = null,
782
        $fullName = null,
783
        $industry = null,
784
        $websiteUrl = null,
785
        $description = null,
786
        $birthDate = null,
787
        $regDate = null,
788
        $regNumber = null,
789
        $vatNumber = null,
790
        $email = null,
791
        $emailConfirmed = null,
792
        $phone = null,
793
        $phoneConfirmed = null,
794
        $country = null,
795
        $state = null,
796
        $city = null,
797
        $address = null,
798
        $zip = null,
799
        $secondCountry = null,
800
        $secondState = null,
801
        $secondCity = null,
802
        $secondAddress = null,
803
        $secondZip = null,
804
        $providerId = null,
805
        $contactEmail = null,
806
        $contactPhone = null,
807
        $walletType = null,
808
        $nationality = null,
809
        $finalBeneficiary = null,
810
        $employmentStatus = null,
811
        $sourceOfFunds = null,
812
        $issueDate = null,
813
        $expiryDate = null,
814
        $gender = null
815
    ) {
816
        $builder = new self('kyc_profile', $sequenceId);
817
        if ($eventTimestamp === null) {
818
            $eventTimestamp = time();
819
        }
820
        return $builder
821
            ->addKycData(
822
                $eventId,
823
                $eventTimestamp,
824
                $groupId,
825
                $status,
826
                $code,
827
                $reason,
828
                $providerResult,
829
                $providerCode,
830
                $providerReason,
831
                $profileId,
832
                $profileType,
833
                $profileSubType,
834
                $industry,
835
                $description,
836
                $regDate,
837
                $regNumber,
838
                $vatNumber,
839
                $secondCountry,
840
                $secondState,
841
                $secondCity,
842
                $secondAddress,
843
                $secondZip,
844
                $providerId,
845
                $contactEmail,
846
                $contactPhone,
847
                $walletType,
848
                $nationality,
849
                $finalBeneficiary,
850
                $employmentStatus,
851
                $sourceOfFunds,
852
                $issueDate,
853
                $expiryDate
854
            )
855
            ->addUserData(
856
                $email,
857
                $userId,
858
                $phone,
859
                null,
860
                $firstName,
861
                $lastName,
862
                $gender,
863
                null,
864
                $country,
865
                null,
866
                null,
867
                null,
868
                null,
869
                $emailConfirmed,
870
                $phoneConfirmed,
871
                null,
872
                $birthDate,
873
                $fullName,
874
                $state,
875
                $city,
876
                $address,
877
                $zip,
878
                null
879
            )
880
            ->addWebsiteData($websiteUrl);
881
    }
882
883
    public static function profileUpdateEvent(
884
        $eventId,
885
        $eventTimestamp,
886
        $userMerchantId,
887
        $sequenceId = null,
888
        $groupId = null,
889
        $operation = null,
890
        $accountId = null,
891
        $accountSystem = null,
892
        $currency = null,
893
        $phone = null,
894
        $phoneConfirmed = null,
895
        $email = null,
896
        $emailConfirmed = null,
897
        $contactEmail = null,
898
        $contactPhone = null,
899
        $toFaAllowed = null,
900
        $userName = null,
901
        $password = null,
902
        $socialType = null,
903
        $gameLevel = null,
904
        $firstname = null,
905
        $lastname = null,
906
        $fullName = null,
907
        $birthDate = null,
908
        $age = null,
909
        $gender = null,
910
        $maritalStatus = null,
911
        $nationality = null,
912
        $physique = null,
913
        $height = null,
914
        $weight = null,
915
        $hair = null,
916
        $eyes = null,
917
        $education = null,
918
        $employmentStatus = null,
919
        $sourceOfFunds = null,
920
        $industry = null,
921
        $finalBeneficiary = null,
922
        $walletType = null,
923
        $websiteUrl = null,
924
        $description = null,
925
        $country = null,
926
        $state = null,
927
        $city =  null,
928
        $zip = null,
929
        $address = null,
930
        $addressConfirmed = null,
931
        $secondCountry = null,
932
        $secondState = null,
933
        $secondCity = null,
934
        $secondZip = null,
935
        $secondAddress = null,
936
        $secondAddressConfirmed = null,
937
        $profileId = null,
938
        $profileType = null,
939
        $profileSubType = null,
940
        $documentCountry = null,
941
        $documentConfirmed = null,
942
        $regDate = null,
943
        $issueDate = null,
944
        $expiryDate = null,
945
        $regNumber = null,
946
        $vatNumber = null,
947
        $purposeToOpenAccount = null,
948
        $oneOperationLimit = null,
949
        $dailyLimit = null,
950
        $weeklyLimit = null,
951
        $monthlyLimit = null,
952
        $annualLimit = null,
953
        $activeFeatures = null,
954
        $promotions = null,
955
        $ajaxValidation = null,
956
        $cookieEnabled = null,
957
        $cpuClass = null,
958
        $deviceFingerprint = null,
959
        $deviceId = null,
960
        $doNotTrack = null,
961
        $ip = null,
962
        $realIp = null,
963
        $localIpList = null,
964
        $language = null,
965
        $languages = null,
966
        $languageBrowser = null,
967
        $languageUser = null,
968
        $languageSystem = null,
969
        $os = null,
970
        $screenResolution = null,
971
        $screenOrientation = null,
972
        $clientResolution = null,
973
        $timezoneOffset = null,
974
        $userAgent = null,
975
        $plugins = null,
976
        $refererUrl = null,
977
        $originUrl = null
978
    ) {
979
        $builder = new self(self::EVENT_PROFILE_UPDATE, $sequenceId);
980
981
        return $builder->addProfileData(
982
            $eventId,
983
            $eventTimestamp,
984
            $userMerchantId,
985
            $groupId,
986
            $operation,
987
            $accountId,
988
            $accountSystem,
989
            $currency,
990
            $phone,
991
            $phoneConfirmed,
992
            $email,
993
            $emailConfirmed,
994
            $contactEmail,
995
            $contactPhone,
996
            $toFaAllowed,
997
            $userName,
998
            $password,
999
            $socialType,
1000
            $gameLevel,
1001
            $firstname,
1002
            $lastname,
1003
            $fullName,
1004
            $birthDate,
1005
            $age,
1006
            $gender,
1007
            $maritalStatus,
1008
            $nationality,
1009
            $physique,
1010
            $height,
1011
            $weight,
1012
            $hair,
1013
            $eyes,
1014
            $education,
1015
            $employmentStatus,
1016
            $sourceOfFunds,
1017
            $industry,
1018
            $finalBeneficiary,
1019
            $walletType,
1020
            $websiteUrl,
1021
            $description,
1022
            $country,
1023
            $state,
1024
            $city,
1025
            $zip,
1026
            $address,
1027
            $addressConfirmed,
1028
            $secondCountry,
1029
            $secondState,
1030
            $secondCity,
1031
            $secondZip,
1032
            $secondAddress,
1033
            $secondAddressConfirmed,
1034
            $profileId,
1035
            $profileType,
1036
            $profileSubType,
1037
            $documentCountry,
1038
            $documentConfirmed,
1039
            $regDate,
1040
            $issueDate,
1041
            $expiryDate,
1042
            $regNumber,
1043
            $vatNumber,
1044
            $purposeToOpenAccount,
1045
            $oneOperationLimit,
1046
            $dailyLimit,
1047
            $weeklyLimit,
1048
            $monthlyLimit,
1049
            $annualLimit,
1050
            $activeFeatures,
1051
            $promotions,
1052
            $ajaxValidation,
1053
            $cookieEnabled,
1054
            $cpuClass,
1055
            $deviceFingerprint,
1056
            $deviceId,
1057
            $doNotTrack,
1058
            $ip,
1059
            $realIp,
1060
            $localIpList,
1061
            $language,
1062
            $languages,
1063
            $languageBrowser,
1064
            $languageUser,
1065
            $languageSystem,
1066
            $os,
1067
            $screenResolution,
1068
            $screenOrientation,
1069
            $clientResolution,
1070
            $timezoneOffset,
1071
            $userAgent,
1072
            $plugins,
1073
            $refererUrl,
1074
            $originUrl
1075
        );
1076
1077
    }
1078
1079
    /**
1080
     * Returns builder for kyc_submit request
1081
     *
1082
     * @param string $sequenceId
1083
     * @param string $eventId
1084
     * @param string $userId
1085
     * @param int|null $eventTimestamp
1086
     * @param string|null $groupId
1087
     * @param string|null $status
1088
     * @param string|null $code
1089
     * @param string|null $reason
1090
     * @param string|null $providerResult
1091
     * @param string|null $providerCode
1092
     * @param string|null $providerReason
1093
     *
1094
     * @return Builder
1095
     */
1096
    public static function kycSubmitEvent(
1097
        $sequenceId,
1098
        $eventId,
1099
        $userId,
1100
        $eventTimestamp = null,
1101
        $groupId = null,
1102
        $status = null,
1103
        $code = null,
1104
        $reason = null,
1105
        $providerResult = null,
1106
        $providerCode = null,
1107
        $providerReason = null
1108
    ) {
1109
        $builder = new self('kyc_submit', $sequenceId);
1110
        if ($eventTimestamp === null) {
1111
            $eventTimestamp = time();
1112
        }
1113
        return $builder
1114
            ->addKycData(
1115
                $eventId,
1116
                $eventTimestamp,
1117
                $groupId,
1118
                $status,
1119
                $code,
1120
                $reason,
1121
                $providerResult,
1122
                $providerCode,
1123
                $providerReason
1124
            )
1125
            ->addUserData(
1126
                null,
1127
                $userId
1128
            );
1129
    }
1130
1131
    /**
1132
     * Returns builder for kyc_start request
1133
     *
1134
     * @param string $sequenceId
1135
     * @param string $eventId
1136
     * @param string $userMerchantId
1137
     * @param string $verificationMode
1138
     * @param string $verificationSource
1139
     * @param bool $consent
1140
     * @param null|int $eventTimestamp
1141
     * @param bool|null $allowNaOcrInputs
1142
     * @param bool|null $declineOnSingleStep
1143
     * @param bool|null $backsideProof
1144
     * @param string|null $groupId
1145
     * @param string|null $country
1146
     * @param string|null $kycLanguage
1147
     * @param string|null $redirectUrl
1148
     * @param string|null $email
1149
     * @param string|null $firstName
1150
     * @param string|null $lastName
1151
     * @param string|null $profileId
1152
     * @param string|null $phone
1153
     * @param string|null $birthDate
1154
     * @param string|null $regNumber
1155
     * @param int|null $issueDate
1156
     * @param int|null $expiryDate
1157
     * @param int|null $numberOfDocuments
1158
     * @param string|null $allowedDocumentFormat
1159
     * @return Builder
1160
     */
1161
    public static function kycStartEvent(
1162
        $sequenceId,
1163
        $eventId,
1164
        $userMerchantId,
1165
        $verificationMode,
1166
        $verificationSource,
1167
        $consent,
1168
        $eventTimestamp = null,
1169
        $allowNaOcrInputs = null,
1170
        $declineOnSingleStep = null,
1171
        $backsideProof = null,
1172
        $groupId = null,
1173
        $country = null,
1174
        $kycLanguage = null,
1175
        $redirectUrl = null,
1176
        $email = null,
1177
        $firstName = null,
1178
        $lastName = null,
1179
        $profileId = null,
1180
        $phone = null,
1181
        $birthDate = null,
1182
        $regNumber = null,
1183
        $issueDate = null,
1184
        $expiryDate = null,
1185
        $numberOfDocuments = null,
1186
        $allowedDocumentFormat = null
1187
    ) {
1188
        $envelopeType = 'kyc_start';
1189
        $builder = new self($envelopeType, $sequenceId);
1190
        if ($eventTimestamp === null) {
1191
            $eventTimestamp = time();
1192
        }
1193
        return $builder
1194
            ->addKycData(
1195
                $eventId,
1196
                $eventTimestamp,
1197
                $groupId,
1198
                null,
1199
                null,
1200
                null,
1201
                null,
1202
                null,
1203
                null,
1204
                $profileId,
1205
                null,
1206
                null,
1207
                null,
1208
                null,
1209
                null,
1210
                $regNumber,
1211
                null,
1212
                null,
1213
                null,
1214
                null,
1215
                null,
1216
                null,
1217
                null,
1218
                null,
1219
                null,
1220
                null,
1221
                null,
1222
                null,
1223
                null,
1224
                null,
1225
                $issueDate,
1226
                $expiryDate,
1227
                $verificationMode,
1228
                $verificationSource,
1229
                $consent,
1230
                $allowNaOcrInputs,
1231
                $declineOnSingleStep,
1232
                $backsideProof,
1233
                $kycLanguage,
1234
                $redirectUrl,
1235
                $numberOfDocuments,
1236
                $allowedDocumentFormat
1237
            )
1238
            ->addUserData(
1239
                $email,
1240
                $userMerchantId,
1241
                $phone,
1242
                null,
1243
                $firstName,
1244
                $lastName,
1245
                null,
1246
                null,
1247
                $country,
1248
                null,
1249
                null,
1250
                null,
1251
                null,
1252
                null,
1253
                null,
1254
                null,
1255
                $birthDate,
1256
                null,
1257
                null,
1258
                null,
1259
                null,
1260
                null,
1261
                null
1262
            );
1263
    }
1264
1265
    /**
1266
     * Returns builder for kyc_proof request
1267
     *
1268
     * @param int $kycStartId
1269
     */
1270
    public static function kycProofEvent($kycStartId)
1271
    {
1272
        $envelopeType = 'kyc_proof';
1273
        $sequenceId = '';
1274
1275
        $builder = new self($envelopeType, $sequenceId);
1276
1277
        return $builder
1278
            ->addKycProofData($kycStartId);
1279
    }
1280
1281
    /**
1282
     * Returns builder for order_item request
1283
     *
1284
     * @param string $sequenceId
1285
     * @param float $amount
1286
     * @param string $currency
1287
     * @param string $eventId
1288
     * @param int $eventTimestamp
1289
     * @param string $orderType
1290
     * @param string|null $transactionId
1291
     * @param string|null $groupId
1292
     * @param string|null $affiliateId
1293
     * @param float|null $amountConverted
1294
     * @param string|null $campaign
1295
     * @param string|null $carrier
1296
     * @param string|null $carrierShippingId
1297
     * @param string|null $carrierUrl
1298
     * @param string|null $carrierPhone
1299
     * @param int|null $couponStartDate
1300
     * @param int|null $couponEndDate
1301
     * @param string|null $couponId
1302
     * @param string|null $couponName
1303
     * @param string|null $customerComment
1304
     * @param int|null $deliveryEstimate
1305
     * @param string|null $email
1306
     * @param string|null $firstName
1307
     * @param string|null $lastName
1308
     * @param string|null $phone
1309
     * @param string|null $productDescription
1310
     * @param string|null $productName
1311
     * @param int|null $productQuantity
1312
     * @param string|null $shippingAddress
1313
     * @param string|null $shippingCity
1314
     * @param string|null $shippingCountry
1315
     * @param string|null $shippingCurrency
1316
     * @param float|null $shippingFee
1317
     * @param float|null $shippingFeeConverted
1318
     * @param string|null $shippingState
1319
     * @param string|null $shippingZip
1320
     * @param string|null $socialType
1321
     * @param string|null $source
1322
     * @param string|null $sourceFeeCurrency
1323
     * @param float|null $sourceFee
1324
     * @param float|null $sourceFeeConverted
1325
     * @param string|null $taxCurrency
1326
     * @param float|null $taxFee
1327
     * @param float|null $taxFeeConverted
1328
     * @param string|null $userMerchantId
1329
     * @param string|null $websiteUrl
1330
     * @param string|null $productUrl
1331
     * @param string|null $productImageUrl
1332
     * @return Builder
1333
     */
1334
    public static function orderItemEvent(
1335
        $sequenceId,
1336
        $amount,
1337
        $currency,
1338
        $eventId,
1339
        $eventTimestamp,
1340
        $orderType,
1341
        $transactionId = null,
1342
        $groupId = null,
1343
        $affiliateId = null,
1344
        $amountConverted = null,
1345
        $campaign = null,
1346
        $carrier = null,
1347
        $carrierShippingId = null,
1348
        $carrierUrl = null,
1349
        $carrierPhone = null,
1350
        $couponStartDate = null,
1351
        $couponEndDate = null,
1352
        $couponId = null,
1353
        $couponName = null,
1354
        $customerComment = null,
1355
        $deliveryEstimate = null,
1356
        $email = null,
1357
        $firstName = null,
1358
        $lastName = null,
1359
        $phone = null,
1360
        $productDescription = null,
1361
        $productName = null,
1362
        $productQuantity = null,
1363
        $shippingAddress = null,
1364
        $shippingCity = null,
1365
        $shippingCountry = null,
1366
        $shippingCurrency = null,
1367
        $shippingFee = null,
1368
        $shippingFeeConverted = null,
1369
        $shippingState = null,
1370
        $shippingZip = null,
1371
        $socialType = null,
1372
        $source = null,
1373
        $sourceFeeCurrency = null,
1374
        $sourceFee = null,
1375
        $sourceFeeConverted = null,
1376
        $taxCurrency = null,
1377
        $taxFee = null,
1378
        $taxFeeConverted = null,
1379
        $userMerchantId = null,
1380
        $websiteUrl = null,
1381
        $productUrl = null,
1382
        $productImageUrl = null
1383
    ) {
1384
        $envelopeType = 'order_item';
1385
        $builder = new self($envelopeType, $sequenceId);
1386
        if ($eventTimestamp === null) {
1387
            $eventTimestamp = time();
1388
        }
1389
        return $builder
1390
            ->addOrderData(
1391
                $envelopeType,
1392
                $amount,
1393
                $currency,
1394
                $eventId,
1395
                $eventTimestamp,
1396
                $transactionId,
1397
                $groupId,
1398
                null,
1399
                $orderType,
1400
                $amountConverted,
1401
                $campaign,
1402
                $carrier,
1403
                $carrierShippingId,
1404
                $carrierUrl,
1405
                $carrierPhone,
1406
                $couponStartDate,
1407
                $couponEndDate,
1408
                $couponId,
1409
                $couponName,
1410
                $customerComment,
1411
                $deliveryEstimate,
1412
                $shippingAddress,
1413
                $shippingCity,
1414
                $shippingCountry,
1415
                $shippingCurrency,
1416
                $shippingFee,
1417
                $shippingFeeConverted,
1418
                $shippingState,
1419
                $shippingZip,
1420
                $source,
1421
                $sourceFee,
1422
                $sourceFeeCurrency,
1423
                $sourceFeeConverted,
1424
                $taxCurrency,
1425
                $taxFee,
1426
                $taxFeeConverted,
1427
                $productUrl,
1428
                $productImageUrl
1429
            )
1430
            ->addUserData(
1431
                $email,
1432
                $userMerchantId,
1433
                $phone,
1434
                '',
1435
                $firstName,
1436
                $lastName,
1437
                '',
1438
                0,
1439
                '',
1440
                $socialType
1441
            )
1442
            -> addProductData(
1443
                $productQuantity,
1444
                $productName,
1445
                $productDescription
1446
            )
1447
            ->addWebsiteData(
1448
                $websiteUrl,
1449
                null,
1450
                $affiliateId
1451
            );
1452
    }
1453
1454
    /**
1455
     * Returns builder for order_submit request
1456
     *
1457
     * @param string $sequenceId
1458
     * @param float $amount
1459
     * @param string $currency
1460
     * @param string $eventId
1461
     * @param int $eventTimestamp
1462
     * @param int $itemsQuantity
1463
     * @param string|null $transactionId
1464
     * @param string|null $groupId
1465
     * @param string|null $affiliateId
1466
     * @param float|null $amountConverted
1467
     * @param string|null $campaign
1468
     * @param string|null $carrier
1469
     * @param string|null $carrierShippingId
1470
     * @param string|null $carrierUrl
1471
     * @param string|null $carrierPhone
1472
     * @param int|null $couponStartDate
1473
     * @param int|null $couponEndDate
1474
     * @param string|null $couponId
1475
     * @param string|null $couponName
1476
     * @param string|null $customerComment
1477
     * @param int|null $deliveryEstimate
1478
     * @param string|null $email
1479
     * @param string|null $firstName
1480
     * @param string|null $lastName
1481
     * @param string|null $phone
1482
     * @param string|null $shippingAddress
1483
     * @param string|null $shippingCity
1484
     * @param string|null $shippingCountry
1485
     * @param string|null $shippingCurrency
1486
     * @param float|null $shippingFee
1487
     * @param float|null $shippingFeeConverted
1488
     * @param string|null $shippingState
1489
     * @param string|null $shippingZip
1490
     * @param string|null $socialType
1491
     * @param string|null $source
1492
     * @param string|null $sourceFeeCurrency
1493
     * @param float|null $sourceFee
1494
     * @param float|null $sourceFeeConverted
1495
     * @param string|null $taxCurrency
1496
     * @param float|null $taxFee
1497
     * @param float|null $taxFeeConverted
1498
     * @param string|null $userMerchantId
1499
     * @param string|null $websiteUrl
1500
     * @param string|null $productUrl
1501
     * @param string|null $productImageUrl
1502
     * @return Builder
1503
     */
1504
    public static function orderSubmitEvent(
1505
        $sequenceId,
1506
        $amount,
1507
        $currency,
1508
        $eventId,
1509
        $eventTimestamp,
1510
        $itemsQuantity,
1511
        $transactionId = null,
1512
        $groupId = null,
1513
        $affiliateId = null,
1514
        $amountConverted = null,
1515
        $campaign = null,
1516
        $carrier = null,
1517
        $carrierShippingId = null,
1518
        $carrierUrl = null,
1519
        $carrierPhone = null,
1520
        $couponStartDate = null,
1521
        $couponEndDate = null,
1522
        $couponId = null,
1523
        $couponName = null,
1524
        $customerComment = null,
1525
        $deliveryEstimate = null,
1526
        $email = null,
1527
        $firstName = null,
1528
        $lastName = null,
1529
        $phone = null,
1530
        $shippingAddress = null,
1531
        $shippingCity = null,
1532
        $shippingCountry = null,
1533
        $shippingCurrency = null,
1534
        $shippingFee = null,
1535
        $shippingFeeConverted = null,
1536
        $shippingState = null,
1537
        $shippingZip = null,
1538
        $socialType = null,
1539
        $source = null,
1540
        $sourceFeeCurrency = null,
1541
        $sourceFee = null,
1542
        $sourceFeeConverted = null,
1543
        $taxCurrency = null,
1544
        $taxFee = null,
1545
        $taxFeeConverted = null,
1546
        $userMerchantId = null,
1547
        $websiteUrl = null,
1548
        $productUrl = null,
1549
        $productImageUrl = null
1550
    ) {
1551
        $envelopeType = 'order_submit';
1552
        $builder = new self($envelopeType, $sequenceId);
1553
        if ($eventTimestamp === null) {
1554
            $eventTimestamp = time();
1555
        }
1556
        return $builder
1557
            ->addOrderData(
1558
                $envelopeType,
1559
                $amount,
1560
                $currency,
1561
                $eventId,
1562
                $eventTimestamp,
1563
                $transactionId,
1564
                $groupId,
1565
                $itemsQuantity,
1566
                null,
1567
                $amountConverted,
1568
                $campaign,
1569
                $carrier,
1570
                $carrierShippingId,
1571
                $carrierUrl,
1572
                $carrierPhone,
1573
                $couponStartDate,
1574
                $couponEndDate,
1575
                $couponId,
1576
                $couponName,
1577
                $customerComment,
1578
                $deliveryEstimate,
1579
                $shippingAddress,
1580
                $shippingCity,
1581
                $shippingCountry,
1582
                $shippingCurrency,
1583
                $shippingFee,
1584
                $shippingFeeConverted,
1585
                $shippingState,
1586
                $shippingZip,
1587
                $source,
1588
                $sourceFee,
1589
                $sourceFeeCurrency,
1590
                $sourceFeeConverted,
1591
                $taxCurrency,
1592
                $taxFee,
1593
                $taxFeeConverted,
1594
                $productUrl,
1595
                $productImageUrl
1596
            )
1597
            ->addUserData(
1598
                $email,
1599
                $userMerchantId,
1600
                $phone,
1601
                '',
1602
                $firstName,
1603
                $lastName,
1604
                '',
1605
                0,
1606
                '',
1607
                $socialType
1608
            )
1609
            ->addWebsiteData(
1610
                $websiteUrl,
1611
                null,
1612
                $affiliateId
1613
            );
1614
    }
1615
1616
    /**
1617
     * Returns builder for postback request
1618
     *
1619
     * @param int|null $requestId
1620
     * @param string|null $transactionId
1621
     * @param string|null $transactionStatus
1622
     * @param string|null $code
1623
     * @param string|null $reason
1624
     * @param string|null $secure3d
1625
     * @param string|null $avsResult
1626
     * @param string|null $cvvResult
1627
     * @param string|null $pspCode
1628
     * @param string|null $pspReason
1629
     * @param string|null $arn
1630
     * @param string|null $paymentAccountId
1631
     * @return Builder
1632
     */
1633
    public static function postBackEvent(
1634
        $requestId =  null,
1635
        $transactionId = null,
1636
        $transactionStatus = null,
1637
        $code = null,
1638
        $reason = null,
1639
        $secure3d = null,
1640
        $avsResult = null,
1641
        $cvvResult = null,
1642
        $pspCode = null,
1643
        $pspReason = null,
1644
        $arn = null,
1645
        $paymentAccountId = null
1646
    ) {
1647
        $builder = new self('postback', '');
1648
        return $builder->addPostBackData(
1649
            $requestId,
1650
            $transactionId,
1651
            $transactionStatus,
1652
            $code,
1653
            $reason,
1654
            $secure3d,
1655
            $avsResult,
1656
            $cvvResult,
1657
            $pspCode,
1658
            $pspReason,
1659
            $arn,
1660
            $paymentAccountId
1661
       );
1662
    }
1663
1664
    /**
1665
     * Builder constructor.
1666
     *
1667
     * @param string $envelopeType
1668
     * @param string $sequenceId
1669
     */
1670
    public function __construct($envelopeType, $sequenceId)
1671
    {
1672
        if (!is_string($envelopeType)) {
1673
            throw new \InvalidArgumentException('Envelope type must be string');
1674
        }
1675
1676 View Code Duplication
        if ($envelopeType == self::EVENT_PROFILE_UPDATE) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1677
            if (!is_null($sequenceId) && !is_string($sequenceId)) {
1678
                throw new \InvalidArgumentException('Sequence ID must be string or null');
1679
            }
1680
        } else {
1681
            if (!is_string($sequenceId)) {
1682
                throw new \InvalidArgumentException('Sequence ID must be string');
1683
            }
1684
        }
1685
1686
        $this->type = $envelopeType;
1687
        $this->sequenceId = $sequenceId;
1688
    }
1689
1690
    /**
1691
     * Returns built envelope
1692
     *
1693
     * @return EnvelopeInterface
1694
     */
1695
    public function build()
1696
    {
1697
        return new Envelope(
1698
            $this->type,
1699
            $this->sequenceId,
1700
            $this->identities,
1701
            array_filter($this->data, function ($data) {
1702
                return $data !== null;
1703
            })
1704
        );
1705
    }
1706
1707
    /**
1708
     * Replaces value in internal array if provided value not empty
1709
     *
1710
     * @param string $key
1711
     * @param string|int|float|bool|null $value
1712
     */
1713
    private function replace($key, $value)
1714
    {
1715
        if ($value !== null && $value !== '' && $value !== 0 && $value !== 0.0) {
1716
            $this->data[$key] = $value;
1717
        }
1718
    }
1719
1720
    /**
1721
     * Adds identity node
1722
     *
1723
     * @param IdentityNodeInterface $identity
1724
     *
1725
     * @return $this
1726
     */
1727
    public function addIdentity(IdentityNodeInterface $identity)
1728
    {
1729
        $this->identities[] = $identity;
1730
        return $this;
1731
    }
1732
1733
    /**
1734
     * Provides website URL to envelope
1735
     *
1736
     * @param string|null $websiteUrl
1737
     * @param string|null $traffic_source
1738
     * @param string|null $affiliate_id
1739
     * @param string|null $campaign
1740
     *
1741
     * @return $this
1742
     */
1743
    public function addWebsiteData($websiteUrl = null, $traffic_source = null, $affiliate_id = null, $campaign = null)
1744
    {
1745
        if ($websiteUrl !== null && !is_string($websiteUrl)) {
1746
            throw new \InvalidArgumentException('Website URL must be string');
1747
        }
1748
        if ($traffic_source !== null && !is_string($traffic_source)) {
1749
            throw new \InvalidArgumentException('Traffic source must be string');
1750
        }
1751
        if ($affiliate_id !== null && !is_string($affiliate_id)) {
1752
            throw new \InvalidArgumentException('Affiliate ID must be string');
1753
        }
1754
        if ($campaign !== null && !is_string($campaign)) {
1755
            throw new \InvalidArgumentException('Campaign must be string');
1756
        }
1757
1758
        $this->replace('website_url', $websiteUrl);
1759
        $this->replace('traffic_source', $traffic_source);
1760
        $this->replace('affiliate_id', $affiliate_id);
1761
        $this->replace('campaign', $campaign);
1762
        return $this;
1763
    }
1764
1765
    /**
1766
     * Provides IP information for envelope
1767
     *
1768
     * @param string|null $ip User's IP address
1769
     * @param string|null $realIp User's real IP address, if available
1770
     * @param string|null $merchantIp Your website's IP address
1771
     *
1772
     * @return $this
1773
     */
1774
    public function addIpData($ip = '', $realIp = '', $merchantIp = '')
1775
    {
1776
        if ($ip !== null && !is_string($ip)) {
1777
            throw new \InvalidArgumentException('IP must be string');
1778
        }
1779
        if ($realIp !== null && !is_string($realIp)) {
1780
            throw new \InvalidArgumentException('Real IP must be string');
1781
        }
1782
        if ($merchantIp !== null && !is_string($merchantIp)) {
1783
            throw new \InvalidArgumentException('Merchant IP must be string');
1784
        }
1785
1786
        $this->replace('ip', $ip);
1787
        $this->replace('real_ip', $realIp);
1788
        $this->replace('merchant_ip', $merchantIp);
1789
1790
        return $this;
1791
    }
1792
1793
    /**
1794
     * Provides browser information for envelope
1795
     *
1796
     * @param string|null $deviceFingerprint
1797
     * @param string|null $userAgent
1798
     * @param string|null $cpuClass
1799
     * @param string|null $screenOrientation
1800
     * @param string|null $screenResolution
1801
     * @param string|null $os
1802
     * @param int|null $timezoneOffset
1803
     * @param string|null $languages
1804
     * @param string|null $language
1805
     * @param string|null $languageBrowser
1806
     * @param string|null $languageUser
1807
     * @param string|null $languageSystem
1808
     * @param bool|null $cookieEnabled
1809
     * @param bool|null $doNotTrack
1810
     * @param bool|null $ajaxValidation
1811
     * @param string|null $deviceId
1812
     * @param string|null $ipList
1813
     * @param string|null $plugins
1814
     * @param string|null $refererUrl
1815
     * @param string|null $originUrl
1816
     * @param string|null $clientResolution
1817
     * @return $this
1818
     */
1819
    public function addBrowserData(
1820
        $deviceFingerprint = '',
1821
        $userAgent = '',
1822
        $cpuClass = '',
1823
        $screenOrientation = '',
1824
        $screenResolution = '',
1825
        $os = '',
1826
        $timezoneOffset = null,
1827
        $languages = '',
1828
        $language = '',
1829
        $languageBrowser = '',
1830
        $languageUser = '',
1831
        $languageSystem = '',
1832
        $cookieEnabled = null,
1833
        $doNotTrack = null,
1834
        $ajaxValidation = null,
1835
        $deviceId = '',
1836
        $ipList = null,
1837
        $plugins = null,
1838
        $refererUrl = null,
1839
        $originUrl = null,
1840
        $clientResolution = null
1841
    ) {
1842
        if ($deviceFingerprint !== null && !is_string($deviceFingerprint)) {
1843
            throw new \InvalidArgumentException('Device fingerprint must be string');
1844
        }
1845
        if ($userAgent !== null && !is_string($userAgent)) {
1846
            throw new \InvalidArgumentException('User agent must be string');
1847
        }
1848
        if ($cpuClass !== null && !is_string($cpuClass)) {
1849
            throw new \InvalidArgumentException('CPU class must be string');
1850
        }
1851
        if ($screenOrientation !== null && !is_string($screenOrientation)) {
1852
            throw new \InvalidArgumentException('Screen orientation must be string');
1853
        }
1854
        if ($screenResolution !== null && !is_string($screenResolution)) {
1855
            throw new \InvalidArgumentException('Screen resolution must be string');
1856
        }
1857
        if ($os !== null && !is_string($os)) {
1858
            throw new \InvalidArgumentException('OS must be string');
1859
        }
1860
        if ($timezoneOffset !== null && $timezoneOffset !== null && !is_int($timezoneOffset)) {
1861
            throw new \InvalidArgumentException('Timezone offset must be integer or null');
1862
        }
1863
        if ($languages !== null && !is_string($languages)) {
1864
            throw new \InvalidArgumentException('Languages must be string');
1865
        }
1866
        if ($language !== null && !is_string($language)) {
1867
            throw new \InvalidArgumentException('Language must be string');
1868
        }
1869
        if ($languageBrowser !== null && !is_string($languageBrowser)) {
1870
            throw new \InvalidArgumentException('Browser language must be string');
1871
        }
1872
        if ($languageUser !== null && !is_string($languageUser)) {
1873
            throw new \InvalidArgumentException('User language must be string');
1874
        }
1875
        if ($languageSystem !== null && !is_string($languageSystem)) {
1876
            throw new \InvalidArgumentException('System language must be string');
1877
        }
1878
        if ($cookieEnabled !== null && !is_bool($cookieEnabled)) {
1879
            throw new \InvalidArgumentException('Cookie enabled flag must be boolean');
1880
        }
1881
        if ($doNotTrack !== null && !is_bool($doNotTrack)) {
1882
            throw new \InvalidArgumentException('DNT flag must be boolean');
1883
        }
1884
        if ($ajaxValidation !== null && !is_bool($ajaxValidation)) {
1885
            throw new \InvalidArgumentException('AJAX validation flag must be boolean');
1886
        }
1887
        if ($deviceId !== null && !is_string($deviceId)) {
1888
            throw new \InvalidArgumentException('Device id must be string');
1889
        }
1890
        if ($ipList !== null && !is_string($ipList)) {
1891
            throw new \InvalidArgumentException('Ip list must be string');
1892
        }
1893
        if ($plugins !== null && !is_string($plugins)) {
1894
            throw new \InvalidArgumentException('Plugins must be string');
1895
        }
1896
        if ($refererUrl !== null && !is_string($refererUrl)) {
1897
            throw new \InvalidArgumentException('Referer url must be string');
1898
        }
1899
        if ($originUrl !== null && !is_string($originUrl)) {
1900
            throw new \InvalidArgumentException('Origin url must be string');
1901
        }
1902
        if ($clientResolution !== null && !is_string($clientResolution)) {
1903
            throw new \InvalidArgumentException('Client resolution must be string');
1904
        }
1905
1906
        $this->replace('device_fingerprint', $deviceFingerprint);
1907
        $this->replace('user_agent', $userAgent);
1908
        $this->replace('cpu_class', $cpuClass);
1909
        $this->replace('screen_orientation', $screenOrientation);
1910
        $this->replace('screen_resolution', $screenResolution);
1911
        $this->replace('os', $os);
1912
        $this->replace('timezone_offset', $timezoneOffset);
1913
        $this->replace('languages', $languages);
1914
        $this->replace('language', $language);
1915
        $this->replace('language_browser', $languageBrowser);
1916
        $this->replace('language_system', $languageSystem);
1917
        $this->replace('language_user', $languageUser);
1918
        $this->replace('cookie_enabled', $cookieEnabled);
1919
        $this->replace('do_not_track', $doNotTrack);
1920
        $this->replace('ajax_validation', $ajaxValidation);
1921
        $this->replace('device_id', $deviceId);
1922
        $this->replace('local_ip_list', $ipList);
1923
        $this->replace('plugins', $plugins);
1924
        $this->replace('referer_url', $refererUrl);
1925
        $this->replace('origin_url', $originUrl);
1926
        $this->replace('client_resolution', $clientResolution);
1927
1928
        return $this;
1929
    }
1930
1931
    /**
1932
     * Provides user data for envelope
1933
     *
1934
     * @param string|null $email
1935
     * @param string|null $userId
1936
     * @param string|null $phone
1937
     * @param string|null $userName
1938
     * @param string|null $firstName
1939
     * @param string|null $lastName
1940
     * @param string|null $gender
1941
     * @param int|null $age
1942
     * @param string|null $country
1943
     * @param string|null $socialType
1944
     * @param int|null $registrationTimestamp
1945
     * @param int|null $loginTimeStamp
1946
     * @param int|null $confirmationTimeStamp
1947
     * @param bool|null $emailConfirmed
1948
     * @param bool|null $phoneConfirmed
1949
     * @param bool|null $loginFailed
1950
     * @param int|null $birthDate
1951
     * @param string|null $fullname
1952
     * @param string|null $state
1953
     * @param string|null $city
1954
     * @param string|null $address
1955
     * @param string|null $zip
1956
     * @param string|null $password
1957
     *
1958
     * @return $this
1959
     */
1960
    public function addUserData(
1961
        $email = '',
1962
        $userId = '',
1963
        $phone = '',
1964
        $userName = '',
1965
        $firstName = '',
1966
        $lastName = '',
1967
        $gender = '',
1968
        $age = 0,
1969
        $country = '',
1970
        $socialType = '',
1971
        $registrationTimestamp = 0,
1972
        $loginTimeStamp = 0,
1973
        $confirmationTimeStamp = 0,
1974
        $emailConfirmed = null,
1975
        $phoneConfirmed = null,
1976
        $loginFailed = null,
1977
        $birthDate = null,
1978
        $fullname = null,
1979
        $state = null,
1980
        $city = null,
1981
        $address = null,
1982
        $zip = null,
1983
        $password = ''
1984
    )
1985
    {
1986
        if ($userName !== null && !is_string($userName)) {
1987
            throw new \InvalidArgumentException('User name must be string');
1988
        }
1989
        if ($password !== null && !is_string($password)) {
1990
            throw new \InvalidArgumentException('Password must be string');
1991
        }
1992
        if ($gender !== null && !is_string($gender)) {
1993
            throw new \InvalidArgumentException('Gender must be string');
1994
        }
1995
        if ($age !== null && !is_int($age)) {
1996
            throw new \InvalidArgumentException('Age must be integer');
1997
        }
1998
        if ($socialType !== null && !is_string($socialType)) {
1999
            throw new \InvalidArgumentException('Social type must be string');
2000
        }
2001
        if ($registrationTimestamp !== null && !is_int($registrationTimestamp)) {
2002
            throw new \InvalidArgumentException('Registration timestamp must be integer');
2003
        }
2004
        if ($loginTimeStamp !== null && !is_int($loginTimeStamp)) {
2005
            throw new \InvalidArgumentException('Login timestamp must be integer');
2006
        }
2007
        if ($confirmationTimeStamp !== null && !is_int($confirmationTimeStamp)) {
2008
            throw new \InvalidArgumentException('Confirmation timestamp must be integer');
2009
        }
2010
        if ($birthDate !== null && !is_int($birthDate)) {
2011
            throw new \InvalidArgumentException('Birthdate timestamp must be integer');
2012
        }
2013
        if ($emailConfirmed !== null && !is_bool($emailConfirmed)) {
2014
            throw new \InvalidArgumentException('Email confirmed flag must be boolean');
2015
        }
2016
        if ($phoneConfirmed !== null && !is_bool($phoneConfirmed)) {
2017
            throw new \InvalidArgumentException('Phone confirmed flag must be boolean');
2018
        }
2019
        if ($loginFailed !== null && !is_bool($loginFailed)) {
2020
            throw new \InvalidArgumentException('Login failed flag must be boolean');
2021
        }
2022
        if ($fullname !== null && !is_string($fullname)) {
2023
            throw new \InvalidArgumentException('Fullname must be string');
2024
        }
2025
        if ($state !== null && !is_string($state)) {
2026
            throw new \InvalidArgumentException('State must be string');
2027
        }
2028
        if ($city !== null && !is_string($city)) {
2029
            throw new \InvalidArgumentException('City must be string');
2030
        }
2031
        if ($address !== null && !is_string($address)) {
2032
            throw new \InvalidArgumentException('Address must be string');
2033
        }
2034
        if ($zip !== null && !is_string($zip)) {
2035
            throw new \InvalidArgumentException('Zip must be string');
2036
        }
2037
2038
        $this->addShortUserData($email, $userId, $phone, $firstName, $lastName, $country);
2039
2040
        $this->replace('user_name', $userName);
2041
        $this->replace('gender', $gender);
2042
        $this->replace('age', $age);
2043
        $this->replace('social_type', $socialType);
2044
        $this->replace('registration_timestamp', $registrationTimestamp);
2045
        $this->replace('login_timestamp', $loginTimeStamp);
2046
        $this->replace('confirmation_timestamp', $confirmationTimeStamp);
2047
        $this->replace('email_confirmed', $emailConfirmed);
2048
        $this->replace('phone_confirmed', $phoneConfirmed);
2049
        $this->replace('login_failed', $loginFailed);
2050
        $this->replace('birth_date', $birthDate);
2051
        $this->replace('fullname', $fullname);
2052
        $this->replace('state', $state);
2053
        $this->replace('city', $city);
2054
        $this->replace('address', $address);
2055
        $this->replace('zip', $zip);
2056
        $this->replace('password', $password);
2057
2058
        return $this;
2059
    }
2060
2061
    /**
2062
     * Provides user data for envelope
2063
     *
2064
     * @param string|null $email
2065
     * @param string|null $userId
2066
     * @param string|null $phone
2067
     * @param string|null $firstName
2068
     * @param string|null $lastName
2069
     * @param string|null $country
2070
     *
2071
     * @return $this
2072
     */
2073
    public function addShortUserData(
2074
        $email = '',
2075
        $userId = '',
2076
        $phone = '',
2077
        $firstName = '',
2078
        $lastName = '',
2079
        $country = ''
2080
    ) {
2081
        if ($email !== null && !is_string($email)) {
2082
            throw new \InvalidArgumentException('Email must be string');
2083
        }
2084
        if (is_int($userId)) {
2085
            $userId = strval($userId);
2086
        }
2087
        if ($userId !== null && !is_string($userId)) {
2088
            throw new \InvalidArgumentException('UserId must be string or integer');
2089
        }
2090
        if ($phone !== null && !is_string($phone)) {
2091
            throw new \InvalidArgumentException('Phone must be string');
2092
        }
2093
        if ($firstName !== null && !is_string($firstName)) {
2094
            throw new \InvalidArgumentException('First name must be string');
2095
        }
2096
        if ($lastName !== null && !is_string($lastName)) {
2097
            throw new \InvalidArgumentException('Last name must be string');
2098
        }
2099
        if ($country !== null && !is_string($country)) {
2100
            throw new \InvalidArgumentException('Country must be string');
2101
        }
2102
2103
        $this->replace('email', $email);
2104
        $this->replace('user_merchant_id', $userId);
2105
        $this->replace('phone', $phone);
2106
        $this->replace('firstname', $firstName);
2107
        $this->replace('lastname', $lastName);
2108
        $this->replace('country', $country);
2109
2110
        return $this;
2111
    }
2112
2113
    /**
2114
     * Provides credit card data to envelope
2115
     *
2116
     * @param string|null $transactionId
2117
     * @param string|null $transactionSource
2118
     * @param string|null $transactionType
2119
     * @param string|null $transactionMode
2120
     * @param string|null $transactionTimestamp
2121
     * @param string|null $transactionCurrency
2122
     * @param string|null $transactionAmount
2123
     * @param float|null $amountConverted
2124
     * @param string|null $paymentMethod
2125
     * @param string|null $paymentSystem
2126
     * @param string|null $paymentMidName
2127
     * @param string|null $paymentAccountId
2128
     * @param string|null $merchantCountry
2129
     * @param string|null $mcc
2130
     * @param string|null $acquirerMerchantId
2131
     * @return $this
2132
     */
2133
    public function addCCTransactionData(
2134
        $transactionId,
2135
        $transactionSource,
2136
        $transactionType,
2137
        $transactionMode,
2138
        $transactionTimestamp,
2139
        $transactionCurrency,
2140
        $transactionAmount,
2141
        $amountConverted = null,
2142
        $paymentMethod = null,
2143
        $paymentSystem = null,
2144
        $paymentMidName = null,
2145
        $paymentAccountId = null,
2146
        $merchantCountry = null,
2147
        $mcc = null,
2148
        $acquirerMerchantId = null
2149
    ) {
2150
        if ($transactionId !== null && !is_string($transactionId)) {
2151
            throw new \InvalidArgumentException('Transaction ID must be string');
2152
        }
2153
        if ($transactionSource !== null && !is_string($transactionSource)) {
2154
            throw new \InvalidArgumentException('Transaction source must be string');
2155
        }
2156
        if ($transactionType !== null && !is_string($transactionType)) {
2157
            throw new \InvalidArgumentException('Transaction type must be string');
2158
        }
2159
        if ($transactionMode !== null && !is_string($transactionMode)) {
2160
            throw new \InvalidArgumentException('Transaction mode must be string');
2161
        }
2162
        if ($transactionTimestamp !== null && !is_int($transactionTimestamp)) {
2163
            throw new \InvalidArgumentException('Transaction timestamp must be integer');
2164
        }
2165
        if ($transactionAmount !== null && !is_int($transactionAmount) && !is_float($transactionAmount)) {
2166
            throw new \InvalidArgumentException('Transaction amount must be float');
2167
        }
2168
        if ($transactionCurrency !== null && !is_string($transactionCurrency)) {
2169
            throw new \InvalidArgumentException('Transaction currency must be string');
2170
        }
2171
        if ($paymentMethod !== null && !is_string($paymentMethod)) {
2172
            throw new \InvalidArgumentException('Payment method must be string');
2173
        }
2174
        if ($paymentSystem !== null && !is_string($paymentSystem)) {
2175
            throw new \InvalidArgumentException('Payment system must be string');
2176
        }
2177
        if ($paymentMidName !== null && !is_string($paymentMidName)) {
2178
            throw new \InvalidArgumentException('Payment MID name must be string');
2179
        }
2180
        if ($paymentAccountId !== null && !is_string($paymentAccountId)) {
2181
            throw new \InvalidArgumentException('Payment account id must be string');
2182
        }
2183 View Code Duplication
        if ($amountConverted !== null && !is_int($amountConverted) && !is_float($amountConverted)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2184
            throw new \InvalidArgumentException('Transaction amount converted must be float');
2185
        }
2186
2187
        if ($merchantCountry !== null && !is_string($merchantCountry)) {
2188
            throw new \InvalidArgumentException('Merchant country must be string');
2189
        }
2190
        if ($mcc !== null && !is_string($mcc)) {
2191
            throw new \InvalidArgumentException('MCC must be string');
2192
        }
2193
        if ($acquirerMerchantId !== null && !is_string($acquirerMerchantId)) {
2194
            throw new \InvalidArgumentException('Acquirer merchant id be string');
2195
        }
2196
        $this->replace('transaction_id', $transactionId);
2197
        $this->replace('transaction_source', $transactionSource);
2198
        $this->replace('transaction_type', $transactionType);
2199
        $this->replace('transaction_mode', $transactionMode);
2200
        $this->replace('transaction_timestamp', $transactionTimestamp);
2201
        $this->replace('transaction_amount', floatval($transactionAmount));
2202
        $this->replace('transaction_amount_converted', floatval($amountConverted));
2203
        $this->replace('transaction_currency', $transactionCurrency);
2204
        $this->replace('payment_method', $paymentMethod);
2205
        $this->replace('payment_system', $paymentSystem);
2206
        $this->replace('payment_mid', $paymentMidName);
2207
        $this->replace('payment_account_id', $paymentAccountId);
2208
        $this->replace('merchant_country', $merchantCountry);
2209
        $this->replace('mcc', $mcc);
2210
        $this->replace('acquirer_merchant_id', $acquirerMerchantId);
2211
2212
        return $this;
2213
    }
2214
2215
    /**
2216
     * Provides Card data to envelope
2217
     *
2218
     * @param string|null $cardId
2219
     * @param int|null $cardBin
2220
     * @param string|null $cardLast4
2221
     * @param int|null $expirationMonth
2222
     * @param int|null $expirationYear
2223
     *
2224
     * @return $this
2225
     */
2226
    public function addCardData(
2227
        $cardBin,
2228
        $cardLast4,
2229
        $expirationMonth,
2230
        $expirationYear,
2231
        $cardId = null
2232
    ) {
2233
        if ($cardId !== null && !is_string($cardId)) {
2234
            throw new \InvalidArgumentException('Card ID must be string');
2235
        }
2236
        if ($cardBin !== null && !is_int($cardBin)) {
2237
            throw new \InvalidArgumentException('Card BIN must be integer');
2238
        }
2239
        if ($cardLast4 !== null && !is_string($cardLast4)) {
2240
            throw new \InvalidArgumentException('Card last4  must be string');
2241
        }
2242
        if ($expirationMonth !== null && !is_int($expirationMonth)) {
2243
            throw new \InvalidArgumentException('Expiration month must be integer');
2244
        }
2245
        if ($expirationYear !== null && !is_int($expirationYear)) {
2246
            throw new \InvalidArgumentException('Expiration year must be integer');
2247
        }
2248
2249
        $this->replace('card_id', $cardId);
2250
        $this->replace('card_bin', $cardBin);
2251
        $this->replace('card_last4', $cardLast4);
2252
        $this->replace('expiration_month', $expirationMonth);
2253
        $this->replace('expiration_year', $expirationYear);
2254
2255
        return $this;
2256
    }
2257
2258
    /**
2259
     * Provides billing data to envelope
2260
     *
2261
     * @param string|null $billingFirstName
2262
     * @param string|null $billingLastName
2263
     * @param string|null $billingFullName
2264
     * @param string|null $billingCountry
2265
     * @param string|null $billingState
2266
     * @param string|null $billingCity
2267
     * @param string|null $billingAddress
2268
     * @param string|null $billingZip
2269
     *
2270
     * @return $this
2271
     */
2272
    public function addBillingData(
2273
        $billingFirstName = null,
2274
        $billingLastName = null,
2275
        $billingFullName = null,
2276
        $billingCountry = null,
2277
        $billingState = null,
2278
        $billingCity = null,
2279
        $billingAddress = null,
2280
        $billingZip = null
2281
    ) {
2282
        if ($billingFirstName !== null && !is_string($billingFirstName)) {
2283
            throw new \InvalidArgumentException('Billing first name must be string');
2284
        }
2285
        if ($billingLastName !== null && !is_string($billingLastName)) {
2286
            throw new \InvalidArgumentException('Billing last name must be string');
2287
        }
2288
        if ($billingFullName !== null && !is_string($billingFullName)) {
2289
            throw new \InvalidArgumentException('Billing full name must be string');
2290
        }
2291
        if ($billingCountry !== null && !is_string($billingCountry)) {
2292
            throw new \InvalidArgumentException('Billing country name must be string');
2293
        }
2294
        if ($billingState !== null && !is_string($billingState)) {
2295
            throw new \InvalidArgumentException('Billing state must be string');
2296
        }
2297
        if ($billingCity !== null && !is_string($billingCity)) {
2298
            throw new \InvalidArgumentException('Billing city must be string');
2299
        }
2300
        if ($billingAddress !== null && !is_string($billingAddress)) {
2301
            throw new \InvalidArgumentException('Billing address must be string');
2302
        }
2303
        if ($billingZip !== null && !is_string($billingZip)) {
2304
            throw new \InvalidArgumentException('Billing zip must be string');
2305
        }
2306
2307
        $this->replace('billing_firstname', $billingFirstName);
2308
        $this->replace('billing_lastname', $billingLastName);
2309
        $this->replace('billing_fullname', $billingFullName);
2310
        $this->replace('billing_country', $billingCountry);
2311
        $this->replace('billing_state', $billingState);
2312
        $this->replace('billing_city', $billingCity);
2313
        $this->replace('billing_address', $billingAddress);
2314
        $this->replace('billing_zip', $billingZip);
2315
2316
        return $this;
2317
    }
2318
2319
    /**
2320
     * Provides product information to envelope
2321
     *
2322
     * @param float|null $productQuantity
2323
     * @param string|null $productName
2324
     * @param string|null $productDescription
2325
     *
2326
     * @return $this
2327
     */
2328
    public function addProductData(
2329
        $productQuantity = null,
2330
        $productName = null,
2331
        $productDescription = null
2332
    ) {
2333
        if ($productQuantity !== null && !is_int($productQuantity) && !is_float($productQuantity)) {
2334
            throw new \InvalidArgumentException('Product quantity must be int or float');
2335
        }
2336
        if ($productName !== null && !is_string($productName)) {
2337
            throw new \InvalidArgumentException('Product name must be string');
2338
        }
2339
        if ($productDescription !== null && !is_string($productDescription)) {
2340
            throw new \InvalidArgumentException('Product description must be string');
2341
        }
2342
2343
        $this->replace('product_quantity', $productQuantity);
2344
        $this->replace('product_name', $productName);
2345
        $this->replace('product_description', $productDescription);
2346
2347
        return $this;
2348
    }
2349
2350
    /**
2351
     * Provides payout information to envelope
2352
     *
2353
     * @param string $payoutId
2354
     * @param int $payoutTimestamp
2355
     * @param int|float $payoutAmount
2356
     * @param string $payoutCurrency
2357
     * @param string|null $payoutCardId
2358
     * @param string|null $payoutAccountId
2359
     * @param string|null $payoutMethod
2360
     * @param string|null $payoutSystem
2361
     * @param string|null $payoutMid
2362
     * @param int|float|null $amountConverted
2363
     * @param int|null $payoutCardBin
2364
     * @param string|null $payoutCardLast4
2365
     * @param int|null $payoutExpirationMonth
2366
     * @param int|null $payoutExpirationYear
2367
     *
2368
     * @return $this
2369
     */
2370
    public function addPayoutData(
2371
        $payoutId,
2372
        $payoutTimestamp,
2373
        $payoutAmount,
2374
        $payoutCurrency,
2375
        $payoutCardId =  null,
2376
        $payoutAccountId = null,
2377
        $payoutMethod = null,
2378
        $payoutSystem = null,
2379
        $payoutMid = null,
2380
        $amountConverted = null,
2381
        $payoutCardBin = null,
2382
        $payoutCardLast4 = null,
2383
        $payoutExpirationMonth = null,
2384
        $payoutExpirationYear = null
2385
    ) {
2386
        if (!is_string($payoutId)) {
2387
            throw new \InvalidArgumentException('Payout ID must be string');
2388
        }
2389
        if (!is_int($payoutTimestamp)) {
2390
            throw new \InvalidArgumentException('Payout timestamp must be int');
2391
        }
2392
        if (!is_float($payoutAmount) && !is_int($payoutAmount)) {
2393
            throw new \InvalidArgumentException('Amount must be number');
2394
        }
2395
        if (!is_string($payoutCurrency)) {
2396
            throw new \InvalidArgumentException('Payout currency must be string');
2397
        }
2398
        if ($payoutAccountId !== null && !is_string($payoutAccountId)) {
2399
            throw new \InvalidArgumentException('Account ID must be string');
2400
        }
2401
        if ($payoutCardId !== null && !is_string($payoutCardId)) {
2402
            throw new \InvalidArgumentException('Card ID must be string');
2403
        }
2404
        if ($payoutMethod !== null && !is_string($payoutMethod)) {
2405
            throw new \InvalidArgumentException('Payout method must be string');
2406
        }
2407
        if ($payoutSystem !== null && !is_string($payoutSystem)) {
2408
            throw new \InvalidArgumentException('Payout system must be string');
2409
        }
2410
        if ($payoutMid !== null && !is_string($payoutMid)) {
2411
            throw new \InvalidArgumentException('Payout MID must be string');
2412
        }
2413 View Code Duplication
        if ($amountConverted !== null && !is_float($amountConverted) && !is_int($amountConverted)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2414
            throw new \InvalidArgumentException('Payout converted amount must be number');
2415
        }
2416
        if ($payoutCardBin !== null && !is_int($payoutCardBin)) {
2417
            throw new \InvalidArgumentException('Payout card BIN must be integer');
2418
        }
2419
        if ($payoutCardLast4 !== null && !is_string($payoutCardLast4)) {
2420
            throw new \InvalidArgumentException('Payout last 4 must be string');
2421
        }
2422
        if ($payoutExpirationMonth !== null && !is_int($payoutExpirationMonth)) {
2423
            throw new \InvalidArgumentException('Payout card expiration month must be integer');
2424
        }
2425
        if ($payoutExpirationYear !== null && !is_int($payoutExpirationYear)) {
2426
            throw new \InvalidArgumentException('Payout card expiration year must be integer');
2427
        }
2428
2429
        $this->replace('payout_id', $payoutId);
2430
        $this->replace('payout_timestamp', $payoutTimestamp);
2431
        $this->replace('payout_card_id', $payoutCardId);
2432
        $this->replace('payout_account_id', $payoutAccountId);
2433
        $this->replace('payout_amount', (float) $payoutAmount);
2434
        $this->replace('payout_currency', $payoutCurrency);
2435
        $this->replace('payout_method', $payoutMethod);
2436
        $this->replace('payout_system', $payoutSystem);
2437
        $this->replace('payout_mid', $payoutMid);
2438
        $this->replace('payout_amount_converted', (float) $amountConverted);
2439
        $this->replace('payout_card_bin', $payoutCardBin);
2440
        $this->replace('payout_card_last4', $payoutCardLast4);
2441
        $this->replace('payout_expiration_month', $payoutExpirationMonth);
2442
        $this->replace('payout_expiration_year', $payoutExpirationYear);
2443
2444
        return $this;
2445
    }
2446
2447
    /**
2448
     * Provides install information to envelope
2449
     *
2450
     * @param int $installTimestamp
2451
     *
2452
     * @return $this
2453
     */
2454
    public function addInstallData($installTimestamp)
2455
    {
2456
        if (!is_int($installTimestamp)) {
2457
            throw new \InvalidArgumentException('Install timestamp must be int');
2458
        }
2459
2460
        $this->replace('install_timestamp', $installTimestamp);
2461
2462
        return $this;
2463
    }
2464
2465
    /**
2466
     * Provides refund information to envelope
2467
     *
2468
     * @param string $refundId
2469
     * @param int|float $refundAmount
2470
     * @param string $refundCurrency
2471
     * @param int|null $refundTimestamp
2472
     * @param int|float|null $refundAmountConverted
2473
     * @param string|null $refundSource
2474
     * @param string|null $refundType
2475
     * @param string|null $refundCode
2476
     * @param string|null $refundReason
2477
     * @param string|null $agentId
2478
     * @param string|null $refundMethod
2479
     * @param string|null $refundSystem
2480
     * @param string|null $refundMid
2481
     *
2482
     * @return $this
2483
     */
2484
    public function addRefundData(
2485
        $refundId,
2486
        $refundTimestamp,
2487
        $refundAmount,
2488
        $refundCurrency,
2489
        $refundAmountConverted = null,
2490
        $refundSource = null,
2491
        $refundType = null,
2492
        $refundCode = null,
2493
        $refundReason = null,
2494
        $agentId = null,
2495
        $refundMethod = null,
2496
        $refundSystem = null,
2497
        $refundMid = null
2498
    ) {
2499
        if (!is_string($refundId)) {
2500
            throw new \InvalidArgumentException('Refund ID must be string');
2501
        }
2502
        if (!is_int($refundTimestamp)) {
2503
            throw new \InvalidArgumentException('Refund timestamp must be int');
2504
        }
2505
        if (!is_float($refundAmount) && !is_int($refundAmount)) {
2506
            throw new \InvalidArgumentException('Amount must be number');
2507
        }
2508
        if (!is_string($refundCurrency)) {
2509
            throw new \InvalidArgumentException('Refund currency must be string');
2510
        }
2511
        if ($refundAmountConverted !== null && !is_float($refundAmountConverted) && !is_int($refundAmountConverted)) {
2512
            throw new \InvalidArgumentException('Refund converted amount must be number');
2513
        }
2514
        if ($refundSource !== null && !is_string($refundSource)) {
2515
            throw new \InvalidArgumentException('Refund source must be string');
2516
        }
2517
        if ($refundType !== null && !is_string($refundType)) {
2518
            throw new \InvalidArgumentException('Refund type must be string');
2519
        }
2520
        if ($refundCode !== null && !is_string($refundCode)) {
2521
            throw new \InvalidArgumentException('Refund code must be string');
2522
        }
2523
        if ($refundReason !== null && !is_string($refundReason)) {
2524
            throw new \InvalidArgumentException('Refund reason must be string');
2525
        }
2526
        if ($agentId !== null && !is_string($agentId)) {
2527
            throw new \InvalidArgumentException('Agent id must be string');
2528
        }
2529
        if ($refundMethod !== null && !is_string($refundMethod)) {
2530
            throw new \InvalidArgumentException('Refund method must be string');
2531
        }
2532
        if ($refundSystem !== null && !is_string($refundSystem)) {
2533
            throw new \InvalidArgumentException('Refund system must be string');
2534
        }
2535
        if ($refundMid !== null && !is_string($refundMid)) {
2536
            throw new \InvalidArgumentException('Refund mid must be string');
2537
        }
2538
2539
        $this->replace('refund_id', $refundId);
2540
        $this->replace('refund_timestamp', $refundTimestamp);
2541
        $this->replace('refund_amount', $refundAmount);
2542
        $this->replace('refund_currency', $refundCurrency);
2543
        $this->replace('refund_amount_converted', $refundAmountConverted);
2544
        $this->replace('refund_source', $refundSource);
2545
        $this->replace('refund_type', $refundType);
2546
        $this->replace('refund_code', $refundCode);
2547
        $this->replace('refund_reason', $refundReason);
2548
        $this->replace('agent_id', $agentId);
2549
        $this->replace('refund_method', $refundMethod);
2550
        $this->replace('refund_system', $refundSystem);
2551
        $this->replace('refund_mid', $refundMid);
2552
2553
        return $this;
2554
    }
2555
2556
    /**
2557
     * Provides transfer information to envelope
2558
     *
2559
     * @param string $eventId
2560
     * @param int $eventTimestamp
2561
     * @param float $amount
2562
     * @param string $currency
2563
     * @param string $accountId
2564
     * @param string $secondAccountId
2565
     * @param string $accountSystem
2566
     * @param float|null $amountConverted
2567
     * @param string|null $method
2568
     * @param string|null $operation
2569
     * @param string|null $secondEmail
2570
     * @param string|null $secondPhone
2571
     * @param string|int $secondBirthDate
2572
     * @param string|null $secondFirstname
2573
     * @param string|null $secondLastname
2574
     * @param string|null $secondFullname
2575
     * @param string|null $secondState
2576
     * @param string|null $secondCity
2577
     * @param string|null $secondAddress
2578
     * @param string|null $secondZip
2579
     * @param string|null $secondGender
2580
     * @param string|null $secondCountry
2581
     * @param string|null $iban
2582
     * @param string|null $secondIban
2583
     * @param string|null $bic
2584
     * @param string|null $source
2585
     * @param string|null $secondUserMerchantId
2586
     *
2587
     * @return $this
2588
     */
2589
    public function addTransferData(
2590
        $eventId,
2591
        $eventTimestamp,
2592
        $amount,
2593
        $currency,
2594
        $accountId,
2595
        $secondAccountId,
2596
        $accountSystem,
2597
        $amountConverted = null,
2598
        $method = null,
2599
        $operation = null,
2600
        $secondEmail = null,
2601
        $secondPhone = null,
2602
        $secondBirthDate = null,
2603
        $secondFirstname = null,
2604
        $secondLastname = null,
2605
        $secondFullname = null,
2606
        $secondState = null,
2607
        $secondCity = null,
2608
        $secondAddress = null,
2609
        $secondZip = null,
2610
        $secondGender = null,
2611
        $secondCountry = null,
2612
        $iban = null,
2613
        $secondIban = null,
2614
        $bic = null,
2615
        $source = null,
2616
        $secondUserMerchantId = null
2617
    ) {
2618
        if (!is_string($eventId)) {
2619
            throw new \InvalidArgumentException('Event ID must be string');
2620
        }
2621
        if (!is_int($eventTimestamp)) {
2622
            throw new \InvalidArgumentException('Event timestamp must be int');
2623
        }
2624
        if (!is_int($amount) && !is_float($amount)) {
2625
            throw new \InvalidArgumentException('Amount must be number');
2626
        }
2627
        if (!is_string($currency)) {
2628
            throw new \InvalidArgumentException('Currency must be string');
2629
        }
2630
        if ($accountId !== null && !is_string($accountId)) {
2631
            throw new \InvalidArgumentException('Account id must be string');
2632
        }
2633
        if ($secondAccountId !== null && !is_string($secondAccountId)) {
2634
            throw new \InvalidArgumentException('Second account id must be string');
2635
        }
2636
        if ($accountSystem !== null && !is_string($accountSystem)) {
2637
            throw new \InvalidArgumentException('Account system must be string');
2638
        }
2639 View Code Duplication
        if ($amountConverted !== null && !is_int($amountConverted) && !is_float($amountConverted)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2640
            throw new \InvalidArgumentException('Amount converted must be number');
2641
        }
2642
        if ($method !== null && !is_string($method)) {
2643
            throw new \InvalidArgumentException('Method must be string');
2644
        }
2645
        if ($operation !== null && !is_string($operation)) {
2646
            throw new \InvalidArgumentException('Operation must be string');
2647
        }
2648
        if ($secondPhone !== null && !is_string($secondPhone)) {
2649
            throw new \InvalidArgumentException('Second phone must be string');
2650
        }
2651
        if ($secondEmail !== null && !is_string($secondEmail)) {
2652
            throw new \InvalidArgumentException('Second email must be string');
2653
        }
2654
        if ($secondBirthDate !== null && !is_int($secondBirthDate)) {
2655
            throw new \InvalidArgumentException('Second birth date must be int');
2656
        }
2657
        if ($secondFirstname !== null && !is_string($secondFirstname)) {
2658
            throw new \InvalidArgumentException('Second firstname must be string');
2659
        }
2660
        if ($secondLastname !== null && !is_string($secondLastname)) {
2661
            throw new \InvalidArgumentException('Second lastname must be string');
2662
        }
2663
        if ($secondFullname !== null && !is_string($secondFullname)) {
2664
            throw new \InvalidArgumentException('Second fullname must be string');
2665
        }
2666
        if ($secondState !== null && !is_string($secondState)) {
2667
            throw new \InvalidArgumentException('Second state must be string');
2668
        }
2669
        if ($secondCity !== null && !is_string($secondCity)) {
2670
            throw new \InvalidArgumentException('Second city must be string');
2671
        }
2672
        if ($secondAddress !== null && !is_string($secondAddress)) {
2673
            throw new \InvalidArgumentException('Second address must be string');
2674
        }
2675
        if ($secondZip !== null && !is_string($secondZip)) {
2676
            throw new \InvalidArgumentException('Second zip must be string');
2677
        }
2678
        if ($secondGender !== null && !is_string($secondGender)) {
2679
            throw new \InvalidArgumentException('Second gender must be string');
2680
        }
2681
        if ($secondCountry !== null && !is_string($secondCountry)) {
2682
            throw new \InvalidArgumentException('Second country must be string');
2683
        }
2684
        if ($iban !== null && !is_string($iban)) {
2685
            throw new \InvalidArgumentException('Iban must be string');
2686
        }
2687
        if ($secondIban !== null && !is_string($secondIban)) {
2688
            throw new \InvalidArgumentException('Second iban must be string');
2689
        }
2690
        if ($bic !== null && !is_string($bic)) {
2691
            throw new \InvalidArgumentException('Bic must be string');
2692
        }
2693
        if ($source !== null && !is_string($source)) {
2694
            throw new \InvalidArgumentException('Transfer source must be string');
2695
        }
2696
        if ($source !== null && !is_string($secondUserMerchantId)) {
2697
            throw new \InvalidArgumentException('Transfer second user merchant id must be string');
2698
        }
2699
2700
        $this->replace('event_id', $eventId);
2701
        $this->replace('event_timestamp', $eventTimestamp);
2702
        $this->replace('amount', $amount);
2703
        $this->replace('currency', $currency);
2704
        $this->replace('account_id', $accountId);
2705
        $this->replace('second_account_id', $secondAccountId);
2706
        $this->replace('account_system', $accountSystem);
2707
        $this->replace('amount_converted', $amountConverted);
2708
        $this->replace('method', $method);
2709
        $this->replace('operation', $operation);
2710
        $this->replace('second_email', $secondEmail);
2711
        $this->replace('second_phone', $secondPhone);
2712
        $this->replace('second_birth_date', $secondBirthDate);
2713
        $this->replace('second_firstname', $secondFirstname);
2714
        $this->replace('second_lastname', $secondLastname);
2715
        $this->replace('second_fullname', $secondFullname);
2716
        $this->replace('second_state', $secondState);
2717
        $this->replace('second_city', $secondCity);
2718
        $this->replace('second_address', $secondAddress);
2719
        $this->replace('second_zip', $secondZip);
2720
        $this->replace('second_gender', $secondGender);
2721
        $this->replace('second_country', $secondCountry);
2722
        $this->replace('iban', $iban);
2723
        $this->replace('second_iban', $secondIban);
2724
        $this->replace('bic', $bic);
2725
        $this->replace('transfer_source', $source);
2726
        $this->replace('second_user_merchant_id', $secondUserMerchantId);
2727
2728
        return $this;
2729
    }
2730
2731
    /**
2732
     * Provides kyc information to envelope
2733
     *
2734
     * @param string $eventId
2735
     * @param int $eventTimestamp
2736
     * @param string|null $groupId
2737
     * @param string|null $status
2738
     * @param string|null $code
2739
     * @param string|null $reason
2740
     * @param string|null $providerResult
2741
     * @param string|null $providerCode
2742
     * @param string|null $providerReason
2743
     * @param string|null $profileId
2744
     * @param string|null $profileType
2745
     * @param string|null $profileSubType
2746
     * @param string|null $industry
2747
     * @param string|null $description
2748
     * @param int|null $regDate
2749
     * @param string|null $regNumber
2750
     * @param string|null $vatNumber
2751
     * @param string|null $secondCountry
2752
     * @param string|null $secondState
2753
     * @param string|null $secondCity
2754
     * @param string|null $secondAddress
2755
     * @param string|null $secondZip
2756
     * @param string|null $providerId
2757
     * @param string|null $contactEmail
2758
     * @param string|null $contactPhone
2759
     * @param string|null $walletType
2760
     * @param string|null $nationality
2761
     * @param bool|null $finalBeneficiary
2762
     * @param string|null $employmentStatus
2763
     * @param string|null $sourceOfFunds
2764
     * @param int|null $issueDate
2765
     * @param int|null $expiryDate
2766
     * @param string|null $verificationMode
2767
     * @param string|null $verificationSource
2768
     * @param bool|null $consent
2769
     * @param bool|null $allowNaOcrInputs
2770
     * @param bool|null $declineOnSingleStep
2771
     * @param bool|null $backsideProof
2772
     * @param string|null $kycLanguage
2773
     * @param string|null $redirectUrl
2774
     * @param int|null $numberOfDocuments
2775
     * @param string|null $allowedDocumentFormat
2776
     * @return $this
2777
     */
2778
    public function addKycData(
2779
        $eventId,
2780
        $eventTimestamp,
2781
        $groupId = null,
2782
        $status = null,
2783
        $code = null,
2784
        $reason = null,
2785
        $providerResult = null,
2786
        $providerCode = null,
2787
        $providerReason = null,
2788
        $profileId = null,
2789
        $profileType = null,
2790
        $profileSubType = null,
2791
        $industry = null,
2792
        $description = null,
2793
        $regDate = null,
2794
        $regNumber = null,
2795
        $vatNumber = null,
2796
        $secondCountry = null,
2797
        $secondState = null,
2798
        $secondCity = null,
2799
        $secondAddress = null,
2800
        $secondZip = null,
2801
        $providerId = null,
2802
        $contactEmail = null,
2803
        $contactPhone = null,
2804
        $walletType = null,
2805
        $nationality = null,
2806
        $finalBeneficiary = null,
2807
        $employmentStatus = null,
2808
        $sourceOfFunds = null,
2809
        $issueDate = null,
2810
        $expiryDate = null,
2811
        $verificationMode = null,
2812
        $verificationSource = null,
2813
        $consent = null,
2814
        $allowNaOcrInputs = null,
2815
        $declineOnSingleStep = null,
2816
        $backsideProof = null,
2817
        $kycLanguage = null,
2818
        $redirectUrl = null,
2819
        $numberOfDocuments = null,
2820
        $allowedDocumentFormat = null
2821
    ) {
2822
        if (!is_string($eventId)) {
2823
            throw new \InvalidArgumentException('Event ID must be string');
2824
        }
2825
        if (!is_int($eventTimestamp)) {
2826
            throw new \InvalidArgumentException('Event timestamp must be int');
2827
        }
2828
        if ($groupId !== null && !is_string($groupId)) {
2829
            throw new \InvalidArgumentException('Group id must be string');
2830
        }
2831
        if ($status !== null && !is_string($status)) {
2832
            throw new \InvalidArgumentException('Status must be string');
2833
        }
2834
        if ($code !== null && !is_string($code)) {
2835
            throw new \InvalidArgumentException('Code must be string');
2836
        }
2837
        if ($reason !== null && !is_string($reason)) {
2838
            throw new \InvalidArgumentException('Reason must be string');
2839
        }
2840
        if ($providerResult !== null && !is_string($providerResult)) {
2841
            throw new \InvalidArgumentException('Provider result must be string');
2842
        }
2843
        if ($providerCode !== null && !is_string($providerCode)) {
2844
            throw new \InvalidArgumentException('Provider code must be string');
2845
        }
2846
        if ($providerReason !== null && !is_string($providerReason)) {
2847
            throw new \InvalidArgumentException('Provider reason must be string');
2848
        }
2849
        if ($profileId !== null && !is_string($profileId)) {
2850
            throw new \InvalidArgumentException('Profile id must be string');
2851
        }
2852
        if ($profileType !== null && !is_string($profileType)) {
2853
            throw new \InvalidArgumentException('Profile type must be string');
2854
        }
2855
        if ($profileSubType !== null && !is_string($profileSubType)) {
2856
            throw new \InvalidArgumentException('Profile sub type must be string');
2857
        }
2858
        if ($industry !== null && !is_string($industry)) {
2859
            throw new \InvalidArgumentException('Industry must be string');
2860
        }
2861
        if ($description !== null && !is_string($description)) {
2862
            throw new \InvalidArgumentException('Description must be string');
2863
        }
2864
        if ($regDate !== null && !is_int($regDate)) {
2865
            throw new \InvalidArgumentException('Reg date must be integer');
2866
        }
2867
        if ($regNumber !== null && !is_string($regNumber)) {
2868
            throw new \InvalidArgumentException('Reg number must be string');
2869
        }
2870
        if ($vatNumber !== null && !is_string($vatNumber)) {
2871
            throw new \InvalidArgumentException('Vat number must be string');
2872
        }
2873
        if ($secondCountry !== null && !is_string($secondCountry)) {
2874
            throw new \InvalidArgumentException('Secondary country must be string');
2875
        }
2876
        if ($secondState !== null && !is_string($secondState)) {
2877
            throw new \InvalidArgumentException('Second state must be string');
2878
        }
2879
        if ($secondCity !== null && !is_string($secondCity)) {
2880
            throw new \InvalidArgumentException('Second city must be string');
2881
        }
2882
        if ($secondAddress !== null && !is_string($secondAddress)) {
2883
            throw new \InvalidArgumentException('Second address must be string');
2884
        }
2885
        if ($secondZip !== null && !is_string($secondZip)) {
2886
            throw new \InvalidArgumentException('Second zip must be string');
2887
        }
2888
        if ($providerId !== null && !is_string($providerId)) {
2889
            throw new \InvalidArgumentException('Provider id must be string');
2890
        }
2891
        if ($contactEmail !== null && !is_string($contactEmail)) {
2892
            throw new \InvalidArgumentException('Contact email must be string');
2893
        }
2894
        if ($contactPhone !== null && !is_string($contactPhone)) {
2895
            throw new \InvalidArgumentException('Contact phone must be string');
2896
        }
2897
        if ($walletType !== null && !is_string($walletType)) {
2898
            throw new \InvalidArgumentException('Wallet type must be string');
2899
        }
2900
        if ($nationality !== null && !is_string($nationality)) {
2901
            throw new \InvalidArgumentException('Nationality must be string');
2902
        }
2903
        if ($finalBeneficiary !== null && !is_bool($finalBeneficiary)) {
2904
            throw new \InvalidArgumentException('Final beneficiary must be boolean');
2905
        }
2906
        if ($employmentStatus !== null && !is_string($employmentStatus)) {
2907
            throw new \InvalidArgumentException('Employment status must be string');
2908
        }
2909
        if ($sourceOfFunds !== null && !is_string($sourceOfFunds)) {
2910
            throw new \InvalidArgumentException('Source of funds must be string');
2911
        }
2912
        if ($issueDate !== null && !is_int($issueDate)) {
2913
            throw new \InvalidArgumentException('Issue date must be integer');
2914
        }
2915
        if ($expiryDate !== null && !is_int($expiryDate)) {
2916
            throw new \InvalidArgumentException('Expiry date must be integer');
2917
        }
2918
        if ($verificationMode !== null && !is_string($verificationMode)) {
2919
            throw new \InvalidArgumentException('Verification mode must be string');
2920
        }
2921
        if ($verificationSource !== null && !is_string($verificationSource)) {
2922
            throw new \InvalidArgumentException('Verification source must be string');
2923
        }
2924
        if ($consent !== null && !is_bool($consent)) {
2925
            throw new \InvalidArgumentException('Consent must be boolean');
2926
        }
2927
        if ($allowNaOcrInputs !== null && !is_bool($allowNaOcrInputs)) {
2928
            throw new \InvalidArgumentException('Allow na ocr inputs must be boolean');
2929
        }
2930
        if ($declineOnSingleStep !== null && !is_bool($declineOnSingleStep)) {
2931
            throw new \InvalidArgumentException('Decline on single step must be boolean');
2932
        }
2933
        if ($backsideProof !== null && !is_bool($backsideProof)) {
2934
            throw new \InvalidArgumentException('Backside proof must be boolean');
2935
        }
2936
        if ($kycLanguage !== null && !is_string($kycLanguage)) {
2937
            throw new \InvalidArgumentException('Kyc language must be string');
2938
        }
2939
        if ($redirectUrl !== null && !is_string($redirectUrl)) {
2940
            throw new \InvalidArgumentException('Redirect url must be string');
2941
        }
2942
        if ($numberOfDocuments !== null && !in_array($numberOfDocuments, [0, 1, 2])) {
2943
            throw new \InvalidArgumentException('Incorrect value. Number Of Documents must contains 0, 1 or 2');
2944
        }
2945
        if ($allowedDocumentFormat !== null && !is_string($allowedDocumentFormat)) {
2946
            throw new \InvalidArgumentException('Allowed document format must be string');
2947
        }
2948
2949
        $this->replace('event_id', $eventId);
2950
        $this->replace('event_timestamp', $eventTimestamp);
2951
        $this->replace('group_id', $groupId);
2952
        $this->replace('status', $status);
2953
        $this->replace('code', $code);
2954
        $this->replace('reason', $reason);
2955
        $this->replace('provider_result', $providerResult);
2956
        $this->replace('provider_code', $providerCode);
2957
        $this->replace('provider_reason', $providerReason);
2958
        $this->replace('profile_id', $profileId);
2959
        $this->replace('profile_type', $profileType);
2960
        $this->replace('profile_sub_type', $profileSubType);
2961
        $this->replace('industry', $industry);
2962
        $this->replace('description', $description);
2963
        $this->replace('reg_date', $regDate);
2964
        $this->replace('reg_number', $regNumber);
2965
        $this->replace('vat_number', $vatNumber);
2966
        $this->replace('second_country', $secondCountry);
2967
        $this->replace('second_state', $secondState);
2968
        $this->replace('second_city', $secondCity);
2969
        $this->replace('second_address', $secondAddress);
2970
        $this->replace('second_zip', $secondZip);
2971
        $this->replace('provider_id', $providerId);
2972
        $this->replace('contact_email', $contactEmail);
2973
        $this->replace('contact_phone', $contactPhone);
2974
        $this->replace('wallet_type', $walletType);
2975
        $this->replace('nationality', $nationality);
2976
        $this->replace('final_beneficiary', $finalBeneficiary);
2977
        $this->replace('employment_status', $employmentStatus);
2978
        $this->replace('source_of_funds', $sourceOfFunds);
2979
        $this->replace('issue_date', $issueDate);
2980
        $this->replace('expiry_date', $expiryDate);
2981
        $this->replace('verification_mode', $verificationMode);
2982
        $this->replace('verification_source', $verificationSource);
2983
        $this->replace('consent', $consent);
2984
        $this->replace('allow_na_ocr_inputs', $allowNaOcrInputs);
2985
        $this->replace('decline_on_single_step', $declineOnSingleStep);
2986
        $this->replace('backside_proof', $backsideProof);
2987
        $this->replace('kyc_language', $kycLanguage);
2988
        $this->replace('redirect_url', $redirectUrl);
2989
        $this->replace('number_of_documents', $numberOfDocuments);
2990
        $this->replace('allowed_document_format', $allowedDocumentFormat);
2991
2992
        return $this;
2993
    }
2994
2995
    /**
2996
     * Provides order information to envelope
2997
     *
2998
     * @param string $envelopeType
2999
     * @param float $amount
3000
     * @param string $currency
3001
     * @param string $eventId
3002
     * @param int $eventTimestamp
3003
     * @param string|null $transactionId
3004
     * @param string|null $groupId
3005
     * @param int|null $itemsQuantity
3006
     * @param string|null $orderType
3007
     * @param float|null $amountConverted
3008
     * @param string|null $campaign
3009
     * @param string|null $carrier
3010
     * @param string|null $carrierShippingId
3011
     * @param string|null $carrierUrl
3012
     * @param string|null $carrierPhone
3013
     * @param int|null $couponStartDate
3014
     * @param int|null $couponEndDate
3015
     * @param string|null $couponId
3016
     * @param string|null $couponName
3017
     * @param string|null $customerComment
3018
     * @param int|null $deliveryEstimate
3019
     * @param string|null $shippingAddress
3020
     * @param string|null $shippingCity
3021
     * @param string|null $shippingCountry
3022
     * @param string|null $shippingCurrency
3023
     * @param float|null $shippingFee
3024
     * @param float|null $shippingFeeConverted
3025
     * @param string|null $shippingState
3026
     * @param string|null $shippingZip
3027
     * @param string|null $source
3028
     * @param float|null $sourceFee
3029
     * @param string|null $sourceFeeCurrency
3030
     * @param float|null $sourceFeeConverted
3031
     * @param string|null $taxCurrency
3032
     * @param float|null $taxFee
3033
     * @param float|null $taxFeeConverted
3034
     * @param string|null $productUrl
3035
     * @param string|null $productImageUrl
3036
     * @return Builder
3037
     */
3038
    public function addOrderData(
3039
        $envelopeType,
3040
        $amount,
3041
        $currency,
3042
        $eventId,
3043
        $eventTimestamp,
3044
        $transactionId = null,
3045
        $groupId = null,
3046
        $itemsQuantity = null,
3047
        $orderType = null,
3048
        $amountConverted = null,
3049
        $campaign = null,
3050
        $carrier = null,
3051
        $carrierShippingId = null,
3052
        $carrierUrl = null,
3053
        $carrierPhone = null,
3054
        $couponStartDate = null,
3055
        $couponEndDate = null,
3056
        $couponId = null,
3057
        $couponName = null,
3058
        $customerComment = null,
3059
        $deliveryEstimate = null,
3060
        $shippingAddress = null,
3061
        $shippingCity = null,
3062
        $shippingCountry = null,
3063
        $shippingCurrency = null,
3064
        $shippingFee = null,
3065
        $shippingFeeConverted = null,
3066
        $shippingState = null,
3067
        $shippingZip = null,
3068
        $source = null,
3069
        $sourceFee = null,
3070
        $sourceFeeCurrency = null,
3071
        $sourceFeeConverted = null,
3072
        $taxCurrency = null,
3073
        $taxFee = null,
3074
        $taxFeeConverted = null,
3075
        $productUrl = null,
3076
        $productImageUrl = null
3077
    ) {
3078
        if (!is_string($envelopeType)) {
3079
            throw new \InvalidArgumentException('Envelope type must be string');
3080
        }
3081
        if (!is_int($amount) && !is_float($amount)) {
3082
            throw new \InvalidArgumentException('Amount must be number');
3083
        }
3084
        if (!is_string($currency)) {
3085
            throw new \InvalidArgumentException('Currency must be string');
3086
        }
3087
        if (!is_string($eventId)) {
3088
            throw new \InvalidArgumentException('Event ID must be string');
3089
        }
3090
        if (!is_int($eventTimestamp)) {
3091
            throw new \InvalidArgumentException('Event timestamp must be int');
3092
        }
3093
        if ($envelopeType === 'order_submit' && !is_int($itemsQuantity)) {
3094
            throw new \InvalidArgumentException('Items quantity must be int');
3095
        }
3096
        if ($envelopeType === 'order_item' && !is_string($orderType)) {
3097
            throw new \InvalidArgumentException('Order type must be string');
3098
        }
3099
        if ($transactionId !== null && !is_string($transactionId)) {
3100
            throw new \InvalidArgumentException('Transaction id must be string');
3101
        }
3102
        if ($groupId !== null && !is_string($groupId)) {
3103
            throw new \InvalidArgumentException('Group id must be string');
3104
        }
3105 View Code Duplication
        if ($amountConverted !== null && !is_int($amountConverted) && !is_float($amountConverted)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3106
            throw new \InvalidArgumentException('Amount converted must be number');
3107
        }
3108
        if ($campaign !== null && !is_string($campaign)) {
3109
            throw new \InvalidArgumentException('Campaign must be string');
3110
        }
3111
        if ($carrier !== null && !is_string($carrier)) {
3112
            throw new \InvalidArgumentException('Carrier must be string');
3113
        }
3114
        if ($carrierShippingId !== null && !is_string($carrierShippingId)) {
3115
            throw new \InvalidArgumentException('Carrier shipping id must be string');
3116
        }
3117
        if ($carrierUrl !== null && !is_string($carrierUrl)) {
3118
            throw new \InvalidArgumentException('Carrier url must be string');
3119
        }
3120
        if ($carrierPhone !== null && !is_string($carrierPhone)) {
3121
            throw new \InvalidArgumentException('Carrier phone must be string');
3122
        }
3123
        if ($couponStartDate !== null && !is_int($couponStartDate)) {
3124
            throw new \InvalidArgumentException('Coupon start date must be int');
3125
        }
3126
        if ($couponEndDate !== null && !is_int($couponEndDate)) {
3127
            throw new \InvalidArgumentException('Coupon end date must be int');
3128
        }
3129
        if ($couponId !== null && !is_string($couponId)) {
3130
            throw new \InvalidArgumentException('Coupon id must be string');
3131
        }
3132
        if ($couponName !== null && !is_string($couponName)) {
3133
            throw new \InvalidArgumentException('Coupon name must be string');
3134
        }
3135
        if ($customerComment !== null && !is_string($customerComment)) {
3136
            throw new \InvalidArgumentException('Customer comment must be string');
3137
        }
3138
        if ($deliveryEstimate !== null && !is_int($deliveryEstimate)) {
3139
            throw new \InvalidArgumentException('Delivery estimate must be int');
3140
        }
3141
        if ($shippingAddress !== null && !is_string($shippingAddress)) {
3142
            throw new \InvalidArgumentException('Shipping address must be string');
3143
        }
3144
        if ($shippingCity !== null && !is_string($shippingCity)) {
3145
            throw new \InvalidArgumentException('Shipping city must be string');
3146
        }
3147
        if ($shippingCountry !== null && !is_string($shippingCountry)) {
3148
            throw new \InvalidArgumentException('Shipping country must be string');
3149
        }
3150
        if ($shippingCurrency !== null && !is_string($shippingCurrency)) {
3151
            throw new \InvalidArgumentException('Shipping currency must be string');
3152
        }
3153
        if ($shippingFee !== null && !is_int($shippingFee) && !is_float($shippingFee)) {
3154
            throw new \InvalidArgumentException('Shipping fee must be number');
3155
        }
3156
        if ($shippingFeeConverted !== null && !is_int($shippingFeeConverted) && !is_float($shippingFeeConverted)) {
3157
            throw new \InvalidArgumentException('Shipping fee converted must be number');
3158
        }
3159
        if ($shippingState !== null && !is_string($shippingState)) {
3160
            throw new \InvalidArgumentException('Shipping state must be string');
3161
        }
3162
        if ($shippingZip !== null && !is_string($shippingZip)) {
3163
            throw new \InvalidArgumentException('Shipping zip must be string');
3164
        }
3165
        if ($source !== null && !is_string($source)) {
3166
            throw new \InvalidArgumentException('Order source must be string');
3167
        }
3168
        if ($sourceFee !== null && !is_int($sourceFee) && !is_float($sourceFee)) {
3169
            throw new \InvalidArgumentException('Source fee must be number');
3170
        }
3171
        if ($sourceFeeConverted !== null && !is_int($sourceFeeConverted) && !is_float($sourceFeeConverted)) {
3172
            throw new \InvalidArgumentException('Source fee converted must be number');
3173
        }
3174
        if ($sourceFeeCurrency !== null && !is_string($sourceFeeCurrency)) {
3175
            throw new \InvalidArgumentException('Source fee currency must be string');
3176
        }
3177
        if ($taxCurrency !== null && !is_string($taxCurrency)) {
3178
            throw new \InvalidArgumentException('Tax currency must be string');
3179
        }
3180
        if ($taxFee !== null && !is_int($taxFee) && !is_float($taxFee)) {
3181
            throw new \InvalidArgumentException('Tax fee must be number');
3182
        }
3183
        if ($taxFeeConverted !== null && !is_int($taxFeeConverted) && !is_float($taxFeeConverted)) {
3184
            throw new \InvalidArgumentException('Tax fee converted must be number');
3185
        }
3186
        if ($productUrl !== null && !is_string($productUrl)) {
3187
            throw new \InvalidArgumentException('Product url must be string');
3188
        }
3189
        if ($productImageUrl !== null && !is_string($productImageUrl)) {
3190
            throw new \InvalidArgumentException('Product image url must be string');
3191
        }
3192
        if ($productImageUrl !== null && !is_string($productImageUrl)) {
3193
            throw new \InvalidArgumentException('Product image url must be string');
3194
        }
3195
        $this->replace('amount', $amount);
3196
        $this->replace('currency', $currency);
3197
        $this->replace('event_id', $eventId);
3198
        $this->replace('event_timestamp', $eventTimestamp);
3199
        $this->replace('items_quantity', $itemsQuantity);
3200
        $this->replace('order_type', $orderType);
3201
        $this->replace('transaction_id', $transactionId);
3202
        $this->replace('group_id', $groupId);
3203
        $this->replace('amount_converted', $amountConverted);
3204
        $this->replace('campaign', $campaign);
3205
        $this->replace('carrier', $carrier);
3206
        $this->replace('carrier_shipping_id', $carrierShippingId);
3207
        $this->replace('carrier_url', $carrierUrl);
3208
        $this->replace('carrier_phone', $carrierPhone);
3209
        $this->replace('coupon_start_date', $couponStartDate);
3210
        $this->replace('coupon_end_date', $couponEndDate);
3211
        $this->replace('coupon_id', $couponId);
3212
        $this->replace('coupon_name', $couponName);
3213
        $this->replace('customer_comment', $customerComment);
3214
        $this->replace('delivery_estimate', $deliveryEstimate);
3215
        $this->replace('shipping_address', $shippingAddress);
3216
        $this->replace('shipping_city', $shippingCity);
3217
        $this->replace('shipping_country', $shippingCountry);
3218
        $this->replace('shipping_currency', $shippingCurrency);
3219
        $this->replace('shipping_fee', $shippingFee);
3220
        $this->replace('shipping_fee_converted', $shippingFeeConverted);
3221
        $this->replace('shipping_state', $shippingState);
3222
        $this->replace('shipping_zip', $shippingZip);
3223
        $this->replace('order_source', $source);
3224
        $this->replace('source_fee', $sourceFee);
3225
        $this->replace('source_fee_currency', $sourceFeeCurrency);
3226
        $this->replace('source_fee_converted', $sourceFeeConverted);
3227
        $this->replace('tax_currency', $taxCurrency);
3228
        $this->replace('tax_fee', $taxFee);
3229
        $this->replace('tax_fee_converted', $taxFeeConverted);
3230
        $this->replace('product_url', $productUrl);
3231
        $this->replace('product_image_url', $productImageUrl);
3232
3233
        return $this;
3234
    }
3235
3236
    /**
3237
     * Provides postback information to envelope
3238
     *
3239
     * @param int|null $requestId
3240
     * @param string|null $transactionId
3241
     * @param string|null $transactionStatus
3242
     * @param string|null $code
3243
     * @param string|null $reason
3244
     * @param string|null $secure3d
3245
     * @param string|null $avsResult
3246
     * @param string|null $cvvResult
3247
     * @param string|null $pspCode
3248
     * @param string|null $pspReason
3249
     * @param string|null $arn
3250
     * @param string|null $paymentAccountId
3251
     * @return $this
3252
     */
3253
    public function addPostbackData(
3254
        $requestId = null,
3255
        $transactionId = null,
3256
        $transactionStatus = null,
3257
        $code = null,
3258
        $reason = null,
3259
        $secure3d = null,
3260
        $avsResult = null,
3261
        $cvvResult = null,
3262
        $pspCode = null,
3263
        $pspReason = null,
3264
        $arn = null,
3265
        $paymentAccountId = null
3266
    ) {
3267
        if ($requestId === null && $transactionId === null) {
3268
            throw new \InvalidArgumentException('request_id or transaction_id should be provided');
3269
        }
3270
        if ($transactionId !== null && !is_string($transactionId)) {
3271
            throw new \InvalidArgumentException('TransactionId must be string');
3272
        }
3273
        if ($requestId !== null && !is_int($requestId)) {
3274
            throw new \InvalidArgumentException('RequestId must be int');
3275
        }
3276
        if ($transactionStatus !== null && !is_string($transactionStatus)) {
3277
            throw new \InvalidArgumentException('Transaction status must be string');
3278
        }
3279
        if ($code !== null && !is_string($code)) {
3280
            throw new \InvalidArgumentException('Code must be string');
3281
        }
3282
        if ($reason !== null && !is_string($reason)) {
3283
            throw new \InvalidArgumentException('Reason must be string');
3284
        }
3285
        if ($secure3d !== null && !is_string($secure3d)) {
3286
            throw new \InvalidArgumentException('Secure3d must be string');
3287
        }
3288
        if ($avsResult !== null && !is_string($avsResult)) {
3289
            throw new \InvalidArgumentException('AvsResult must be string');
3290
        }
3291
        if ($cvvResult !== null && !is_string($cvvResult)) {
3292
            throw new \InvalidArgumentException('CvvResult must be string');
3293
        }
3294
        if ($pspCode !== null && !is_string($pspCode)) {
3295
            throw new \InvalidArgumentException('PspCode must be string');
3296
        }
3297
        if ($pspReason !== null && !is_string($pspReason)) {
3298
            throw new \InvalidArgumentException('PspReason must be string');
3299
        }
3300
        if ($arn !== null && !is_string($arn)) {
3301
            throw new \InvalidArgumentException('Arn must be string');
3302
        }
3303
        if ($paymentAccountId !== null && !is_string($paymentAccountId)) {
3304
            throw new \InvalidArgumentException('PaymentAccoutId must be string');
3305
        }
3306
3307
        $this->replace('request_id', $requestId);
3308
        $this->replace('transaction_id', $transactionId);
3309
        $this->replace('transaction_status', $transactionStatus);
3310
        $this->replace('code', $code);
3311
        $this->replace('reason', $reason);
3312
        $this->replace('secure3d', $secure3d);
3313
        $this->replace('avs_result', $avsResult);
3314
        $this->replace('cvv_result', $cvvResult);
3315
        $this->replace('psp_code', $pspCode);
3316
        $this->replace('psp_reason', $pspReason);
3317
        $this->replace('arn', $arn);
3318
        $this->replace('payment_account_id', $paymentAccountId);
3319
3320
        return $this;
3321
    }
3322
3323
    /**
3324
     * Adds custom data field to envelope
3325
     *
3326
     * @param string $name
3327
     * @param string $value
3328
     *
3329
     * @return $this
3330
     */
3331
    public function addCustomField($name, $value)
3332
    {
3333
        if (!is_string($name)) {
3334
            throw new \InvalidArgumentException('Custom field name must be string');
3335
        }
3336
        if (!is_string($value)) {
3337
            throw new \InvalidArgumentException('Custom field value must be string');
3338
        }
3339
3340
        if (strlen($name) < 8 || substr($name, 0, 7) !== 'custom_') {
3341
            $name = 'custom_' . $name;
3342
        }
3343
3344
        $this->replace($name, $value);
3345
        return $this;
3346
    }
3347
3348
    /**
3349
     * Provides group id value to envelope
3350
     *
3351
     * @param string|null $groupId
3352
     * @return $this
3353
     */
3354
    public function addGroupId($groupId = null)
3355
    {
3356
        if ($groupId !== null && !is_string($groupId)) {
3357
            throw new \InvalidArgumentException('Group id must be string');
3358
        }
3359
        $this->replace('group_id', $groupId);
3360
3361
        return $this;
3362
    }
3363
3364
    /**
3365
     * Provides kycProof value to envelope
3366
     *
3367
     * @param int $kycStartId
3368
     * @return $this
3369
     */
3370
    public function addKycProofData($kycStartId)
3371
    {
3372
        if (!is_int($kycStartId)) {
3373
            throw new \InvalidArgumentException('KycStartId must be integer');
3374
        }
3375
3376
        $this->replace('kyc_start_id', $kycStartId);
3377
3378
        return $this;
3379
    }
3380
3381
    public function addProfileData(
3382
        $eventId,
3383
        $eventTimestamp,
3384
        $userMerchantId,
3385
        $groupId = null,
3386
        $operation = null,
3387
        $accountId = null,
3388
        $accountSystem = null,
3389
        $currency = null,
3390
        $phone = null,
3391
        $phoneConfirmed = null,
3392
        $email = null,
3393
        $emailConfirmed = null,
3394
        $contactEmail = null,
3395
        $contactPhone = null,
3396
        $toFaAllowed = null,
3397
        $username = null,
3398
        $password = null,
3399
        $socialType = null,
3400
        $gameLevel = null,
3401
        $firstname = null,
3402
        $lastname = null,
3403
        $fullName = null,
3404
        $birthDate = null,
3405
        $age = null,
3406
        $gender = null,
3407
        $maritalStatus = null,
3408
        $nationality = null,
3409
        $physique = null,
3410
        $height = null,
3411
        $weight = null,
3412
        $hair = null,
3413
        $eyes = null,
3414
        $education = null,
3415
        $employmentStatus = null,
3416
        $sourceOfFunds = null,
3417
        $industry = null,
3418
        $finalBeneficiary = null,
3419
        $walletType = null,
3420
        $websiteUrl = null,
3421
        $description = null,
3422
        $country = null,
3423
        $state = null,
3424
        $city =  null,
3425
        $zip = null,
3426
        $address = null,
3427
        $addressConfirmed = null,
3428
        $secondCountry = null,
3429
        $secondState = null,
3430
        $secondCity = null,
3431
        $secondZip = null,
3432
        $secondAddress = null,
3433
        $secondAddressConfirmed = null,
3434
        $profileId = null,
3435
        $profileType = null,
3436
        $profileSubType = null,
3437
        $documentCountry = null,
3438
        $documentConfirmed = null,
3439
        $regDate = null,
3440
        $issueDate = null,
3441
        $expiryDate = null,
3442
        $regNumber = null,
3443
        $vatNumber = null,
3444
        $purposeToOpenAccount = null,
3445
        $oneOperationLimit = null,
3446
        $dailyLimit = null,
3447
        $weeklyLimit = null,
3448
        $monthlyLimit = null,
3449
        $annualLimit = null,
3450
        $activeFeatures = null,
3451
        $promotions = null,
3452
        $ajaxValidation = null,
3453
        $cookieEnabled = null,
3454
        $cpuClass = null,
3455
        $deviceFingerprint = null,
3456
        $deviceId = null,
3457
        $doNotTrack = null,
3458
        $ip = null,
3459
        $realIp = null,
3460
        $localIpList = null,
3461
        $language = null,
3462
        $languages = null,
3463
        $languageBrowser = null,
3464
        $languageUser = null,
3465
        $languageSystem = null,
3466
        $os = null,
3467
        $screenResolution = null,
3468
        $screenOrientation = null,
3469
        $clientResolution = null,
3470
        $timezoneOffset = null,
3471
        $userAgent = null,
3472
        $plugins = null,
3473
        $refererUrl = null,
3474
        $originUrl = null
3475
    ) {
3476
        if (!is_string($eventId)) {
3477
            throw new \InvalidArgumentException('Event ID must be string');
3478
        }
3479
3480
        if (!is_int($eventTimestamp)) {
3481
            throw new \InvalidArgumentException('Event Timestamp must be int');
3482
        }
3483
3484
        if (!is_string($userMerchantId)) {
3485
            throw new \InvalidArgumentException('User Merchant ID must be string');
3486
        }
3487
3488
        if ($groupId !== null && !is_string($groupId)) {
3489
            throw new \InvalidArgumentException('Group Id must be string');
3490
        }
3491
3492
        if ($operation !== null && !is_string($operation)) {
3493
            throw new \InvalidArgumentException('Operation must be string');
3494
        }
3495
3496
        if ($accountId !== null && !is_string($accountId)) {
3497
            throw new \InvalidArgumentException('Account Id must be string');
3498
        }
3499
3500
        if ($accountSystem !== null && !is_string($accountSystem)) {
3501
            throw new \InvalidArgumentException('Account System must be string');
3502
        }
3503
3504
        if ($currency !== null && !is_string($currency)) {
3505
            throw new \InvalidArgumentException('Currency must be string');
3506
        }
3507
3508
        if ($phone !== null && !is_string($phone)) {
3509
            throw new \InvalidArgumentException('Phone must be string');
3510
        }
3511
3512
        if ($phoneConfirmed !== null && !is_bool($phoneConfirmed)) {
3513
            throw new \InvalidArgumentException('Phone Confirmed flag must be boolean');
3514
        }
3515
3516
        if ($email !== null && !is_string($email)) {
3517
            throw new \InvalidArgumentException('Email must be string');
3518
        }
3519
3520
        if ($emailConfirmed !== null && !is_bool($emailConfirmed)) {
3521
            throw new \InvalidArgumentException('Email Confirmed flag must be boolean');
3522
        }
3523
3524
        if ($contactEmail !== null && !is_string($contactEmail)) {
3525
            throw new \InvalidArgumentException('Contact Email must be string');
3526
        }
3527
3528
        if ($contactPhone !== null && !is_string($contactPhone)) {
3529
            throw new \InvalidArgumentException('Contact Phone must be string');
3530
        }
3531
3532
        if ($toFaAllowed !== null && !is_bool($toFaAllowed)) {
3533
            throw new \InvalidArgumentException('2faAllowed flag must be boolean');
3534
        }
3535
3536
        if ($username !== null && !is_string($username)) {
3537
            throw new \InvalidArgumentException('Username must be string');
3538
        }
3539
3540
        if ($password !== null && !is_string($password)) {
3541
            throw new \InvalidArgumentException('Password must be string');
3542
        }
3543
3544
        if ($socialType !== null && !is_string($socialType)) {
3545
            throw new \InvalidArgumentException('Social Type must be string');
3546
        }
3547
3548
        if ($gameLevel !== null && !is_string($gameLevel)) {
3549
            throw new \InvalidArgumentException('Game Level must be string');
3550
        }
3551
3552
        if ($firstname !== null && !is_string($firstname)) {
3553
            throw new \InvalidArgumentException('Firstname must be string');
3554
        }
3555
3556
        if ($lastname !== null && !is_string($lastname)) {
3557
            throw new \InvalidArgumentException('Lastname must be string');
3558
        }
3559
3560
        if ($fullName !== null && !is_string($fullName)) {
3561
            throw new \InvalidArgumentException('Full Name must be string');
3562
        }
3563
3564
        if ($birthDate !== null && !is_int($birthDate)) {
3565
            throw new \InvalidArgumentException('Birth Date must be int');
3566
        }
3567
3568
        if ($age !== null && !is_int($age)) {
3569
            throw new \InvalidArgumentException('Age must be int');
3570
        }
3571
3572
        if ($gender !== null && !is_string($gender)) {
3573
            throw new \InvalidArgumentException('Gender must be string');
3574
        }
3575
3576
        if ($maritalStatus !== null && !is_string($maritalStatus)) {
3577
            throw new \InvalidArgumentException('Marital Status must be string');
3578
        }
3579
3580
        if ($nationality !== null && !is_string($nationality)) {
3581
            throw new \InvalidArgumentException('Nationality must be string');
3582
        }
3583
3584
        if ($physique !== null && !is_string($physique)) {
3585
            throw new \InvalidArgumentException('Physique must be string');
3586
        }
3587
3588
        if ($height !== null && !is_float($height)) {
3589
            throw new \InvalidArgumentException('Height must be float');
3590
        }
3591
3592
        if ($weight !== null && !is_float($weight)) {
3593
            throw new \InvalidArgumentException('Weight must be float');
3594
        }
3595
3596
        if ($hair !== null && !is_string($hair)) {
3597
            throw new \InvalidArgumentException('Hair must be string');
3598
        }
3599
3600
        if ($eyes !== null && !is_string($eyes)) {
3601
            throw new \InvalidArgumentException('Eyes must be string');
3602
        }
3603
3604
        if ($education !== null && !is_string($education)) {
3605
            throw new \InvalidArgumentException('Education must be string');
3606
        }
3607
3608
        if ($employmentStatus !== null && !is_string($employmentStatus)) {
3609
            throw new \InvalidArgumentException('Employment Status must be string');
3610
        }
3611
3612
        if ($sourceOfFunds !== null && !is_string($sourceOfFunds)) {
3613
            throw new \InvalidArgumentException('Source Of Funds must be string');
3614
        }
3615
3616
        if ($industry !== null && !is_string($industry)) {
3617
            throw new \InvalidArgumentException('Industry must be string');
3618
        }
3619
3620
        if ($finalBeneficiary !== null && !is_bool($finalBeneficiary)) {
3621
            throw new \InvalidArgumentException('Final Beneficiary must be boolean');
3622
        }
3623
3624
        if ($walletType !== null && !is_string($walletType)) {
3625
            throw new \InvalidArgumentException('Wallet Type must be string');
3626
        }
3627
3628
        if ($websiteUrl !== null && !is_string($websiteUrl)) {
3629
            throw new \InvalidArgumentException('Website Url must be string');
3630
        }
3631
3632
        if ($description !== null && !is_string($description)) {
3633
            throw new \InvalidArgumentException('Description must be string');
3634
        }
3635
3636
        if ($country !== null && !is_string($country)) {
3637
            throw new \InvalidArgumentException('Country must be string');
3638
        }
3639
3640
        if ($state !== null && !is_string($state)) {
3641
            throw new \InvalidArgumentException('State must be string');
3642
        }
3643
3644
        if ($city !== null && !is_string($city)) {
3645
            throw new \InvalidArgumentException('City must be string');
3646
        }
3647
3648
        if ($zip !== null && !is_string($zip)) {
3649
            throw new \InvalidArgumentException('Zip must be string');
3650
        }
3651
3652
        if ($address !== null && !is_string($address)) {
3653
            throw new \InvalidArgumentException('Address must be string');
3654
        }
3655
3656
        if ($addressConfirmed !== null && !is_bool($addressConfirmed)) {
3657
            throw new \InvalidArgumentException('Address Confirmed must be boolean');
3658
        }
3659
3660
        if ($secondCountry !== null && !is_string($secondCountry)) {
3661
            throw new \InvalidArgumentException('Second Country must be string');
3662
        }
3663
3664
        if ($secondState !== null && !is_string($secondState)) {
3665
            throw new \InvalidArgumentException('Second State must be string');
3666
        }
3667
3668
        if ($secondCity !== null && !is_string($secondCity)) {
3669
            throw new \InvalidArgumentException('Second City must be string');
3670
        }
3671
3672
        if ($secondZip !== null && !is_string($secondZip)) {
3673
            throw new \InvalidArgumentException('Second Zip must be string');
3674
        }
3675
3676
        if ($secondAddress !== null && !is_string($secondAddress)) {
3677
            throw new \InvalidArgumentException('Second Address must be string');
3678
        }
3679
3680
        if ($secondAddressConfirmed !== null && !is_bool($secondAddressConfirmed)) {
3681
            throw new \InvalidArgumentException('Second Address Confirmed must be boolean');
3682
        }
3683
3684
        if ($profileId !== null && !is_string($profileId)) {
3685
            throw new \InvalidArgumentException('Profile Id must be string');
3686
        }
3687
3688
        if ($profileType !== null && !is_string($profileType)) {
3689
            throw new \InvalidArgumentException('Profile Type must be string');
3690
        }
3691
3692
        if ($profileSubType !== null && !is_string($profileSubType)) {
3693
            throw new \InvalidArgumentException('Profile Sub Type must be string');
3694
        }
3695
3696
        if ($documentCountry !== null && !is_string($documentCountry)) {
3697
            throw new \InvalidArgumentException('Document Country must be string');
3698
        }
3699
3700
        if ($documentConfirmed !== null && !is_bool($documentConfirmed)) {
3701
            throw new \InvalidArgumentException('Document Confirmed must be boolean');
3702
        }
3703
3704
        if ($regDate !== null && !is_int($regDate)) {
3705
            throw new \InvalidArgumentException('Reg Date must be int');
3706
        }
3707
3708
        if ($issueDate !== null && !is_int($issueDate)) {
3709
            throw new \InvalidArgumentException('Issue Date must be int');
3710
        }
3711
3712
        if ($expiryDate !== null && !is_int($expiryDate)) {
3713
            throw new \InvalidArgumentException('Expiry Date must be int');
3714
        }
3715
3716
        if ($regNumber !== null && !is_string($regNumber)) {
3717
            throw new \InvalidArgumentException('Reg Number must be string');
3718
        }
3719
3720
        if ($vatNumber !== null && !is_string($vatNumber)) {
3721
            throw new \InvalidArgumentException('Vat Number must be string');
3722
        }
3723
3724
        if ($purposeToOpenAccount !== null && !is_string($purposeToOpenAccount)) {
3725
            throw new \InvalidArgumentException('Purpose To Open Account must be string');
3726
        }
3727
3728
        if ($oneOperationLimit !== null && !is_float($oneOperationLimit)) {
3729
            throw new \InvalidArgumentException('One Operation Limit must be float');
3730
        }
3731
3732
        if ($dailyLimit !== null && !is_float($dailyLimit)) {
3733
            throw new \InvalidArgumentException('Daily Limit must be float');
3734
        }
3735
3736
        if ($weeklyLimit !== null && !is_float($weeklyLimit)) {
3737
            throw new \InvalidArgumentException('Weekly Limit must be float');
3738
        }
3739
3740
        if ($monthlyLimit !== null && !is_float($monthlyLimit)) {
3741
            throw new \InvalidArgumentException('Monthly Limit must be float');
3742
        }
3743
3744
        if ($annualLimit !== null && !is_float($annualLimit)) {
3745
            throw new \InvalidArgumentException('Annual Limit must be float');
3746
        }
3747
3748
        if ($activeFeatures !== null && !is_string($activeFeatures)) {
3749
            throw new \InvalidArgumentException('Active Features must be string');
3750
        }
3751
3752
        if ($promotions !== null && !is_string($promotions)) {
3753
            throw new \InvalidArgumentException('Promotions must be string');
3754
        }
3755
3756
        if ($ajaxValidation !== null && !is_bool($ajaxValidation)) {
3757
            throw new \InvalidArgumentException('Ajax Validation must be boolean');
3758
        }
3759
3760
        if ($cookieEnabled !== null && !is_bool($cookieEnabled)) {
3761
            throw new \InvalidArgumentException('Cookie Enabled must be boolean');
3762
        }
3763
3764
        if ($cpuClass !== null && !is_string($cpuClass)) {
3765
            throw new \InvalidArgumentException('CPU Class must be string');
3766
        }
3767
3768
        if ($deviceFingerprint !== null && !is_string($deviceFingerprint)) {
3769
            throw new \InvalidArgumentException('Device Fingerprint must be string');
3770
        }
3771
3772
        if ($deviceId !== null && !is_string($deviceId)) {
3773
            throw new \InvalidArgumentException('Device Id must be string');
3774
        }
3775
3776
        if ($doNotTrack !== null && !is_bool($doNotTrack)) {
3777
            throw new \InvalidArgumentException('Do Not Track must be boolean');
3778
        }
3779
3780
        if ($ip !== null && !is_string($ip)) {
3781
            throw new \InvalidArgumentException('IP must be string');
3782
        }
3783
3784
        if ($realIp !== null && !is_string($realIp)) {
3785
            throw new \InvalidArgumentException('Real IP must be string');
3786
        }
3787
3788
        if ($localIpList !== null && !is_string($localIpList)) {
3789
            throw new \InvalidArgumentException('Local IP List must be string');
3790
        }
3791
3792
        if ($language !== null && !is_string($language)) {
3793
            throw new \InvalidArgumentException('Language must be string');
3794
        }
3795
3796
        if ($languages !== null && !is_string($languages)) {
3797
            throw new \InvalidArgumentException('Languages must be string');
3798
        }
3799
3800
        if ($languageBrowser !== null && !is_string($languageBrowser)) {
3801
            throw new \InvalidArgumentException('Language Browser must be string');
3802
        }
3803
3804
        if ($languageUser !== null && !is_string($languageUser)) {
3805
            throw new \InvalidArgumentException('Language User must be string');
3806
        }
3807
3808
        if ($languageSystem !== null && !is_string($languageSystem)) {
3809
            throw new \InvalidArgumentException('Language System must be string');
3810
        }
3811
3812
        if ($os !== null && !is_string($os)) {
3813
            throw new \InvalidArgumentException('OS must be string');
3814
        }
3815
3816
        if ($screenResolution !== null && !is_string($screenResolution)) {
3817
            throw new \InvalidArgumentException('Screen Resolution must be string');
3818
        }
3819
3820
        if ($screenOrientation !== null && !is_string($screenOrientation)) {
3821
            throw new \InvalidArgumentException('Screen Orientation must be string');
3822
        }
3823
3824
        if ($clientResolution !== null && !is_string($clientResolution)) {
3825
            throw new \InvalidArgumentException('Client Resolution must be string');
3826
        }
3827
3828
        if ($timezoneOffset !== null && !is_int($timezoneOffset)) {
3829
            throw new \InvalidArgumentException('Timezone Offset must be int');
3830
        }
3831
3832
        if ($userAgent !== null && !is_string($userAgent)) {
3833
            throw new \InvalidArgumentException('User Agent must be string');
3834
        }
3835
3836
        if ($plugins !== null && !is_string($plugins)) {
3837
            throw new \InvalidArgumentException('Plugins must be string');
3838
        }
3839
3840
        if ($refererUrl !== null && !is_string($refererUrl)) {
3841
            throw new \InvalidArgumentException('Referer Url must be string');
3842
        }
3843
3844
        if ($originUrl !== null && !is_string($originUrl)) {
3845
            throw new \InvalidArgumentException('Origin Url must be string');
3846
        }
3847
3848
        $this->replace('event_id', $eventId);
3849
        $this->replace('event_timestamp', $eventTimestamp);
3850
        $this->replace('user_merchant_id', $userMerchantId);
3851
        $this->replace('group_id', $groupId);
3852
        $this->replace('operation', $operation);
3853
        $this->replace('account_id', $accountId);
3854
        $this->replace('account_system', $accountSystem);
3855
        $this->replace('currency', $currency);
3856
        $this->replace('phone', $phone);
3857
        $this->replace('phone_confirmed', $phoneConfirmed);
3858
        $this->replace('email', $email);
3859
        $this->replace('email_confirmed', $emailConfirmed);
3860
        $this->replace('contact_email', $contactEmail);
3861
        $this->replace('contact_phone', $contactPhone);
3862
        $this->replace('2fa_allowed', $toFaAllowed);
3863
        $this->replace('user_name', $username);
3864
        $this->replace('password', $password);
3865
        $this->replace('social_type', $socialType);
3866
        $this->replace('game_level', $gameLevel);
3867
        $this->replace('firstname', $firstname);
3868
        $this->replace('lastname', $lastname);
3869
        $this->replace('fullname', $fullName);
3870
        $this->replace('birth_date', $birthDate);
3871
        $this->replace('age', $age);
3872
        $this->replace('gender', $gender);
3873
        $this->replace('marital_status', $maritalStatus);
3874
        $this->replace('nationality', $nationality);
3875
        $this->replace('physique', $physique);
3876
        $this->replace('height', $height);
3877
        $this->replace('weight', $weight);
3878
        $this->replace('hair', $hair);
3879
        $this->replace('eyes', $eyes);
3880
        $this->replace('education', $education);
3881
        $this->replace('employment_status', $employmentStatus);
3882
        $this->replace('source_of_funds', $sourceOfFunds);
3883
        $this->replace('industry', $industry);
3884
        $this->replace('final_beneficiary', $finalBeneficiary);
3885
        $this->replace('wallet_type', $walletType);
3886
        $this->replace('website_url', $websiteUrl);
3887
        $this->replace('description', $description);
3888
        $this->replace('country', $country);
3889
        $this->replace('state', $state);
3890
        $this->replace('city', $city);
3891
        $this->replace('zip', $zip);
3892
        $this->replace('address', $address);
3893
        $this->replace('address_confirmed', $addressConfirmed);
3894
        $this->replace('second_country', $secondCountry);
3895
        $this->replace('second_state', $secondState);
3896
        $this->replace('second_city', $secondCity);
3897
        $this->replace('second_zip', $secondZip);
3898
        $this->replace('second_address', $secondAddress);
3899
        $this->replace('second_address_confirmed', $secondAddressConfirmed);
3900
        $this->replace('profile_id', $profileId);
3901
        $this->replace('profile_type', $profileType);
3902
        $this->replace('profile_sub_type', $profileSubType);
3903
        $this->replace('document_country', $documentCountry);
3904
        $this->replace('document_confirmed', $documentConfirmed);
3905
        $this->replace('reg_date', $regDate);
3906
        $this->replace('issue_date', $issueDate);
3907
        $this->replace('expiry_date', $expiryDate);
3908
        $this->replace('reg_number', $regNumber);
3909
        $this->replace('vat_number', $vatNumber);
3910
        $this->replace('purpose_to_open_account', $purposeToOpenAccount);
3911
        $this->replace('one_operation_limit', $oneOperationLimit);
3912
        $this->replace('daily_limit', $dailyLimit);
3913
        $this->replace('weekly_limit', $weeklyLimit);
3914
        $this->replace('monthly_limit', $monthlyLimit);
3915
        $this->replace('annual_limit', $annualLimit);
3916
        $this->replace('active_features', $activeFeatures);
3917
        $this->replace('promotions', $promotions);
3918
        $this->replace('ajax_validation', $ajaxValidation);
3919
        $this->replace('cookie_enabled', $cookieEnabled);
3920
        $this->replace('cpu_class', $cpuClass);
3921
        $this->replace('device_fingerprint', $deviceFingerprint);
3922
        $this->replace('device_id', $deviceId);
3923
        $this->replace('do_not_track', $doNotTrack);
3924
        $this->replace('ip', $ip);
3925
        $this->replace('real_ip', $realIp);
3926
        $this->replace('local_ip_list', $localIpList);
3927
        $this->replace('language', $language);
3928
        $this->replace('languages', $languages);
3929
        $this->replace('language_browser', $languageBrowser);
3930
        $this->replace('language_user', $languageUser);
3931
        $this->replace('language_system', $languageSystem);
3932
        $this->replace('os', $os);
3933
        $this->replace('screen_resolution', $screenResolution);
3934
        $this->replace('screen_orientation', $screenOrientation);
3935
        $this->replace('client_resolution', $clientResolution);
3936
        $this->replace('timezone_offset', $timezoneOffset);
3937
        $this->replace('user_agent', $userAgent);
3938
        $this->replace('plugins', $plugins);
3939
        $this->replace('referer_url', $refererUrl);
3940
        $this->replace('origin_url', $originUrl);
3941
3942
        return $this;
3943
    }
3944
3945
3946
}
3947