Monkey Bytes - Gain, entertain, retain

Back end

Create bet

https:/{your_server}/bets

Is called whenever a user tries to participate one or more tournaments. To cancel the participations respond with a JSON object with an error property and HTTP status 402 Payment Required.

This happens whether the tournaments are free or not. To fulfill the participations, deduct the appropriate amount of money from the user's wallet and respond with an OK.

This callback will be called with:


{
  headers: {
    authorization: 'Bearer %customer% {user_token}'
  },
  body: {
    bets: [{
      user: {                       // Data about the user creating the fantasy team
        client: String,             // Name of white label, most likely yours
        uid: String,                // Unique ID of user
        name: String                // Username
        ip: String                  // Ip of the user
      },
      pool: {                       // Data about betting pool (tournament)
        client: String,             // Name of white label, most likely yours
        game: String,               // Type of game being played. Should be "fantasy" or "micro"
        uid: Integer,               // Id of tournament, unique within game scope
        currency: String            // Base currency of the pool
        overdraw: String <Decimal>  // Guaranteed prize pool amount / Freeroll prize
        category: String            // Tournament type (admin_created, hidden, user_created, draft_and_go)
        amount: Number              // Tournament buy in, in base currency
      },
      bet: {                        // Data about the bet being made (fantasy team)
        uid: Integer,               // Id of the fantasy team, unique within game scope
        uuid: String                //
        base_amount: Number         // Buy-in in tournament's base currency
        amount: String <Decimal>,   // Buy-in
        rake: String <Decimal>,     // Rake. User must afford buy-in + rake
        currency: String            // Currency of the bet(the users currency)
        ticket: String <optional>   // Ticket token (see appendix later)
      }
    }]
  }
}

Ticket tokens

If the user has a tournament ticket, they can spend it to register a fantasy team for free in tournaments fitting the ticket constraints.

Tickets can be for a single tournament, or work for a specific amount of buy-in within a specific season.

Tickets are JWT-encoded and should be decoded using your secret key.

When decoded, a valid tickets looks like so:


{
  ticket: Integer  // Id of the ticket being used
  cost: Number // cost of ticket in tournament's base currency
}

You should ensure that the ticket can be decoded using your key, and that the ticket id is not one that has been used before.

If you do not wish to support tickets in your system, you can throw an error upon seeing the ticket field, or simply ignore it.

Previous
About callbacks