Skip to content

Commit

Permalink
updating with utf8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ivikramsahu committed Jul 2, 2020
1 parent a6b440e commit 4674439
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 48 deletions.
87 changes: 41 additions & 46 deletions src/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,52 @@
use Unirest\Request;

/**
* Base controller
*/
* Base controller
*/
class BaseController
{
/**
* User-agent to be sent with API calls
* @var string
*/
const USER_AGENT = 'APIMATIC 2.0';
/**
* User-agent to be sent with API calls
* @var string
*/
const USER_AGENT = 'pepi-php-sdk v5';

/**
* HttpCallBack instance associated with this controller
* @var HttpCallBack
*/
private $httpCallBack = null;
/**
* HttpCallBack instance associated with this controller
* @var HttpCallBack
*/
private $httpCallBack = null;

/**
* Set HttpCallBack for this controller
* @param HttpCallBack $httpCallBack Http Callbacks called before/after each API call
*/
public function setHttpCallBack(HttpCallBack $httpCallBack)
{
$this->httpCallBack = $httpCallBack;
}
/**
* Set HttpCallBack for this controller
* @param HttpCallBack $httpCallBack Http Callbacks called before/after each API call
*/
public function setHttpCallBack(HttpCallBack $httpCallBack)
{
$this->httpCallBack = $httpCallBack;
}

/**
* Get HttpCallBack for this controller
* @return HttpCallBack The HttpCallBack object set for this controller
*/
public function getHttpCallBack()
{
return $this->httpCallBack;
}
/**
* Get HttpCallBack for this controller
* @return HttpCallBack The HttpCallBack object set for this controller
*/
public function getHttpCallBack()
{
return $this->httpCallBack;
}

/**
* Get a new JsonMapper instance for mapping objects
* @return \apimatic\jsonmapper\JsonMapper JsonMapper instance
*/
protected function getJsonMapper()
{
$mapper = new JsonMapper();
return $mapper;
}
/**
* Get a new JsonMapper instance for mapping objects
* @return \apimatic\jsonmapper\JsonMapper JsonMapper instance
*/
protected function getJsonMapper()
{
$mapper = new JsonMapper();
return $mapper;
}

protected function validateResponse(HttpResponse $response, HttpContext $_httpContext)
{
if ($response->getStatusCode() == 400) {
throw new APIException('Bad request', $_httpContext);
}
if (($response->getStatusCode() < 200) || ($response->getStatusCode() > 208)) { //[200,208] = HTTP OK
throw new APIException('HTTP Response Not OK', $_httpContext);
}
}
protected function validateResponse(HttpResponse $response, HttpContext $_httpContext)
{
return $_httpContext;
}
}
2 changes: 1 addition & 1 deletion src/Models/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function jsonSerialize()
{
$json = array();
$json['type'] = $this->type;
$json['value'] = $this->value;
$json['value'] = utf8_encode($this->value);

return $json;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function __construct()
if (12 == func_num_args()) {
$this->replyTo = func_get_arg(0);
$this->from = func_get_arg(1);
$this->subject = func_get_arg(2);
$this->subject = utf8_encode(func_get_arg(2));
$this->templateId = func_get_arg(3);
$this->content = func_get_arg(4);
$this->attachments = func_get_arg(5);
Expand Down

0 comments on commit 4674439

Please sign in to comment.