Class: Telerivet::Task

Inherits:
Entity
  • Object
show all
Defined in:
lib/telerivet/task.rb

Overview

Represents an asynchronous task that is applied to all entities matching a filter.

Tasks include services applied to contacts, messages, or data rows; adding or removing contacts from a group; blocking or unblocking sending messages to a contact; updating a custom variable; deleting contacts, messages, or data rows; or exporting data to CSV.

Fields:

- id (string, max 34 characters)
  * ID of the task
  * Read-only

- task_type (string)
  * The task type
  * Read-only

- task_params (Hash)
  * Parameters applied to all matching rows (specific to `task_type`). See
      [project.createTask](#Project.createTask).
  * Read-only

- filter_type
  * Type of filter defining the rows that the task is applied to
  * Read-only

- filter_params (Hash)
  * Parameters defining the rows that the task is applied to (specific to
      `filter_type`). See [project.createTask](#Project.createTask).
  * Read-only

- time_created (UNIX timestamp)
  * Time the task was created in Telerivet
  * Read-only

- time_active (UNIX timestamp)
  * Time Telerivet started executing the task
  * Read-only

- time_complete (UNIX timestamp)
  * Time Telerivet finished executing the task
  * Read-only

- total_rows (int)
  * The total number of rows matching the filter (null if not known)
  * Read-only

- current_row (int)
  * The number of rows that have been processed so far
  * Read-only

- status (string)
  * The current status of the task
  * Allowed values: created, queued, active, complete, failed, cancelled
  * Read-only

- error_message (string)
  * Error message if the task failed
  * Read-only

- vars (Hash)
  * Custom variables stored for this task. Variable names may be up to 32 characters in
      length and can contain the characters a-z, A-Z, 0-9, and _.
      Values may be strings, numbers, or boolean (true/false).
      String values may be up to 4096 bytes in length when encoded as UTF-8.
      Up to 100 variables are supported per object.
      Setting a variable to null will delete the variable.
  * Read-only

- table_id (string, max 34 characters)
  * ID of the data table this task is applied to (if applicable)
  * Read-only

- user_id (string, max 34 characters)
  * ID of the Telerivet user who created the task (if applicable)
  * Read-only

- project_id
  * ID of the project this task belongs to
  * Read-only

Instance Method Summary collapse

Methods inherited from Entity

#get, #initialize, #load, #save, #set, #set_data, #to_s, #vars

Constructor Details

This class inherits a constructor from Telerivet::Entity

Instance Method Details

#cancelObject

Cancels a task that is not yet complete.

Returns: Telerivet::Task



93
94
95
96
# File 'lib/telerivet/task.rb', line 93

def cancel()
    require_relative 'task'
    Task.new(@api, @api.do_request("POST", get_base_api_path() + "/cancel"))
end

#current_rowObject



134
135
136
# File 'lib/telerivet/task.rb', line 134

def current_row
    get('current_row')
end

#error_messageObject



142
143
144
# File 'lib/telerivet/task.rb', line 142

def error_message
    get('error_message')
end

#filter_paramsObject



114
115
116
# File 'lib/telerivet/task.rb', line 114

def filter_params
    get('filter_params')
end

#filter_typeObject



110
111
112
# File 'lib/telerivet/task.rb', line 110

def filter_type
    get('filter_type')
end

#get_base_api_pathObject



158
159
160
# File 'lib/telerivet/task.rb', line 158

def get_base_api_path()
    "/projects/#{get('project_id')}/tasks/#{get('id')}"
end

#idObject



98
99
100
# File 'lib/telerivet/task.rb', line 98

def id
    get('id')
end

#project_idObject



154
155
156
# File 'lib/telerivet/task.rb', line 154

def project_id
    get('project_id')
end

#statusObject



138
139
140
# File 'lib/telerivet/task.rb', line 138

def status
    get('status')
end

#table_idObject



146
147
148
# File 'lib/telerivet/task.rb', line 146

def table_id
    get('table_id')
end

#task_paramsObject



106
107
108
# File 'lib/telerivet/task.rb', line 106

def task_params
    get('task_params')
end

#task_typeObject



102
103
104
# File 'lib/telerivet/task.rb', line 102

def task_type
    get('task_type')
end

#time_activeObject



122
123
124
# File 'lib/telerivet/task.rb', line 122

def time_active
    get('time_active')
end

#time_completeObject



126
127
128
# File 'lib/telerivet/task.rb', line 126

def time_complete
    get('time_complete')
end

#time_createdObject



118
119
120
# File 'lib/telerivet/task.rb', line 118

def time_created
    get('time_created')
end

#total_rowsObject



130
131
132
# File 'lib/telerivet/task.rb', line 130

def total_rows
    get('total_rows')
end

#user_idObject



150
151
152
# File 'lib/telerivet/task.rb', line 150

def user_id
    get('user_id')
end