Skip to content

Commit

Permalink
IT-516 Added getLabelFormats
Browse files Browse the repository at this point in the history
  • Loading branch information
Priit1337 committed May 5, 2021
1 parent ea1445d commit 687061d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maksekeskus-php
}
],
"require": {
"maksekeskus/maksekeskus-php": "v1.4.2"
"maksekeskus/maksekeskus-php": "v1.4.3"
}
}
```
Expand All @@ -25,7 +25,7 @@ Download the packaged library form the repository [releases]
(https://github.com/maksekeskus/maksekeskus-php/releases/).

Unpack it into your project folder (i.e. /htdocs/myshop/ )
and include the libarary file ( i.e. /htdocs/myshop/Maksekeskus-1.4.2/Maksekeskus.php )
and include the libarary file ( i.e. /htdocs/myshop/Maksekeskus-1.4.3/Maksekeskus.php )

Get your API keys from [merchant.maksekeskus.ee](https://merchant.maksekeskus.ee) or [merchant.test.maksekeskus.ee](https://merchant.test.maksekeskus.ee)

Expand All @@ -34,7 +34,7 @@ Get your API keys from [merchant.maksekeskus.ee](https://merchant.maksekeskus.ee
``` php
<?php

require __DIR__ . '/maksekeskus-1.4.2/vendor/autoload.php'; //Comment this line out if you are using Composer to build your project
require __DIR__ . '/maksekeskus-1.4.3/vendor/autoload.php'; //Comment this line out if you are using Composer to build your project

use Maksekeskus\Maksekeskus;

Expand Down
23 changes: 20 additions & 3 deletions lib/Maksekeskus.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Maksekeskus
/**
* @var string library Version
*/
private $version = "1.4.2";
private $version = "1.4.3";

/**
* Response object of the last API request
Expand Down Expand Up @@ -929,8 +929,25 @@ public function createShipments ($request_body)
}
}

/**
* get label formats
*
* @param mixed An object or array containing request body
* @throws Exception if failed to get label formats list
* @return array List of label formats
*/
public function getLabelFormats ()
{
$response = $this->makeGetRequest('/v1/shipments/labels/formats');

if (in_array($response->code, array(200, 201))) {
return $response->body;
} else {
throw new Exception('Could not get parcel label formats. Response ('.$response->code.'): '.$response->raw_body);
}
}

/**
/**
* generate parcel labels for shipments registered at carriers
*
* @param mixed An object or array containing request body
Expand All @@ -944,7 +961,7 @@ public function createLabels ($request_body)
if (in_array($response->code, array(200, 201))) {
return $response->body;
} else {
throw new MKException($response->raw_body, 'Could generate parcel labels. Response ('.$response->code.'): '.$response->raw_body, $response->body->code);
throw new MKException($response->raw_body, 'Could not generate parcel labels. Response ('.$response->code.'): '.$response->raw_body, $response->body->code);
}
}

Expand Down

0 comments on commit 687061d

Please sign in to comment.