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