streetcred 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/streetcred/version.rb +1 -1
- data/lib/streetcred.rb +11 -7
- data/spec/streetcred_spec.rb +7 -6
- data/streetcred.gemspec +1 -0
- metadata +18 -2
data/lib/streetcred/version.rb
CHANGED
data/lib/streetcred.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'streetcred/version'
|
2
2
|
require 'koala'
|
3
|
+
require 'active_support'
|
3
4
|
|
4
5
|
module StreetCred
|
5
6
|
class Handler
|
@@ -13,7 +14,16 @@ module StreetCred
|
|
13
14
|
def handle(params)
|
14
15
|
validate_signed_request(params[:signed_request])
|
15
16
|
|
16
|
-
if params[:
|
17
|
+
if params[:order_details]
|
18
|
+
order_details = ActiveSupport::JSON.decode(params[:order_details])
|
19
|
+
response = {
|
20
|
+
'content' => {
|
21
|
+
'order_id' => order_details['order_id'],
|
22
|
+
'status' => 'settled'
|
23
|
+
},
|
24
|
+
'method' => 'payments_status_update'
|
25
|
+
}
|
26
|
+
else
|
17
27
|
product_info = {
|
18
28
|
'method' => 'pay',
|
19
29
|
'title' => 'My Awsome Virtual Item',
|
@@ -27,12 +37,6 @@ module StreetCred
|
|
27
37
|
'content' => [product_info],
|
28
38
|
'method' => 'payments_get_items'
|
29
39
|
}
|
30
|
-
else
|
31
|
-
response = {
|
32
|
-
'method' => 'payments_status_update',
|
33
|
-
'order_id' => '1234',
|
34
|
-
'status' => 'settled',
|
35
|
-
}
|
36
40
|
end
|
37
41
|
|
38
42
|
response
|
data/spec/streetcred_spec.rb
CHANGED
@@ -19,8 +19,7 @@ describe 'StreetCred::Handler' do
|
|
19
19
|
it "should handle the params for info request, and respond with a hash to populate the dialogue" do
|
20
20
|
# example parmas for info request, and expected response
|
21
21
|
params = {
|
22
|
-
:signed_request => SIGNED_REQUEST
|
23
|
-
:order_status => 'tag'
|
22
|
+
:signed_request => SIGNED_REQUEST
|
24
23
|
}
|
25
24
|
product_info = {
|
26
25
|
'method' => 'pay',
|
@@ -46,12 +45,14 @@ describe 'StreetCred::Handler' do
|
|
46
45
|
# example parmas for info request, and expected response
|
47
46
|
params = {
|
48
47
|
:signed_request => SIGNED_REQUEST,
|
49
|
-
:order_details => '1234
|
48
|
+
:order_details => "{'order_id':1234}"
|
50
49
|
}
|
51
50
|
expected_response = {
|
52
|
-
'
|
53
|
-
|
54
|
-
|
51
|
+
'content' => {
|
52
|
+
'order_id' => 1234,
|
53
|
+
'status' => 'settled'
|
54
|
+
},
|
55
|
+
'method' => 'payments_status_update'
|
55
56
|
}
|
56
57
|
|
57
58
|
# handle the sample params, and compare response to expected_response
|
data/streetcred.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streetcred
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: koala
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: active_support
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rspec
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|