1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://flipboxfactory.com/software/hubspot/license |
6
|
|
|
* @link https://www.flipboxfactory.com/software/hubspot/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\hubspot\services\resources; |
10
|
|
|
|
11
|
|
|
use flipbox\hubspot\criteria\CompanyMutator; |
12
|
|
|
use flipbox\hubspot\criteria\ObjectMutatorInterface; |
13
|
|
|
use flipbox\hubspot\criteria\CompanyAccessor; |
14
|
|
|
use flipbox\hubspot\criteria\ObjectAccessorInterface; |
15
|
|
|
use flipbox\hubspot\transformers\collections\DynamicTransformerCollection; |
16
|
|
|
use flipbox\hubspot\transformers\collections\TransformerCollectionInterface; |
17
|
|
|
use flipbox\hubspot\transformers\DynamicModelSuccess; |
18
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\Company\Create; |
19
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\Company\Delete; |
20
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\Company\Read; |
21
|
|
|
use Flipbox\Relay\HubSpot\Builder\Resources\Company\Update; |
22
|
|
|
use yii\base\Component; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @author Flipbox Factory <[email protected]> |
26
|
|
|
* @since 1.0.0 |
27
|
|
|
*/ |
28
|
|
|
class Companies extends Component implements CRUDInterface |
29
|
|
|
{ |
30
|
|
|
use traits\SyncByElementTrait, |
31
|
|
|
traits\ReadObjectTrait, |
32
|
|
|
traits\UpsertObjectTrait, |
33
|
|
|
traits\DeleteObjectTrait; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The HubSpot Resource name |
37
|
|
|
*/ |
38
|
|
|
const HUBSPOT_RESOURCE = 'companies'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
public static function defaultTransformer() |
44
|
|
|
{ |
45
|
|
|
return [ |
46
|
|
|
'class' => DynamicTransformerCollection::class, |
47
|
|
|
'handle' => self::HUBSPOT_RESOURCE, |
48
|
|
|
'transformers' => [ |
49
|
|
|
TransformerCollectionInterface::SUCCESS_KEY => [ |
50
|
|
|
'class' => DynamicModelSuccess::class, |
51
|
|
|
'resource' => self::HUBSPOT_RESOURCE |
52
|
|
|
] |
53
|
|
|
] |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param array $config |
59
|
|
|
* @return ObjectAccessorInterface |
60
|
|
|
*/ |
61
|
|
|
public function getAccessorCriteria(array $config = []): ObjectAccessorInterface |
62
|
|
|
{ |
63
|
|
|
return new CompanyAccessor($config); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param array $config |
68
|
|
|
* @return ObjectMutatorInterface |
69
|
|
|
*/ |
70
|
|
|
public function getMutatorCriteria(array $config = []): ObjectMutatorInterface |
71
|
|
|
{ |
72
|
|
|
return new CompanyMutator($config); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @inheritdoc |
77
|
|
|
*/ |
78
|
|
|
protected static function createRelayBuilderClass(): string |
79
|
|
|
{ |
80
|
|
|
return Create::class; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritdoc |
85
|
|
|
*/ |
86
|
|
|
protected static function readRelayBuilderClass(): string |
87
|
|
|
{ |
88
|
|
|
return Read::class; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @inheritdoc |
93
|
|
|
*/ |
94
|
|
|
protected static function updateRelayBuilderClass(): string |
95
|
|
|
{ |
96
|
|
|
return Update::class; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritdoc |
101
|
|
|
*/ |
102
|
|
|
protected static function deleteRelayBuilderClass(): string |
103
|
|
|
{ |
104
|
|
|
return Delete::class; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|