hukd 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,12 +22,15 @@ You can start of by creating an instance of the client, which just needs an Api
22
22
  require 'hukd'
23
23
  hukd = Hukd.new("YOUR_API_KEY_HERE")
24
24
 
25
- You can then make an API request to receive a hash containing the following keys:
25
+ You can then make an API request to receive an Array of Deal objects
26
26
 
27
27
  deals = hukd.hottest('deals')
28
28
 
29
- :deals - An array containing Deal objects
30
- :total_results - The total number of results that can be retrieved using the current filter options
29
+ Once you've made a successful request, the total_results attribute will become available
30
+
31
+ hukd.total_results
32
+
33
+ This gives you the total number of results that can be retrieved using the current filter options
31
34
 
32
35
  The following API calls are available
33
36
 
@@ -73,13 +76,11 @@ Combining everything together will give you something like this:
73
76
  require 'hukd'
74
77
  hukd = Hukd.new("YOUR_API_KEY_HERE")
75
78
  deals = hukd.hottest('deals')
76
- deals[:deals].each |deal| do
79
+ deals.each |deal| do
77
80
  puts(deal.title)
78
81
  end
79
- puts(deals[:total_results])
80
82
 
81
83
  This will fetch the hottest deals (default at 20) and print the title to the console.
82
- The total number of available results will be printed underneath
83
84
 
84
85
  Support
85
86
  --------
@@ -1,6 +1,6 @@
1
1
  module Hukd
2
2
  class Base
3
- attr_accessor :api_key
3
+ attr_accessor :api_key, :total_results
4
4
  API_VERSION = "2.0"
5
5
  API_BASE_URL = "http://api.hotukdeals.com/rest_api/v2/"
6
6
 
@@ -79,6 +79,10 @@ module Hukd
79
79
  end
80
80
 
81
81
  def get(forum='', category='', limit=20, options={})
82
+
83
+ # Reset total results
84
+ total_results = 0
85
+
82
86
  # Set the API_KEY
83
87
  options['key'] = @api_key
84
88
  options['output'] = 'json'
@@ -109,7 +113,8 @@ module Hukd
109
113
  raise Exception, resp['error']
110
114
  end
111
115
  # Returned parsed deals
112
- return {:deals => parse_deals(resp), :total_results => resp['total_results'] }
116
+ total_results = resp['total_results']
117
+ return parse_deals(resp)
113
118
  end
114
119
 
115
120
  end
@@ -1,3 +1,3 @@
1
1
  module Hukd
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -4,7 +4,7 @@ require "hukd"
4
4
  describe Hukd::Deal do
5
5
 
6
6
  before(:all) do
7
- @deal = Hukd.new("API_KEY_HERE").hottest('deals','',1)[:deals][0]
7
+ @deal = Hukd.new("API_KEY_HERE").hottest('deals','',1)[0]
8
8
  end
9
9
 
10
10
  it "should have a rounded temperature" do
@@ -8,45 +8,45 @@ describe Hukd::Base do
8
8
  end
9
9
 
10
10
  it "should get hottest deals" do
11
- Hukd.new("API_KEY_HERE").hottest('deals')[:deals].count.should equal(20)
11
+ Hukd.new("API_KEY_HERE").hottest('deals').count.should equal(20)
12
12
  end
13
13
 
14
14
  it "should get a custom number of deals" do
15
- Hukd.new("API_KEY_HERE").hottest('deals','',10)[:deals].count.should equal(10)
15
+ Hukd.new("API_KEY_HERE").hottest('deals','',10).count.should equal(10)
16
16
  end
17
17
 
18
18
  it "shouldn't get more than 500 deals" do
19
- Hukd.new("API_KEY_HERE").hottest('deals','',10000)[:deals].count.should equal(500)
19
+ Hukd.new("API_KEY_HERE").hottest('deals','',10000).count.should equal(500)
20
20
  end
21
21
 
22
22
  it "should be able to specify a forum" do
23
- Hukd.new("API_KEY_HERE").hottest('vouchers','',1)[:deals][0].forum_url_name.should == "vouchers"
23
+ Hukd.new("API_KEY_HERE").hottest('vouchers','',1)[0].forum_url_name.should == "vouchers"
24
24
  end
25
25
 
26
26
  it "should be able to specify a category" do
27
- Hukd.new("API_KEY_HERE").hottest('','fashion',0)[:deals][0].category_url_name.should == "fashion"
27
+ Hukd.new("API_KEY_HERE").hottest('','fashion',0)[0].category_url_name.should == "fashion"
28
28
  end
29
29
 
30
30
  it "should be able to specify a forum and category" do
31
- deal = Hukd.new("API_KEY_HERE").hottest('freebies','mobiles',1)[:deals][0]
31
+ deal = Hukd.new("API_KEY_HERE").hottest('freebies','mobiles',1)[0]
32
32
  deal.forum_url_name.should == "freebies"
33
33
  deal.category_url_name.should == "mobiles"
34
34
  end
35
35
 
36
36
  it "should search by username" do
37
- Hukd.new("API_KEY_HERE").user('wishihadadonkey','','',1)[:deals][0].poster_name.should == "wishihadadonkey"
37
+ Hukd.new("API_KEY_HERE").user('wishihadadonkey','','',1)[0].poster_name.should == "wishihadadonkey"
38
38
  end
39
39
 
40
40
  it "should search by tag" do
41
- Hukd.new("API_KEY_HERE").tag('xbox','deals','',1)[:deals][0].tags.should include('xbox')
41
+ Hukd.new("API_KEY_HERE").tag('xbox','deals','',1)[0].tags.should include('xbox')
42
42
  end
43
43
 
44
44
  it "should search by merchant" do
45
- Hukd.new("API_KEY_HERE").merchant('itunes.apple.com','','',1)[:deals][0].merchant_url_name.should == "itunes.apple.com"
45
+ Hukd.new("API_KEY_HERE").merchant('itunes.apple.com','','',1)[0].merchant_url_name.should == "itunes.apple.com"
46
46
  end
47
47
 
48
48
  it "should search by keyword" do
49
- Hukd.new("API_KEY_HERE").search('xbox','deals','',false,1,1)[:deals][0].title.downcase.should include("xbox")
49
+ Hukd.new("API_KEY_HERE").search('xbox','deals','',false,1,1)[0].title.downcase.should include("xbox")
50
50
  end
51
51
 
52
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hukd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2165281240 !ruby/object:Gem::Requirement
16
+ requirement: &2161120580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.6'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2165281240
24
+ version_requirements: *2161120580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2165280800 !ruby/object:Gem::Requirement
27
+ requirement: &2161120140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2165280800
35
+ version_requirements: *2161120140
36
36
  description: API Wrapper for HotUKDeals (HUKD)
37
37
  email:
38
38
  - messages@cubewebsites.com