module Strutta # Participants belong to a Strutta::Games object # Instance methods found in Strutta::APIObject class Participants < APIObject # Initializes the Strutta::Participants object # # @param id [Integer, nil] Entry id # @param game [Strutta::Games] Master Strutta::Games object # @return [Strutta::Participants] instantiated Strutta::Participants object def initialize(id = nil, game) @id = id @game = game @root_path = "participants/#{@id}" @no_id_error = Errors::PARTICIPANT_ID_REQUIRED end # GET participant by email address # games/:game_id/participants/search # # @return [Hash] Parsed body of the API response def search(params) fail Errors::InvalidSearchParameters, Errors::INVALID_SEARCH unless params.key? :email @game.verify_no_id(@id) @game.get(params, 'participants/search') end # PATCH update Participant token # games/:game_id/participants/:id/token # # @return [Hash] Parsed body of the API response def token_renew(params = {}) participant_id_required @game.update(params, "participants/#{@id}/token") end # GET participant permissions # games/:game_id/participants/:id/permissions # # @return [Hash] Parsed body of the API response def permissions(params = {}) participant_id_required @game.get(params, "participants/#{@id}/permissions") end # PATCH participant permissions # games/:game_id/participants/:id/permissions # # @return [Hash] Parsed body of the API response def permissions_update(params = {}) participant_id_required @game.update(params, "participants/#{@id}/permissions") end private def participant_id_required @game.verify_id(@id, Errors::PARTICIPANT_ID_REQUIRED) end end end