Class: Podio::Experiment
Instance Attribute Summary
#attributes
Class Method Summary
collapse
-
.activate_variation(experiment, variation) ⇒ Object
-
.assign_variation(experiment, variation, attributes) ⇒ Object
-
.associate_subject(identifier) ⇒ Object
-
.combined(supported_variations_map, identifier = nil, attributes = {}) ⇒ Object
-
.create_subject(attributes) ⇒ Object
-
.create_variation(experiment, variation) ⇒ Object
-
.deactivate_variation(experiment, variation) ⇒ Object
-
.delete_variation(experiment, variation) ⇒ Object
-
.find(experiment) ⇒ Object
-
.find_all ⇒ Object
-
.find_variation_for_subject(identifier, experiment, supported_variations) ⇒ Object
-
.find_variation_for_user(experiment, supported_variations) ⇒ Object
-
.update_variation_weight(experiment, variation, weight) ⇒ Object
#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param
Class Method Details
.activate_variation(experiment, variation) ⇒ Object
53
54
55
|
# File 'lib/podio/models/experiment.rb', line 53
def activate_variation(experiment, variation)
Podio.connection.post("/experiment/#{experiment}/variation/#{variation}/activate")
end
|
.assign_variation(experiment, variation, attributes) ⇒ Object
72
73
74
75
76
77
|
# File 'lib/podio/models/experiment.rb', line 72
def assign_variation(experiment, variation, attributes)
Podio.connection.post do |req|
req.url "/experiment/#{experiment}/variation/#{variation}/assign"
req.body = attributes
end
end
|
.associate_subject(identifier) ⇒ Object
21
22
23
|
# File 'lib/podio/models/experiment.rb', line 21
def associate_subject(identifier)
Podio.connection.post("/experiment/subject/#{identifier}/associate")
end
|
.combined(supported_variations_map, identifier = nil, attributes = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/podio/models/experiment.rb', line 79
def combined(supported_variations_map, identifier=nil, attributes={})
connection = Podio.client.oauth_token ? Podio.client.connection : Podio.client.trusted_connection
body = attributes.merge({
"experiments" => supported_variations_map
})
body["identifier"] = identifier if identifier.present?
connection.post do |req|
req.url "/experiment/combined"
req.body = body
end.body
end
|
.create_subject(attributes) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/podio/models/experiment.rb', line 13
def create_subject(attributes)
response = Podio.client.trusted_connection.post do |req|
req.url '/experiment/subject/'
req.body = attributes
end
response.body['identifier']
end
|
.create_variation(experiment, variation) ⇒ Object
49
50
51
|
# File 'lib/podio/models/experiment.rb', line 49
def create_variation(experiment, variation)
Podio.connection.post("/experiment/#{experiment}/variation/#{variation}")
end
|
.deactivate_variation(experiment, variation) ⇒ Object
57
58
59
|
# File 'lib/podio/models/experiment.rb', line 57
def deactivate_variation(experiment, variation)
Podio.connection.post("/experiment/#{experiment}/variation/#{variation}/deactivate")
end
|
.delete_variation(experiment, variation) ⇒ Object
61
62
63
|
# File 'lib/podio/models/experiment.rb', line 61
def delete_variation(experiment, variation)
Podio.connection.delete("/experiment/#{experiment}/variation/#{variation}")
end
|
.find(experiment) ⇒ Object
45
46
47
|
# File 'lib/podio/models/experiment.rb', line 45
def find(experiment)
member Podio.connection.get("/experiment/#{experiment}").body
end
|
.find_all ⇒ Object
41
42
43
|
# File 'lib/podio/models/experiment.rb', line 41
def find_all
list Podio.connection.get('/experiment/').body
end
|
.find_variation_for_subject(identifier, experiment, supported_variations) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/podio/models/experiment.rb', line 25
def find_variation_for_subject(identifier, experiment, supported_variations)
response = Podio.client.trusted_connection.post do |req|
req.url "/experiment/#{experiment}/subject/#{identifier}"
req.body = supported_variations
end
response.body['variation']
end
|
.find_variation_for_user(experiment, supported_variations) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/podio/models/experiment.rb', line 33
def find_variation_for_user(experiment, supported_variations)
response = Podio.connection.post do |req|
req.url "/experiment/#{experiment}/user"
req.body = supported_variations
end
response.body['variation']
end
|
.update_variation_weight(experiment, variation, weight) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/podio/models/experiment.rb', line 65
def update_variation_weight(experiment, variation, weight)
Podio.connection.post do |req|
req.url "/experiment/#{experiment}/variation/#{variation}/weight"
req.body = { "weight" => weight }
end
end
|