Identify API Ruby
This gem provides simple API to make requests to the Split's Identify API.
Installation
Add this gem to your Gemfile as usual:
gem 'splitapi-rb'
Usage
Initialize client
client = SplitApi::Client.new(api_key: 'SPLIT_ADMIN_TOKEN', base_uri: 'SPLIT_IDENTIFY_BASE_URI')
Make requests
Now we have following models Attributes, Environments, Identities, TrafficTypes.
Attributes
Available methods:
list: fetch all known attributes for traffic type
arguments: traffic_type_id
client.attributes.list('traffic_type_id')
# example response:
[
{
"id" => "string",
"traffic_type_id" => "string",
"display_name" => "string",
"description" => "string",
"dataType" => "string"
},
# ...
]
save: create new attribute for traffic type
arguments: attribute_hash
client.attributes.save(
id: "string",
traffic_type_id: "string",
display_name: "string",
description: "string",
data_type: "string"
)
# example response:
{
"id" => "string",
"organization_id" => "string",
"traffic_type_id" => "string",
"display_name" => "string",
"description" => "string",
"data_type" => "string"
}
delete: delete attribute by key
arguments: traffic_type_id, attribute_id
client.attributes.delete('traffic_type_id', 'attribute_id')
# example response:
true
Environments
Available methods:
list: fetch environments
arguments: none
client.environments.list
# example response
[
{
"id" => "string",
"name" => "string"
},
# ...
]
Identities
Available methods:
save: add identity
arguments: identity_hash
client.identities.save(
traffic_type_id: "string",
environment_id: "string",
key: "string",
values: {
key: "value"
}
)
# example response:
{
"traffic_type_id" => "string",
"environment_id" => "string",
"key" => "string",
"values" => {
"key" => "value"
}
}
update: update identity
arguments: identity_hash
client.identities.update(
traffic_type_id: "string",
environment_id: "string",
key: "string",
values: {
key: "value"
}
)
# example response:
{
"traffic_type_id" => "string",
"environment_id" => "string",
"key" => "string",
"values" => {
"key" => "value"
}
}
save_all: save multiple identities
arguments: traffic_type_id, environment_id, identity_array
client.identities.save_all("string", "string",
[
{
"traffic_type_id" => "string",
"environment_id" => "string",
"key" => "string",
"values" => {
"foo" => "bar"
}
},
# ...
]
)
# example response:
{
[
{
"values" => { "foo" => "bar" },
"key" => "string",
"environment_id" => "string",
"traffic_type_id" => "string",
"organization_id" => "string",
"timestamp" => "integer"
},
# ...
]
}
delete: delete all attributes of a specific key
arguments: traffic_type_id, environment_id, key
client.identities.delete(`traffic_type_id`, `environment_id`, `key`)
# example response:
true
Traffic Types
Available methods:
list: list traffic types
arguments: none
client.traffic_types.list
# example response:
[
{
"id": "string",
"name": "string",
"display_attribute_id": "string"
},
# ...
]