Class: Bernoulli
- Inherits:
-
Object
- Object
- Bernoulli
- Defined in:
- lib/bernoulli.rb
Constant Summary collapse
- URL =
'https://bernoulli.herokuapp.com/client/api/experiments/'
Class Method Summary collapse
- .get_experiments(experiment_ids, user_id, client_id = nil, segment_data = nil, should_bucket = true) ⇒ Object
- .goal_attained(experiment_id, user_id, client_id = nil) ⇒ Object
Class Method Details
.get_experiments(experiment_ids, user_id, client_id = nil, segment_data = nil, should_bucket = true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bernoulli.rb', line 7 def self.get_experiments(experiment_ids, user_id, client_id=nil, segment_data=nil, should_bucket=true) if client_id == nil client_id = ENV['BERNOULLI_CLIENT_ID'] if client_id == nil raise ArgumentError, 'client_id' end end if experiment_ids.kind_of?(Array) experiment_ids = experiment_ids.join(',') end response = RestClient.get(URL, { :accept => :json, :params => { :clientId => client_id, :experimentIds => experiment_ids, :userId => user_id, :segmentData => segment_data, :shouldBucketIfNecessary => should_bucket, } }) data = JSON.parse(response) if data['status'] == 'ok' return data['value'] else raise data['message'] end end |
.goal_attained(experiment_id, user_id, client_id = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bernoulli.rb', line 40 def self.goal_attained(experiment_id, user_id, client_id=nil) if client_id == nil client_id = ENV['BERNOULLI_CLIENT_ID'] if client_id == nil raise ArgumentError, 'client_id' end end response = RestClient.post(URL, { :clientId => client_id, :experimentId => experiment_id, :userId => user_id, }) data = JSON.parse(response) return data['status'] == 'ok' end |