paysio 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +23 -4
- data/README.rdoc +9 -6
- data/VERSION +1 -1
- data/lib/paysio/actions/create.rb +1 -2
- data/lib/paysio/actions/find.rb +1 -0
- data/lib/paysio/actions/update.rb +7 -2
- data/lib/paysio/client.rb +8 -8
- data/lib/paysio/exceptions.rb +6 -0
- data/lib/paysio/json.rb +1 -1
- data/lib/paysio/resource.rb +21 -22
- data/lib/paysio/resources/charge.rb +0 -4
- data/lib/paysio/resources/coupon.rb +0 -3
- data/lib/paysio/resources/customer.rb +0 -3
- data/lib/paysio/resources/payout.rb +8 -0
- data/lib/paysio/resources/reward.rb +0 -3
- data/lib/paysio/resources/wallet.rb +0 -3
- data/lib/paysio/version.rb +1 -1
- data/lib/paysio.rb +3 -3
- data/paysio.gemspec +3 -0
- data/spec/requests/base_spec.rb +17 -0
- data/spec/resources/charge_spec.rb +13 -0
- data/spec/resources/coupon_spec.rb +13 -0
- data/spec/resources/customer_spec.rb +13 -0
- data/spec/resources/event_spec.rb +4 -0
- data/spec/resources/log_spec.rb +4 -0
- data/spec/resources/payout_spec.rb +20 -0
- data/spec/resources/reward_spec.rb +13 -0
- data/spec/resources/wallet_spec.rb +13 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/paysio.rb +24 -0
- data/spec/support/paysio_responses.rb +156 -0
- data/spec/support/test_matchers.rb +27 -0
- metadata +65 -4
- data/lib/paysio/errors/not_authorized.rb +0 -7
- data/lib/paysio/errors/resource_not_valid.rb +0 -7
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paysio (1.0.
|
4
|
+
paysio (1.0.3)
|
5
|
+
activemodel
|
5
6
|
activesupport
|
6
7
|
oj (> 2)
|
7
8
|
rest-client (~> 1.4)
|
@@ -9,20 +10,38 @@ PATH
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
13
|
+
activemodel (3.2.12)
|
14
|
+
activesupport (= 3.2.12)
|
15
|
+
builder (~> 3.0.0)
|
12
16
|
activesupport (3.2.12)
|
13
17
|
i18n (~> 0.6)
|
14
18
|
multi_json (~> 1.0)
|
15
|
-
|
19
|
+
builder (3.0.4)
|
20
|
+
diff-lcs (1.2.1)
|
21
|
+
i18n (0.6.4)
|
22
|
+
metaclass (0.0.1)
|
16
23
|
mime-types (1.21)
|
17
|
-
|
18
|
-
|
24
|
+
mocha (0.10.5)
|
25
|
+
metaclass (~> 0.0.1)
|
26
|
+
multi_json (1.6.1)
|
27
|
+
oj (2.0.10)
|
19
28
|
rake (10.0.3)
|
20
29
|
rest-client (1.6.7)
|
21
30
|
mime-types (>= 1.16)
|
31
|
+
rspec (2.13.0)
|
32
|
+
rspec-core (~> 2.13.0)
|
33
|
+
rspec-expectations (~> 2.13.0)
|
34
|
+
rspec-mocks (~> 2.13.0)
|
35
|
+
rspec-core (2.13.1)
|
36
|
+
rspec-expectations (2.13.0)
|
37
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
38
|
+
rspec-mocks (2.13.0)
|
22
39
|
|
23
40
|
PLATFORMS
|
24
41
|
ruby
|
25
42
|
|
26
43
|
DEPENDENCIES
|
44
|
+
mocha
|
27
45
|
paysio!
|
28
46
|
rake
|
47
|
+
rspec
|
data/README.rdoc
CHANGED
@@ -17,18 +17,21 @@
|
|
17
17
|
Paysio::Customer.all # get list of customers
|
18
18
|
|
19
19
|
== Actions: update
|
20
|
-
customer = Paysio::Customer.
|
21
|
-
customer.
|
20
|
+
customer = Paysio::Customer.retrieve("cs_1111111")
|
21
|
+
customer.description = "test user"
|
22
|
+
customer.save
|
22
23
|
|
23
24
|
== Actions: destroy
|
24
|
-
customer = Paysio::Customer.
|
25
|
+
customer = Paysio::Customer.retrieve("cs_1111111")
|
25
26
|
customer.destroy
|
26
27
|
|
27
28
|
== Actions: refund charge
|
28
|
-
charge = Paysio::Charge.
|
29
|
+
charge = Paysio::Charge.retrieve("ch_1111111")
|
29
30
|
charge.refund
|
30
31
|
|
31
32
|
|
32
33
|
== Actions: redirect to charge after create (e.g. in Ruby on Rails)
|
33
|
-
|
34
|
-
|
34
|
+
def create
|
35
|
+
charge = Paysio::Charge.create(amount: 100, payment_system_id: 't_123', description: 'test charge')
|
36
|
+
redirect_to charge.redirect
|
37
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
@@ -3,9 +3,8 @@ module Paysio
|
|
3
3
|
module Create
|
4
4
|
module ClassMethods
|
5
5
|
def create(attrs = {})
|
6
|
-
validate!(attrs)
|
7
6
|
response = Paysio::Client.request(:post, path, attrs)
|
8
|
-
Resource.build_from(response)
|
7
|
+
response["error"].blank? ? Resource.build_from(response) : response
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
data/lib/paysio/actions/find.rb
CHANGED
@@ -2,9 +2,14 @@ module Paysio
|
|
2
2
|
module Actions
|
3
3
|
module Update
|
4
4
|
def update(attrs = {})
|
5
|
-
validate!(to_hash.merge(attrs))
|
6
5
|
response = Paysio::Client.request(:put, path, attrs)
|
7
|
-
refresh_from(response.to_hash)
|
6
|
+
response["error"].blank? ? refresh_from(response.to_hash) : response
|
7
|
+
end
|
8
|
+
|
9
|
+
def save
|
10
|
+
@previously_changed = changes
|
11
|
+
@changed_attributes.clear
|
12
|
+
update(changed_attributes)
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
data/lib/paysio/client.rb
CHANGED
@@ -3,17 +3,17 @@ module Paysio
|
|
3
3
|
class << self
|
4
4
|
def request(method, path, params = {}, headers = {})
|
5
5
|
unless Paysio.api_key
|
6
|
-
raise Paysio::
|
6
|
+
raise Paysio::Exceptions::NotAuthorized, "Please specify Paysio.api_key"
|
7
7
|
end
|
8
8
|
headers = {
|
9
|
-
user_agent
|
10
|
-
content_type
|
9
|
+
:user_agent => "Pays.io RubyClient/#{Paysio::VERSION}",
|
10
|
+
:content_type => 'application/x-www-form-urlencoded'
|
11
11
|
}.merge(headers)
|
12
12
|
opts = {
|
13
|
-
url
|
14
|
-
method
|
15
|
-
timeout
|
16
|
-
headers
|
13
|
+
:url => Paysio.api_url(path),
|
14
|
+
:method => method,
|
15
|
+
:timeout => 80,
|
16
|
+
:headers => headers
|
17
17
|
}
|
18
18
|
|
19
19
|
# build params
|
@@ -28,7 +28,7 @@ module Paysio
|
|
28
28
|
begin
|
29
29
|
resp = Paysio::JSON.decode(body)
|
30
30
|
rescue Oj::ParseError
|
31
|
-
|
31
|
+
raise Paysio::Exceptions::APIError.new("Invalid response object from API: #{body.inspect} (#{code})", code, body)
|
32
32
|
end
|
33
33
|
Paysio::Resource.build_from(resp, response.headers[:location])
|
34
34
|
end
|
data/lib/paysio/json.rb
CHANGED
data/lib/paysio/resource.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'active_model/dirty'
|
1
2
|
module Paysio
|
2
3
|
class Resource
|
3
|
-
|
4
|
+
include ActiveModel::Dirty
|
5
|
+
|
6
|
+
attr_accessor :redirect
|
4
7
|
|
5
8
|
def initialize(id = nil)
|
6
9
|
@values = {}
|
@@ -23,7 +26,13 @@ module Paysio
|
|
23
26
|
end
|
24
27
|
|
25
28
|
def method_missing(name, *opts)
|
26
|
-
|
29
|
+
if name[-1] == '='
|
30
|
+
name = name.to_s.gsub(/\=$/, '')
|
31
|
+
send(:"#{name}_will_change!")
|
32
|
+
@values[name.to_s] = opts.first if @values.has_key?(name.to_s)
|
33
|
+
else
|
34
|
+
@values[name.to_s] if @values.has_key?(name.to_s)
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
def to_json(*opts)
|
@@ -38,6 +47,14 @@ module Paysio
|
|
38
47
|
@values
|
39
48
|
end
|
40
49
|
|
50
|
+
def attributes
|
51
|
+
to_hash.reject{ |k, v| v.is_a? (Paysio::Resource)}
|
52
|
+
end
|
53
|
+
|
54
|
+
def attribute(key)
|
55
|
+
to_hash[key]
|
56
|
+
end
|
57
|
+
|
41
58
|
def each(&blk)
|
42
59
|
@values.each(&blk)
|
43
60
|
end
|
@@ -56,25 +73,6 @@ module Paysio
|
|
56
73
|
@@registered_resources << resource_name.to_s
|
57
74
|
end
|
58
75
|
|
59
|
-
def validates_presence_of(field)
|
60
|
-
@validate_presence_of ||= []
|
61
|
-
@validate_presence_of << field.to_s
|
62
|
-
end
|
63
|
-
|
64
|
-
def valid?(attrs)
|
65
|
-
@validate_presence_of ||= []
|
66
|
-
@validate_presence_of.all? do |field|
|
67
|
-
attrs.symbolize_keys.has_key?(field.to_sym)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def validate!(attrs)
|
72
|
-
unless valid?(attrs)
|
73
|
-
raise Paysio::Errors::ResourceNotValid,
|
74
|
-
"#{self.name} should have following attributes: #{@validate_presence_of.inspect}"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
76
|
def path
|
79
77
|
"/#{self.name.demodulize.tableize}"
|
80
78
|
end
|
@@ -91,7 +89,8 @@ module Paysio
|
|
91
89
|
end
|
92
90
|
resource = klass.new(resp['id'])
|
93
91
|
resource.refresh_from(resp)
|
94
|
-
resource.
|
92
|
+
resource.class.define_attribute_methods(resource.attributes.keys)
|
93
|
+
resource.redirect = redirect_url
|
95
94
|
resource
|
96
95
|
else
|
97
96
|
resp
|
@@ -6,10 +6,6 @@ module Paysio
|
|
6
6
|
include Paysio::Actions::Find
|
7
7
|
resource :charge
|
8
8
|
|
9
|
-
validates_presence_of :amount
|
10
|
-
validates_presence_of :payment_system_id
|
11
|
-
validates_presence_of :description
|
12
|
-
|
13
9
|
def refund(attrs = {})
|
14
10
|
response = Paysio::Client.request(:post, action_path(:refund), attrs)
|
15
11
|
refresh_from(response.to_hash)
|
data/lib/paysio/version.rb
CHANGED
data/lib/paysio.rb
CHANGED
@@ -17,9 +17,8 @@ require 'paysio/actions/update'
|
|
17
17
|
require 'paysio/actions/destroy'
|
18
18
|
require 'paysio/actions/find'
|
19
19
|
|
20
|
-
#
|
21
|
-
require 'paysio/
|
22
|
-
require 'paysio/errors/resource_not_valid'
|
20
|
+
# exceptions
|
21
|
+
require 'paysio/exceptions'
|
23
22
|
|
24
23
|
# resources
|
25
24
|
require 'paysio/resources/list'
|
@@ -29,6 +28,7 @@ require 'paysio/resources/customer'
|
|
29
28
|
require 'paysio/resources/reward'
|
30
29
|
require 'paysio/resources/coupon'
|
31
30
|
require 'paysio/resources/event'
|
31
|
+
require 'paysio/resources/payout'
|
32
32
|
require 'paysio/resources/log'
|
33
33
|
|
34
34
|
module Paysio
|
data/paysio.gemspec
CHANGED
@@ -15,9 +15,12 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency('rest-client', '~> 1.4')
|
17
17
|
s.add_dependency('activesupport')
|
18
|
+
s.add_dependency('activemodel')
|
18
19
|
s.add_dependency('oj', '> 2')
|
19
20
|
|
20
21
|
s.add_development_dependency('rake')
|
22
|
+
s.add_development_dependency('rspec')
|
23
|
+
s.add_development_dependency('mocha')
|
21
24
|
|
22
25
|
s.files = `git ls-files`.split("\n")
|
23
26
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe "API Bindings" do
|
3
|
+
|
4
|
+
before :all do
|
5
|
+
@client = authorized_paysio_client
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should not fetch from network while creating a new Resource" do
|
9
|
+
@client.expects(:get).never
|
10
|
+
Paysio::Charge.new("someid")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should add redirect url to resource from location" do
|
14
|
+
@client.expects(:get).once.returns(test_response(test_charge, 200, 'http://example.com'))
|
15
|
+
Paysio::Charge.retrieve("someid").redirect == 'http://example.com'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Charge do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
it { should be_updatable_resource }
|
5
|
+
|
6
|
+
it "should return charge on create" do
|
7
|
+
client = authorized_paysio_client
|
8
|
+
|
9
|
+
client.expects(:post).once.returns(test_response(test_charge))
|
10
|
+
c = Paysio::Charge.create
|
11
|
+
c.should be_a_kind_of(Paysio::Charge)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Coupon do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
it { should be_updatable_resource }
|
5
|
+
|
6
|
+
it "should return coupon on create" do
|
7
|
+
client = authorized_paysio_client
|
8
|
+
|
9
|
+
client.expects(:post).once.returns(test_response(test_coupon))
|
10
|
+
c = Paysio::Coupon.create
|
11
|
+
c.should be_a_kind_of(Paysio::Coupon)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Customer do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
it { should be_updatable_resource }
|
5
|
+
|
6
|
+
it "should return charge on create" do
|
7
|
+
client = authorized_paysio_client
|
8
|
+
|
9
|
+
client.expects(:post).once.returns(test_response(test_customer))
|
10
|
+
c = Paysio::Charge.create
|
11
|
+
c.should be_a_kind_of(Paysio::Customer)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Payout do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
|
5
|
+
it "should return payout on create" do
|
6
|
+
client = authorized_paysio_client
|
7
|
+
|
8
|
+
client.expects(:post).once.returns(test_response(test_payout))
|
9
|
+
c = Paysio::Payout.create
|
10
|
+
c.should be_a_kind_of(Paysio::Payout)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have wallet" do
|
14
|
+
client = authorized_paysio_client
|
15
|
+
|
16
|
+
client.expects(:get).once.returns(test_response(test_payout))
|
17
|
+
c = Paysio::Payout.retrieve('someid')
|
18
|
+
c.wallet.should be_a_kind_of(Paysio::Wallet)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Reward do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
it { should be_updatable_resource }
|
5
|
+
|
6
|
+
it "should return reward on create" do
|
7
|
+
client = authorized_paysio_client
|
8
|
+
|
9
|
+
client.expects(:post).once.returns(test_response(test_reward))
|
10
|
+
c = Paysio::Reward.create
|
11
|
+
c.should be_a_kind_of(Paysio::Reward)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Paysio::Wallet do
|
3
|
+
it { should be_listable_resource }
|
4
|
+
it { should be_updatable_resource }
|
5
|
+
|
6
|
+
it "should return wallet on create" do
|
7
|
+
client = authorized_paysio_client
|
8
|
+
|
9
|
+
client.expects(:post).once.returns(test_response(test_wallet))
|
10
|
+
c = Paysio::Wallet.create
|
11
|
+
c.should be_a_kind_of(Paysio::Wallet)
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Paysio
|
2
|
+
class Client
|
3
|
+
@mock_rest_client = nil
|
4
|
+
|
5
|
+
def self.mock_rest_client(mock_client)
|
6
|
+
@mock_rest_client = mock_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.execute(opts)
|
10
|
+
get_params = (opts[:headers] || {})[:params]
|
11
|
+
post_params = opts[:payload]
|
12
|
+
case opts[:method]
|
13
|
+
when :get then @mock_rest_client.get opts[:url], get_params, post_params
|
14
|
+
when :post then @mock_rest_client.post opts[:url], get_params, post_params
|
15
|
+
when :put then @mock_rest_client.put opts[:url], get_params, post_params
|
16
|
+
when :delete then @mock_rest_client.delete opts[:url], get_params, post_params
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
def authorized_paysio_client
|
22
|
+
Paysio.api_key = 'paysio'
|
23
|
+
Paysio::Client.mock_rest_client(mock)
|
24
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
module Paysio::TestResponses
|
2
|
+
def test_response(body, code = 200, location = 'test')
|
3
|
+
body = Paysio::JSON.encode(body) if !(body.kind_of? String)
|
4
|
+
m = mock
|
5
|
+
m.instance_variable_set('@data', { body: body, code: code , location: location})
|
6
|
+
def m.body; @data[:body]; end
|
7
|
+
def m.code; @data[:code]; end
|
8
|
+
def m.headers; {location: @data[:location]} end
|
9
|
+
m
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_customer(params={})
|
13
|
+
{
|
14
|
+
:object => 'customer',
|
15
|
+
:merchant_id => 'm_12345',
|
16
|
+
:email => 'user@example.com',
|
17
|
+
:phone_number => '+71234567',
|
18
|
+
:name => 'Bruce Lee',
|
19
|
+
:description => 'Foo bar',
|
20
|
+
:created => '1345537759',
|
21
|
+
:livemode => false
|
22
|
+
}.merge(params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_customer_array
|
26
|
+
{
|
27
|
+
:data => [test_customer, test_customer, test_customer],
|
28
|
+
:object => 'list'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_charge(params={})
|
33
|
+
{
|
34
|
+
:object => 'charge',
|
35
|
+
:merchant_id => 'm_12345',
|
36
|
+
:amount => 100,
|
37
|
+
:fee => 10,
|
38
|
+
:status => 'pending',
|
39
|
+
:order_id => 'o_1234234',
|
40
|
+
:return_url => 'http://example.com',
|
41
|
+
:livemode => false
|
42
|
+
}.merge(params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_charge_array
|
46
|
+
{
|
47
|
+
:data => [test_charge, test_charge, test_charge],
|
48
|
+
:object => 'list'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_coupon(params={})
|
53
|
+
{
|
54
|
+
:object => 'coupon',
|
55
|
+
:merchant_id => 'm_12345',
|
56
|
+
:percent_off => 30,
|
57
|
+
:currency_id => 'usd',
|
58
|
+
:code => 'foo',
|
59
|
+
:livemode => false
|
60
|
+
}.merge(params)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_coupon_array
|
64
|
+
{
|
65
|
+
:data => [test_coupon, test_coupon, test_coupon],
|
66
|
+
:object => 'list'
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_event(params={})
|
71
|
+
{
|
72
|
+
:object => 'event',
|
73
|
+
:merchant_id => 'm_12345',
|
74
|
+
:type => 'charge.create',
|
75
|
+
:livemode => false
|
76
|
+
}.merge(params)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_event_array
|
80
|
+
{
|
81
|
+
:data => [test_event, test_event, test_event],
|
82
|
+
:object => 'list'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_log(params={})
|
87
|
+
{
|
88
|
+
:object => 'log',
|
89
|
+
:request_url => 'http://example.com',
|
90
|
+
:request_ip => '127.0.0.1',
|
91
|
+
:livemode => false
|
92
|
+
}.merge(params)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_log_array
|
96
|
+
{
|
97
|
+
:data => [test_log, test_log, test_log],
|
98
|
+
:object => 'list'
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_wallet(params={})
|
103
|
+
{
|
104
|
+
:object => 'wallet',
|
105
|
+
:merchant_id => 'm_12345',
|
106
|
+
:type => 'test',
|
107
|
+
:account => 'foo',
|
108
|
+
:account_number => '12345',
|
109
|
+
:account_id => 'ac_12345',
|
110
|
+
:livemode => false
|
111
|
+
}.merge(params)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_wallet_array
|
115
|
+
{
|
116
|
+
:data => [test_wallet, test_wallet, test_wallet],
|
117
|
+
:object => 'list'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_payout(params={})
|
122
|
+
{
|
123
|
+
:object => 'payout',
|
124
|
+
:merchant_id => 'm_12345',
|
125
|
+
:amount => 50,
|
126
|
+
:status => 'success',
|
127
|
+
:wallet => test_wallet,
|
128
|
+
:livemode => false
|
129
|
+
}.merge(params)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_payout_array
|
133
|
+
{
|
134
|
+
:data => [test_payout, test_payout, test_payout],
|
135
|
+
:object => 'list'
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_reward(params={})
|
140
|
+
{
|
141
|
+
:object => 'reward',
|
142
|
+
:merchant_id => 'm_12345',
|
143
|
+
:title => 'Foo Bar',
|
144
|
+
:percent_off => 50,
|
145
|
+
:max_amount => 100,
|
146
|
+
:livemode => false
|
147
|
+
}.merge(params)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_reward_array
|
151
|
+
{
|
152
|
+
:data => [test_reward, test_reward, test_reward],
|
153
|
+
:object => 'list'
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec::Matchers.define :be_listable_resource do |expected|
|
2
|
+
match do |actual|
|
3
|
+
client = authorized_paysio_client
|
4
|
+
subject = actual.class
|
5
|
+
test_response_hash = send(:"test_#{subject.name.demodulize.underscore}_array")
|
6
|
+
|
7
|
+
client.expects(:get).once.returns(test_response(test_response_hash))
|
8
|
+
c = subject.all.data
|
9
|
+
|
10
|
+
c.should be_a_kind_of(Array)
|
11
|
+
c[0].should be_a_kind_of(subject)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
RSpec::Matchers.define :be_updatable_resource do |expected|
|
15
|
+
match do |actual|
|
16
|
+
client = authorized_paysio_client
|
17
|
+
subject = actual.class
|
18
|
+
|
19
|
+
client.expects(:get).once.returns(test_response(test_customer({name: "foo"})))
|
20
|
+
client.expects(:put).once.returns(test_response(test_customer({name: "bar"})))
|
21
|
+
c = subject.retrieve("resource_id")
|
22
|
+
c.name.should == "foo"
|
23
|
+
c.name = "bar"
|
24
|
+
c.save
|
25
|
+
c.name.should == "bar"
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paysio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.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-
|
12
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activemodel
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: oj
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +91,38 @@ dependencies:
|
|
75
91
|
- - ! '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: mocha
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
78
126
|
description: See https://paysio.com for details.
|
79
127
|
email:
|
80
128
|
- gvalmon@gmail.com
|
@@ -101,8 +149,7 @@ files:
|
|
101
149
|
- lib/paysio/actions/list.rb
|
102
150
|
- lib/paysio/actions/update.rb
|
103
151
|
- lib/paysio/client.rb
|
104
|
-
- lib/paysio/
|
105
|
-
- lib/paysio/errors/resource_not_valid.rb
|
152
|
+
- lib/paysio/exceptions.rb
|
106
153
|
- lib/paysio/json.rb
|
107
154
|
- lib/paysio/resource.rb
|
108
155
|
- lib/paysio/resources/charge.rb
|
@@ -111,10 +158,24 @@ files:
|
|
111
158
|
- lib/paysio/resources/event.rb
|
112
159
|
- lib/paysio/resources/list.rb
|
113
160
|
- lib/paysio/resources/log.rb
|
161
|
+
- lib/paysio/resources/payout.rb
|
114
162
|
- lib/paysio/resources/reward.rb
|
115
163
|
- lib/paysio/resources/wallet.rb
|
116
164
|
- lib/paysio/version.rb
|
117
165
|
- paysio.gemspec
|
166
|
+
- spec/requests/base_spec.rb
|
167
|
+
- spec/resources/charge_spec.rb
|
168
|
+
- spec/resources/coupon_spec.rb
|
169
|
+
- spec/resources/customer_spec.rb
|
170
|
+
- spec/resources/event_spec.rb
|
171
|
+
- spec/resources/log_spec.rb
|
172
|
+
- spec/resources/payout_spec.rb
|
173
|
+
- spec/resources/reward_spec.rb
|
174
|
+
- spec/resources/wallet_spec.rb
|
175
|
+
- spec/spec_helper.rb
|
176
|
+
- spec/support/paysio.rb
|
177
|
+
- spec/support/paysio_responses.rb
|
178
|
+
- spec/support/test_matchers.rb
|
118
179
|
homepage: https://paysio.com
|
119
180
|
licenses: []
|
120
181
|
post_install_message:
|