<?php

class PBReusableModel_Errors extends CI_Model {

    const RETAILERS = 'sq_retailers';
    const PRODUCTS = 'sq_products';
    const CODE_REDEEMS = 'sq_retailer_code_redeems';

    function __construct() {
        parent::__construct();
		$this->load->helper('date');
        // $this->load->model('PBReusableModel_Security','appsecurity');
        // $this->load->model('PBReusableModel_Analytics','analytics');
        // $this->load->model('PBReusableModel_Partner','partners');
        // $this->load->model('PBReusableModel_Global','globals');
    }

    // *************************************************
    // SUBSCRIPTIONS
    // *************************************************

    function processErrorsFromBraintree($errors,$debug_message) {
        $error_response = array();
        $error_response['success'] = false;
        $error_response['message'] = $debug_message;
        $errors_array = array();
        foreach($errors AS $error) {
            $error_array = array();
            $error_array['error_type'] = $error->attribute;
            $error_array['error_code'] = $error->code;
            $error_array['error_message'] = $error->message;
            array_push($errors_array,$error_array);
        }
        $error_response['errors'] = $errors_array;
        echo json_encode($error_response);
        exit;
    }

}
