Module: Selligent::Client::Lists
- Included in:
- Selligent::Client
- Defined in:
- lib/selligent/client/lists.rb
Overview
Implements the list endpoints
In this module, list_name is the list name as it appears in the API urls.
/organizations/:organization/lists/*
Instance Method Summary collapse
-
#create_fields(list_name, model) ⇒ Object
Create list fields.
-
#create_list(model) ⇒ Object
Create a new list.
-
#create_relation(list_name, model) ⇒ Object
Create a relation between two lists.
-
#delete_field(list_name, field_name) ⇒ Object
Delete a list field.
-
#delete_list(list_name, options = {}) ⇒ Object
Delete a list.
-
#delete_record(list_name, record_id) ⇒ Object
Delete a single record by id.
-
#delete_relation(list_name, scope) ⇒ Object
Delete a relation between two lists.
-
#fields(list_name) ⇒ Object
Get list fields for the given list.
-
#list(list_name) ⇒ Object
Get details for the list with the given name.
-
#lists(options = {}) ⇒ Object
Returns an overview of all of the lists in this organization.
-
#records_count(list_name) ⇒ Object
Get the number of records for the given list.
-
#relation(list_name, scope) ⇒ Object
Get relation details based based on the list name and the relation scope name.
-
#relations(list_name) ⇒ Object
Get all relations associated with a list.
-
#segment(list_name, segment_name) ⇒ Object
Get segment details based on list API name and segment API name.
-
#segments(list_name, options = {}) ⇒ Object
Get an overview of the segments defined on the given list.
-
#update_field(list_name, field_name, model) ⇒ Object
Update a list field.
-
#update_list(list_name, model) ⇒ Object
Update a list.
-
#update_relation(list_name, scope, model) ⇒ Object
Update an existing relation.
Instance Method Details
#create_fields(list_name, model) ⇒ Object
Create list fields
The model has the following shape:
{
"fields": [
{
"name": "string",
"data_type": "Boolean",
"length": 0,
"description": "string",
"allow_null": true
}
]
}
117 118 119 |
# File 'lib/selligent/client/lists.rb', line 117 def create_fields(list_name, model) post "#{base_url}/lists/#{list_name}/fields", model end |
#create_list(model) ⇒ Object
Create a new list
The model has the following shape:
"api_name": "list_name_in_api",
"name": "list_name",
"type": "Userlist",
"description": "description",
"tags": [
"tag1",
"tag2"
]
38 39 40 |
# File 'lib/selligent/client/lists.rb', line 38 def create_list(model) post "#{base_url}/lists", model end |
#create_relation(list_name, model) ⇒ Object
Create a relation between two lists
The model has the following shape:
{
"relations": [
{
"scope": "string",
"type": "OneToOne",
"masterlist_field_name": "string",
"slavelist_api_name": "string",
"slavelist_field_name": "string",
"constraints": [
{
"list1": "string",
"field1": "string",
"operator": "Unknown",
"list2": "string",
"field2": "string",
"value": "string"
}
]
}
]
}
195 196 197 |
# File 'lib/selligent/client/lists.rb', line 195 def create_relation(list_name, model) post "#{base_url}/lists/#{list_name}/relations", model end |
#delete_field(list_name, field_name) ⇒ Object
Delete a list field
125 126 127 |
# File 'lib/selligent/client/lists.rb', line 125 def delete_field(list_name, field_name) delete "#{base_url}/lists/#{list_name}/fields/#{field_name}" end |
#delete_list(list_name, options = {}) ⇒ Object
Delete a list
47 48 49 |
# File 'lib/selligent/client/lists.rb', line 47 def delete_list(list_name, = {}) delete "#{base_url}/lists/#{list_name}", end |
#delete_record(list_name, record_id) ⇒ Object
Delete a single record by id
156 157 158 |
# File 'lib/selligent/client/lists.rb', line 156 def delete_record(list_name, record_id) delete "#{base_url}/lists/#{list_name}/records/#{record_id}" end |
#delete_relation(list_name, scope) ⇒ Object
Delete a relation between two lists
203 204 205 |
# File 'lib/selligent/client/lists.rb', line 203 def delete_relation(list_name, scope) delete "#{base_url}/lists/#{list_name}/relations/#{scope}" end |
#fields(list_name) ⇒ Object
Get list fields for the given list
95 96 97 |
# File 'lib/selligent/client/lists.rb', line 95 def fields(list_name) get "#{base_url}/lists/#{list_name}/fields" end |
#list(list_name) ⇒ Object
Get details for the list with the given name
54 55 56 |
# File 'lib/selligent/client/lists.rb', line 54 def list(list_name) get "#{base_url}/lists/#{list_name}" end |
#lists(options = {}) ⇒ Object
Returns an overview of all of the lists in this organization
18 19 20 |
# File 'lib/selligent/client/lists.rb', line 18 def lists( = {}) get "#{base_url}/lists", end |
#records_count(list_name) ⇒ Object
Get the number of records for the given list
148 149 150 |
# File 'lib/selligent/client/lists.rb', line 148 def records_count(list_name) get "#{base_url}/lists/#{list_name}/records" end |
#relation(list_name, scope) ⇒ Object
Get relation details based based on the list name and the relation scope name
211 212 213 |
# File 'lib/selligent/client/lists.rb', line 211 def relation(list_name, scope) get "#{base_url}/lists/#{list_name}/relations/#{scope}" end |
#relations(list_name) ⇒ Object
Get all relations associated with a list
163 164 165 |
# File 'lib/selligent/client/lists.rb', line 163 def relations(list_name) get "#{base_url}/lists/#{list_name}/relations" end |
#segment(list_name, segment_name) ⇒ Object
Get segment details based on list API name and segment API name
259 260 261 |
# File 'lib/selligent/client/lists.rb', line 259 def segment(list_name, segment_name) get "#{base_url}/lists/#{list_name}/segments/#{segment_name}" end |
#segments(list_name, options = {}) ⇒ Object
Get an overview of the segments defined on the given list
251 252 253 |
# File 'lib/selligent/client/lists.rb', line 251 def segments(list_name, = {}) get "#{base_url}/lists/#{list_name}/segments", end |
#update_field(list_name, field_name, model) ⇒ Object
Update a list field
The model has the following shape:
"field_name": "FIELD",
"field_description": "This is FIELD."
141 142 143 |
# File 'lib/selligent/client/lists.rb', line 141 def update_field(list_name, field_name, model) put "#{base_url}/lists/#{list_name}/fields/#{field_name}", model end |
#update_list(list_name, model) ⇒ Object
Update a list
The model has the following shape:
{
"api_name": "list_name_in_api",
"name": "list_name",
"description": "description",
"tags": [
"tag1",
"tag2"
],
"email_quality_configuration": {
"type": "Normal",
"bounce_scope": "MASTER",
"actions": [
{
"name": "OPTOUT",
"value": "10"
}
],
"bouncestoredprocedures": [
"ST_Bounce_Sp1",
"ST_Bounce_Sp2"
]
}
}
88 89 90 |
# File 'lib/selligent/client/lists.rb', line 88 def update_list(list_name, model) put "#{base_url}/lists/#{list_name}", model end |
#update_relation(list_name, scope, model) ⇒ Object
Update an existing relation
The model has the following shape:
{
"scope_name": "RELATION",
"relation_type": "OneToMany",
"master_list_field_name": "MASTERLISTFIELD",
"slave_list_api_name": "SLAVELIST",
"slave_list_field_name": "SLAVELISTFIELD",
"constraints": [
{
"source_list": "MASTER",
"source_field": "master_field",
"operator": "EqualTo",
"destination_list": "SLAVE",
"destination_field": "slave_field",
"field_value": ""
}
]
}
240 241 242 |
# File 'lib/selligent/client/lists.rb', line 240 def update_relation(list_name, scope, model) put "#{base_url}/lists/#{list_name}/relations/#{scope}", model end |