Sha256: 3b1a63f343262a52ff765ac47486eacfd58e6a97f0642d19b876b1472b0b425b
Contents?: true
Size: 1.24 KB
Versions: 30
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Decidim module BulletinBoard module Authority # This command uses the GraphQL client to get the status of the election. class GetElectionStatus < Decidim::BulletinBoard::Command # Public: Initializes the command. # # election_id - The local election identifier def initialize(election_id) @election_id = election_id end # Executes the command. Broadcasts these events: # # - :ok when everything is valid and the query operation is successful. # - :error if query operation was not successful. # # Returns nothing. def call # arguments used inside the graphql operation args = { unique_id: unique_election_id(election_id) } response = graphql.query do query do election(uniqueId: args[:unique_id]) do status end end end broadcast(:ok, response.data.election.status) rescue Graphlient::Errors::ServerError broadcast(:error, "Sorry, something went wrong") end private attr_reader :election_id end end end end
Version data entries
30 entries across 30 versions & 1 rubygems