|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SevenShores\Hubspot\Resources; |
|
4
|
|
|
|
|
5
|
|
|
class EcommerceBridge extends Resource |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Installs the ecommerce bridge into a portal. |
|
9
|
|
|
* |
|
10
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
11
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
12
|
|
|
*/ |
|
13
|
|
|
function install() |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/installs'; |
|
16
|
|
|
|
|
17
|
|
|
return $this->client->request('post', $endpoint); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Check the status of the ecommerce bridge. |
|
22
|
|
|
* |
|
23
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
24
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
25
|
|
|
*/ |
|
26
|
|
|
function checkInstall() |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/installs/status'; |
|
29
|
|
|
|
|
30
|
|
|
return $this->client->request('get', $endpoint); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Uninstall the ecommerce settings from a portal. |
|
35
|
|
|
* |
|
36
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
37
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
38
|
|
|
*/ |
|
39
|
|
|
function uninstall() |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/installs/uninstall'; |
|
42
|
|
|
|
|
43
|
|
|
return $this->client->request('post', $endpoint); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Create or update the ecommerce settings. |
|
48
|
|
|
* |
|
49
|
|
|
* @param array $settings |
|
50
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
51
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
52
|
|
|
*/ |
|
53
|
|
|
function upsertSettings($settings = []) |
|
|
|
|
|
|
54
|
|
|
{ |
|
55
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/settings'; |
|
56
|
|
|
|
|
57
|
|
|
$options['json'] = $settings; |
|
58
|
|
|
|
|
59
|
|
|
return $this->client->request('put', $endpoint, $options); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Delete the ecommerce settings for your app or portal. |
|
64
|
|
|
* Note: This action cannot be undone. If you want to disable sync messages from being applied, it is recommended that you disable the settings rather than deleting them. |
|
65
|
|
|
* |
|
66
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
67
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
68
|
|
|
*/ |
|
69
|
|
|
function deleteSettings() |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/settings'; |
|
72
|
|
|
|
|
73
|
|
|
return $this->client->request('delete', $endpoint); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Send a group of sync messages for a specific object type. Sync messages would be notifications of creates, updates, or deletes of ecommerce objects. |
|
78
|
|
|
* |
|
79
|
|
|
* @param string $objectType - The object type that the updates are for. One of CONTACT, DEAL, PRODUCT, or LINE_ITEM. |
|
80
|
|
|
* @param array $messages |
|
81
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
82
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
83
|
|
|
*/ |
|
84
|
|
|
function sendSyncMessages($objectType, $messages = []) |
|
|
|
|
|
|
85
|
|
|
{ |
|
86
|
|
|
$endpoint = "https://api.hubapi.com/extensions/ecomm/v1/sync-messages/{$objectType}"; |
|
87
|
|
|
|
|
88
|
|
|
$options['json'] = $messages; |
|
89
|
|
|
|
|
90
|
|
|
return $this->client->request('put', $endpoint, $options); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Get errors from previously processed sync messages. |
|
95
|
|
|
* |
|
96
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
97
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
98
|
|
|
*/ |
|
99
|
|
|
function getSyncErrors() |
|
|
|
|
|
|
100
|
|
|
{ |
|
101
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/sync-errors'; |
|
102
|
|
|
|
|
103
|
|
|
return $this->client->request('get', $endpoint); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Set the URI for the import initialization webhook. |
|
108
|
|
|
* |
|
109
|
|
|
* @param string $importTriggerUri - The URI that will be hit with the import webhook. |
|
110
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
111
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
112
|
|
|
*/ |
|
113
|
|
|
function setImportUri($importTriggerUri) |
|
|
|
|
|
|
114
|
|
|
{ |
|
115
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/import-settings'; |
|
116
|
|
|
|
|
117
|
|
|
$options['json'] = [ |
|
|
|
|
|
|
118
|
|
|
'importTriggerUri' => $importTriggerUri |
|
119
|
|
|
]; |
|
120
|
|
|
|
|
121
|
|
|
return $this->client->request('put', $endpoint, $options); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Retrieve the ecommerce import settings for an app. |
|
126
|
|
|
* |
|
127
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
128
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
129
|
|
|
*/ |
|
130
|
|
|
function getImportSettings() |
|
|
|
|
|
|
131
|
|
|
{ |
|
132
|
|
|
$endpoint = 'https://api.hubapi.com/extensions/ecomm/v1/import-settings'; |
|
133
|
|
|
|
|
134
|
|
|
return $this->client->request('get', $endpoint); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @param int $importStartedAt - Timestamp from the import initialization request |
|
139
|
|
|
* @param string $objectType - The object type this data corresponds to. Must be one of CONTACT, DEAL, LINE_ITEM, or PRODUCT. |
|
140
|
|
|
* @param int $pageNumber - A numeric page number that identifies this page of data |
|
141
|
|
|
* @param array $messages - The import messages |
|
142
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
143
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
144
|
|
|
*/ |
|
145
|
|
|
function importObjects($importStartedAt, $objectType, $pageNumber, $messages) |
|
|
|
|
|
|
146
|
|
|
{ |
|
147
|
|
|
$endpoint = "https://api.hubapi.com/import-pages/{$importStartedAt}/{$objectType}/{$pageNumber}"; |
|
148
|
|
|
|
|
149
|
|
|
$options['json'] = $messages; |
|
|
|
|
|
|
150
|
|
|
|
|
151
|
|
|
return $this->client->request('put', $endpoint, $options); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param int $importStartedAt - Timestamp from the import initialization request |
|
156
|
|
|
* @param string $objectType - The object type this data corresponds to. Must be one of CONTACT, DEAL, LINE_ITEM, or PRODUCT. |
|
157
|
|
|
* @param int $pageCount - The total number of pages sent via the import pages endpoint. |
|
158
|
|
|
* @param int $itemCount - The total number of items sent via the import pages endpoint. |
|
159
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
160
|
|
|
* @throws \SevenShores\Hubspot\Exceptions\BadRequest |
|
161
|
|
|
*/ |
|
162
|
|
|
function signalImportEnd($importStartedAt, $objectType, $pageCount, $itemCount) |
|
|
|
|
|
|
163
|
|
|
{ |
|
164
|
|
|
$endpoint = "https://api.hubapi.com/import-pages/{$importStartedAt}/{$objectType}/end"; |
|
165
|
|
|
|
|
166
|
|
|
$options['json'] = [ |
|
|
|
|
|
|
167
|
|
|
'pageCount' => $pageCount, |
|
168
|
|
|
'itemCount' => $itemCount |
|
169
|
|
|
]; |
|
170
|
|
|
|
|
171
|
|
|
return $this->client->request('put', $endpoint, $options); |
|
172
|
|
|
} |
|
173
|
|
|
} |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.