Module: StripeMock::RequestHandlers::Disputes

Included in:
Instance
Defined in:
lib/stripe_mock/request_handlers/disputes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
# File 'lib/stripe_mock/request_handlers/disputes.rb', line 5

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

Instance Method Details

#close_dispute(route, method_url, params, headers) ⇒ Object



23
24
25
26
27
# File 'lib/stripe_mock/request_handlers/disputes.rb', line 23

def close_dispute(route, method_url, params, headers)
  dispute = get_dispute(route, method_url, params, headers)
  dispute.merge!({:status => 'lost'})
  dispute
end

#get_dispute(route, method_url, params, headers) ⇒ Object



12
13
14
15
# File 'lib/stripe_mock/request_handlers/disputes.rb', line 12

def get_dispute(route, method_url, params, headers)
  route =~ method_url
  assert_existence :dispute, $1, disputes[$1]
end

#list_disputes(route, method_url, params, headers) ⇒ Object



29
30
31
# File 'lib/stripe_mock/request_handlers/disputes.rb', line 29

def list_disputes(route, method_url, params, headers)
  Data.mock_list_object(disputes.values, params)
end

#update_dispute(route, method_url, params, headers) ⇒ Object



17
18
19
20
21
# File 'lib/stripe_mock/request_handlers/disputes.rb', line 17

def update_dispute(route, method_url, params, headers)
  dispute = get_dispute(route, method_url, params, headers)
  dispute.merge!(params)
  dispute
end