Sha256: aa36f6624cedd6e29e45e454903a7e7d206a348f36edaee8a4f59f2bca58f176

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'json'
require 'sinatra'
require 'byebug'

register_session_response = {
  "status" => 1,
  "sessionID" => 200,
  "action" => "registerSession"
}

get_association_response = {
  "status" => 1,
  "sessionID" => 200,
  "action" => "getAssociation",
  "associationID" => 231
}

get_selected_coupons_response = {
  "status" => 1,
  "sessionID" => 200,
  "action" => "getAssociation",
  "coupons" => []
}

cash_selected_coupons_response = {
  "status" => 1,
  "sessionID" => 200,
  "action" => "registerSession"
}

response_map = {
  'registerSession' => register_session_response,
  'getAssociation' => get_association_response,
  'getSelectedCoupons' => get_selected_coupons_response,
  'cashSelectedCoupons' => cash_selected_coupons_response
}

post '/action.php' do
  request_body = JSON.parse request.body.read
  response_map[request_body["action"]].to_json
end

post '/deny/action.php' do
  request_body = JSON.parse request.body.read
  response = response_map[request_body["action"]].clone
  response["status"] = -1
  response.to_json
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
LYBC-0.1.0 mock_server.rb