1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helix\Shopify; |
4
|
|
|
|
5
|
|
|
use Helix\Shopify\Base\AbstractEntity; |
6
|
|
|
use Helix\Shopify\Base\AbstractEntity\CrudTrait; |
7
|
|
|
use Helix\Shopify\MarketingEvent\Engagement; |
8
|
|
|
use Helix\Shopify\MarketingEvent\Resource; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A marketing event. |
12
|
|
|
* |
13
|
|
|
* @see https://shopify.dev/docs/admin-api/rest/reference/marketingevent |
14
|
|
|
* |
15
|
|
|
* @method number getBudget () |
16
|
|
|
* @method string getBudgetType () see the budget constants |
17
|
|
|
* @method string getCurrency () |
18
|
|
|
* @method string getDescription () |
19
|
|
|
* @method string getEndedAt () |
20
|
|
|
* @method string getEventType () see the type constants. |
21
|
|
|
* @method string getManageUrl () |
22
|
|
|
* @method Resource[] getMarketedResources () |
23
|
|
|
* @method string getMarketingChannel () see the channel constants. |
24
|
|
|
* @method bool isPaid () |
25
|
|
|
* @method string getPreviewUrl () |
26
|
|
|
* @method string getReferringDomain () |
27
|
|
|
* @method string getRemoteId () |
28
|
|
|
* @method string getScheduledToEndAt () |
29
|
|
|
* @method string getStartedAt () |
30
|
|
|
* @method string getUtmCampaign () |
31
|
|
|
* @method string getUtmMedium () |
32
|
|
|
* @method string getUtmSource () |
33
|
|
|
* |
34
|
|
|
* @method $this setBudget (number $budget) |
35
|
|
|
* @method $this setBudgetType (string $type) see the budget constants |
36
|
|
|
* @method $this setCurrency (string $currency) |
37
|
|
|
* @method $this setDescription (string $text) |
38
|
|
|
* @method $this setEndedAt (string $iso8601) |
39
|
|
|
* @method $this setEventType (string $type) @depends required, see the type constants. |
40
|
|
|
* @method $this setManageUrl (string $url) |
41
|
|
|
* @method $this setMarketedResources (Resource[] $resources) |
42
|
|
|
* @method $this setMarketingChannel (string $channel) @depends required, see the channel constants. |
43
|
|
|
* @method $this setPaid (bool $paid) @depends required |
44
|
|
|
* @method $this setPreviewUrl (string $url) |
45
|
|
|
* @method $this setReferringDomain (string $domain) |
46
|
|
|
* @method $this setRemoteId (string $id) |
47
|
|
|
* @method $this setScheduledToEndAt (string $iso8601) |
48
|
|
|
* @method $this setStartedAt (string $iso8601) @depends required |
49
|
|
|
* @method $this setUtmCampaign (string $campaign) |
50
|
|
|
* @method $this setUtmMedium (string $medium) |
51
|
|
|
* @method $this setUtmSource (string $source) |
52
|
|
|
*/ |
53
|
|
|
class MarketingEvent extends AbstractEntity |
54
|
|
|
{ |
55
|
|
|
|
56
|
|
|
use CrudTrait; |
57
|
|
|
|
58
|
|
|
const TYPE = 'marketing_event'; |
59
|
|
|
const DIR = 'marketing_events'; |
60
|
|
|
|
61
|
|
|
const MAP = [ |
62
|
|
|
'marketed_resources' => [Resource::class] |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
const BUDGET_DAILY = 'daily'; |
66
|
|
|
const BUDGET_LIFETIME = 'lifetime'; |
67
|
|
|
|
68
|
|
|
const CHANNEL_DISPLAY = 'display'; |
69
|
|
|
const CHANNEL_EMAIL = 'email'; |
70
|
|
|
const CHANNEL_REFERRAL = 'referral'; |
71
|
|
|
const CHANNEL_SEARCH = 'search'; |
72
|
|
|
const CHANNEL_SOCIAL = 'social'; |
73
|
|
|
|
74
|
|
|
const TYPE_ABANDONED_CART = 'abandoned_cart'; |
75
|
|
|
const TYPE_AD = 'ad'; |
76
|
|
|
const TYPE_AFFILIATE = 'affiliate'; |
77
|
|
|
const TYPE_LOYALTY = 'loyalty'; |
78
|
|
|
const TYPE_MESSAGE = 'message'; |
79
|
|
|
const TYPE_NEWSLETTER = 'newsletter'; |
80
|
|
|
const TYPE_POST = 'post'; |
81
|
|
|
const TYPE_RETARGETING = 'retargeting'; |
82
|
|
|
const TYPE_TRANSACTIONAL = 'transactional'; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Factory. |
86
|
|
|
* |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
|
|
public function newEngagement() |
90
|
|
|
{ |
91
|
|
|
return $this->api->factory($this, Engagement::class); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Factory. |
96
|
|
|
* |
97
|
|
|
* @return Resource |
98
|
|
|
*/ |
99
|
|
|
public function newResource() |
100
|
|
|
{ |
101
|
|
|
return $this->api->factory($this, Resource::class); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param Engagement[] $engagements |
106
|
|
|
* @return $this |
107
|
|
|
*/ |
108
|
|
|
public function sendEngagements(array $engagements) |
109
|
|
|
{ |
110
|
|
|
$this->api->post("{$this}/engagements", [ |
111
|
|
|
'engagements' => $engagements |
112
|
|
|
]); |
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
} |