Ruby Table of Contents
Description
This is an example of a wrapper Ruby library for our API functionality, it provide an easy way to interact with Split from within your application.
The Ruby client is instantiated using an admin API key. For more information on how to generate API key, click here.
Get Started
- Download the Ruby library from the following
Link - Once the library is downloaded, run the following command to install the gem
gem install --local splitapi-rb-2.0.0.gem
- Instantiate the Wrapper and Create a New Split API Client
require 'splitapi-rb'
require 'json'
client = SplitApi::Client.new(api_key: 'ADMIN API KEY')
Workspaces
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
- Methods
list
Return list of existing Workspaces in the Organization as workspace object
workspaces=client.workspaces.list
(0..workspaces.length-1).each do |i|
puts workspaces[i].name, workspaces[i].id
end
Environments
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"production": "boolean" // Production environment or not
- Methods
list
Return list of existing Environments for given Workspace
Params: Workspace ID
environments=client.environments.list('Workspace Id')
(0..environments.length-1).each do |i|
puts environments[i].name, environments[i].id
end
TrafficTypes
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"displayAttributeId": "string" // (Optional) Attribute used for display name in UI
- Methods
list
Return list of all existing TestTypes in the organization
tt=client.traffic_types.list('Workspace Id')
(0..tt.length-1).each do |i|
puts tt[i].name, tt[i].id
end
Attributes
- Structure
"id": "string", // Attribute identifier, same as used in identity value map
"trafficTypeId": "string", // Traffic type this attribute is associated with
"displayName": "string", // (Optional) How the attribute will be displayed in the UI, defaults to the id
"description": "string", // (Optional) A description of the attribute
"dataType": "string", // (Optional) The data type of the attribute used for display formatting, defaults to displaying the raw string. Must be one of: null, "string", "datetime", "number", "set"
"isSearchable": boolean // (Optional) Deprecated, included for backward compatibility
- Methods
list
Return list of all existing Attributes for a given Workspace and TestType Ids
Params: Workspace Id, TestType Id
ab=client.attributes.list('TestType Id', 'Workspace Id')
(0..ab.length-1).each do |i|
puts ab[i].display_name, ab[i].id
end
save
Save an attribute for a traffic type ID. The attribute is created if it does not exist and is overwritten completely if it does.
Params: workspace Id, trafficType Id, display name, description, data type, isSearchable
client.attributes.save(
{id: "attrib888",
traffic_type_id: "Traffic Type Id",
display_name: "Marital",
description: "",
data_type: "string"},
'Workspace Id'
)
Customer Identities
- Structure
key: "string", // Key used for getTreatment() calls
trafficTypeId: "string", // Traffic Type Identifier
environmentId: "string", // Environment Identifier
values: { // Attribute Values (key: Attribute Id, value: value)
key: "string",...
- Methods
save
Create or overwrite a single customer ID for a given traffic type and environment.
Params: environment Id, trafficType Id, key, value
client.identities.save({
traffic_type_id: "string",
environment_id: "string",
key: "string",
values: {
attribute_id: "value"
}
})
save_all
Create or overwrite a single customer ID for a given traffic type and environment.
Params: environment Id, trafficType Id, Idenitiy[]
client.identities.save_all("traffic_type_id", "environment_id",
[
{
trafficTypeId: "string",
environmentId: "string",
key: "string",
values: {
attribute_id: "value"
}
},
# ...
]
)
update
Update a single customer ID for a given traffic type and environment. Any provided attribute values will be overwritten, but existing values will otherwise remain.
Params: environment Id, trafficType Id, key, values
client.identities.update({
traffic_type_id: "string",
environment_id: "string",
key: "string",
values: {
key: "value"
}
})
Comments
0 comments
Please sign in to leave a comment.