Class: PlataformaSocial::Ranking
- Inherits:
-
Object
- Object
- PlataformaSocial::Ranking
- Includes:
- Support
- Defined in:
- lib/plataforma_social/ranking.rb,
lib/plataforma_social/ranking/custom.rb,
lib/plataforma_social/ranking/general.rb
Defined Under Namespace
Class Method Summary collapse
-
.socialp_route ⇒ Object
Método para retornar a url do módulo de ranking na plataforma.
Instance Method Summary collapse
-
#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 }.
-
#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 }.
-
#destroy_all ⇒ Object
Método para destruir todo o ranking do aplicativo Esse método não aceita nenhum parâmetro.
-
#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 }.
-
#window(options = {}) ⇒ Object
Método para retornar os usuários e suas posições.
Class Method Details
.socialp_route ⇒ Object
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. 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 = {} .symbolize_keys! verify_if_has_all_required_parameters [{ :start_date => :end_date }, { :end_date => :start_date }, :user_reference, :points], post_request "users/#{[:user_reference]}/ranking", { :start_date => [:start_date], :end_date => [:end_date], :min => [:min], :max => [:max], :points => [: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 = {} # Not implemented yet return "Method not implemented yet" end |
#destroy_all ⇒ Object
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 = {} .symbolize_keys! verify_if_has_all_required_parameters [:user_reference], get_request "users/ranking", { :friends => true, :reference => [:user_reference], :limit => [:limit], :page => [: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 = {} .symbolize_keys! verify_if_has_all_required_parameters [:user_reference], get_request "users/ranking/#{[:up].to_i}/#{[:down].to_i}/window", { :start_date => [:start_date], :end_date => [:end_date], :friends => [:friends], :limit => [:limit], :reference => [:user_reference] } rescue => e return e.to_s end |