Class: Decidim::BulletinBoard::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/bulletin_board/client.rb

Overview

The Bulletin Board client

Direct Known Subclasses

FileClient

Instance Method Summary collapse

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

Yields:



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.message_id if block_given?
  cast_vote.on(:ok) { |pending_message| return pending_message }
  cast_vote.on(:error) { |error_message| raise StandardError, error_message }
  cast_vote.call
end

#create_election(election_id, election_data) {|create_election.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  create_election.on(:ok) { |election| return election }
  create_election.on(:error) { |error_message| raise StandardError, error_message }
  create_election.call
end

#end_vote(election_id) {|end_vote.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  end_vote.on(:ok) { |pending_message| return pending_message }
  end_vote.on(:error) { |error_message| raise StandardError, error_message }
  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) { |error_message| raise StandardError, error_message }
  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) { |error_message| raise StandardError, error_message }
  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 get_pending_message_status(message_id)
  get_pending_message_status = configure Voter::GetPendingMessageStatus.new(message_id)
  get_pending_message_status.on(:ok) { |status| return status }
  get_pending_message_status.on(:error) { |error_message| raise StandardError, error_message }
  get_pending_message_status.call
end

#in_person_vote(election_id, voter_id, polling_station_id) {|in_person_vote.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  in_person_vote.on(:ok) { |pending_message| return pending_message }
  in_person_vote.on(:error) { |error_message| raise StandardError, error_message }
  in_person_vote.call
end

#publish_results(election_id) {|publish_results.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  publish_results.on(:ok) { |pending_message| return pending_message }
  publish_results.on(:error) { |error_message| raise StandardError, error_message }
  publish_results.call
end

#report_missing_trustee(election_id, trustee_id) {|report_missing_trustee.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  report_missing_trustee.on(:ok) { |pending_message| return pending_message }
  report_missing_trustee.on(:error) { |error_message| raise StandardError, error_message }
  report_missing_trustee.call
end

#reset_test_databaseObject



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) { |error_message| raise StandardError, error_message }
  reset_test_database.call
end

#start_key_ceremony(election_id) {|start_key_ceremony.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  start_key_ceremony.on(:ok) { |pending_message| return pending_message }
  start_key_ceremony.on(:error) { |error_message| raise StandardError, error_message }
  start_key_ceremony.call
end

#start_tally(election_id) {|start_tally.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  start_tally.on(:ok) { |pending_message| return pending_message }
  start_tally.on(:error) { |error_message| raise StandardError, error_message }
  start_tally.call
end

#start_vote(election_id) {|start_vote.message_id| ... } ⇒ Object

Yields:



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.message_id if block_given?
  start_vote.on(:ok) { |pending_message| return pending_message }
  start_vote.on(:error) { |error_message| raise StandardError, error_message }
  start_vote.call
end