Unauthorized API - myna/ruby-eventmachine-client GitHub Wiki
Unauthorized API
If you just want to make suggestions and rewards the following unauthorized API will do.
Myna.experiment(uuid)
Constructs an Experiment
given a string UUID.
Example
expt = Myna.experiment('45923780-80ed-47c6-aa46-15e2ae7a0e8c')
Experiment#suggest
Returns a Future
of a Suggestion
. A Suggestion
has two attributes:
choice
, a string representing the choice Myna suggeststoken
, a string representing the token you must pass toreward
Example
expt = Myna.experiment('45923780-80ed-47c6-aa46-15e2ae7a0e8c')
future = expt.suggest.get
suggestion = future.get
puts "Now do something with the suggestion #{suggestion.choice}"
Experiment#reward(token, [amount])
Rewards a suggestion. Token is a string, and the optional amount is a number between 0 and 1. Returned is a future of the Ok singleton.
Example
expt = Myna.experiment('45923780-80ed-47c6-aa46-15e2ae7a0e8c')
suggestion = expt.suggest.get
puts("Choice is #{suggestion.choice}")
expt.reward(suggestion.token, 1.0)