Sha256: e2115e1a8dc4263447865970a57c97224d48f45d41d5da38f043dae3482f0c58
Contents?: true
Size: 1.24 KB
Versions: 3
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 = client.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
3 entries across 3 versions & 1 rubygems