amiando 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/amiando.gemspec +1 -1
- data/lib/amiando/event.rb +3 -3
- data/lib/amiando/partner.rb +2 -2
- data/lib/amiando/resource.rb +1 -1
- data/lib/amiando/ticket_shop.rb +1 -1
- data/lib/amiando/user.rb +2 -2
- data/lib/amiando/version.rb +1 -1
- data/test/amiando/resource_test.rb +27 -2
- data/test/support/hydra_monkey_patch.rb +11 -0
- data/test/test_helper.rb +1 -0
- metadata +13 -11
data/amiando.gemspec
CHANGED
data/lib/amiando/event.rb
CHANGED
@@ -27,7 +27,7 @@ module Amiando
|
|
27
27
|
def self.create(attributes)
|
28
28
|
object = new
|
29
29
|
post object, '/api/event/create',
|
30
|
-
:params =>
|
30
|
+
:params => attributes,
|
31
31
|
:populate_method => :populate_create
|
32
32
|
|
33
33
|
object
|
@@ -39,10 +39,10 @@ module Amiando
|
|
39
39
|
# @param id
|
40
40
|
# @param [Hash] attributes
|
41
41
|
#
|
42
|
-
# @return [
|
42
|
+
# @return [Result] if it was successful or not.
|
43
43
|
def self.update(id, attributes)
|
44
44
|
object = Result.new
|
45
|
-
post object, "/api/event/#{id}", :params =>
|
45
|
+
post object, "/api/event/#{id}", :params => attributes
|
46
46
|
|
47
47
|
object
|
48
48
|
end
|
data/lib/amiando/partner.rb
CHANGED
@@ -19,7 +19,7 @@ module Amiando
|
|
19
19
|
def self.create(attributes)
|
20
20
|
object = new
|
21
21
|
post object, '/api/partner/create',
|
22
|
-
:params =>
|
22
|
+
:params => attributes,
|
23
23
|
:populate_method => :populate_create
|
24
24
|
|
25
25
|
object
|
@@ -34,7 +34,7 @@ module Amiando
|
|
34
34
|
# @return [Result] saying if the update was successful
|
35
35
|
def self.update(id, attributes)
|
36
36
|
object = Result.new
|
37
|
-
post object, "/api/partner/#{id}", :params =>
|
37
|
+
post object, "/api/partner/#{id}", :params => attributes
|
38
38
|
|
39
39
|
object
|
40
40
|
end
|
data/lib/amiando/resource.rb
CHANGED
@@ -57,7 +57,7 @@ module Amiando
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def do_request(object, verb, path, options = {})
|
60
|
-
req = Request.new(object, verb, path, options[:params] || {})
|
60
|
+
req = Request.new(object, verb, path, map_params(options[:params] || {}))
|
61
61
|
object.request = req
|
62
62
|
|
63
63
|
req.log_request
|
data/lib/amiando/ticket_shop.rb
CHANGED
@@ -49,7 +49,7 @@ module Amiando
|
|
49
49
|
# @return [Boolean] deferred object indicating the result of the update.
|
50
50
|
def self.update(event_id, attributes)
|
51
51
|
object = Boolean.new('success')
|
52
|
-
post object, "/api/event/#{event_id}/ticketShop", :params =>
|
52
|
+
post object, "/api/event/#{event_id}/ticketShop", :params => attributes
|
53
53
|
|
54
54
|
object
|
55
55
|
end
|
data/lib/amiando/user.rb
CHANGED
@@ -42,7 +42,7 @@ module Amiando
|
|
42
42
|
def self.create(attributes)
|
43
43
|
object = new
|
44
44
|
post object, '/api/user/create',
|
45
|
-
:params =>
|
45
|
+
:params => attributes,
|
46
46
|
:populate_method => :populate_create
|
47
47
|
|
48
48
|
object
|
@@ -56,7 +56,7 @@ module Amiando
|
|
56
56
|
# @param [String] username
|
57
57
|
def self.update(user_id, attributes)
|
58
58
|
object = Boolean.new('success')
|
59
|
-
post object, "/api/user/#{user_id}", :params =>
|
59
|
+
post object, "/api/user/#{user_id}", :params => attributes
|
60
60
|
|
61
61
|
object
|
62
62
|
end
|
data/lib/amiando/version.rb
CHANGED
@@ -6,11 +6,23 @@ describe Amiando::Resource do
|
|
6
6
|
map :last_name , :lastName
|
7
7
|
map :creation, :creation, :type => :time
|
8
8
|
|
9
|
-
def self.create
|
9
|
+
def self.create(params = {})
|
10
10
|
object = new
|
11
|
-
post object, 'somewhere', :populate_method => :populate_create
|
11
|
+
post object, 'somewhere', :params => params, :populate_method => :populate_create
|
12
12
|
object
|
13
13
|
end
|
14
|
+
|
15
|
+
def self.find(id)
|
16
|
+
object = new
|
17
|
+
get object, 'somewhere', :populate_method => :populate_test
|
18
|
+
object
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def populate_test(body)
|
24
|
+
extract_attributes_from(body, 'wadus')
|
25
|
+
end
|
14
26
|
end
|
15
27
|
|
16
28
|
it 'raises error when amiando is down' do
|
@@ -68,6 +80,19 @@ describe Amiando::Resource do
|
|
68
80
|
Wadus.reverse_map_params(:creation => '1970-01-01T00:00:00Z').must_equal expected
|
69
81
|
end
|
70
82
|
|
83
|
+
it 'automatically maps attributes for a request' do
|
84
|
+
result = Wadus.create :first_name => 'George'
|
85
|
+
result.request.params.must_equal(:firstName => 'George')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'automatically reverse maps attributes on responses' do
|
89
|
+
stub_request(:any, /somewhere/).to_return(:status => 200, :body => '{"wadus":{"firstName":"George"}}')
|
90
|
+
result = Wadus.find(1)
|
91
|
+
Amiando.run
|
92
|
+
|
93
|
+
result.attributes.must_equal(:first_name => "George")
|
94
|
+
end
|
95
|
+
|
71
96
|
describe 'synchronous calls' do
|
72
97
|
it 'accepts synchronous calls' do
|
73
98
|
stub_request(:post, /somewhere/).to_return(:status => 200, :body => '{"success":true}')
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amiando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jorge Dias
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
20
|
-
default_executable:
|
19
|
+
date: 2011-12-19 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: typhoeus
|
@@ -69,12 +68,14 @@ dependencies:
|
|
69
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
69
|
none: false
|
71
70
|
requirements:
|
72
|
-
- -
|
71
|
+
- - ~>
|
73
72
|
- !ruby/object:Gem::Version
|
74
|
-
hash:
|
73
|
+
hash: 7
|
75
74
|
segments:
|
76
|
-
-
|
77
|
-
|
75
|
+
- 1
|
76
|
+
- 7
|
77
|
+
- 6
|
78
|
+
version: 1.7.6
|
78
79
|
type: :development
|
79
80
|
version_requirements: *id004
|
80
81
|
- !ruby/object:Gem::Dependency
|
@@ -222,8 +223,8 @@ files:
|
|
222
223
|
- test/fixtures/User/efb3543620c2a1753972b79b1a747b00.yml
|
223
224
|
- test/support/factory.rb
|
224
225
|
- test/support/hydra_cache.rb
|
226
|
+
- test/support/hydra_monkey_patch.rb
|
225
227
|
- test/test_helper.rb
|
226
|
-
has_rdoc: true
|
227
228
|
homepage: ""
|
228
229
|
licenses: []
|
229
230
|
|
@@ -253,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
254
|
requirements: []
|
254
255
|
|
255
256
|
rubyforge_project: amiando
|
256
|
-
rubygems_version: 1.
|
257
|
+
rubygems_version: 1.8.10
|
257
258
|
signing_key:
|
258
259
|
specification_version: 3
|
259
260
|
summary: A ruby client for the amiando REST API
|
@@ -356,4 +357,5 @@ test_files:
|
|
356
357
|
- test/fixtures/User/efb3543620c2a1753972b79b1a747b00.yml
|
357
358
|
- test/support/factory.rb
|
358
359
|
- test/support/hydra_cache.rb
|
360
|
+
- test/support/hydra_monkey_patch.rb
|
359
361
|
- test/test_helper.rb
|