Skip to content

Commit

Permalink
[*] MO - powatag : added request
Browse files Browse the repository at this point in the history
  • Loading branch information
tbigueres committed Nov 21, 2014
1 parent 5cbe6f8 commit d086cca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
powatag/.yo-rc.json
powatag/config.xml
config*.xml
logs.txt
14 changes: 14 additions & 0 deletions api/v1/PowaTagAPIAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* International Registered Trademark & Property of PrestaShop SA
*/

require_once(dirname(__FILE__).'/../../classes/PowaTagRequestLogs.php');

abstract class PowaTagAPIAbstract
{

Expand Down Expand Up @@ -123,6 +125,15 @@ public function __construct($request)
self::$api_log = Configuration::get('POWATAG_API_LOG');
self::$request_log = Configuration::get('POWATAG_REQUEST_LOG');


PowaTagRequestLogs::add(array(
'args' => $this->args,
'endpoint' => $this->endpoint,
'verb' => $this->verb,
'method' => $this->method,
'data' => $this->data,
));

$this->module = Module::getInstanceByName('powatag');
}

Expand Down Expand Up @@ -151,6 +162,9 @@ protected function _response($data)
$status = $this->getResponse();

header("HTTP/1.1 ".$status." ".$this->_requestStatus($status));
PowaTagRequestLogs::add(array(
'response' => Tools::jsonEncode($data)
));
return Tools::jsonEncode($data);
}

Expand Down
40 changes: 40 additions & 0 deletions classes/PowaTagRequestLogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2014 PrestaShop SA
* @version Release: $Revision: 7776 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class PowaTagRequestLogs {


static public function add($datas)
{
$handle = fopen(dirname(__FILE__).'/../logs_requests.txt', 'a+');
fwrite($handle, print_r($datas, true));
fclose($handle);

}


}

0 comments on commit d086cca

Please sign in to comment.