1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<?php
class ModelExtensionOpenBayEtsy extends Model{
public function install() {
$this->load->model('setting/event');
$this->model_setting_event->addEvent('openbay_etsy_add_order', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/openbay/etsy/eventAddOrderHistory');
$settings = array();
$settings["etsy_token"] = '';
$settings["etsy_secret"] = '';
$settings["etsy_encryption_key"] = '';
$settings["etsy_encryption_iv"] = '';
$settings["etsy_logging"] = '1';
$this->model_setting_setting->editSetting('etsy', $settings);
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "etsy_setting_option` (
`etsy_setting_option_id` INT(11) NOT NULL AUTO_INCREMENT,
`key` VARCHAR(100) NOT NULL,
`last_updated` DATETIME NOT NULL,
`data` TEXT NOT NULL,
PRIMARY KEY (`etsy_setting_option_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "etsy_listing` (
`etsy_listing_id` int(11) NOT NULL AUTO_INCREMENT,
`etsy_item_id` char(100) NOT NULL,
`product_id` int(11) NOT NULL,
`status` SMALLINT(3) NOT NULL DEFAULT '1',
`created` DATETIME NOT NULL,
PRIMARY KEY (`etsy_listing_id`),
KEY `product_id` (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "etsy_order` (
`etsy_order_id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`receipt_id` int(11) NOT NULL,
`paid` int(1) NOT NULL,
`shipped` int(1) NOT NULL,
PRIMARY KEY (`etsy_order_id`),
KEY `order_id` (`order_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
$this->db->query("
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "etsy_order_lock` (
`order_id` int(11) NOT NULL,
PRIMARY KEY (`order_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
}
public function uninstall() {
$this->load->model('setting/event');
$this->model_setting_event->deleteEventByCode('openbay_etsy_add_order');
}
public function patch() {
if ($this->config->get('etsy_status') == 1) {
}
}
public function verifyAccount() {
if ($this->openbay->etsy->validate() == true) {
return $this->openbay->etsy->call('v1/etsy/account/info/', 'GET');
} else {
return false;
}
}
}
|