decidim-bulletin_board 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module BulletinBoard
5
- module Authority
6
- # This command uses the GraphQL client to request the closing of the ballot box.
7
- class CloseBallotBox < Decidim::BulletinBoard::Command
8
- # Public: Initializes the command.
9
- #
10
- # election_id - The local election identifier
11
- def initialize(election_id)
12
- @election_id = election_id
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid and the query operation is successful.
18
- # - :error if query operation was not successful.
19
- #
20
- # Returns nothing.
21
- def call
22
- message_id = message_id(unique_election_id(election_id), "close_ballot_box")
23
- signed_data = sign_message(message_id, {})
24
-
25
- begin
26
- response = client.query do
27
- mutation do
28
- closeBallotBox(messageId: message_id, signedData: signed_data) do
29
- election do
30
- status
31
- end
32
- error
33
- end
34
- end
35
- end
36
-
37
- return broadcast(:error, response.data.close_ballot_box.error) if response.data.close_ballot_box.error.present?
38
-
39
- broadcast(:ok, response.data.close_ballot_box.election)
40
- rescue Graphlient::Errors::ServerError
41
- broadcast(:error, "Sorry, something went wrong")
42
- end
43
- end
44
-
45
- private
46
-
47
- attr_reader :election_id
48
- end
49
- end
50
- end
51
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module BulletinBoard
5
- module Authority
6
- # This command uses the GraphQL client to request the opening of the ballot box.
7
- class OpenBallotBox < Decidim::BulletinBoard::Command
8
- # Public: Initializes the command.
9
- #
10
- # election_id - The local election identifier
11
- def initialize(election_id)
12
- @election_id = election_id
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid and the query operation is successful.
18
- # - :error if query operation was not successful.
19
- #
20
- # Returns nothing.
21
- def call
22
- message_id = message_id(unique_election_id(election_id), "open_ballot_box")
23
- signed_data = sign_message(message_id, {})
24
-
25
- begin
26
- response = client.query do
27
- mutation do
28
- openBallotBox(messageId: message_id, signedData: signed_data) do
29
- election do
30
- status
31
- end
32
- error
33
- end
34
- end
35
- end
36
-
37
- return broadcast(:error, response.data.open_ballot_box.error) if response.data.open_ballot_box.error.present?
38
-
39
- broadcast(:ok, response.data.open_ballot_box.election)
40
- rescue Graphlient::Errors::ServerError
41
- broadcast(:error, "Sorry, something went wrong")
42
- end
43
- end
44
-
45
- private
46
-
47
- attr_reader :election_id
48
- end
49
- end
50
- end
51
- end