Class: FlagEvaluationService

Inherits:
Object
  • Object
show all
Defined in:
lib/flag_evaluation_service.rb

Overview

Servicio para acceder a flag evaluation

Class Method Summary collapse

Class Method Details

.evaluate(token, user_id = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/flag_evaluation_service.rb', line 7

def self.evaluate(token, user_id = nil)
  url = FlagEvaluationLib::StaticEnvs::SERVICE_URL
  params = user_id == nil ?
    { params: { flag: token } } :
    { params: { flag: token, userId: user_id } }

  response = RestClient.get url, params
  if response.code == 200
    JSON.parse(response.body)
  else
    raise "An error has occured. Response was #{response.code}"
  end
end