tumbz 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/README.md +21 -7
- data/lib/tumbz/middleware/parse.rb +1 -1
- data/lib/tumbz/model.rb +1 -1
- data/lib/tumbz/partner_lookup.rb +1 -0
- data/lib/tumbz/product.rb +1 -0
- data/lib/tumbz/user.rb +2 -2
- data/lib/tumbz/user_suggestion.rb +7 -0
- data/lib/tumbz/version.rb +1 -1
- data/lib/tumbz.rb +5 -2
- metadata +3 -7
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,17 +7,13 @@ This gem allows you to easily use the [Tum.bz API](http://tum.bz/api). It’s po
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'tumbz'
|
10
|
+
gem 'tumbz', :git => "git://github.com/remiprev/tumbz.git", :branch => "master"
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
15
|
$ bundle
|
16
16
|
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install tumbz
|
20
|
-
|
21
17
|
## Usage
|
22
18
|
|
23
19
|
First, you must define a `configure` block with your API key:
|
@@ -33,6 +29,9 @@ That’s it! You’ll then be able to use :
|
|
33
29
|
```ruby
|
34
30
|
Tumbz::User.find("remi")
|
35
31
|
# => #<Tumbz::User(users/4f0e32936edcb2000100029d) id="4f0e32936edcb2000100029d" username="remi" profile_url="http://tum.bz/u/remi" firstname="Rémi" lastname="Prévost"…>
|
32
|
+
|
33
|
+
Tumbz::Product.search(:q => "office", :cat => "tv")
|
34
|
+
# => [#<Tumbz::Product(products/50b4caaac042690002010e1c) id="50b4caaac042690002010e1c" cat="tv" url="http://tum.bz/tv/50b4caaac042690002010e1c/the-offic..." title="The Office (US)" artist=nil external_id="73244" img_thumb=nil img_cover=""…>]
|
36
35
|
```
|
37
36
|
|
38
37
|
Other modules are:
|
@@ -43,6 +42,7 @@ Other modules are:
|
|
43
42
|
* `Tumbz::PartnerLookup`
|
44
43
|
* `Tumbz::Product`
|
45
44
|
* `Tumbz::User`
|
45
|
+
* `Tumbz::UserSuggestion`
|
46
46
|
|
47
47
|
The API wrapper is powered by [Her](https://github.com/remiprev/her), so most of [its documentation](https://github.com/remiprev/her) will be helpful.
|
48
48
|
|
@@ -52,12 +52,26 @@ Support for OAuth-authenticated calls is supported, but very premitive (not quit
|
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
Tumbz::User.sign_in!("<email>", "<password>")
|
55
|
-
# =>
|
55
|
+
# => "abc123edgfh" (next calls will be made as the authenticated user using this key)
|
56
56
|
|
57
|
-
Tumbz::Review.create(:product_external_id => "tt0458339", :positive => "1", :cat => "movie")
|
57
|
+
review = Tumbz::Review.create(:product_external_id => "tt0458339", :positive => "1", :cat => "movie")
|
58
58
|
# => #<Tumbz::Review(reviews/50b9ebd7a9d29c000200af7c) id="50b9ebd7a9d29c000200af7c" positive=true text=""…>
|
59
59
|
|
60
60
|
Tumbz::User.sign_out!
|
61
|
+
# => true (next calls will be made anonymously)
|
62
|
+
|
63
|
+
review = Tumbz::Review.create(:product_external_id => "tt0458339", :positive => "1", :cat => "movie")
|
64
|
+
# => #<Tumbz::Review(reviews)>
|
65
|
+
review.errors
|
66
|
+
# => ["Token is invalid or expired"]
|
67
|
+
```
|
68
|
+
|
69
|
+
You don’t need to use `User.sign_in!` each time, you can also set the `access_token` manually (eg. if you store it in a session):
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
Tumbz.access_token = "abc123edgfh"
|
73
|
+
review = Tumbz::Review.create(:product_external_id => "tt0458339", :positive => "1", :cat => "movie")
|
74
|
+
# => #<Tumbz::Review(reviews/50b9ebd7a9d29c000200af7c) id="50b9ebd7a9d29c000200af7c" positive=true text=""…>
|
61
75
|
```
|
62
76
|
|
63
77
|
## Contributing
|
data/lib/tumbz/model.rb
CHANGED
data/lib/tumbz/partner_lookup.rb
CHANGED
data/lib/tumbz/product.rb
CHANGED
data/lib/tumbz/user.rb
CHANGED
@@ -3,17 +3,17 @@ module Tumbz
|
|
3
3
|
include Model
|
4
4
|
include Her::Model
|
5
5
|
uses_api Tumbz.api
|
6
|
+
custom_get :search
|
6
7
|
|
7
8
|
def self.sign_in!(email, password)
|
8
9
|
post_raw("auth", :email => email, :password => password) do |parsed_data|
|
9
10
|
Tumbz.access_token = parsed_data[:data][:access_token]
|
10
11
|
end
|
11
|
-
|
12
|
-
Tumbz.access_token.nil? ? false : true
|
13
12
|
end
|
14
13
|
|
15
14
|
def self.sign_out!
|
16
15
|
Tumbz.access_token = nil
|
16
|
+
Tumbz.access_token.nil?
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/tumbz/version.rb
CHANGED
data/lib/tumbz.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Dependencies
|
2
|
-
require "
|
3
|
-
Bundler.require
|
2
|
+
require "her"
|
4
3
|
|
5
4
|
# Modules
|
6
5
|
require "tumbz/version"
|
@@ -29,9 +28,12 @@ module Tumbz
|
|
29
28
|
|
30
29
|
@api = Her::API.new
|
31
30
|
@api.setup :url => "http://api.tum.bz/v1/" do |connection|
|
31
|
+
# Request middleware
|
32
32
|
connection.use Tumbz::Middleware::ApiKey, :api_key => options.api_key
|
33
33
|
connection.use Tumbz::Middleware::Auth
|
34
34
|
connection.use Faraday::Request::UrlEncoded
|
35
|
+
|
36
|
+
# Response middleware
|
35
37
|
connection.use Tumbz::Middleware::Parse
|
36
38
|
connection.use Faraday::Adapter::NetHttp
|
37
39
|
end
|
@@ -42,5 +44,6 @@ module Tumbz
|
|
42
44
|
require "tumbz/partner_lookup"
|
43
45
|
require "tumbz/product"
|
44
46
|
require "tumbz/user"
|
47
|
+
require "tumbz/user_suggestion"
|
45
48
|
end
|
46
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tumbz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/tumbz/product.rb
|
52
52
|
- lib/tumbz/review.rb
|
53
53
|
- lib/tumbz/user.rb
|
54
|
+
- lib/tumbz/user_suggestion.rb
|
54
55
|
- lib/tumbz/version.rb
|
55
56
|
- tumbz.gemspec
|
56
57
|
homepage: ''
|
@@ -65,18 +66,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
66
|
- - ! '>='
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: '0'
|
68
|
-
segments:
|
69
|
-
- 0
|
70
|
-
hash: -3848226679834362904
|
71
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
70
|
none: false
|
73
71
|
requirements:
|
74
72
|
- - ! '>='
|
75
73
|
- !ruby/object:Gem::Version
|
76
74
|
version: '0'
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
hash: -3848226679834362904
|
80
75
|
requirements: []
|
81
76
|
rubyforge_project:
|
82
77
|
rubygems_version: 1.8.23
|
@@ -84,3 +79,4 @@ signing_key:
|
|
84
79
|
specification_version: 3
|
85
80
|
summary: Ruby wrapper for the Tum.bz API
|
86
81
|
test_files: []
|
82
|
+
has_rdoc:
|