Class: PlataformaSocial::Ranking

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/plataforma_social/ranking.rb,
lib/plataforma_social/ranking/custom.rb,
lib/plataforma_social/ranking/general.rb

Direct Known Subclasses

Custom, General

Defined Under Namespace

Classes: Custom, General

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.socialp_routeObject

Método para retornar a url do módulo de ranking na plataforma



7
8
9
# File 'lib/plataforma_social/ranking.rb', line 7

def self.socialp_route
  PlataformaSocial.domains(:ranking)
end

Instance Method Details

#create(options = {}) ⇒ Object

Método para criar um novo ranking na plataforma Esse método aceita como parâmetros: options =

:user_reference => REFERENCIA_DO_USUARIO, <- Obrigatorio
:points => PONTOS_DO_USUARIO, <- Obrigatorio
:start_date => DATA_INICIO_DO_RANKING,
:end_date => DATA_FIM_DO_RANKING,
:min => MINIMO_DE_PONTOS_QUE_O_USUARIO_PODE_TER,
:max => MAXIMO_DE_PONTOS_QUE_O_USUARIO_PODE_TER

Quando é passado a data iniciom é obrigado a ter a data fim. Quando os dois parâmetros de data são passados, é criado um ranking para aquele intervalo de tempo e também é computado no ranking geral do app.



25
26
27
28
29
30
31
# File 'lib/plataforma_social/ranking.rb', line 25

def create options = {}
  options.symbolize_keys!
  verify_if_has_all_required_parameters [{ :start_date => :end_date }, { :end_date => :start_date }, :user_reference, :points], options
  post_request "users/#{options[:user_reference]}/ranking", { :start_date => options[:start_date], :end_date => options[:end_date], :min => options[:min], :max => options[:max], :points => options[:points] }
rescue => e
  return e.to_s
end

#destroy(options = {}) ⇒ Object

Método para destruir um ranking específico do aplicativo Esse método aceita como parâmetro: options =

:start_date => DATA_INICIO_DO_RANKING,
:end_date => DATA_FIM_DO_RANKING,
:user_reference => REFERENCIA_DO_USUARIO



86
87
88
89
# File 'lib/plataforma_social/ranking.rb', line 86

def destroy options = {}
  # Not implemented yet
  return "Method not implemented yet"
end

#destroy_allObject

Método para destruir todo o ranking do aplicativo Esse método não aceita nenhum parâmetro



73
74
75
76
# File 'lib/plataforma_social/ranking.rb', line 73

def destroy_all
  # Not implemented yet
  return "Method not implemented yet"
end

#friends(options = {}) ⇒ Object

Método para retornar o ranking completo de todos amigos do app Esse método aceita como parâmetro: options =

:user_reference => REFERENCIA_DO_USUARIO, <- Obrigatório
:limit => NUMERO_MAXIMO_DE_REGISTROS_A_SEREM_RETORNADOS,
:page =>  PAGINA_A_SER_RETORNADA_NA_PAGINACAO



62
63
64
65
66
67
68
# File 'lib/plataforma_social/ranking.rb', line 62

def friends options = {}
  options.symbolize_keys!
  verify_if_has_all_required_parameters [:user_reference], options
  get_request "users/ranking", { :friends => true, :reference => options[:user_reference], :limit => options[:limit], :page => options[:page] }
rescue => e
  return e.to_s
end

#window(options = {}) ⇒ Object

Método para retornar os usuários e suas posições. Nesse método é possível retornar o ranking cortado. Ou seja, caso você queira pegar apenas 2 usuário acima e 2 abaixo de algum outro usuário é possível usando esse método Esse método aceita como parâmetros: options =

:start_date => DATA_INICIO_DO_RANKING,
:end_date => DATA_FIM_DO_RANKING,
:friends => SE_IREMOS_PEGAR_OS_AMIGOS_DO_USUARIO_EM_QUESTAO_OU_NAO(Boolean),
:user_reference => REFERENCIA_DO_USUARIO, <- Obrigatório
:up => NUMERO_DE_USUARIO_A_SEREM_PEGOS_QUE_ESTAO_ACIMA_DO_USUARIO_EM_QUESTAO,
:down => NUMERO_DE_USUARIO_A_SEREM_PEGOS_QUE_ESTAO_ABAIXO_DO_USUARIO_EM_QUESTAO,
:limit => NUMERO_MAXIMO_DE_REGISTROS_QUE_IRA_SER_LEVADO_EM_CONTA_NA_HORA_DE_PEGAR_O_USUARIO_E_A_JANELA



46
47
48
49
50
51
52
# File 'lib/plataforma_social/ranking.rb', line 46

def window options = {}
  options.symbolize_keys!
  verify_if_has_all_required_parameters [:user_reference], options
  get_request "users/ranking/#{options[:up].to_i}/#{options[:down].to_i}/window", { :start_date => options[:start_date], :end_date => options[:end_date], :friends => options[:friends], :limit => options[:limit], :reference => options[:user_reference] }
rescue => e
  return e.to_s
end