--- /dev/null
+class VoteResultStruct < ActionWebService::Struct
+ member :plurality_winners, :string
+ member :approval_winners, :string
+ member :condorcet_winners, :string
+ member :ssd_winners, :string
+ member :borda_winners, :string
+ member :errors, :string
+end
+class SelectricityAPI < ActionWebService::API::Base
+ api_method :cast_quickvote, :expects => [:int, :int, [[:int]]], :returns => [:string]
+ api_method :get_quickvote_results, :expects => [:string], :returns => [VoteResultStruct]
+end
+
+
--- /dev/null
+class SelectricityServiceController < ApplicationController
+ web_service_dispatching_mode :delegated
+ web_service :vote, SelectricityService.new
+end
--- /dev/null
+require 'action_controller/integration'
+
+class SelectricityService < ActionWebService::Base
+ web_service_api SelectricityAPI
+ def cast_quickvote(election_id, vote_id, vote_list)
+ #Obviously not implemented
+ end
+ def get_quickvote_results(shortname)
+ #TODO: Validate shortname
+ session=ActionController::Integration::Session.new
+ debugger
+ controller=session.get "quickvote/#{shortname}/results"
+ result=VoteResultStruct.new
+ result.plurality_winners=session.controller.plurality_result.winners.inspect
+ result.approval_winners=session.controller.approval_result.winners.inspect
+ result.condorcet_winners=session.controller.condorcet_result.winners.inspect
+ result.ssd_winners=session.controller.ssd_result.winners.inspect
+ result.borda_winners=session.controller.borda_result.winners.inspect
+ result
+ end
+end