Client library for the BigDoor REST API (bigdoor.com). This package provides both low-level procedural (BigDoor::Client) and object-oriented (BigDoor::Resource object hierarchy) interfaces to BigDoor REST API.
See documentation for BigDoor REST API at publisher.bigdoor.com
require 'rubygems' require 'bigdoor' # see API Keys http://publisher.bigdoor.com/ APP_KEY = '28d3da80bf36fad415ab57b3130c6cb6' APP_SECRET = 'B66F956ED83AE218612CB0FBAC2EF01C' client = BigDoor::Client.new( APP_SECRET, APP_KEY ) currency = BigDoor::Currency.new({ 'pub_title' => 'Coins', 'pub_description' => 'an example of the Purchase currency type', 'end_user_title' => 'Coins', 'end_user_description' => 'can only be purchased', 'currency_type_id' => '1', 'currency_type_title' => 'Purchase', 'exchange_rate' => 900.00, 'relative_weight' => 2, }) currency.save( client ) currency.load( client ) # reload object currency.pub_title = 'Bank Notes' currency.save( client ) # update object keeping same ID currency_id = currency.resource_id currency.load( client, currency_id) # load object by explictly defined id nlc = BigDoor::NamedLevelCollection.new({ 'pub_title' => 'Test Named Level Collection', 'pub_description' => 'test description', 'end_user_title' => 'test user title', 'end_user_description' => 'test user description', 'currency_id' => currency.resource_id, }) nlc.save( client ) nl = BigDoor::NamedLevel.new({ 'pub_title' => 'Named Level pub title', 'pub_description' => 'Named Level pub description', 'end_user_title' => 'Named Level end user title', 'end_user_description' => 'Named Level end user description', 'relative_weight' => 1, 'threshold' => 10, 'named_level_collection_id' => nlc.resource_id, }) nl.save( client ) ntg = BigDoor::NamedTransactionGroup.new({ 'pub_title' => 'Test Transaction Group', 'pub_description' => 'test description', 'end_user_title' => 'end user title', 'end_user_description' => 'end user description', 'end_user_cap' => '-1', 'end_user_cap_interval' => '-1', }) ntg.save( client ) nt = BigDoor::NamedTransaction.new({ 'pub_title' => 'Test Transaction', 'pub_description' => 'test description', 'end_user_title' => 'end user title', 'end_user_description' => 'end user description', 'currency_id' => currency.resource_id, 'amount' => '50', 'default_amount' => '50', }) nt.save( client ) ntg.associate_with( nt, client, 1 ) username = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join end_user = BigDoor::EndUser.new({ 'end_user_login' => username }) end_user.save( client ) ntg.execute( username, { 'good_receiver' => username }, client ) # cleanup currency.delete( client ) ntg.delete( client ) nt.delete( client ) nl.delete( client ) nlc.delete( client ) end_user.delete( client )
-
rest-client
-
uuidtools
-
addressable
-
json
The bigdoorkit
is distributed as a RubyGem and is available immediately after installation.
gem install bigdoorkit
Alternately, download the gem and install manually.
Tests requre rspec 2.x and cucumber gems installed. To access BigDoor API you need to get API keys ( see publisher.bigdoor.com/ site) - place them into appropriate environment variable in you shell - BIGDOOR_API_KEY and BIGDOOR_API_SECRET.
WARNING: Test suite was initially designed to be run against empty account without any objects created (except predefined Attributes and CurrencyTypes) and there is no checks for existing objects. While tests shouldn’t touch or remove any objects other than those they have created, there is still possibility of bugs, so be careful running these tests against account with live economy.
BigDoor Open License Copyright © 2010 BigDoor Media, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
This copyright notice and all listed conditions and disclaimers shall
be included in all copies and portions of the Software including any redistributions in binary form.
-
The Software connects with the BigDoor API (api.bigdoor.com) and
all uses, copies, modifications, derivative works, mergers, publications, distributions, sublicenses and sales shall also connect to the BigDoor API and shall not be used to connect with any API, software or service that competes with BigDoor’s API, software and services.
-
Except as contained in this notice, this license does not grant you rights to
use BigDoor Media, Inc. or any contributors’ name, logo, or trademarks.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.