devcycle-server-sdk

DevCycle - the Ruby gem for the DevCycle Bucketing API

Documents the DevCycle Bucketing API which provides and API interface to User Bucketing and for generated SDKs.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Install the gem

gem install devcycle-server-sdk

Getting Started

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

# Load the gem
require 'devcycle-server-sdk'

# Setup authorization
DevCycle.configure do |config|
  # Configure API key authorization
  config.api_key['bearerAuth'] = 'YOUR API KEY'
end

api_instance = DevCycle::DVCClient.new
user_data = DevCycle::UserData.new({user_id: 'user_id_example'}) # UserData | 

begin
  #Get all features for user data
  result = api_instance.all_features(user_data)
  p result
rescue DevCycle::ApiError => e
  puts "Exception when calling DVCClient->all_features: #{e}"
end

Usage

Configure SDK

# Load the gem
require 'devcycle-server-sdk'

# Setup authorization
DevCycle.configure do |config|
  # Configure API key authorization
  config.api_key['bearerAuth'] = 'YOUR API KEY'
end

api_instance = DevCycle::DVCClient.new
user_data = DevCycle::UserData.new({user_id: 'user_id_example'}) # UserData | 

Get all features

begin
  #Get all features for user data
  result = api_instance.all_features(user_data)
  p result
rescue DevCycle::ApiError => e
  puts "Exception when calling DVCClient->all_features: #{e}"
end

Get variable by key

begin
  # Get value of given variable by key, using default value if segmentation is not passed or variable does not exit
  result = api_instance.variable("variable-key", user_data, true)
  p "Received value for #{result.key}: #{result.value}"
rescue DevCycle::ApiError => e
  puts "Exception when calling DVCClient->variable: #{e}"
end

Get all variables

begin
  #Get all variables for user data
  result = api_instance.all_variables(user_data)
  p result
rescue DevCycle::ApiError => e
  puts "Exception when calling DVCClient->all_variables: #{e}"
end

Send events


event_data = DevCycle::Event.new({
  type: "my-event",
  target: "some_event_target",
  value: 12,
  meta_data: {
    myKey: "my-value"
  }
})

begin
  # Post events for given user data
  result = api_instance.track(user_data, event_data)
  p result
rescue DevCycle::ApiError => e
  puts "Exception when calling DVCClient->track: #{e}"
end

Override Logger

To provide a custom logger, override the logger property of the SDK configuration.

DevCycle.configure do |config|
  # Configure API key authorization
  config.api_key['bearerAuth'] = 'YOUR API KEY'

  # Override the default logger
  config.logger = MyLogger
end

Troubleshooting

To see a detailed log of the requests being made to the DevCycle API, enable SDK debug logging:

DevCycle.configure do |config|
  # Configure API key authorization
  config.api_key['bearerAuth'] = 'YOUR API KEY'

  # Enable detailed debug logs of requests being sent to the DevCycle API
  config.debugging = true
end

Documentation for Models

Development

To build the Ruby code into a gem:

gem build devcycle-server-sdk.gemspec

Then either install the gem locally:

gem install ./devcycle-server-sdk-1.0.0.gem

(for development, run gem install --dev ./devcycle-server-sdk-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'devcycle-server-sdk', '~> 1.0.0'