Class: Decidim::BulletinBoard::Client
- Inherits:
-
Object
- Object
- Decidim::BulletinBoard::Client
- Defined in:
- lib/decidim/bulletin_board/client.rb
Overview
The Bulletin Board client
Direct Known Subclasses
Instance Method Summary collapse
- #cast_vote(election_id, voter_id, encrypted_vote) {|cast_vote.message_id| ... } ⇒ Object
- #create_election(election_id, election_data) {|create_election.message_id| ... } ⇒ Object
- #end_vote(election_id) {|end_vote.message_id| ... } ⇒ Object
- #get_election_results(election_id) ⇒ Object
- #get_election_status(election_id) ⇒ Object
- #get_pending_message_status(message_id) ⇒ Object
- #in_person_vote(election_id, voter_id, polling_station_id) {|in_person_vote.message_id| ... } ⇒ Object
-
#initialize(config = Decidim::BulletinBoard) ⇒ Client
constructor
A new instance of Client.
- #publish_results(election_id) {|publish_results.message_id| ... } ⇒ Object
- #report_missing_trustee(election_id, trustee_id) {|report_missing_trustee.message_id| ... } ⇒ Object
- #reset_test_database ⇒ Object
- #start_key_ceremony(election_id) {|start_key_ceremony.message_id| ... } ⇒ Object
- #start_tally(election_id) {|start_tally.message_id| ... } ⇒ Object
- #start_vote(election_id) {|start_vote.message_id| ... } ⇒ Object
Constructor Details
#initialize(config = Decidim::BulletinBoard) ⇒ Client
Returns a new instance of Client.
25 26 27 28 |
# File 'lib/decidim/bulletin_board/client.rb', line 25 def initialize(config = Decidim::BulletinBoard) @settings = Settings.new(config) @graphql = Graphql::Factory.client_for(settings) end |
Instance Method Details
#cast_vote(election_id, voter_id, encrypted_vote) {|cast_vote.message_id| ... } ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/decidim/bulletin_board/client.rb', line 59 def cast_vote(election_id, voter_id, encrypted_vote) cast_vote = configure Voter::CastVote.new(election_id, voter_id, encrypted_vote) yield cast_vote. if block_given? cast_vote.on(:ok) { || return } cast_vote.on(:error) { || raise StandardError, } cast_vote.call end |
#create_election(election_id, election_data) {|create_election.message_id| ... } ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/decidim/bulletin_board/client.rb', line 35 def create_election(election_id, election_data) create_election = configure Authority::CreateElection.new(election_id, election_data) yield create_election. if block_given? create_election.on(:ok) { |election| return election } create_election.on(:error) { || raise StandardError, } create_election.call end |
#end_vote(election_id) {|end_vote.message_id| ... } ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/decidim/bulletin_board/client.rb', line 82 def end_vote(election_id) end_vote = configure Authority::EndVote.new(election_id) yield end_vote. if block_given? end_vote.on(:ok) { || return } end_vote.on(:error) { || raise StandardError, } end_vote.call end |
#get_election_results(election_id) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/decidim/bulletin_board/client.rb', line 113 def get_election_results(election_id) get_log_entries = configure Authority::GetElectionResults.new(election_id) get_log_entries.on(:ok) { |result| return result } get_log_entries.on(:error) { || raise StandardError, } get_log_entries.call end |
#get_election_status(election_id) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/decidim/bulletin_board/client.rb', line 90 def get_election_status(election_id) get_election_status = configure Authority::GetElectionStatus.new(election_id) get_election_status.on(:ok) { |status| return status } get_election_status.on(:error) { || raise StandardError, } get_election_status.call end |
#get_pending_message_status(message_id) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/decidim/bulletin_board/client.rb', line 75 def () = configure Voter::GetPendingMessageStatus.new() .on(:ok) { |status| return status } .on(:error) { || raise StandardError, } .call end |
#in_person_vote(election_id, voter_id, polling_station_id) {|in_person_vote.message_id| ... } ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/decidim/bulletin_board/client.rb', line 67 def in_person_vote(election_id, voter_id, polling_station_id) in_person_vote = configure Voter::InPersonVote.new(election_id, voter_id, polling_station_id) yield in_person_vote. if block_given? in_person_vote.on(:ok) { || return } in_person_vote.on(:error) { || raise StandardError, } in_person_vote.call end |
#publish_results(election_id) {|publish_results.message_id| ... } ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/decidim/bulletin_board/client.rb', line 120 def publish_results(election_id) publish_results = configure Authority::PublishResults.new(election_id) yield publish_results. if block_given? publish_results.on(:ok) { || return } publish_results.on(:error) { || raise StandardError, } publish_results.call end |
#report_missing_trustee(election_id, trustee_id) {|report_missing_trustee.message_id| ... } ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/decidim/bulletin_board/client.rb', line 105 def report_missing_trustee(election_id, trustee_id) report_missing_trustee = configure Authority::ReportMissingTrustee.new(election_id, trustee_id) yield report_missing_trustee. if block_given? report_missing_trustee.on(:ok) { || return } report_missing_trustee.on(:error) { || raise StandardError, } report_missing_trustee.call end |
#reset_test_database ⇒ Object
129 130 131 132 133 134 |
# File 'lib/decidim/bulletin_board/client.rb', line 129 def reset_test_database reset_test_database = configure Test::ResetTestDatabase.new reset_test_database.on(:ok) { |result| return result } reset_test_database.on(:error) { || raise StandardError, } reset_test_database.call end |
#start_key_ceremony(election_id) {|start_key_ceremony.message_id| ... } ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/decidim/bulletin_board/client.rb', line 43 def start_key_ceremony(election_id) start_key_ceremony = configure Authority::StartKeyCeremony.new(election_id) yield start_key_ceremony. if block_given? start_key_ceremony.on(:ok) { || return } start_key_ceremony.on(:error) { || raise StandardError, } start_key_ceremony.call end |
#start_tally(election_id) {|start_tally.message_id| ... } ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/decidim/bulletin_board/client.rb', line 97 def start_tally(election_id) start_tally = configure Authority::StartTally.new(election_id) yield start_tally. if block_given? start_tally.on(:ok) { || return } start_tally.on(:error) { || raise StandardError, } start_tally.call end |
#start_vote(election_id) {|start_vote.message_id| ... } ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/decidim/bulletin_board/client.rb', line 51 def start_vote(election_id) start_vote = configure Authority::StartVote.new(election_id) yield start_vote. if block_given? start_vote.on(:ok) { || return } start_vote.on(:error) { || raise StandardError, } start_vote.call end |