class Telerivet::Label

Represents a label used to organize messages within Telerivet.

Fields:

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

- name
    * Name of the label
    * Updatable via API

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

- vars (Hash)
    * Custom variables stored for this label
    * Updatable via API

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

Public Instance Methods

delete() click to toggle source

Deletes the given label (Note: no messages are deleted.)

# File lib/telerivet/label.rb, line 114
def delete()
    @api.do_request("DELETE", get_base_api_path())
end
get_base_api_path() click to toggle source
# File lib/telerivet/label.rb, line 138
def get_base_api_path()
    "/projects/#{get('project_id')}/labels/#{get('id')}"
end
id() click to toggle source
# File lib/telerivet/label.rb, line 118
def id
    get('id')
end
name() click to toggle source
# File lib/telerivet/label.rb, line 122
def name
    get('name')
end
name=(value) click to toggle source
# File lib/telerivet/label.rb, line 126
def name=(value)
    set('name', value)
end
project_id() click to toggle source
# File lib/telerivet/label.rb, line 134
def project_id
    get('project_id')
end
query_messages(options = nil) click to toggle source

Queries messages with the given label.

Arguments:

- options (Hash)

  - direction
      * Filter messages by direction
      * Allowed values: incoming, outgoing

  - message_type
      * Filter messages by message_type
      * Allowed values: sms, mms, ussd, call, service

  - source
      * Filter messages by source
      * Allowed values: phone, provider, web, api, service, webhook, scheduled,
          integration

  - starred (bool)
      * Filter messages by starred/unstarred

  - status
      * Filter messages by status
      * Allowed values: ignored, processing, received, sent, queued, failed,
          failed_queued, cancelled, delivered, not_delivered

  - time_created[min] (UNIX timestamp)
      * Filter messages created on or after a particular time

  - time_created[max] (UNIX timestamp)
      * Filter messages created before a particular time

  - external_id
      * Filter messages by ID from an external provider

  - contact_id
      * ID of the contact who sent/received the message

  - phone_id
      * ID of the phone (basic route) that sent/received the message

  - broadcast_id
      * ID of the broadcast containing the message

  - scheduled_id
      * ID of the scheduled message that created this message

  - sort
      * Sort the results based on a field
      * Allowed values: default
      * Default: default

  - sort_dir
      * Sort the results in ascending or descending order
      * Allowed values: asc, desc
      * Default: asc

  - page_size (int)
      * Number of results returned per page (max 500)
      * Default: 50

  - offset (int)
      * Number of items to skip from beginning of result set
      * Default: 0

Returns:

Telerivet::APICursor (of Telerivet::Message)
# File lib/telerivet/label.rb, line 99
def query_messages(options = nil)
    require_relative 'message'
    @api.cursor(Message, get_base_api_path() + "/messages", options)
end
save() click to toggle source

Saves any fields that have changed for the label.

Calls superclass method Telerivet::Entity#save
# File lib/telerivet/label.rb, line 107
def save()
    super
end
time_created() click to toggle source
# File lib/telerivet/label.rb, line 130
def time_created
    get('time_created')
end