This gem abstracts the Badgeville API behind high level concepts such as user, player, activities, rewards, etc.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install gamifier
Configure Gamifier with the right parameter for the API you're using:
Gamifier.set :key => "1234", :uri => "http://sandbox.v2.badgeville.com/api/berlin/"
Gamifier support the last version of Badgeville API using enterprise api key:
Gamifier.set :key => '1234', :uri => "http://sandbox.v2.badgeville.com/api/berlin/", :enterprise_key => '5678'
Note that you have to specify either a private API key or an enterprise API key.
Then here is an example usage to credit an existing player:
Gamifier.engine do |engine| player = engine.players.find_by_site_and_email('my-site.com', 'email@example.com') player.credit('visit', :url => "http://server.ltd/page.html", :other_key => "value") end
examples/ directory for examples on how to use the DSL to
declare activities, rewards and missions, and you can execute a DSL as
BADGEVILLE_KEY=xzy bundle exec ruby -I lib examples/dev.rb
Since the new Badgeville API, you can create new Network and API Keys using the Badgeville API. We updated the DSL for you:
network = Gamifier.dsl do set :label, 'MyNetwork' set :email, 'firstname.lastname@example.org' api_key do set :access, 'public' end api_key do set :access, 'private' end site 'foo' do # as usual here end end
To only save the network on Badgeville do:
To only save the sites, behaviors, rewards, etc do:
If you want to create a new Network and create Sites, Behaviors, Rewards, etc on that new Network, you'll need the network's private API key.
api_key do set :access, 'private' end
These lines will create a new Private API key on current network. You'll need to:
- Create and Save the network:
- Create and Save the sites, behaviors and so on:
network.save! will use by default the new private API key if any, otherwise it will fallback to Gamifier's config.
Run the unit tests with:
bundle exec rspec spec/unit
Run the integration tests as follows:
BADGEVILLE_KEY=1234 bundle exec rspec spec/integration
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request on Github
- Cyril Rohr email@example.com