No description or website provided.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This library provides an easy way to integrate Licensario's API with your awesome Python application.


This gem provides you with a couple of resource classes that you can use in your applications, coupled with a base API class which you need to configure before start working. These are the steps you need to follow:

  1. Configure: first you need to setup your connection to Licensario's API server. You can do so by:

        Base.establish_connection(key = "MY_API_KEY" , secret = "MY_API_SECRET" )  
  2. Use: now you can start playing with Licensario's interface classes. This gem provides you with four public accessible ones: User, License, LicensedResource and LicensedFeature. You can now do cool things like:

        # Import some important packages
        from licensario.base import Base
        from licensario.user import User
        # Initialize an User
        user = User(external_user_id = 1, email = '')
        # Retrieve this user's Licenses
        feature_ids = [1,2,3]
        payment_plan_ids = [1,2,3]
        licenses = user.get_licenses(feature_ids, payment_plan_ids)
        # Get the current amount available of a given Feature
        feature_id = '19273812'
        payment_plan_id = '123987128'
        feature_amount = user.get_available_feature_amount(feature_id, payment_plan_id)
        # Increment the previous feature's usage (i.e. diminish the available amount)
        user.increment_feature_usage(1, feature_id, payment_plan_id)
        # Create a new License for this User
        new_license = user.create_license(payment_plan_id)

Good luck!


So you have initialized your Base class, as described earlier, and are ready to start doing some serious work. Here are some commom use cases to help you start using the gem. First, a common code to facilitate the reading of these examples:

    # Import some important packages
    from licensario.base import Base
    from licensario.user import User

    # Fire up the API Connection in Debug mode so you can see what's happening under the hood
    Base.establish_connection(key = "MY_API_KEY" , secret = "MY_API_SECRET", debug = true )

    # ID of the Payment Plan
    payment_plan_id = 'MY_PAYMENT_PLAN_ID'

    # ID of the Feature
    feature_id = 'MY_FEATURE_ID'

Initializing an User

You can have an User, which has an licensario_user_id provided by Licensario or, if you prefer to store user information on your own system, you can work with External Users, where you only provide the service a external_user_id string. This parameter can be the ID of the user in your system, a slug, etc.

    # ID of the Payment Plan
    user = User(licensario_user_id = '123123')

Get a list of Licenses

    licenses = user.get_licenses([feature_id],[payment_plan_id])

Create a License

    new_license = user.create_license(payment_plan_id)

Ensure that a License exists

    license = user.ensure_has_license(payment_plan_id)

Read Feature's Allocation

    feature_amount = user.get_available_feature_amount(feature_id, payment_plan_id)

Update a Feature's Allocation

    # IMPORTANT: this will override the available amount o that feature
    user.update_feature_usage(1, feature_id, payment_plan_id)

Increment a Feature's Allocation

    # IMPORTANT: contrary to the Update method, this will increment (or decrement) the available amount.
    user.increment_feature_usage(1, feature_id, payment_plan_id)

Ensure the existence of an External User

    Base.api.ensure_external_user_exists(user_id, user_email)


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request