1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the slince/shopify-api-php |
5
|
|
|
* |
6
|
|
|
* (c) Slince <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Slince\Shopify\Manager\Customer; |
13
|
|
|
|
14
|
|
|
use Slince\Shopify\Common\Manager\GeneralCurdable; |
15
|
|
|
use Slince\Shopify\Manager\Order\Order; |
16
|
|
|
|
17
|
|
|
class CustomerManager extends GeneralCurdable implements CustomerManagerInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* {@inheritdoc} |
21
|
|
|
*/ |
22
|
|
|
public static function getServiceName() |
23
|
|
|
{ |
24
|
|
|
return 'customers'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
public function getResourceName() |
31
|
|
|
{ |
32
|
|
|
return 'customer'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
|
|
public function getModelClass() |
39
|
|
|
{ |
40
|
|
|
return Customer::class; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
public function createAccountActivationUrl($id) |
47
|
|
|
{ |
48
|
|
|
$data = $this->client->post('customers/'.$id.'/account_activation_url', []); |
49
|
|
|
|
50
|
|
|
return $data['account_activation_url']; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
|
|
public function sendInvite($id, array $data) |
57
|
|
|
{ |
58
|
|
|
$data = $this->client->post('customers/'.$id.'/send_invite', [ |
59
|
|
|
'customer_invite' => $data, |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
return $this->fromArray($data, CustomerInvite::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
|
|
public function search(array $query = []) |
69
|
|
|
{ |
70
|
|
|
$data = $this->client->get('customers/search', $query); |
71
|
|
|
|
72
|
|
|
return $this->createMany(reset($data)); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function orders($id) |
79
|
|
|
{ |
80
|
|
|
$data = $this->client->get('customers/'.$id.'/orders'); |
81
|
|
|
|
82
|
|
|
return $this->createMany(reset($data), Order::class); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|