Class: Telerivet::Label
Overview
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
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes the given label (Note: no messages are deleted.).
- #get_base_api_path ⇒ Object
- #id ⇒ Object
- #name ⇒ Object
- #name=(value) ⇒ Object
- #project_id ⇒ Object
-
#query_messages(options = nil) ⇒ Object
Queries messages with the given label.
-
#save ⇒ Object
Saves any fields that have changed for the label.
- #time_created ⇒ Object
Methods inherited from Entity
#get, #initialize, #load, #set, #set_data, #to_s, #vars
Constructor Details
This class inherits a constructor from Telerivet::Entity
Instance Method Details
#delete ⇒ Object
Deletes the given label (Note: no messages are deleted.)
122 123 124 |
# File 'lib/telerivet/label.rb', line 122 def delete() @api.do_request("DELETE", get_base_api_path()) end |
#get_base_api_path ⇒ Object
146 147 148 |
# File 'lib/telerivet/label.rb', line 146 def get_base_api_path() "/projects/#{get('project_id')}/labels/#{get('id')}" end |
#id ⇒ Object
126 127 128 |
# File 'lib/telerivet/label.rb', line 126 def id get('id') end |
#name ⇒ Object
130 131 132 |
# File 'lib/telerivet/label.rb', line 130 def name get('name') end |
#name=(value) ⇒ Object
134 135 136 |
# File 'lib/telerivet/label.rb', line 134 def name=(value) set('name', value) end |
#project_id ⇒ Object
142 143 144 |
# File 'lib/telerivet/label.rb', line 142 def project_id get('project_id') end |
#query_messages(options = nil) ⇒ Object
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, ussd_session, call, chat, 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, read
- 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
* Allowed modifiers: external_id[ne], external_id[exists]
- contact_id
* ID of the contact who sent/received the message
* Allowed modifiers: contact_id[ne], contact_id[exists]
- phone_id
* ID of the phone (basic route) that sent/received the message
- broadcast_id
* ID of the broadcast containing the message
* Allowed modifiers: broadcast_id[ne], broadcast_id[exists]
- scheduled_id
* ID of the scheduled message that created this message
* Allowed modifiers: scheduled_id[ne], scheduled_id[exists]
- group_id
* Filter messages sent or received by contacts in a particular group. The group must
be a normal group, not a dynamic group.
- 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)
107 108 109 110 |
# File 'lib/telerivet/label.rb', line 107 def ( = nil) require_relative 'message' @api.cursor(Message, get_base_api_path() + "/messages", ) end |
#save ⇒ Object
Saves any fields that have changed for the label.
115 116 117 |
# File 'lib/telerivet/label.rb', line 115 def save() super end |
#time_created ⇒ Object
138 139 140 |
# File 'lib/telerivet/label.rb', line 138 def time_created get('time_created') end |