Example #1
0
 public function parseResponse($doc, $format = TWG_DEFAULT_DATA_FORMAT)
 {
     $data = ApiData::parseDocument($doc, $format);
     if (empty($data)) {
         return false;
     }
     if (!empty($data['error'])) {
         $this->errors = ApiData::getObjects($data['error']);
     }
     $this->data = $data;
     return true;
 }
Example #2
0
function fn_twg_get_api_data($response, $format, $required = true)
{
    $data = array();
    if (!empty($_REQUEST['data'])) {
        $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
    } elseif ($required) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));
        $response->returnResponse();
    }
    return $data;
}
Example #3
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
use Tygh\Registry;
use Twigmo\Core\Functions\Order\TwigmoOrder;
use Twigmo\Core\Functions\Image\TwigmoImage;
use Twigmo\Core\Api;
use Twigmo\Api\ApiData;
$format = !empty($_REQUEST['format']) ? $_REQUEST['format'] : TWG_DEFAULT_DATA_FORMAT;
$api_version = !empty($_REQUEST['api_version']) ? $_REQUEST['api_version'] : TWG_DEFAULT_API_VERSION;
$response = new ApiData($api_version, $format);
$object = !empty($_REQUEST['object']) ? $_REQUEST['object'] : '';
$lang_code = CART_LANGUAGE;
if (!empty($_REQUEST['language'])) {
    if (in_array($_REQUEST['language'], array_keys(Registry::get('languages')))) {
        $lang_code = $_REQUEST['language'];
    }
}
if (!fn_twg_validate_auth()) {
    $response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
    $response->returnResponse();
}
$data = '';
if (!empty($_REQUEST['data'])) {
    $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
    if (!empty($_REQUEST['action'])) {
Example #4
0
use Twigmo\Core\TwigmoSettings;
$format = !empty($_REQUEST['format']) ? $_REQUEST['format'] : TWG_DEFAULT_DATA_FORMAT;
$api_version = !empty($_REQUEST['api_version']) ? $_REQUEST['api_version'] : TWG_DEFAULT_API_VERSION;
$response = new ApiData($api_version, $format);
if (!empty($_REQUEST['callback'])) {
    $response->setCallback($_REQUEST['callback']);
}
$object = !empty($_REQUEST['object']) ? $_REQUEST['object'] : '';
$lang_code = DESCR_SL;
$action = $_REQUEST['action'];
if (empty($action) || !fn_twg_check_permissions($object, $action, $auth)) {
    fn_twg_throw_error_denied($response);
}
$data = '';
if (!empty($_REQUEST['data'])) {
    $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
}
$update_actions = array('update', 'update_status', 'update_info', 'delete');
if (($_SERVER['REQUEST_METHOD'] == 'POST' || $format == 'jsonp') && in_array($action, $update_actions)) {
    if (empty($data)) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));
    }
    if ($mode == 'post') {
        if ($object == 'profile') {
            $user_data = fn_twg_get_api_data($response, $format);
            $user_data['ship_to_another'] = empty($user_data['copy_address']) ? 'Y' : '';
            if (empty($user_data['ship_to_another'])) {
                $profile_fields = fn_get_profile_fields('O');
                fn_fill_address($user_data, $profile_fields);
            }
            if (isset($user_data['fields']) && is_array($user_data['fields'])) {
Example #5
0
 public function postData($data, $object, $action, $additional_params = array())
 {
     $request_data = ApiData::applyFormat($data);
     $params = array('data' => rawurlencode(base64_encode($request_data)), 'object' => $object, 'action' => $action);
     $params = array_merge($params, $additional_params);
     return $this->sendRequest($params, 'POST');
 }
Example #6
0
 public static function apiOrdersGetData($order_id, $type, $object_type, $data = array(), $single = true)
 {
     if (empty($data)) {
         $data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = ?s", $order_id, $type);
         // Payment information
         if ($type == 'P') {
             $data = @unserialize(fn_decrypt_text($data));
             // Coupons, Taxes and Shipping information
         } elseif (strpos('CTL', $type) !== false) {
             $data = @unserialize($data);
         }
         if (empty($data)) {
             return array();
         }
     }
     if ($single) {
         return self::getAsApiObject($object_type, $data);
     }
     return self::getAsList($object_type, ApiData::getObjects($data));
 }