sayso-api-client 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sayso.rb +8 -2
- data/sayso-api-client.gemspec +1 -1
- metadata +68 -49
data/lib/sayso.rb
CHANGED
@@ -3,7 +3,8 @@ require 'crack'
|
|
3
3
|
require 'active_support/all'
|
4
4
|
#
|
5
5
|
# Example usage:
|
6
|
-
# sayso = Sayso.new(:consumer_key => 'your_key', :consumer_secret => 'your_secret', :callback
|
6
|
+
# sayso = Sayso.new(:consumer_key => 'your_key', :consumer_secret => 'your_secret', :callback => 'http://localhost:3000')
|
7
|
+
# sayso = Sayso.new(:consumer_key => sayso_key, :consumer_secret => sayso_secret, :callback => 'http://localhost:3000')
|
7
8
|
# sayso.get("/places/search?what=restaurant&where=antwerpen")
|
8
9
|
# sayso.get("/places/search", :what => 'restaurant', :where => 'antwerpen')
|
9
10
|
# sayso.authorize_url # go here (=> "http://api.sayso.com/api1/oauth/authorize?oauth_token=some_token_hash")
|
@@ -65,12 +66,17 @@ class Sayso
|
|
65
66
|
# Gets from the Sayso API and returns the parsed XML.
|
66
67
|
# Access the unparsed response using the response method.
|
67
68
|
# Examples:
|
68
|
-
# get("/places/search?what=restaurant&where=antwerpen")
|
69
|
+
# get("/places/search?what=restaurant&where=antwerpen&base_country=BE")
|
69
70
|
# get("/places/search", :what => 'restaurant', :where => 'antwerpen', :base_country => 'BE')
|
70
71
|
def get(path, params = {})
|
72
|
+
params = params.with_indifferent_access
|
73
|
+
# We should always include a base_country in searches.
|
74
|
+
raise ArgumentError, "You should add a :country parameter to a search request to prevent weird/incorrect replies." if path =~ /^\/places\/search/ && !(params.include?(:base_country) || path =~ /(\?|&)base\_country\=/)
|
75
|
+
|
71
76
|
path = "/api#{self.version}#{path}"
|
72
77
|
path += "?#{params.to_query}" unless params.blank?
|
73
78
|
@response = @access_token.get(path)
|
79
|
+
raise StandardError, "Got non 200 HTTP response from SaySo" if not @response.code == '200'
|
74
80
|
result = Crack::XML.parse(@response.body)
|
75
81
|
HashWithIndifferentAccess.new(result)
|
76
82
|
end
|
data/sayso-api-client.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = %q{sayso-api-client}
|
5
|
-
spec.version = '0.1.
|
5
|
+
spec.version = '0.1.3'
|
6
6
|
spec.platform = Gem::Platform::RUBY
|
7
7
|
spec.description = spec.summary = 'Ruby gem to use the SaySo API (v1).'
|
8
8
|
spec.authors = ['Joost Hietbrink']
|
metadata
CHANGED
@@ -1,81 +1,100 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sayso-api-client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Joost Hietbrink
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2012-04-02 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: oauth
|
16
|
-
requirement: &70305012430520 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
33
30
|
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: crack
|
34
34
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
44
42
|
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: activesupport
|
45
46
|
prerelease: false
|
46
|
-
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
47
56
|
description: Ruby gem to use the SaySo API (v1).
|
48
57
|
email: joost@truvolabs.com
|
49
58
|
executables: []
|
59
|
+
|
50
60
|
extensions: []
|
61
|
+
|
51
62
|
extra_rdoc_files: []
|
52
|
-
|
63
|
+
|
64
|
+
files:
|
53
65
|
- Gemfile
|
54
66
|
- README.rdoc
|
55
67
|
- lib/sayso.rb
|
56
68
|
- sayso-api-client.gemspec
|
69
|
+
has_rdoc: true
|
57
70
|
homepage: http://www.sayso.com
|
58
71
|
licenses: []
|
72
|
+
|
59
73
|
post_install_message:
|
60
74
|
rdoc_options: []
|
61
|
-
|
75
|
+
|
76
|
+
require_paths:
|
62
77
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
75
92
|
requirements: []
|
93
|
+
|
76
94
|
rubyforge_project:
|
77
|
-
rubygems_version: 1.
|
95
|
+
rubygems_version: 1.3.6
|
78
96
|
signing_key:
|
79
97
|
specification_version: 3
|
80
98
|
summary: Ruby gem to use the SaySo API (v1).
|
81
99
|
test_files: []
|
100
|
+
|