ringioAPI 0.0.8 → 0.0.9
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/README.mkdn +4 -4
- data/lib/ringioAPI/contact.rb +54 -0
- data/lib/ringioAPI/note.rb +46 -1
- data/lib/ringioAPI/ring.rb +32 -0
- data/lib/ringioAPI/user.rb +6 -1
- data/lib/ringioAPI/version.rb +1 -1
- data/lib/ringioAPI.rb +1 -0
- data/ringioAPI.gemspec +1 -1
- metadata +7 -6
data/README.mkdn
CHANGED
@@ -8,7 +8,7 @@ Provides a wrapper for the [API of Ringio][ringio] in Ruby, using classes that i
|
|
8
8
|
|
9
9
|
Available classes at the moment are:
|
10
10
|
|
11
|
-
Contact, Feed, Note, User
|
11
|
+
Contact, Feed, Note, Ring, User
|
12
12
|
|
13
13
|
|
14
14
|
## Installing
|
@@ -29,7 +29,7 @@ You can configure the API token like this:
|
|
29
29
|
require 'ringioAPI'
|
30
30
|
RingioAPI::Base.user = 'RINGIO API TOKEN'
|
31
31
|
|
32
|
-
Currently there is a bug in Rails 3.0.
|
32
|
+
Currently there is a bug in Rails 3.0.X that makes JSON objects be parsed wrong.
|
33
33
|
Check the possible solutions and patches in [the corresponding thread in the Rails forums for developers][bug]
|
34
34
|
|
35
35
|
|
@@ -51,7 +51,7 @@ In the root of the project, run:
|
|
51
51
|
|
52
52
|
For example, to get the contact with id = 14 :
|
53
53
|
|
54
|
-
contact14 =
|
54
|
+
contact14 = RingioAPI::Contact.find(14)
|
55
55
|
|
56
56
|
To change the title of that contact:
|
57
57
|
|
@@ -64,7 +64,7 @@ To destroy that contact:
|
|
64
64
|
|
65
65
|
To create a Contact for the user with person_id = 78 :
|
66
66
|
|
67
|
-
newContact =
|
67
|
+
newContact = RingioAPI::Contact.new(:name => 'New contact name', :userId => 78)
|
68
68
|
newContact.save
|
69
69
|
|
70
70
|
If you have problems, check Ringio API specifications for details.
|
data/lib/ringioAPI/contact.rb
CHANGED
@@ -1,6 +1,60 @@
|
|
1
1
|
module RingioAPI
|
2
2
|
|
3
3
|
class Contact < Base
|
4
|
+
|
5
|
+
# override methods as a TEMPORARY solution of the JSON parsing bugs of Rails
|
6
|
+
|
7
|
+
# move the nested resource to the root
|
8
|
+
def self.find(contact_id)
|
9
|
+
super(contact_id).contact
|
10
|
+
end
|
11
|
+
|
12
|
+
def save
|
13
|
+
|
14
|
+
# change the array of Datum objects to an array of hashes just to make it easy to parse as JSON
|
15
|
+
new_data = []
|
16
|
+
begin
|
17
|
+
old_data = self.data
|
18
|
+
self.data.each do |d|
|
19
|
+
if d
|
20
|
+
new_data << {:type => d.type, :value => d.value, :is_primary => d.is_primary, :rel => d.rel}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
self.data = new_data
|
24
|
+
rescue NoMethodError
|
25
|
+
end
|
26
|
+
|
27
|
+
result = super
|
28
|
+
|
29
|
+
# restore the array of Datums
|
30
|
+
begin
|
31
|
+
self.data = old_data
|
32
|
+
rescue NoMethodError
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# move the fields returned after an update response to their proper place in the root
|
37
|
+
begin
|
38
|
+
self.id = self.contact.id
|
39
|
+
rescue NoMethodError
|
40
|
+
end
|
41
|
+
begin
|
42
|
+
self.last_updated = self.contact.last_updated
|
43
|
+
rescue NoMethodError
|
44
|
+
end
|
45
|
+
begin
|
46
|
+
self.date_created = self.contact.last_updated
|
47
|
+
rescue NoMethodError
|
48
|
+
end
|
49
|
+
|
50
|
+
# clean the unused nested resource
|
51
|
+
begin
|
52
|
+
self.contact = nil
|
53
|
+
rescue NoMethodError
|
54
|
+
end
|
55
|
+
|
56
|
+
result
|
57
|
+
end
|
4
58
|
|
5
59
|
end
|
6
60
|
|
data/lib/ringioAPI/note.rb
CHANGED
@@ -1,7 +1,52 @@
|
|
1
1
|
module RingioAPI
|
2
2
|
|
3
3
|
class Note < Base
|
4
|
-
|
4
|
+
|
5
|
+
# override methods as a temporary solution of the JSON parsing bugs of Rails
|
6
|
+
def self.find(note_id)
|
7
|
+
super(note_id).note
|
8
|
+
end
|
9
|
+
|
10
|
+
def save
|
11
|
+
|
12
|
+
result = super
|
13
|
+
|
14
|
+
# move the fields returned after an update response to their proper place in the root
|
15
|
+
begin
|
16
|
+
self.id = self.note.id
|
17
|
+
rescue NoMethodError
|
18
|
+
end
|
19
|
+
begin
|
20
|
+
self.contact_id = self.note.contact_id
|
21
|
+
rescue NoMethodError
|
22
|
+
end
|
23
|
+
begin
|
24
|
+
self.author_id = self.note.author_id
|
25
|
+
rescue NoMethodError
|
26
|
+
end
|
27
|
+
begin
|
28
|
+
self.body = self.note.body
|
29
|
+
rescue NoMethodError
|
30
|
+
end
|
31
|
+
begin
|
32
|
+
self.last_updated = self.note.last_updated
|
33
|
+
rescue NoMethodError
|
34
|
+
end
|
35
|
+
begin
|
36
|
+
self.date_created = self.note.last_updated
|
37
|
+
rescue NoMethodError
|
38
|
+
end
|
39
|
+
|
40
|
+
# clean the unused nested resource
|
41
|
+
begin
|
42
|
+
self.note = nil
|
43
|
+
rescue NoMethodError
|
44
|
+
end
|
45
|
+
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
49
|
+
|
5
50
|
end
|
6
51
|
|
7
52
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RingioAPI
|
2
|
+
|
3
|
+
class Ring < Base
|
4
|
+
|
5
|
+
# override methods as a temporary solution of the JSON parsing bugs of Rails
|
6
|
+
def self.find(ring_id)
|
7
|
+
super(ring_id).ring
|
8
|
+
end
|
9
|
+
|
10
|
+
def save
|
11
|
+
|
12
|
+
result = super
|
13
|
+
|
14
|
+
# move the fields returned after an update response to their proper place in the root
|
15
|
+
begin
|
16
|
+
self.id = self.ring.id
|
17
|
+
rescue NoMethodError
|
18
|
+
end
|
19
|
+
|
20
|
+
# clean the unused nested resource
|
21
|
+
begin
|
22
|
+
self.ring = nil
|
23
|
+
rescue NoMethodError
|
24
|
+
end
|
25
|
+
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/ringioAPI/user.rb
CHANGED
data/lib/ringioAPI/version.rb
CHANGED
data/lib/ringioAPI.rb
CHANGED
data/ringioAPI.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
9
9
|
|
10
10
|
spec.required_rubygems_version = ">= 1.3.6"
|
11
|
-
spec.add_dependency "activeresource", "
|
11
|
+
spec.add_dependency "activeresource", ">= 3.0.3"
|
12
12
|
|
13
13
|
spec.files = Dir['*'] + Dir['lib/*.rb'] + Dir['lib/ringioAPI/*.rb']
|
14
14
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "\xC3\x81lvaro Mart\xC3\xADn Fraguas"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-13 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -23,13 +23,13 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 3
|
30
30
|
- 0
|
31
|
-
-
|
32
|
-
version: 3.0.
|
31
|
+
- 3
|
32
|
+
version: 3.0.3
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
description: "\tIMPORTANT: this project has just started, so the functionality is not complete yet.\n Provides a wrapper for the Ringio API in Ruby, using ActiveResource.\n\n You can configure it for example by adding a file with this in config/initializers/ :\n\n require 'ringioAPI'\n RingioAPI::Base.user = 'RINGIO API TOKEN'\n"
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/ringioAPI.rb
|
49
49
|
- lib/ringioAPI/version.rb
|
50
50
|
- lib/ringioAPI/feed.rb
|
51
|
+
- lib/ringioAPI/ring.rb
|
51
52
|
- lib/ringioAPI/base.rb
|
52
53
|
- lib/ringioAPI/user.rb
|
53
54
|
- lib/ringioAPI/note.rb
|