Class: Strutta::Participants

Inherits:
APIObject show all
Defined in:
lib/strutta-api/participants.rb

Overview

Participants belong to a Strutta::Games object Instance methods found in Strutta::APIObject

Instance Attribute Summary

Attributes inherited from APIObject

#game

Instance Method Summary collapse

Methods inherited from APIObject

#all, #create, #delete, #get, #method_disabled, #update

Constructor Details

#initialize(id = nil, game) ⇒ Strutta::Participants

Initializes the Strutta::Participants object

Parameters:

  • id (Integer, nil) (defaults to: nil)

    Entry id

  • game (Strutta::Games)

    Master Strutta::Games object



10
11
12
13
14
15
# File 'lib/strutta-api/participants.rb', line 10

def initialize(id = nil, game)
  @id = id
  @game = game
  @root_path = "participants/#{@id}"
  @no_id_error = Errors::PARTICIPANT_ID_REQUIRED
end

Instance Method Details

#permissions(params = {}) ⇒ Hash

GET participant permissions games/:game_id/participants/:id/permissions

Returns:

  • (Hash)

    Parsed body of the API response



40
41
42
43
# File 'lib/strutta-api/participants.rb', line 40

def permissions(params = {})
  participant_id_required
  @game.get(params, "participants/#{@id}/permissions")
end

#permissions_update(params = {}) ⇒ Hash

PATCH participant permissions games/:game_id/participants/:id/permissions

Returns:

  • (Hash)

    Parsed body of the API response



49
50
51
52
# File 'lib/strutta-api/participants.rb', line 49

def permissions_update(params = {})
  participant_id_required
  @game.update(params, "participants/#{@id}/permissions")
end

#search(params) ⇒ Hash

GET participant by email address games/:game_id/participants/search

Returns:

  • (Hash)

    Parsed body of the API response



21
22
23
24
25
# File 'lib/strutta-api/participants.rb', line 21

def search(params)
  fail Errors::InvalidSearchParameters, Errors::INVALID_SEARCH unless params.key? :email
  @game.verify_no_id(@id)
  @game.get(params, 'participants/search')
end

#token_renew(params = {}) ⇒ Hash

PATCH update Participant token games/:game_id/participants/:id/token

Returns:

  • (Hash)

    Parsed body of the API response



31
32
33
34
# File 'lib/strutta-api/participants.rb', line 31

def token_renew(params = {})
  participant_id_required
  @game.update(params, "participants/#{@id}/token")
end