From 9156552f91c0c0edb1c076db43109be1f9d52f53 Mon Sep 17 00:00:00 2001 From: 16mhz Date: Fri, 18 Jul 2014 18:21:07 +0200 Subject: [PATCH] Add Humble Store Discount Bridge --- bridges/HumbleStoreDiscountBridge.php | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bridges/HumbleStoreDiscountBridge.php diff --git a/bridges/HumbleStoreDiscountBridge.php b/bridges/HumbleStoreDiscountBridge.php new file mode 100644 index 0000000..4bcea23 --- /dev/null +++ b/bridges/HumbleStoreDiscountBridge.php @@ -0,0 +1,59 @@ +returnError('Could not request the Humble Store.', 404); + $string = json_decode($result, true); + $items = $string['results']; + $store_link = 'https://www.humblebundle.com/store/p/'; + $limit = 0; + + foreach ($items as $key => $value) { + if ($limit < 10) { + $new_price = $value['current_price'][0] . ' ' . $value['current_price'][1]; + $full_price = $value['full_price'][0] . ' ' . $value['full_price'][1]; + $product_name = $value['human_name']; + $product_uri = $store_link . $value['machine_name']; + $platforms = str_replace('\'', '', implode("','", $value['platforms'])); + $delivery_methods = str_replace('\'', '', implode("','", $value['delivery_methods'])); + + $content = '' . $product_name . '
Current price: ' . $new_price . '
Full price: ' . $full_price + . '
Delivery methods: ' . $delivery_methods . '
Platforms: ' + . $platforms . '
' . $value['description']; + + $item = new \Item(); + $item->title = $product_name . ' - ' . $new_price; + $item->uri = $product_uri; + $item->content = $content; + $this->items[] = $item; + $limit++; + } + } + } + + public function getName(){ + return 'HumbleStoreDiscount'; + } + + public function getURI(){ + return 'https://www.humblebundle.com/store'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} +