|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Carl Owens ([email protected]) |
|
4
|
|
|
* Company: PartFire Ltd (www.partfire.co.uk) |
|
5
|
|
|
* Copyright © 2016 PartFire Ltd. All rights reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* User: Carl Owens |
|
8
|
|
|
* Date: 27/11/2016 |
|
9
|
|
|
* Time: 21:11 |
|
10
|
|
|
* File: UserQuery.php |
|
11
|
|
|
**/ |
|
12
|
|
|
|
|
13
|
|
|
namespace PartFire\MangoPayBundle\Models\Adapters; |
|
14
|
|
|
|
|
15
|
|
|
use MangoPay\Libraries\Exception; |
|
16
|
|
|
use MangoPay\Libraries\ResponseException; |
|
17
|
|
|
use MangoPay\MangoPayApi; |
|
18
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\Translators\UserTranslator; |
|
19
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\User; |
|
20
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\UserBase; |
|
21
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\UserLegal as PFUserLegal; |
|
22
|
|
|
use PartFire\MangoPayBundle\Models\DTOs\UserNatural as PFUserNatural; |
|
23
|
|
|
use PartFire\MangoPayBundle\Models\Exception as PartFireException; |
|
24
|
|
|
use PartFire\MangoPayBundle\Models\UserQueryInterface; |
|
25
|
|
|
use Symfony\Bridge\Monolog\Logger; |
|
26
|
|
|
|
|
27
|
|
|
class UserQuery extends AbstractQuery implements UserQueryInterface |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var UserTranslator |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $userTranslator; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* UserQuery constructor. |
|
36
|
|
|
* @param $clientId |
|
37
|
|
|
* @param $clientPassword |
|
38
|
|
|
* @param $baseUrl |
|
39
|
|
|
* @param MangoPayApi $mangoPayApi |
|
40
|
|
|
* @param Logger $logger |
|
41
|
|
|
* @param UserTranslator $userTranslator |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct( |
|
44
|
|
|
$clientId, |
|
45
|
|
|
$clientPassword, |
|
46
|
|
|
$baseUrl, |
|
47
|
|
|
MangoPayApi $mangoPayApi, |
|
48
|
|
|
Logger $logger, |
|
49
|
|
|
UserTranslator $userTranslator |
|
50
|
|
|
) { |
|
51
|
|
|
parent::__construct($clientId, $clientPassword, $baseUrl,$mangoPayApi, $logger); |
|
52
|
|
|
$this->userTranslator = $userTranslator; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function createNatural(PFUserNatural $userDto) |
|
56
|
|
|
{ |
|
57
|
|
|
$mangoUser = $this->userTranslator->convertDTOToMangoPayNaturalUser($userDto); |
|
58
|
|
|
try { |
|
59
|
|
|
$mangoUser = $this->mangoPayApi->Users->Create($mangoUser); |
|
60
|
|
|
} catch (ResponseException $e) { |
|
61
|
|
|
$this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]); |
|
62
|
|
|
throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
63
|
|
|
} catch (Exception $e) { |
|
64
|
|
|
$this->logger->addError($e->getMessage()); |
|
65
|
|
|
throw new PartFireException($e->getMessage(), $e->getCode(), $e); |
|
66
|
|
|
} |
|
67
|
|
|
return $this->userTranslator->convertMangoPayNaturalUserToDTO($mangoUser); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function createLegal(PFUserLegal $userDto) |
|
71
|
|
|
{ |
|
72
|
|
|
// TODO: Implement createLegal() method. |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function get($userId) |
|
76
|
|
|
{ |
|
77
|
|
|
// TODO: Implement get() method. |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getAll() |
|
81
|
|
|
{ |
|
82
|
|
|
// TODO: Implement getAll() method. |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function update(UserBase $userDto) |
|
86
|
|
|
{ |
|
87
|
|
|
// TODO: Implement update() method. |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function delete($userId) |
|
91
|
|
|
{ |
|
92
|
|
|
// TODO: Implement delete() method. |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|