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
- Install RVM:
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
- 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
- Install dependencies:
bundle install
1.2. Build and Publish stage-ruby
Gem Locally
To build and publish stage-ruby
gem locally for development or test, follow these steps:
- Build Ruby code into a gem:
gem build stage-ruby.gemspec
- Install the gem locally, where
{VERSION}
is the gem's version number:
gem install ./stage-ruby-{VERSION}.gem
To find the installation directory, run the following command: rvm gemdir
.
1.3. Build and Publish stage-ruby
Gem to RubyGems.org
Before proceeding, please see the RubyGems's documentation on how to publish a gem
here. To build and publish stage-ruby
gem to
RubyGems.org, follow these steps:
Either create an account on RubyGems.org or use an existing account (username:
dennis_stage
, password: see the password stored in Doppler'sRUBY_GEMS_PASSWORD
, under thegeneral
environment).Build Ruby code into a gem:
gem build stage-ruby.gemspec
- Push
stage-ruby
to RubyGems.org, where{VERSION}
is the gem's version number (enter your username and password when prompted):
gem push stage-ruby-{VERSION}.gem
2. Using stage-ruby
Gem
When the stage-ruby
gem is installed locally, add the following to your project's Gemfile, where {VERSION}
is
the gem's version number, and {GEM_DIR}
is your local gem installation directory (again, rvm gemdir
to find out):
gem 'stage-ruby', '~> {VERSION}', :path => '{GEM_DIR}'
To use the stage-ruby
from RubyGems.org, 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}"
mark_accessed = true
result = api_instance.has_access(user_identifier, feature_identifier: 'BASIC_PLAN', mark_accessed)
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 | get_plans | GET /sdk-api/v1/plans | Gets all plans. |
Stage::StageApi | has_access | GET /sdk-api/v1/users/userIdentifier/features | Checks if a user has access to the identified features. |
Stage::StageApi | access | POST /sdk-api/v1/users/userIdentifier/features | If the user has access to the features, this marks those features as accessed. |
Stage::StageApi | decrement_access_count_or_credit_usage | DELETE /sdk-api/v1/users/userIdentifier/features | Either decrements the access count or credits the one usage for each of the accessible features. |
Stage::StageApi | update_user_plan | PUT /sdk-api/v1/users/userIdentifier/plans | Updates a user's plan. |
5. Documentation for Models
- Stage::AccessFeatureForm
- Stage::AccessForm
- Stage::ClientUserForm
- Stage::ClientUserObjectForm
- Stage::FeatureObjectForm
- Stage::Field
- Stage::PlanObjectForm
- Stage::StageError
- Stage::StageUserObjectForm
6. Documentation for Authorization
stage-api-token
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header