@@ 100-116 (lines=17) @@ | ||
97 | * @return Result |
|
98 | * @throws Exception |
|
99 | */ |
|
100 | public function createClickEvent($pageId, $event) |
|
101 | { |
|
102 | if (!($event instanceOf ClickEvent)) { |
|
103 | throw new Exception("Expected argument of type ClickEvent", |
|
104 | Exception::CODE_INVALID_ARG); |
|
105 | } |
|
106 | ||
107 | $postData = $event->toArray(); |
|
108 | ||
109 | $result = $this->client->sendApiRequest("/pages/$pageId/events", array(), 'POST', |
|
110 | $postData); |
|
111 | ||
112 | $event = new ClickEvent($result->getDecodedJsonData()); |
|
113 | $result->setPayload($event); |
|
114 | ||
115 | return $result; |
|
116 | } |
|
117 | ||
118 | /** |
|
119 | * Creates a new custom event. |
|
@@ 125-141 (lines=17) @@ | ||
122 | * @return Result |
|
123 | * @throws Exception |
|
124 | */ |
|
125 | public function createCustomEvent($projectId, $event) |
|
126 | { |
|
127 | if (!($event instanceOf CustomEvent)) { |
|
128 | throw new Exception("Expected argument of type CustomEvent", |
|
129 | Exception::CODE_INVALID_ARG); |
|
130 | } |
|
131 | ||
132 | $postData = $event->toArray(); |
|
133 | ||
134 | $result = $this->client->sendApiRequest("/projects/$projectId/custom_events", array(), 'POST', |
|
135 | $postData); |
|
136 | ||
137 | $event = new CustomEvent($result->getDecodedJsonData()); |
|
138 | $result->setPayload($event); |
|
139 | ||
140 | return $result; |
|
141 | } |
|
142 | ||
143 | /** |
|
144 | * Updates the given click event. |
|
@@ 151-167 (lines=17) @@ | ||
148 | * @return Result |
|
149 | * @throws Exception |
|
150 | */ |
|
151 | public function updateClickEvent($pageId, $eventId, $event) |
|
152 | { |
|
153 | if (!($event instanceOf ClickEvent)) { |
|
154 | throw new Exception("Expected argument of type ClickEvent", |
|
155 | Exception::CODE_INVALID_ARG); |
|
156 | } |
|
157 | ||
158 | $postData = $event->toArray(); |
|
159 | ||
160 | $result = $this->client->sendApiRequest("/pages/$pageId/events/$eventId", array(), 'PATCH', |
|
161 | $postData); |
|
162 | ||
163 | $event = new ClickEvent($result->getDecodedJsonData()); |
|
164 | $result->setPayload($event); |
|
165 | ||
166 | return $result; |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * Updates the given custom event. |
|
@@ 177-193 (lines=17) @@ | ||
174 | * @return Result |
|
175 | * @throws Exception |
|
176 | */ |
|
177 | public function updateCustomEvent($projectId, $eventId, $event) |
|
178 | { |
|
179 | if (!($event instanceOf CustomEvent)) { |
|
180 | throw new Exception("Expected argument of type CustomEvent", |
|
181 | Exception::CODE_INVALID_ARG); |
|
182 | } |
|
183 | ||
184 | $postData = $event->toArray(); |
|
185 | ||
186 | $result = $this->client->sendApiRequest("/projects/$projectId/custom_events/$eventId", array(), 'PATCH', |
|
187 | $postData); |
|
188 | ||
189 | $event = new CustomEvent($result->getDecodedJsonData()); |
|
190 | $result->setPayload($event); |
|
191 | ||
192 | return $result; |
|
193 | } |
|
194 | } |
|
195 | ||
196 |
@@ 90-105 (lines=16) @@ | ||
87 | * Create a new Page in a provided Project |
|
88 | * @param Page $page |
|
89 | */ |
|
90 | public function create($page) |
|
91 | { |
|
92 | if (!($page instanceOf Page)) { |
|
93 | throw new Exception("Expected argument of type Page"); |
|
94 | } |
|
95 | ||
96 | $postData = $page->toArray(); |
|
97 | ||
98 | $result = $this->client->sendApiRequest("/pages", array(), 'POST', |
|
99 | $postData); |
|
100 | ||
101 | $page = new Page($result->getDecodedJsonData()); |
|
102 | $result->setPayload($page); |
|
103 | ||
104 | return $result; |
|
105 | } |
|
106 | ||
107 | /** |
|
108 | * Update a Page in a provided Project |
|
@@ 114-129 (lines=16) @@ | ||
111 | * @return Result |
|
112 | * @throws Exception |
|
113 | */ |
|
114 | public function update($pageId, $page) |
|
115 | { |
|
116 | if (!($page instanceOf Page)) { |
|
117 | throw new Exception("Expected argument of type Page"); |
|
118 | } |
|
119 | ||
120 | $postData = $page->toArray(); |
|
121 | ||
122 | $result = $this->client->sendApiRequest("/pages/$pageId", array(), 'PATCH', |
|
123 | $postData); |
|
124 | ||
125 | $page = new Page($result->getDecodedJsonData()); |
|
126 | $result->setPayload($page); |
|
127 | ||
128 | return $result; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * Delete a Page within a Project by ID. |
@@ 70-84 (lines=15) @@ | ||
67 | * @return Result |
|
68 | * @throws Exception |
|
69 | */ |
|
70 | public function get($projectId) |
|
71 | { |
|
72 | $projectId = (string)$projectId; |
|
73 | ||
74 | if (!preg_match('/^\d+$/', $projectId)) { |
|
75 | throw new Exception("A positive integer project ID expected, while got $projectId"); |
|
76 | } |
|
77 | ||
78 | $result = $this->client->sendApiRequest("/projects/$projectId"); |
|
79 | ||
80 | $project = new Project($result->getDecodedJsonData()); |
|
81 | $result->setPayload($project); |
|
82 | ||
83 | return $result; |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * Create a new Project in your account. |
|
@@ 91-106 (lines=16) @@ | ||
88 | * @param Project $project Project meta information. |
|
89 | * @return Result |
|
90 | */ |
|
91 | public function create($project) |
|
92 | { |
|
93 | if (!($project instanceOf Project)) { |
|
94 | throw new Exception("Expected argument of type Project"); |
|
95 | } |
|
96 | ||
97 | $postData = $project->toArray(); |
|
98 | ||
99 | $result = $this->client->sendApiRequest("/projects", array(), 'POST', |
|
100 | $postData); |
|
101 | ||
102 | $project = new Project($result->getDecodedJsonData()); |
|
103 | $result->setPayload($project); |
|
104 | ||
105 | return $result; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * Update a Project. |
@@ 130-146 (lines=17) @@ | ||
127 | * @return Result |
|
128 | * @throws Exception |
|
129 | */ |
|
130 | public function create($campaign) |
|
131 | { |
|
132 | if (!($campaign instanceOf Campaign)) { |
|
133 | throw new Exception("Expected argument of type Campaign", |
|
134 | Exception::CODE_INVALID_ARG); |
|
135 | } |
|
136 | ||
137 | $postData = $campaign->toArray(); |
|
138 | ||
139 | $result = $this->client->sendApiRequest("/campaigns", array(), 'POST', |
|
140 | $postData); |
|
141 | ||
142 | $campaign = new Campaign($result->getDecodedJsonData()); |
|
143 | $result->setPayload($campaign); |
|
144 | ||
145 | return $result; |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Update a Campaign |
|
@@ 155-171 (lines=17) @@ | ||
152 | * @return Result |
|
153 | * @throws Exception |
|
154 | */ |
|
155 | public function update($campaignId, $campaign) |
|
156 | { |
|
157 | if (!($campaign instanceOf Campaign)) { |
|
158 | throw new Exception("Expected argument of type Campaign", |
|
159 | Exception::CODE_INVALID_ARG); |
|
160 | } |
|
161 | ||
162 | $postData = $campaign->toArray(); |
|
163 | ||
164 | $result = $this->client->sendApiRequest("/campaigns/$campaignId", array(), 'PATCH', |
|
165 | $postData); |
|
166 | ||
167 | $campaign = new Campaign($result->getDecodedJsonData()); |
|
168 | $result->setPayload($campaign); |
|
169 | ||
170 | return $result; |
|
171 | } |
|
172 | ||
173 | /** |
|
174 | * Delete Campaign by ID |