@@ -209,6 +209,206 @@ API2Client\Entities\Order\CustomerPortal Object
209
209
)
210
210
```
211
211
212
+ TemplateMonster API2 Client
213
+ ===========================
214
+
215
+ Installation
216
+ ------------
217
+
218
+ Using Composer (recommended)
219
+
220
+ Add the dependency in your ` composer.json `
221
+
222
+ ``` json
223
+ {
224
+ "repositories" : [
225
+ {
226
+ "type" : " vcs" ,
227
+ "url" : " https://github.com/M0nsterLabs/api2client.git"
228
+ }
229
+ ],
230
+ "require" : {
231
+ "templatemonster/api2-client" :" dev-master"
232
+ }
233
+ }
234
+
235
+ ```
236
+ Usage
237
+ -----
238
+
239
+ # Templates
240
+
241
+ ``` php
242
+ // Create API instance
243
+ $api = new \API2Client\Api ('api2.templatemonster.com', 'myUserName', 'myUserToken');
244
+
245
+
246
+ // Receive a count of all Templates
247
+ $templatesCount = $api->getTemplatesCount ()
248
+
249
+ // Receive a list of Templates
250
+ $offset = 0;
251
+ $limit = 20;
252
+
253
+ $templates = $api->getTemplatesList ($offset, $limit);
254
+
255
+ /** @var API2Client\Entities\Template $template */
256
+ foreach ($templates as $template)
257
+ {
258
+ // Template pages
259
+ $templatePages = $template->getPages ();
260
+ }
261
+
262
+
263
+ // Receive a single Template
264
+ $template_id = 30506;
265
+
266
+ /** @var API2Client\Entities\Template $template */
267
+ $template = $api->getTemplate ($template_id);
268
+
269
+
270
+ ```
271
+
272
+ # Orders
273
+
274
+ ## Receive a status of Order
275
+
276
+ ``` php
277
+
278
+ /** @var \API2Client\Entities\Order\Status $status */
279
+ $status = $api->getOrderStatus ('rgRvuzZQP9OoALyEKGKA');
280
+
281
+ // print status title
282
+ echo $status->getStatusName ();
283
+
284
+ ```
285
+
286
+ ## Get all Statuses
287
+
288
+ ``` php
289
+
290
+ $statuses = $api->getOrderStatuses ();
291
+
292
+ /** @var \API2Client\Entities\Order\Status $status */
293
+ foreach ($statuses as $status)
294
+ {
295
+ echo $status->getStatusCode ();
296
+ echo $status->getStatusName ();
297
+ }
298
+
299
+ ```
300
+
301
+ ## Create an Order
302
+
303
+ ``` php
304
+
305
+ $order = new \API2Client\Entities\Order ();
306
+
307
+ $order->setProjectId (0);
308
+ $order->setAmount (174);
309
+ $order->setBonusesAmount (0);
310
+
311
+ $billingInfo = new \API2Client\Entities\Order\BillingInfo ();
312
+
313
+ $billingInfo->setAccountSId ('u03e9b361c607ju37707iyo8s273sibh9z8lka2e6kt3276e41g11e7f6ozjm0cv7c4a40piorf408bb203of6wnbx2v24xfo61nwr4o7960tu898w50u4bu51zn2fa1');
314
+ $billingInfo->setAddress ('Torenplein Str');
315
+ $billingInfo->setCityName ('Hasselt');
316
+ $billingInfo->setContactPhone (74933242323);
317
+ $billingInfo->setEmail ('
[email protected] ');
318
+ $billingInfo->setCountryISO2 ('BE');
319
+ $billingInfo->setFullName ('Mark Twain');
320
+ $billingInfo->setPhone (74933242323);
321
+ $billingInfo->setPostalCode (12123);
322
+ $billingInfo->setStateISO2 ('XX');
323
+
324
+ $order->setBillingInfo ($billingInfo);
325
+
326
+ $productInfo1 = new \API2Client\Entities\Order\ProductInfo ();
327
+
328
+ $productInfo1->setProductId (49334);
329
+ $productInfo1->setPrice (69);
330
+ $productInfo1->setType ('template');
331
+
332
+ $order->addProductInfo ($productInfo1);
333
+
334
+ $productInfo2 = new \API2Client\Entities\Order\ProductInfo ();
335
+
336
+ $productInfo2->setProductId (49334);
337
+ $productInfo2->setPrice (75);
338
+ $productInfo2->setType ('template');
339
+
340
+ $order->addProductInfo ($productInfo2);
341
+
342
+
343
+ $externalProduct = new \API2Client\Entities\Order\ProductInfo ();
344
+
345
+ $externalProduct->setProductId (0);
346
+ $externalProduct->setPrice (33);
347
+ $externalProduct->setFinalPrice (30);
348
+ $externalProduct->setName ('Headspace Journey Subscription');
349
+ $externalProduct->setType ('external');
350
+
351
+ $order->addProductInfo ($externalProduct);
352
+
353
+ $trackingInfo = new \API2Client\Entities\Order\TrackingInfo ();
354
+
355
+ $trackingInfo->setRmsLocale ('EN');
356
+ $trackingInfo->setRefererUrl ('http://localhost:8081/');
357
+ $trackingInfo->setUserAgent ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36');
358
+ $trackingInfo->setUserIPAddress ('10.0.2.2');
359
+ $trackingInfo->setUserLanguage ('en-US,en;q=0.8,uk;q=0.6,ru;q=0.4');
360
+ $trackingInfo->setUserLocalTime ('Tue May 27 2014 10:31:05 GMT+0300 (EEST)');
361
+
362
+ $order->setTrackingInfo ($trackingInfo);
363
+
364
+ $paymentInfo = new \API2Client\Entities\Order\PaymentInfo ();
365
+
366
+ $paymentInfo->setCurrencyId (0);
367
+ $paymentInfo->setCurrencyRate (1);
368
+ $paymentInfo->setPaymentId (2);
369
+
370
+ $order->setPaymentInfo ($paymentInfo);
371
+
372
+ /** @var \API2Client\Entities\OrderCreated $result */
373
+ $result = $api->createOrder ($order);
374
+
375
+
376
+ ```
377
+
378
+ ## Get url on invoice url by transaction
379
+
380
+ ``` php
381
+ // Create API instance
382
+ $api = new \API2Client\Api ('api2.templatemonster.com', 'myUserName', 'myUserToken');
383
+ $link = $api->getInvoiceUrl('abc12345678');
384
+ ```
385
+ Success response
386
+ ``` php
387
+ API2Client\Entities\Order\BillingPortal Object
388
+ (
389
+ [url:protected] => https://www.domain.com/invoice/a1?token=token
390
+ [status:API2Client\Entities\Order\BillingPortal:private] => 1
391
+ [messages:API2Client\Entities\Order\BillingPortal:private] => Array()
392
+ )
393
+ ```
394
+
395
+ ## Get url on status page url by transaction
396
+
397
+ ``` php
398
+ // Create API instance
399
+ $api = new \API2Client\Api ('api2.templatemonster.com', 'myUserName', 'myUserToken');
400
+ $link = $api->getTransactionStatusUrl('abc12345678');
401
+ ```
402
+ Success response
403
+ ``` php
404
+ API2Client\Entities\Order\BillingPortal Object
405
+ (
406
+ [url:protected] => https://www.domain.com/transaction-statuses/a1?token=token
407
+ [status:API2Client\Entities\Order\BillingPortal:private] => 1
408
+ [messages:API2Client\Entities\Order\BillingPortal:private] => Array()
409
+ )
410
+ ```
411
+
212
412
Error Handling
213
413
--------------
214
414
@@ -229,4 +429,4 @@ catch (\API2Client\Client\APIException $e)
229
429
$e->getMessage ();
230
430
}
231
431
232
- ```
432
+ ```
0 commit comments