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.

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 of the phone
    * Updatable via API

- phone_type
    * Type of this phone/gateway (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 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



233
234
235
# File 'lib/telerivet/phone.rb', line 233

def android_sdk
    get('android_sdk')
end

#app_versionObject



229
230
231
# File 'lib/telerivet/phone.rb', line 229

def app_version
    get('app_version')
end

#batteryObject



217
218
219
# File 'lib/telerivet/phone.rb', line 217

def battery
    get('battery')
end

#chargingObject



221
222
223
# File 'lib/telerivet/phone.rb', line 221

def charging
    get('charging')
end

#countryObject



193
194
195
# File 'lib/telerivet/phone.rb', line 193

def country
    get('country')
end

#get_base_api_pathObject



253
254
255
# File 'lib/telerivet/phone.rb', line 253

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

#idObject



169
170
171
# File 'lib/telerivet/phone.rb', line 169

def id
    get('id')
end

#internet_typeObject



225
226
227
# File 'lib/telerivet/phone.rb', line 225

def internet_type
    get('internet_type')
end

#last_active_timeObject



209
210
211
# File 'lib/telerivet/phone.rb', line 209

def last_active_time
    get('last_active_time')
end

#manufacturerObject



241
242
243
# File 'lib/telerivet/phone.rb', line 241

def manufacturer
    get('manufacturer')
end

#mccmncObject



237
238
239
# File 'lib/telerivet/phone.rb', line 237

def mccmnc
    get('mccmnc')
end

#modelObject



245
246
247
# File 'lib/telerivet/phone.rb', line 245

def model
    get('model')
end

#nameObject



173
174
175
# File 'lib/telerivet/phone.rb', line 173

def name
    get('name')
end

#name=(value) ⇒ Object



177
178
179
# File 'lib/telerivet/phone.rb', line 177

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

#phone_numberObject



181
182
183
# File 'lib/telerivet/phone.rb', line 181

def phone_number
    get('phone_number')
end

#phone_number=(value) ⇒ Object



185
186
187
# File 'lib/telerivet/phone.rb', line 185

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

#phone_typeObject



189
190
191
# File 'lib/telerivet/phone.rb', line 189

def phone_type
    get('phone_type')
end

#project_idObject



213
214
215
# File 'lib/telerivet/phone.rb', line 213

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

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

  - 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

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

  - phone_id
      * ID of the phone that sent/received the 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 200)
      * Default: 50

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

Returns:

Telerivet::APICursor (of Telerivet::Message)


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

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.



165
166
167
# File 'lib/telerivet/phone.rb', line 165

def save()
    super
end

#send_limitObject



249
250
251
# File 'lib/telerivet/phone.rb', line 249

def send_limit
    get('send_limit')
end

#send_pausedObject



197
198
199
# File 'lib/telerivet/phone.rb', line 197

def send_paused
    get('send_paused')
end

#send_paused=(value) ⇒ Object



201
202
203
# File 'lib/telerivet/phone.rb', line 201

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

#time_createdObject



205
206
207
# File 'lib/telerivet/phone.rb', line 205

def time_created
    get('time_created')
end