oos4ruby 0.1.1 → 0.1.2
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/History.txt +8 -0
- data/Manifest.txt +2 -0
- data/README.txt +54 -1
- data/lib/oos4ruby/bean.rb +3 -3
- data/lib/oos4ruby/collection.rb +85 -8
- data/lib/oos4ruby/contact.rb +5 -2
- data/lib/oos4ruby/contacts.rb +1 -5
- data/lib/oos4ruby/feed.rb +3 -1
- data/lib/oos4ruby/http_invoker.rb +10 -6
- data/lib/oos4ruby/media.rb +34 -0
- data/lib/oos4ruby/medias.rb +6 -0
- data/lib/oos4ruby/search.rb +1 -1
- data/lib/oos4ruby/site.rb +24 -10
- data/lib/oos4ruby/sites.rb +1 -5
- data/lib/oos4ruby/version.rb +1 -1
- data/lib/oos4ruby.rb +6 -2
- data/test/test_oos4ruby.rb +14 -1
- data/website/index.html +36 -6
- data/website/index.txt +28 -4
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1 +1,54 @@
|
|
1
|
-
|
1
|
+
oos4ruby is a ruby library to interact with the 11870 API.
|
2
|
+
|
3
|
+
== Installing
|
4
|
+
|
5
|
+
sudo gem install oos4ruby
|
6
|
+
|
7
|
+
== The basics
|
8
|
+
|
9
|
+
The class Oos4ruby::Oos is the endpoint to interact with the api. This class provides the authentication methods in addition to the search and user management methods.
|
10
|
+
|
11
|
+
oos = Oos4ruby::Oos.new
|
12
|
+
|
13
|
+
Authenticate as an application in order to perform searches or explore the user contents:
|
14
|
+
|
15
|
+
oos.auth_app 'your appToken', 'your secret key'
|
16
|
+
|
17
|
+
Authenticate as a user in order to manage his contents:
|
18
|
+
|
19
|
+
oos.auth_user 'user email in 11870.com', 'user authorization token'
|
20
|
+
|
21
|
+
How to perform a search inside 11870:
|
22
|
+
|
23
|
+
oos.search :q => 'cheap restaurants in new york'
|
24
|
+
|
25
|
+
How to obtain the services or places saved by a user:
|
26
|
+
|
27
|
+
#if your app is authenticated with this user authorization token
|
28
|
+
user = oos.user
|
29
|
+
#if your app is authenticated to expore contents
|
30
|
+
user = oos.user 'user slug in 11870'
|
31
|
+
|
32
|
+
sites = user.sites.entries
|
33
|
+
|
34
|
+
How to add a review from a site that doesn't exist in 11870:
|
35
|
+
|
36
|
+
oos.user.sites.create! {:title => 'this site doesn't exist',
|
37
|
+
:user_address => 'the address',
|
38
|
+
:locality => {:name => 'Madrid', :slug => '/es/madrid'},
|
39
|
+
:country => {:name => 'España', :slug => '/es'},
|
40
|
+
:summary => 'review title', :content => 'review content',
|
41
|
+
:tags => ['tapas', 'tipical spanish'], :lists => ['food']}
|
42
|
+
|
43
|
+
How to add a review from a site that exists in 11870:
|
44
|
+
|
45
|
+
oos.user.sites.create! {:id => '11870 site id',
|
46
|
+
:summary => 'review title', :content => 'review content'}
|
47
|
+
|
48
|
+
How to obtain all user contacts in 11870:
|
49
|
+
|
50
|
+
contacts = user.contacts.entries
|
51
|
+
|
52
|
+
How to obtain the multimedia feed associated with a review:
|
53
|
+
|
54
|
+
media_collection = user.sites.entries[0].multimedia
|
data/lib/oos4ruby/bean.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
include Oos4ruby
|
2
2
|
|
3
|
-
module Bean
|
4
|
-
def self.append_features(base)
|
3
|
+
module Bean #:nodoc:
|
4
|
+
def self.append_features(base)
|
5
5
|
super
|
6
6
|
base.extend(ClassMethods)
|
7
7
|
end
|
8
8
|
|
9
|
-
module ClassMethods
|
9
|
+
module ClassMethods #:nodoc:
|
10
10
|
def define_el_reader(opts = {})
|
11
11
|
if !opts.empty?
|
12
12
|
opts.each_pair { |key, value|
|
data/lib/oos4ruby/collection.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
module Oos4ruby
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
This class wraps feed response. You must use its subclass, Oos4ruby::Sites, Oos4ruby::Contacts, Oos4ruby::Medias
|
5
|
+
|
6
|
+
API feed response is paginated, so, this class provides some methods to explore the feed.
|
7
|
+
=end
|
2
8
|
class Collection
|
3
9
|
|
4
10
|
attr_reader :entries
|
@@ -7,32 +13,69 @@ class Collection
|
|
7
13
|
@feed = feed
|
8
14
|
@auth = auth
|
9
15
|
@slug = slug
|
16
|
+
evalued_class = eval(self.class.name.gsub(/s$/, ''))
|
17
|
+
@entries = feed.entries.map {|entry| evalued_class.new(entry, @auth, @slug) }
|
10
18
|
end
|
11
|
-
|
19
|
+
|
20
|
+
=begin rdoc
|
21
|
+
returns true if next page exists into the feed
|
22
|
+
=end
|
12
23
|
def next_page?
|
13
24
|
@feed.next?
|
14
25
|
end
|
15
26
|
|
27
|
+
=begin rdoc
|
28
|
+
returns true if previous page exists into the feed
|
29
|
+
=end
|
16
30
|
def previous_page?
|
17
31
|
@feed.previous?
|
18
32
|
end
|
19
33
|
|
34
|
+
=begin rdoc
|
35
|
+
returns the next feed as a new Collection subclass.
|
36
|
+
=end
|
20
37
|
def next_page
|
21
38
|
return get_page(@feed.next) if next_page?
|
22
39
|
end
|
23
40
|
|
41
|
+
=begin rdoc
|
42
|
+
returns the previous feed as a new Collection subclass.
|
43
|
+
=end
|
24
44
|
def previous_page
|
25
45
|
return get_page(@feed.previous) if previous_page?
|
26
46
|
end
|
27
47
|
|
48
|
+
=begin rdoc
|
49
|
+
updats the current Collection with the next feed response.
|
50
|
+
=end
|
28
51
|
def next_page!
|
29
52
|
return get_page!(@feed.next)
|
30
53
|
end
|
31
54
|
|
55
|
+
=begin rdoc
|
56
|
+
updates the current Collection with the precious feed response.
|
57
|
+
=end
|
32
58
|
def previous!
|
33
59
|
return get_page!(@feed.previous)
|
34
60
|
end
|
35
61
|
|
62
|
+
=begin rdoc
|
63
|
+
returns the size of the current collection.
|
64
|
+
=end
|
65
|
+
def size
|
66
|
+
@feed.size
|
67
|
+
end
|
68
|
+
|
69
|
+
=begin rdoc
|
70
|
+
returns the total size of the feed.
|
71
|
+
=end
|
72
|
+
def total_size
|
73
|
+
@feed.total_size
|
74
|
+
end
|
75
|
+
|
76
|
+
=begin rdoc
|
77
|
+
return all entries into the feed.
|
78
|
+
=end
|
36
79
|
def all
|
37
80
|
all = @entries
|
38
81
|
aux = self
|
@@ -44,6 +87,9 @@ class Collection
|
|
44
87
|
return all
|
45
88
|
end
|
46
89
|
|
90
|
+
=begin rdoc
|
91
|
+
reload the current collection
|
92
|
+
=end
|
47
93
|
def refresh!
|
48
94
|
return get_page!(@feed.self_link)
|
49
95
|
end
|
@@ -52,19 +98,50 @@ class Collection
|
|
52
98
|
@entries.join("\n")
|
53
99
|
end
|
54
100
|
|
101
|
+
=begin rdoc
|
102
|
+
method to create a resource into a collection.
|
103
|
+
opts available keys:
|
104
|
+
* if you want to create a Site:
|
105
|
+
:id => 11870 service/place id if it already exists in 11780
|
106
|
+
if the service/place doesn't exit in 11870 then
|
107
|
+
:title => service/place name (required)
|
108
|
+
:user_address (required)
|
109
|
+
:url (optional)
|
110
|
+
:telephone (optional)
|
111
|
+
:locality => a hash with :name and :slug (required)
|
112
|
+
:country => a hash with :name and :slug (required)
|
113
|
+
:summary => review title
|
114
|
+
:content or :review_content => review_content
|
115
|
+
:privacy => a REXML::Element from 11870 privacy scheme or a string with "true" or "false"
|
116
|
+
:tags => an array of tags
|
117
|
+
:lists => an array of lists
|
118
|
+
* if you want to create a Contact:
|
119
|
+
:contact or :slug or :title => the new contact slug
|
120
|
+
:trusted => a REXML::Element from 11870 trusted scheme or one of the next strings => "public", "trustedContacts", "contacts", "private"
|
121
|
+
* if you want to create a Media:
|
122
|
+
:file => the new media file system path or a File object
|
123
|
+
:content_length => file size
|
124
|
+
:content_type => file content type
|
125
|
+
=end
|
55
126
|
def create!(opts = {})
|
56
127
|
opts[:author] = REXML::XPath.first(@feed.xml, 'author', XmlNamespaces)
|
57
128
|
|
58
|
-
|
59
|
-
|
129
|
+
evalued_class = eval(self.class.name.gsub(/s$/, ''))
|
130
|
+
body = evalued_class.dump! opts, @slug
|
131
|
+
unless self.instance_of?Medias
|
132
|
+
body = "<?xml version='1.0' ?>\n" + body.to_s
|
133
|
+
end
|
60
134
|
|
61
135
|
poster = HTTPInvoker.new( @feed.self_link, @auth)
|
62
136
|
|
63
|
-
|
137
|
+
content_type = opts[:content_type] || AtomEntryContentType
|
138
|
+
opts.reject {|k, v| k == :content_type}
|
139
|
+
opts.each {|k, v| poster.set_header(k, v)}
|
140
|
+
|
141
|
+
worked = poster.post content_type, body
|
64
142
|
|
65
143
|
raise RuntimeError.new unless worked
|
66
|
-
return
|
67
|
-
return Contact.new(poster.entry, @auth, @slug) if self.instance_of?Contacts
|
144
|
+
return evalued_class.new(poster.entry, @auth, @slug)
|
68
145
|
end
|
69
146
|
|
70
147
|
private
|
@@ -86,8 +163,8 @@ class Collection
|
|
86
163
|
end
|
87
164
|
|
88
165
|
def convert( body )
|
89
|
-
|
90
|
-
return
|
166
|
+
evalued_class = eval(self.class.name)
|
167
|
+
return evalued_class.new( Feed.read( body ), @auth, @slug )
|
91
168
|
end
|
92
169
|
|
93
170
|
end
|
data/lib/oos4ruby/contact.rb
CHANGED
@@ -42,8 +42,11 @@ class Contact < BeanClass
|
|
42
42
|
def Contact.dump!(opts, slug)
|
43
43
|
entry = create_entry
|
44
44
|
|
45
|
-
entry.add_element opts[:author]
|
46
|
-
|
45
|
+
entry.add_element opts[:author]
|
46
|
+
|
47
|
+
updated = DateTime::now.strftime("%Y-%m-%dT%H:%M:%S%z").sub(/(..)$/, ':\1')
|
48
|
+
|
49
|
+
add_element entry, 'updated', updated
|
47
50
|
add_element entry, 'id', make_id
|
48
51
|
|
49
52
|
add_element entry, 'title', (opts[:contact] || opts[:slug] || opts[:title])
|
data/lib/oos4ruby/contacts.rb
CHANGED
data/lib/oos4ruby/feed.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rexml/xpath'
|
|
4
4
|
module Oos4ruby
|
5
5
|
class Feed
|
6
6
|
|
7
|
-
attr_reader :previous, :next, :entries, :xml
|
7
|
+
attr_reader :previous, :next, :entries, :xml, :size, :total_size
|
8
8
|
|
9
9
|
def initialize(entries, xml)
|
10
10
|
@entries = entries
|
@@ -12,6 +12,8 @@ class Feed
|
|
12
12
|
@next = Feed.get_link('next', xml)
|
13
13
|
@previous = Feed.get_link 'previous', xml
|
14
14
|
@self = Feed.get_link 'self', xml
|
15
|
+
@size = REXML::XPath.first(xml, "./os:itemsPerPage/text()", XmlNamespaces)
|
16
|
+
@total_size = REXML::XPath.first(xml, "./os:totalResults/text()", XmlNamespaces)
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.get_link(rel, xml)
|
@@ -15,7 +15,7 @@ class HTTPInvoker
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def set_header(name, val)
|
18
|
-
@headers[name] = val
|
18
|
+
@headers[name.to_s.gsub(/_/, '-')] = val
|
19
19
|
end
|
20
20
|
|
21
21
|
def get(depth = 0, req = nil)
|
@@ -48,7 +48,12 @@ class HTTPInvoker
|
|
48
48
|
@headers.each { |k, v| req[k]= v }
|
49
49
|
|
50
50
|
http.start do |connection|
|
51
|
-
|
51
|
+
if body.instance_of?String
|
52
|
+
@response = connection.request(req, body)
|
53
|
+
else
|
54
|
+
req.body_stream = body
|
55
|
+
@response = connection.request(req)
|
56
|
+
end
|
52
57
|
|
53
58
|
return post(contentType, body, depth + 1, req) if need_authentication?(req)
|
54
59
|
|
@@ -113,12 +118,10 @@ class HTTPInvoker
|
|
113
118
|
unless req
|
114
119
|
url = @uri.path
|
115
120
|
url += "?#{@uri.query}" if @uri.query
|
116
|
-
req = Net::HTTP
|
117
|
-
req = Net::HTTP::Post.new( url ) if option == :post
|
118
|
-
req = Net::HTTP::Put.new( url ) if option == :put
|
119
|
-
req = Net::HTTP::Delete.new( url ) if option == :delete
|
121
|
+
req = eval("Net::HTTP::#{option.to_s.capitalize}").new( url )
|
120
122
|
end
|
121
123
|
|
124
|
+
@authent.add_to req
|
122
125
|
return http, req
|
123
126
|
end
|
124
127
|
|
@@ -126,6 +129,7 @@ class HTTPInvoker
|
|
126
129
|
if @response.instance_of?(Net::HTTPUnauthorized) && @authent
|
127
130
|
@authent.add_to req
|
128
131
|
req.body = nil unless req.body.nil?
|
132
|
+
req.body_stream = nil unless req.body_stream.nil?
|
129
133
|
return true
|
130
134
|
end
|
131
135
|
return false
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
include Bean
|
3
|
+
|
4
|
+
module Oos4ruby
|
5
|
+
class Media < Bean::BeanClass
|
6
|
+
|
7
|
+
define_el_reader AtomNamespace => [:title, :updated, :content]
|
8
|
+
|
9
|
+
attr_writer :title
|
10
|
+
|
11
|
+
def initialize(entry, auth, slug = nil)
|
12
|
+
@xml = entry
|
13
|
+
@auth = auth
|
14
|
+
@slug = slug || @xml.child('slug', OosNamespace).text
|
15
|
+
end
|
16
|
+
|
17
|
+
def Media.dump!(opts, slug)
|
18
|
+
if (opts[:file].instance_of?File)
|
19
|
+
file = opts[:file]
|
20
|
+
elsif (opts[:file].instance_of?String)
|
21
|
+
file = File.new( opts[:file ])
|
22
|
+
end
|
23
|
+
return file
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def load!
|
28
|
+
if @title
|
29
|
+
@xml.child('title').text = @title
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/oos4ruby/search.rb
CHANGED
@@ -5,7 +5,7 @@ module Oos4ruby
|
|
5
5
|
class Search
|
6
6
|
|
7
7
|
=begin rdoc
|
8
|
-
Method to search places into 11870
|
8
|
+
Method to search services/places into 11870. Returns a Sites collection
|
9
9
|
available parameters:
|
10
10
|
<tt>q</tt>:: string that represents a siple query.
|
11
11
|
<tt>bbox</tt>:: array of points that delimiters a rectangle, SW and NE.
|
data/lib/oos4ruby/site.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
require 'date'
|
2
3
|
include Bean
|
3
4
|
|
4
5
|
module Oos4ruby
|
@@ -21,13 +22,6 @@ class Site < Bean::BeanClass
|
|
21
22
|
|
22
23
|
attr_writer :review_title, :review_content, :user_address, :url, :locality, :telephone
|
23
24
|
|
24
|
-
def country=(name, slug)
|
25
|
-
@country = REXML::Element.new('oos:country')
|
26
|
-
@country.add_namespace('oos', OosNamespace)
|
27
|
-
@country.add_text name
|
28
|
-
@country.add_attribute 'slug', slug
|
29
|
-
end
|
30
|
-
|
31
25
|
def initialize(xml, auth, slug = nil)
|
32
26
|
@xml = xml
|
33
27
|
@auth = auth
|
@@ -40,6 +34,13 @@ class Site < Bean::BeanClass
|
|
40
34
|
@categories_removed = []
|
41
35
|
end
|
42
36
|
|
37
|
+
def country=(name, slug)
|
38
|
+
@country = REXML::Element.new('oos:country')
|
39
|
+
@country.add_namespace('oos', OosNamespace)
|
40
|
+
@country.add_text name
|
41
|
+
@country.add_attribute 'slug', slug
|
42
|
+
end
|
43
|
+
|
43
44
|
def Site.find_by_user( auth, slug, opts = {} )
|
44
45
|
raise Oos4ruby::UnknownUser if slug.nil?
|
45
46
|
|
@@ -57,12 +58,15 @@ class Site < Bean::BeanClass
|
|
57
58
|
|
58
59
|
entry.add_element opts[:author]
|
59
60
|
|
60
|
-
|
61
|
+
updated = DateTime::now.strftime("%Y-%m-%dT%H:%M:%S%z").sub(/(..)$/, ':\1')
|
62
|
+
|
63
|
+
add_element entry, 'updated', updated
|
61
64
|
add_element entry, 'id', make_id
|
62
65
|
add_element entry, 'oos:id', opts[:id] if opts[:id]
|
63
66
|
add_element entry, 'title', opts[:title] if opts[:title]
|
64
67
|
add_element entry, 'oos:useraddress', opts[:user_address] if opts[:user_address]
|
65
68
|
add_element entry, 'oos:url', opts[:url] if opts[:url]
|
69
|
+
add_element entry, 'oos:telephone', opts[:telephone] if opts[:telephone]
|
66
70
|
add_element entry, 'summary', opts[:review_title] if opts[:review_title]
|
67
71
|
add_element entry, 'summary', opts[:summary] if opts[:summary] and REXML::XPath.first(entry, 'summary', XmlNamespaces).nil?
|
68
72
|
|
@@ -110,8 +114,8 @@ class Site < Bean::BeanClass
|
|
110
114
|
add_element entry, 'oos:country', name, attrs
|
111
115
|
end
|
112
116
|
|
113
|
-
opts[:tags].each { |tag| add_category entry, tag
|
114
|
-
opts[:lists].each { |list| add_category entry, list
|
117
|
+
opts[:tags].each { |tag| add_category entry, tag, "#{TAGS_URL}/#{slug}"} if opts[:tags]
|
118
|
+
opts[:lists].each { |list| add_category entry, list, "#{LISTS_URL}/#{slug}"} if opts[:lists]
|
115
119
|
|
116
120
|
entry
|
117
121
|
end
|
@@ -178,6 +182,16 @@ class Site < Bean::BeanClass
|
|
178
182
|
@privacy_updated = privacy
|
179
183
|
end
|
180
184
|
|
185
|
+
def multimedia
|
186
|
+
href = @xml.first('./atom:source/app:collection').attributes['href']
|
187
|
+
|
188
|
+
getter = HTTPInvoker.new href, @auth
|
189
|
+
worked = getter.get
|
190
|
+
|
191
|
+
raise RuntimeError unless worked
|
192
|
+
Medias.new(Feed.read(getter.body), @auth, @slug)
|
193
|
+
end
|
194
|
+
|
181
195
|
private
|
182
196
|
def load!
|
183
197
|
if @title_review
|
data/lib/oos4ruby/sites.rb
CHANGED
data/lib/oos4ruby/version.rb
CHANGED
data/lib/oos4ruby.rb
CHANGED
@@ -41,6 +41,8 @@ require 'oos4ruby/contact.rb'
|
|
41
41
|
require 'oos4ruby/contacts.rb'
|
42
42
|
require 'oos4ruby/entry.rb'
|
43
43
|
require 'oos4ruby/feed.rb'
|
44
|
+
require 'oos4ruby/media.rb'
|
45
|
+
require 'oos4ruby/medias.rb'
|
44
46
|
require 'oos4ruby/oos.rb'
|
45
47
|
require 'oos4ruby/search.rb'
|
46
48
|
require 'oos4ruby/service.rb'
|
@@ -50,7 +52,7 @@ require 'oos4ruby/user.rb'
|
|
50
52
|
require 'oos4ruby/version.rb'
|
51
53
|
|
52
54
|
|
53
|
-
class String
|
55
|
+
class String #:nodoc:
|
54
56
|
def underscore
|
55
57
|
self.to_s.gsub(/::/, '/').
|
56
58
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
@@ -61,7 +63,8 @@ class String
|
|
61
63
|
end
|
62
64
|
|
63
65
|
require 'rexml/element'
|
64
|
-
|
66
|
+
module REXML #:nodoc:
|
67
|
+
class REXML::Element #:nodoc:
|
65
68
|
def add_category(term, scheme = nil, label = nil)
|
66
69
|
c = REXML::Element.new('category', self)
|
67
70
|
c.add_attribute('term', term)
|
@@ -70,3 +73,4 @@ class REXML::Element
|
|
70
73
|
c
|
71
74
|
end
|
72
75
|
end
|
76
|
+
end
|
data/test/test_oos4ruby.rb
CHANGED
@@ -7,7 +7,6 @@ oos = Oos4ruby::Oos.new
|
|
7
7
|
|
8
8
|
oos.auth_user('david.calavera@11870.com', 'asdf')
|
9
9
|
|
10
|
-
user = oos.user
|
11
10
|
puts user.name
|
12
11
|
puts user.surname
|
13
12
|
puts user.no_mails
|
@@ -73,6 +72,17 @@ site.update!
|
|
73
72
|
|
74
73
|
site.tags.each { |tag| puts "TAG : #{tag.term}, #{tag.scheme} "}
|
75
74
|
|
75
|
+
file_path = '/home/david/media_api_test.png'
|
76
|
+
|
77
|
+
medias = site.multimedia
|
78
|
+
|
79
|
+
media = medias.create!(:file => file_path,
|
80
|
+
:content_length => File.size(file_path), :content_type => 'image/png' )
|
81
|
+
|
82
|
+
puts media.to_s
|
83
|
+
site.multimedia.refresh!
|
84
|
+
|
85
|
+
puts site.multimedia.entries.to_s
|
76
86
|
|
77
87
|
class TestOos4ruby < Test::Unit::TestCase
|
78
88
|
|
@@ -82,4 +92,7 @@ class TestOos4ruby < Test::Unit::TestCase
|
|
82
92
|
def test_truth
|
83
93
|
assert true
|
84
94
|
end
|
95
|
+
|
96
|
+
|
85
97
|
end
|
98
|
+
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>oos4ruby</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oos4ruby"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.1.
|
36
|
+
<a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.1.2</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘oos4ruby’</h1>
|
39
39
|
|
@@ -77,23 +77,53 @@
|
|
77
77
|
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">search</span> <span class="symbol">:q</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">cheap restaurants in new york</span><span class="punct">'</span></pre></p>
|
78
78
|
|
79
79
|
|
80
|
-
<p>
|
80
|
+
<p>How to obtain the services or places saved by a user:</p>
|
81
81
|
|
82
82
|
|
83
83
|
<p><pre class='syntax'>
|
84
|
-
<span class="
|
85
|
-
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span>
|
84
|
+
<span class="comment">#if your app is authenticated with this user authorization token</span>
|
85
|
+
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span>
|
86
|
+
<span class="comment">#if your app is authenticated to expore contents</span>
|
87
|
+
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span> <span class="punct">'</span><span class="string">user slug in 11870</span><span class="punct">'</span>
|
86
88
|
|
87
89
|
<span class="ident">sites</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">entries</span>
|
88
90
|
</pre></p>
|
89
91
|
|
90
92
|
|
91
|
-
<p>
|
93
|
+
<p>How to add a review from a site that doesn’t exist in 11870:</p>
|
94
|
+
|
95
|
+
|
96
|
+
<p><pre class='syntax'>
|
97
|
+
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:title</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">this site doesn</span><span class="punct">'</span><span class="ident">t</span> <span class="ident">exist</span><span class="punct">'</span><span class="string">,
|
98
|
+
:user_address => </span><span class="punct">'</span><span class="ident">the</span> <span class="ident">address</span><span class="punct">'</span><span class="string">,
|
99
|
+
:locality => {:name => </span><span class="punct">'</span><span class="constant">Madrid</span><span class="punct">'</span><span class="string">, :slug => </span><span class="punct">'/</span><span class="ident">es</span><span class="punct">/</span><span class="ident">madrid</span><span class="punct">'</span><span class="string">},
|
100
|
+
:country => {:name => </span><span class="punct">'</span><span class="constant">Españ</span><span class="ident">a</span><span class="punct">'</span><span class="string">, :slug => </span><span class="punct">'/</span><span class="ident">es</span><span class="punct">'</span><span class="string">}
|
101
|
+
:summary => </span><span class="punct">'</span><span class="ident">review</span> <span class="ident">title</span><span class="punct">'</span><span class="string">, :content => </span><span class="punct">'</span><span class="ident">review</span> <span class="ident">content</span><span class="punct">'</span><span class="string">
|
102
|
+
:tags => [</span><span class="punct">'</span><span class="ident">tapas</span><span class="punct">'</span><span class="string">, </span><span class="punct">'</span><span class="ident">tipical</span> <span class="ident">spanish</span><span class="punct">'</span><span class="string">], :lists => [</span><span class="punct">'</span><span class="ident">food</span><span class="punct">'</span><span class="string">]}<span class="normal">
|
103
|
+
</span></span></pre></p>
|
104
|
+
|
105
|
+
|
106
|
+
<p>How to add a review from a site that exists in 11870:</p>
|
107
|
+
|
108
|
+
|
109
|
+
<p><pre class='syntax'>
|
110
|
+
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:id</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">11870 site id</span><span class="punct">',</span>
|
111
|
+
<span class="symbol">:summary</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">review title</span><span class="punct">',</span> <span class="symbol">:content</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">review content</span><span class="punct">'}</span>
|
112
|
+
</pre></p>
|
113
|
+
|
114
|
+
|
115
|
+
<p>How to obtain all user contacts in 11870:</p>
|
92
116
|
|
93
117
|
|
94
118
|
<p><pre class='syntax'><span class="ident">contacts</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">contacts</span><span class="punct">.</span><span class="ident">entries</span></pre></p>
|
95
119
|
|
96
120
|
|
121
|
+
<p>How to obtain the multimedia feed associated with a review:</p>
|
122
|
+
|
123
|
+
|
124
|
+
<p><pre class='syntax'><span class="ident">media_collection</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">entries</span><span class="punct">[</span><span class="number">0</span><span class="punct">].</span><span class="ident">multimedia</span></pre></p>
|
125
|
+
|
126
|
+
|
97
127
|
<h2>Forum</h2>
|
98
128
|
|
99
129
|
|
@@ -120,7 +150,7 @@
|
|
120
150
|
|
121
151
|
<p>Comments are welcome. Send an email to <a href="mailto:david.calavera@gmail.com">David Calavera</a> email via the <a href="http://groups.google.com/group/api-11870">forum</a></p>
|
122
152
|
<p class="coda">
|
123
|
-
<a href="FIXME email">David Calavera</a>,
|
153
|
+
<a href="FIXME email">David Calavera</a>, 16th October 2007<br>
|
124
154
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
125
155
|
</p>
|
126
156
|
</div>
|
data/website/index.txt
CHANGED
@@ -29,19 +29,43 @@ Method to perform a search inside 11870:
|
|
29
29
|
|
30
30
|
<pre syntax="ruby">oos.search :q => 'cheap restaurants in new york'</pre>
|
31
31
|
|
32
|
-
|
32
|
+
How to obtain the services or places saved by a user:
|
33
33
|
|
34
34
|
<pre syntax="ruby">
|
35
|
-
|
36
|
-
user = oos.user
|
35
|
+
#if your app is authenticated with this user authorization token
|
36
|
+
user = oos.user
|
37
|
+
#if your app is authenticated to expore contents
|
38
|
+
user = oos.user 'user slug in 11870'
|
37
39
|
|
38
40
|
sites = user.sites.entries
|
39
41
|
</pre>
|
40
42
|
|
41
|
-
|
43
|
+
How to add a review from a site that doesn't exist in 11870:
|
44
|
+
|
45
|
+
<pre syntax="ruby">
|
46
|
+
oos.user.sites.create! {:title => 'this site doesn't exist',
|
47
|
+
:user_address => 'the address',
|
48
|
+
:locality => {:name => 'Madrid', :slug => '/es/madrid'},
|
49
|
+
:country => {:name => 'España', :slug => '/es'}
|
50
|
+
:summary => 'review title', :content => 'review content'
|
51
|
+
:tags => ['tapas', 'tipical spanish'], :lists => ['food']}
|
52
|
+
</pre>
|
53
|
+
|
54
|
+
How to add a review from a site that exists in 11870:
|
55
|
+
|
56
|
+
<pre syntax="ruby">
|
57
|
+
oos.user.sites.create! {:id => '11870 site id',
|
58
|
+
:summary => 'review title', :content => 'review content'}
|
59
|
+
</pre>
|
60
|
+
|
61
|
+
How to obtain all user contacts in 11870:
|
42
62
|
|
43
63
|
<pre syntax="ruby">contacts = user.contacts.entries</pre>
|
44
64
|
|
65
|
+
How to obtain the multimedia feed associated with a review:
|
66
|
+
|
67
|
+
<pre syntax="ruby">media_collection = user.sites.entries[0].multimedia</pre>
|
68
|
+
|
45
69
|
h2. Forum
|
46
70
|
|
47
71
|
"http://groups.google.com/group/api-11870":http://groups.google.com/group/api-11870
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: oos4ruby
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.1.2
|
7
|
+
date: 2007-10-16 00:00:00 +02:00
|
8
8
|
summary: oos4ruby is a ruby binding for the 11870 API
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -46,6 +46,8 @@ files:
|
|
46
46
|
- lib/oos4ruby/entry.rb
|
47
47
|
- lib/oos4ruby/feed.rb
|
48
48
|
- lib/oos4ruby/http_invoker.rb
|
49
|
+
- lib/oos4ruby/media.rb
|
50
|
+
- lib/oos4ruby/medias.rb
|
49
51
|
- lib/oos4ruby/oos.rb
|
50
52
|
- lib/oos4ruby/search.rb
|
51
53
|
- lib/oos4ruby/service.rb
|