stage-ruby

Stage - the Ruby gem for the Stage API Docs

Stage Technologies, Inc. complete API Documentation

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • stage-ruby's package version: 0.0.01
  • Build package: io.swagger.codegen.v3.generators.ruby.RubyClientCodegen

For more information, please visit https://heystage.com

1. Installation

1.1. Install RVM, Ruby, and Gemsets

  1. Install RVM:
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
  1. Install Ruby, and create a gemset:
rvm list known
rvm install 3.0.0
rvm use 3.0.0

rvm gemset list
rvm 3.0.0@stage-ruby  --create

From here on, you can activate ruby version 3.0.0 and the stage-ruby gemset by running the following:

rvm use 3.0.0@stage-ruby
  1. Install dependencies:
bundle install

1.2. Build Gem and Install Locally

  1. Build Ruby code into a gem:
gem build stage-ruby.gemspec
  1. Install the gem locally, where {VERSION} is the gem's version number:
gem install ./stage-ruby-{VERSION}.gem

2. Using stage-ruby Gem

To use a locally installed stage-ruby gem, add the following to your project's Gemfile, where {GEM_DIR} is your local gem installation directory (run rvm gemdir to find out):

gem 'stage-ruby', "~> 0.0.01", :path => '{GEM_DIR}'

To use the stage-ruby that's uploaded to a gem service, add the following to your project's Gemfile, where {VERSION} is the gem's version number:

gem 'stage-ruby', '~> {VERSION}'

3. Including stage-ruby Code Directly

To run a script that depends on stage-ruby's code in /lib, run the following:

ruby -Ilib script.rb

3. Getting Started

Please follow the installation procedure, and then run the following code:

require 'stage-ruby'

Stage.configure do |config|
  config.host = 'localhost:8080'
  config.api_key['Authorization'] = 'YOUR_API_KEY'
  config.api_key_prefix['Authorization'] = 'stage-api-token'
end

api_instance = Stage::StageApi.new

begin
  user_identifier = '[email protected]'
  new_user = api_instance.create_user(user_identifier, feature_identifier: 'BASIC_PLAN')
  p "Created user: #{new_user}"

  result = api_instance.has_access(user_identifier, feature_identifier: 'BASIC_PLAN')
  p "User #{user_identifier} has access to plan: #{result}"

  updated_user = api_instance.update_user_plan(user_identifier, feature_identifier: 'PRO_PLAN')
  p "Updated user: #{updated_user}"

rescue Stage::ApiError => e
  puts "Exception caught: #{e}"
end

4. Documentation for API Endpoints

Class Method HTTP request Description
Stage::StageApi create_user POST /sdk-api/v1/users Creates a user and assigning it to a pre-defined role.
Stage::StageApi has_access GET /sdk-api/v1/users/userIdentifier/features Checks if a user has access to the identified feature.
Stage::StageApi update_user_plan PUT /sdk-api/v1/users/userIdentifier/plans Updates a user's plan..

5. Documentation for Models

6. Documentation for Authorization

stage-api-token

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header