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:
require 'devcycle-server-sdk'
DevCycle.configure do |config|
config.api_key['bearerAuth'] = 'YOUR API KEY'
end
api_instance = DevCycle::DVCClient.new
user_data = DevCycle::UserData.new({user_id: 'user_id_example'})
begin
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
require 'devcycle-server-sdk'
DevCycle.configure do |config|
config.api_key['bearerAuth'] = 'YOUR API KEY'
end
api_instance = DevCycle::DVCClient.new
user_data = DevCycle::UserData.new({user_id: 'user_id_example'})
Get all features
begin
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
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
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
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|
config.api_key['bearerAuth'] = 'YOUR API KEY'
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|
config.api_key['bearerAuth'] = 'YOUR API KEY'
config.debugging = true
end
Documentation for Models
Development
To build the Ruby code into a gem:
gem build ruby-server-sdk.gemspec
Then either install the gem locally:
gem install ./ruby-server-sdk-1.0.0.gem
(for development, run gem install --dev ./ruby-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 'ruby-server-sdk', '~> 1.0.0'