meducation_sdk 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/meducation_sdk.rb +2 -0
- data/lib/meducation_sdk/services/paypal_purchases.rb +25 -0
- data/lib/meducation_sdk/services/purchases.rb +22 -0
- data/lib/meducation_sdk/version.rb +1 -1
- data/test/services/paypal_purchases_test.rb +37 -0
- data/test/services/purchases_test.rb +30 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0121b131de1651f00d6b084e4c98fd03f72f15
|
4
|
+
data.tar.gz: b3a667d9d9857a57af8cf90453c9e2af3adb2d36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95aba8f4ec6bc58eae9cd792e13350511b50365d366eee6ca7378115481fb127c16a465937a1f5e1e88427f7ed300be56b6a361cd1dd02c8fd558e08ffd67cc
|
7
|
+
data.tar.gz: d5de2f7d11d85fb38c60081a9cab7e7c20e11a7149c15ac90e2f51dd582a03f97cd948482ed290e069aafdc4bf80a106122925c04f600c7040d7f60f6d461569
|
data/CHANGELOG.md
CHANGED
data/lib/meducation_sdk.rb
CHANGED
@@ -6,6 +6,8 @@ require 'meducation_sdk/configuration'
|
|
6
6
|
require 'meducation_sdk/mocker'
|
7
7
|
|
8
8
|
require 'meducation_sdk/helpers'
|
9
|
+
require 'meducation_sdk/services/paypal_purchases'
|
10
|
+
require 'meducation_sdk/services/purchases'
|
9
11
|
require 'meducation_sdk/services/recommender'
|
10
12
|
require 'meducation_sdk/resource'
|
11
13
|
require 'meducation_sdk/email_shortcodes'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module MeducationSDK
|
4
|
+
class PaypalPurchases
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
def self.new_purchase(user, purchase_option_id, return_url, cancel_return_url)
|
8
|
+
new.new_purchase(user, purchase_option_id, return_url, cancel_return_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(basket_id, token)
|
12
|
+
new.create(basket_id, token)
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_purchase(user, purchase_option_id, return_url, cancel_return_url)
|
16
|
+
results = Loquor.get(URI::encode("/paypal_purchases/new?user[signup_email]=#{user['signup_email']}&user[full_name]=#{user['full_name']}&user[password]=#{user['password']}&user[password_confirmation]=#{user['password_confirmation']}&purchase_option_id=#{purchase_option_id}&return_url=#{return_url}&cancel_return_url=#{cancel_return_url}"))
|
17
|
+
results["url"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(basket_id, token)
|
21
|
+
Loquor.post("/paypal_purchases", {basket_id: basket_id, token: token})
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MeducationSDK
|
2
|
+
class Purchases
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def self.create(user, purchase_option_id, order)
|
6
|
+
new(user, purchase_option_id, order).create
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :user, :purchase_option_id, :order
|
10
|
+
|
11
|
+
def initialize(user, purchase_option_id, order)
|
12
|
+
@user = user
|
13
|
+
@purchase_option_id = purchase_option_id
|
14
|
+
@order = order
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
Loquor.post("/purchases", {user: @user, purchase_option_id: @purchase_option_id, order: @order})
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
|
4
|
+
module MeducationSDK
|
5
|
+
class PaypalPurchasesTest < Minitest::Test
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@user = {
|
9
|
+
"full_name" => "Joe Blogs",
|
10
|
+
"signup_email" => "1@redacted.example.com",
|
11
|
+
"password" => "Password",
|
12
|
+
"password_confirmation" => "Password",
|
13
|
+
}
|
14
|
+
|
15
|
+
@purchase_option_id = 1
|
16
|
+
|
17
|
+
@basket_id = 64237
|
18
|
+
|
19
|
+
@token = "abcdef"
|
20
|
+
|
21
|
+
@return_url = "http://localhost/return"
|
22
|
+
@cancel_return_url = "http://localhost/cancel_return"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create
|
26
|
+
Loquor.expects(:post).with("/paypal_purchases", {basket_id: @basket_id, token: @token})
|
27
|
+
MeducationSDK::PaypalPurchases.create(@basket_id, @token)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_new_purchase
|
31
|
+
expected_url = URI::encode("/paypal_purchases/new?user[signup_email]=1@redacted.example.com&user[full_name]=Joe Blogs&user[password]=Password&user[password_confirmation]=Password&purchase_option_id=1&return_url=http://localhost/return&cancel_return_url=http://localhost/cancel_return")
|
32
|
+
Loquor.expects(:get).with(expected_url).returns("url" => "http://returned.url")
|
33
|
+
assert_equal "http://returned.url", MeducationSDK::PaypalPurchases.new_purchase(@user, @purchase_option_id, @return_url, @cancel_return_url)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
module MeducationSDK
|
4
|
+
class PurchasesTest < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@user = {
|
8
|
+
full_name: "Joe Blogs",
|
9
|
+
signup_email: "1@redacted.example.com",
|
10
|
+
password: "Password",
|
11
|
+
password_confirmation: "Password",
|
12
|
+
}
|
13
|
+
|
14
|
+
@purchase_option_id = 1
|
15
|
+
|
16
|
+
@order = {
|
17
|
+
first_name: "Joe",
|
18
|
+
last_name: "Bloggs",
|
19
|
+
card_number: "1234",
|
20
|
+
card_verification: "987"
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_create
|
25
|
+
Loquor.expects(:post).with("/purchases", {user: @user, purchase_option_id: @purchase_option_id, order: @order})
|
26
|
+
MeducationSDK::Purchases.create(@user, @purchase_option_id, @order)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meducation_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -189,6 +189,8 @@ files:
|
|
189
189
|
- lib/meducation_sdk/resources/user_settings.rb
|
190
190
|
- lib/meducation_sdk/resources/view.rb
|
191
191
|
- lib/meducation_sdk/resources/vote.rb
|
192
|
+
- lib/meducation_sdk/services/paypal_purchases.rb
|
193
|
+
- lib/meducation_sdk/services/purchases.rb
|
192
194
|
- lib/meducation_sdk/services/recommender.rb
|
193
195
|
- lib/meducation_sdk/version.rb
|
194
196
|
- meducation_sdk.gemspec
|
@@ -256,6 +258,8 @@ files:
|
|
256
258
|
- test/resources/user_test.rb
|
257
259
|
- test/resources/view_test.rb
|
258
260
|
- test/resources/vote_test.rb
|
261
|
+
- test/services/paypal_purchases_test.rb
|
262
|
+
- test/services/purchases_test.rb
|
259
263
|
- test/services/recommender_test.rb
|
260
264
|
- test/test_helper.rb
|
261
265
|
homepage: http://github.com/meducation/meducation_sdk
|
@@ -278,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
282
|
version: '0'
|
279
283
|
requirements: []
|
280
284
|
rubyforge_project:
|
281
|
-
rubygems_version: 2.2.
|
285
|
+
rubygems_version: 2.2.1
|
282
286
|
signing_key:
|
283
287
|
specification_version: 4
|
284
288
|
summary: The SDK for Meducation
|
@@ -347,5 +351,7 @@ test_files:
|
|
347
351
|
- test/resources/user_test.rb
|
348
352
|
- test/resources/view_test.rb
|
349
353
|
- test/resources/vote_test.rb
|
354
|
+
- test/services/paypal_purchases_test.rb
|
355
|
+
- test/services/purchases_test.rb
|
350
356
|
- test/services/recommender_test.rb
|
351
357
|
- test/test_helper.rb
|