class Telerivet::Phone

Represents a phone or gateway that you use to send/receive messages via Telerivet.

Basic Routes were formerly referred to as “Phones” within Telerivet. API methods, parameters, and properties related to Basic Routes continue to use the term “Phone” to maintain backwards compatibility.

Fields:

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

- name
    * Name of the phone
    * Updatable via API

- phone_number (string)
    * Phone number or sender ID
    * Updatable via API

- phone_type
    * Type of this phone/route (e.g. android, twilio, nexmo, etc)
    * Read-only

- country
    * 2-letter country code (ISO 3166-1 alpha-2) where phone is from
    * Read-only

- send_paused (bool)
    * True if sending messages is currently paused, false if the phone can currently send
        messages
    * Updatable via API

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

- last_active_time (UNIX timestamp)
    * Approximate time this phone last connected to Telerivet
    * Read-only

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

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

- battery (int)
    * Current battery level, on a scale from 0 to 100, as of the last time the phone
        connected to Telerivet (only present for Android phones)
    * Read-only

- charging (bool)
    * True if the phone is currently charging, false if it is running on battery, as of
        the last time it connected to Telerivet (only present for Android phones)
    * Read-only

- internet_type
    * String describing the current type of internet connectivity for an Android phone,
        for example WIFI or MOBILE (only present for Android phones)
    * Read-only

- app_version
    * Currently installed version of Telerivet Android app (only present for Android
        phones)
    * Read-only

- android_sdk (int)
    * Android SDK level, indicating the approximate version of the Android OS installed on
        this phone; see
        <http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels>
        (only present for Android phones)
    * Read-only

- mccmnc
    * Code indicating the Android phone's current country (MCC) and mobile network
        operator (MNC); see <http://en.wikipedia.org/wiki/Mobile_country_code> (only present
        for Android phones). Note this is a string containing numeric digits, not an integer.
    * Read-only

- manufacturer
    * Android phone manufacturer (only present for Android phones)
    * Read-only

- model
    * Android phone model (only present for Android phones)
    * Read-only

- send_limit (int)
    * Maximum number of SMS messages per hour that can be sent by this Android phone. To
        increase this limit, install additional SMS expansion packs in the Telerivet Gateway
        app. (only present for Android phones)
    * Read-only

Public Instance Methods

android_sdk() click to toggle source
# File lib/telerivet/phone.rb, line 247
def android_sdk
    get('android_sdk')
end
app_version() click to toggle source
# File lib/telerivet/phone.rb, line 243
def app_version
    get('app_version')
end
battery() click to toggle source
# File lib/telerivet/phone.rb, line 231
def battery
    get('battery')
end
charging() click to toggle source
# File lib/telerivet/phone.rb, line 235
def charging
    get('charging')
end
country() click to toggle source
# File lib/telerivet/phone.rb, line 207
def country
    get('country')
end
get_base_api_path() click to toggle source
# File lib/telerivet/phone.rb, line 267
def get_base_api_path()
    "/projects/#{get('project_id')}/phones/#{get('id')}"
end
id() click to toggle source
# File lib/telerivet/phone.rb, line 183
def id
    get('id')
end
internet_type() click to toggle source
# File lib/telerivet/phone.rb, line 239
def internet_type
    get('internet_type')
end
last_active_time() click to toggle source
# File lib/telerivet/phone.rb, line 223
def last_active_time
    get('last_active_time')
end
manufacturer() click to toggle source
# File lib/telerivet/phone.rb, line 255
def manufacturer
    get('manufacturer')
end
mccmnc() click to toggle source
# File lib/telerivet/phone.rb, line 251
def mccmnc
    get('mccmnc')
end
model() click to toggle source
# File lib/telerivet/phone.rb, line 259
def model
    get('model')
end
name() click to toggle source
# File lib/telerivet/phone.rb, line 187
def name
    get('name')
end
name=(value) click to toggle source
# File lib/telerivet/phone.rb, line 191
def name=(value)
    set('name', value)
end
phone_number() click to toggle source
# File lib/telerivet/phone.rb, line 195
def phone_number
    get('phone_number')
end
phone_number=(value) click to toggle source
# File lib/telerivet/phone.rb, line 199
def phone_number=(value)
    set('phone_number', value)
end
phone_type() click to toggle source
# File lib/telerivet/phone.rb, line 203
def phone_type
    get('phone_type')
end
project_id() click to toggle source
# File lib/telerivet/phone.rb, line 227
def project_id
    get('project_id')
end
query_messages(options = nil) click to toggle source

Queries messages sent or received by this phone.

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/phone.rb, line 171
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 or custom variables that have changed for this phone.

Calls superclass method Telerivet::Entity#save
# File lib/telerivet/phone.rb, line 179
def save()
    super
end
send_limit() click to toggle source
# File lib/telerivet/phone.rb, line 263
def send_limit
    get('send_limit')
end
send_paused() click to toggle source
# File lib/telerivet/phone.rb, line 211
def send_paused
    get('send_paused')
end
send_paused=(value) click to toggle source
# File lib/telerivet/phone.rb, line 215
def send_paused=(value)
    set('send_paused', value)
end
time_created() click to toggle source
# File lib/telerivet/phone.rb, line 219
def time_created
    get('time_created')
end