Discount Network

Status Code
Climate Gem

Ruby API client for Discount Network API


Add this line to your application's Gemfile:

gem "discountnetwork", "~> 0.1.1"

And then execute:

$ bundle


Once you have your API keys from Discount Network, then you can add an initializer to set up your API keys

DiscountNetwork.configure do |config|
  config.api_key = "YOUR_API_KEY"

  # Default configurations
  # config.api_host = ""



Session API allow you to authenticate a subscriber, create a new session or destroying an existing session.

Create a new session

Creating a new session will verify the subscriber and return the subscriber object with subscription details.

  name: "username", password: "secret_password"


Find user account

To retrieve the user account details using the Discount Network account API

# The `auth_token` is optional, if you don't pass any
# parameter then it will try to retrieve the subscriber
# using the `auth_token` configuration.


Create a user account

To create a new user account you can use the Account.create interface, but one important things to remember that account creation is not available for all white label, so if it's failing then most likely this feature is not supported on your white label.


Update user account

Once the user is logged in and auth_token has been configured properly then we can update the user details using the DiscountNetwork account API



Find a subscriber

The activation offers an easier way to find the subscriber details based on the activation_token. To find a subscriber use


Activate a subscriber

Once subscriber has provided their required information then we can activate their account using the Activation API. The API already has validations in place but it would be easier to implement some validation before sending any activation API request.

  activation_token, subscriber_attributes


Forgot password

If the subscriber forgot their password then developer can allow them to reset their password using the Discount network API.


Validate reset token

Before allowing subscriber to reset their password, developer can validate if the reset token is valid or not as expired or invalid reset token won't allow subscriber to reset their password.


Set new password

Once subscriber has submitted a valid reset request and followed the instruction then we can allow them to set their password as follow

DiscountNetwork::Password.create(reset_token, password_attributes)


Each Discount Network subscription comes with varies number of supplementary subscribers, that means primary member can add one or more of this friends or family member to his subscription. The supplementary API provides an easier way to manage the supplementary subscribers. Please note, This interface expects that the subscriber has already been authenticated before making any API call.

List supplementaries

To list all the supplementary subscribers for the authenticated subscriber developer can use the list interface for supplementary.


Add supplementary

To add a new supplementary subscriber with authenticated subscriber's subscription developer can use the create interface for supplementary.


# subscriber attributes
subscriber_attributes = {
  first_name: "John",
  last_name: "Green",
  phone: "+1 123 345 5678",
  email: "[email protected]"


List destinations

Retrieve the list of destinations based on a search term. This is useful when you are planning to show the list of destinations while user start to type destination name

DiscountNetwork::Destination.list(term: "bangkok")

You can create a new search using the API. Please note: It's advisable to wait 10-15 seconds before trying to retrieve the search results.

  adults: 2,
  children: 0,
  room_numbers: 1
  location_id: 835,
  check_in: "25/10/2016",
  check_out: "28/10/2016",
  location_name: "Bangkok, Thailand",

Retrieve search details

Once, you have created a new search and you have the search id then you can retrieve the search details as



Retrieve search results

Retrieve the hotel search results from the Discount Network API.

  search_id: search_id

Retrieve a hotel details

Retrieve the hotel details for a specific search

  search_id: search_id, hotel_id: hotel_id


Creating a new booking

Submit a new booking request for a specific hotel using the API.

# Creating a new booking request for a specific hotel, Pay close
# attention to the construction of the booking object
# If you want to add multiple travellers in one booking then
# pass an Array for travellers as
# `travellers: [traveller_one_attributes, traveller_two_attributes]`
# If you need to add multiple properties in one request, like one
# hotel and a condo in one booking request, then pass an Array as
#`properties: [property_one_attributes, property_two_attributes]`

  hotel_id: "hotel_id",
  search_id: "search_id",
  travellers: traveller_attributes,
  properties: property_attributes

# Traveller attributes

traveller_attributes = {
  first_name: "John",
  last_name: "Doe",
  phone: "012 345 6789",
  email: "[email protected]",
  address: "123 Main Street",
  city: "New York",
  state: "New York",
  zip: "NY10310"

# Property attributes

property_attributes = {
  property_id: "property_101",
  provider_name: "",
  name: "Nasa Vagas, Thailand",
  price: "100.99",
  description: "Description",
  review_score: "90",
  total_reviews: "10000",
  currency_code: "USD"

Find a booking

To find the details for a specific booking request, including the confirmation number, use



Discount Network partnered with multiple vendors to provide the best possible price in all sort of travel. This will allow developer to add those public provider in their site and let their subscriber search and contact the support to receive their subscriber discount.

Retrieving providers

This will allow developer to retrieve all of the specified public travel partner so they can show them to their site. Note: They type is mandatory and the supported value for type are hotel, cruise, resort, tour, package and car.

DiscountNetwork::Provider.where(type: "hotel")

Find a provider

On the provider listing API, one of the most important attribute the API returns is slug, we can use that slug to retrieve the details about any specific provider.



We are following Sandi Metz's Rules for this gem, you can read the description of the rules here. All new code should follow these rules. If you make changes in a pre-existing file that violates these rules you should fix the violations as part of your contribution.


  • Clone the repository.
git clone
  • Setup your environment.
  • Run the test suite


  • Setup API keys.
cp .sample.pryrc .pryrc
vim .pryrc
  • Start your console.
  • Start playing with it.
DiscountNetwork::Session.create(name: "username", password: "password")



This gem provides an easier way to test Discount Network API Responses. Simply include the following line in your spec_helper and you should have access to all of the test helpers.

require "discountnetwork/rspec"


First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.

Here are a few technical guidelines to follow:

  1. Open an issue to discuss a new feature.
  2. Write tests to support your new feature.
  3. Make sure the entire test suite passes locally and on CI.
  4. Open a Pull Request.
  5. Squash your commits after receiving feedback.
  6. Party!


The gem is available as open source under the terms of the MIT License.