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

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
  }
]

}

Parameters:

  • list_name (String)

    The list API name

  • model (Hash)

    The model containing the data that should be sent



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"
]

Parameters:

  • model (Hash)

    The model containing the data that should be sent



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"
      }
    ]
  }
]

}

Parameters:

  • list_name (String)

    The list API name

  • model (Hash)

    The model containing the data that should be sent



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

Parameters:

  • list_name (String)

    The list API name

  • field_name (String)

    The field name



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

Parameters:

  • list_name (String)

    The list API name

  • options (Hash) (defaults to: {})

    Additional options

Options Hash (options):

  • :dropTable (Boolean)

    delete the associated table



47
48
49
# File 'lib/selligent/client/lists.rb', line 47

def delete_list(list_name, options = {})
  delete "#{base_url}/lists/#{list_name}", options
end

#delete_record(list_name, record_id) ⇒ Object

Delete a single record by id

Parameters:

  • list_name (String)

    The list API name

  • record_id (Integer)

    The record 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

Parameters:

  • list_name (String)

    The list API name

  • scope (String)

    The scope name of the relation



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

Parameters:

  • list_name (String)

    The list API name



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

Parameters:

  • list_name (String)

    The list API 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

Parameters:

  • options (Hash) (defaults to: {})

    Options for filtering, searching, etc.

Options Hash (options):

  • :filter (String)

    Filter list by type

  • :search (String)

    Search a list by name, description or tags

  • :skip (Integer)

    Specify index to start picking list items from

  • :take (Integer)

    Specify count for the number of items to be taken



18
19
20
# File 'lib/selligent/client/lists.rb', line 18

def lists(options = {})
  get "#{base_url}/lists", options
end

#records_count(list_name) ⇒ Object

Get the number of records for the given list

Parameters:

  • list_name (String)

    The list API name



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

Parameters:

  • list_name (String)

    The list API name

  • scope (String)

    The scope name of the relation



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

Parameters:

  • list_name (String)

    The list API name



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

Parameters:

  • list_name (String)

    The list API name

  • segment_name (String)

    The name of the segment



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

Parameters:

  • list_name (String)

    The list API name

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :filter (String)

    Filter segment by type

  • :search (String)

    Search a segment by name, description or tags

  • :skip (Integer)

    Specify index to start picking segment items from

  • :take (Integer)

    Specify count for the number of segments to be taken



251
252
253
# File 'lib/selligent/client/lists.rb', line 251

def segments(list_name, options = {})
  get "#{base_url}/lists/#{list_name}/segments", options
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."

Parameters:

  • list_name (String)

    The list API name

  • field_name (String)

    The field name

  • model (Hash)

    The model containing the data that should be sent



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"
  ]
}

}

Parameters:

  • list_name (String)

    The list API name

  • model (Hash)

    The model containing the data that should be sent



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": ""
  }
]

}

Parameters:

  • list_name (String)

    The list API name

  • scope (String)

    The scope name of the relation

  • model (Hash)

    The model containing the data that should be sent



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