Class: Telerivet::Phone

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

Overview

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

Instance Method Summary collapse

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

#android_sdkObject



247
248
249
# File 'lib/telerivet/phone.rb', line 247

def android_sdk
    get('android_sdk')
end

#app_versionObject



243
244
245
# File 'lib/telerivet/phone.rb', line 243

def app_version
    get('app_version')
end

#batteryObject



231
232
233
# File 'lib/telerivet/phone.rb', line 231

def battery
    get('battery')
end

#chargingObject



235
236
237
# File 'lib/telerivet/phone.rb', line 235

def charging
    get('charging')
end

#countryObject



207
208
209
# File 'lib/telerivet/phone.rb', line 207

def country
    get('country')
end

#get_base_api_pathObject



267
268
269
# File 'lib/telerivet/phone.rb', line 267

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

#idObject



183
184
185
# File 'lib/telerivet/phone.rb', line 183

def id
    get('id')
end

#internet_typeObject



239
240
241
# File 'lib/telerivet/phone.rb', line 239

def internet_type
    get('internet_type')
end

#last_active_timeObject



223
224
225
# File 'lib/telerivet/phone.rb', line 223

def last_active_time
    get('last_active_time')
end

#manufacturerObject



255
256
257
# File 'lib/telerivet/phone.rb', line 255

def manufacturer
    get('manufacturer')
end

#mccmncObject



251
252
253
# File 'lib/telerivet/phone.rb', line 251

def mccmnc
    get('mccmnc')
end

#modelObject



259
260
261
# File 'lib/telerivet/phone.rb', line 259

def model
    get('model')
end

#nameObject



187
188
189
# File 'lib/telerivet/phone.rb', line 187

def name
    get('name')
end

#name=(value) ⇒ Object



191
192
193
# File 'lib/telerivet/phone.rb', line 191

def name=(value)
    set('name', value)
end

#phone_numberObject



195
196
197
# File 'lib/telerivet/phone.rb', line 195

def phone_number
    get('phone_number')
end

#phone_number=(value) ⇒ Object



199
200
201
# File 'lib/telerivet/phone.rb', line 199

def phone_number=(value)
    set('phone_number', value)
end

#phone_typeObject



203
204
205
# File 'lib/telerivet/phone.rb', line 203

def phone_type
    get('phone_type')
end

#project_idObject



227
228
229
# File 'lib/telerivet/phone.rb', line 227

def project_id
    get('project_id')
end

#query_messages(options = nil) ⇒ Object

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)


171
172
173
174
# 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

#saveObject

Saves any fields or custom variables that have changed for this phone.



179
180
181
# File 'lib/telerivet/phone.rb', line 179

def save()
    super
end

#send_limitObject



263
264
265
# File 'lib/telerivet/phone.rb', line 263

def send_limit
    get('send_limit')
end

#send_pausedObject



211
212
213
# File 'lib/telerivet/phone.rb', line 211

def send_paused
    get('send_paused')
end

#send_paused=(value) ⇒ Object



215
216
217
# File 'lib/telerivet/phone.rb', line 215

def send_paused=(value)
    set('send_paused', value)
end

#time_createdObject



219
220
221
# File 'lib/telerivet/phone.rb', line 219

def time_created
    get('time_created')
end