Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 37
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
QuickBooks
0.00% covered (danger)
0.00%
0 / 37
0.00% covered (danger)
0.00%
0 / 4
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
6
 getDRSFieldsArray
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 getDataService
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 getAccountMapArray
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace BuyerKiosk\QuickBooks;
4
5use QuickBooksOnline\API\DataService\DataService;
6
7class QuickBooks {
8
9    protected $db;
10    protected $store;
11    protected $storeDB;
12    protected $log;
13    public $authorizationRequestURL;
14    public $tokenEndPointURL;
15    public $clientID;
16    public $clientSecret;
17    public $oauthScope;
18    public $oauthRedirectURI;
19
20    public function __construct(\Store $store = null)
21    {
22        global $db_name;
23        $this->store = $store;
24        $this->db = dbConnectByName($db_name);
25        $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
26        $this->db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
27
28        if(!$store == null) {
29            $this->storeDB = dbConnectByName($this->store->getDbName());
30            $this->storeDB->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
31            $this->storeDB->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
32        }
33
34        $this->log = new \KLogger($_ENV['LOG_DIR']."quickbooks.log", \KLogger::DEBUG);
35
36        $this->authorizationRequestURL = "https://appcenter.intuit.com/connect/oauth2";
37        $this->tokenEndPointURL = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer";
38        $this->clientID = "AB37C1i2oxTtjyxANG2PWuuRzud9IC0iFUbFGy2hCBnrSHgdBc";
39        $this->clientSecret = "5TPXekIaTfZe2E56pprvPQZ5l8U5n64CbnBCYuhg";
40        $this->oauthScope = "com.intuit.quickbooks.accounting";
41        $this->oauthRedirectURI = "https://buyerkiosk.dev/api/qbCallback.php";
42    }
43
44    public function getDRSFieldsArray() {
45        if($this->store == null) {
46            return false;
47        }
48        $query = $this->storeDB->prepare("SELECT * FROM drsFields WHERE 1 ORDER BY sfileField ASC");
49        $query->execute();
50        $drsFieldsArray = $query->fetchAll(\PDO::FETCH_ASSOC);
51        return $drsFieldsArray;
52    }
53    public function getDataService() {
54
55        $dataService = DataService::Configure(array(
56            'auth_mode' => 'oauth2',
57            'ClientID' => $this->clientID,
58            'ClientSecret' =>  $this->clientSecret,
59            'RedirectURI' => $this->oauthRedirectURI,
60            'scope' => $this->oauthScope,
61            'baseUrl' => "development"
62        ));
63        return $dataService;
64    }
65    public function getAccountMapArray() {
66        $stmt = $this->storeDB->prepare("SELECT * FROM drsFieldMapping WHERE 1");
67        $stmt->execute();
68        $accountMapArray = array();
69        while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
70            $accountMapArray[$row['drsID']] = $row['qbID'];
71        }
72        return $accountMapArray;
73    }
74
75}