forked from stripe-ruby-mock/stripe-ruby-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disputes.rb
35 lines (29 loc) · 1.05 KB
/
disputes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module StripeMock
module RequestHandlers
module Disputes
def Disputes.included(klass)
klass.add_handler 'get /v1/disputes/(.*)', :get_dispute
klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute
klass.add_handler 'post /v1/disputes/(.*)', :update_dispute
klass.add_handler 'get /v1/disputes', :list_disputes
end
def get_dispute(route, method_url, params, headers)
route =~ method_url
assert_existence :dispute, $1, disputes[$1]
end
def update_dispute(route, method_url, params, headers)
dispute = get_dispute(route, method_url, params, headers)
dispute.merge!(params)
dispute
end
def close_dispute(route, method_url, params, headers)
dispute = get_dispute(route, method_url, params, headers)
dispute.merge!({:status => 'lost'})
dispute
end
def list_disputes(route, method_url, params, headers)
Data.mock_list_object(disputes.values, params)
end
end
end
end