telerivet 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/telerivet/airtimetransaction.rb +16 -0
- data/lib/telerivet/apicursor.rb +26 -22
- data/lib/telerivet/broadcast.rb +15 -4
- data/lib/telerivet/contact.rb +20 -10
- data/lib/telerivet/datatable.rb +15 -4
- data/lib/telerivet/group.rb +14 -14
- data/lib/telerivet/label.rb +10 -2
- data/lib/telerivet/message.rb +76 -34
- data/lib/telerivet/organization.rb +124 -2
- data/lib/telerivet/phone.rb +19 -9
- data/lib/telerivet/project.rb +930 -112
- data/lib/telerivet/relativescheduledmessage.rb +361 -0
- data/lib/telerivet/route.rb +1 -1
- data/lib/telerivet/scheduledmessage.rb +112 -22
- data/lib/telerivet/service.rb +140 -32
- data/lib/telerivet.rb +1 -1
- metadata +3 -2
@@ -15,11 +15,53 @@ module Telerivet
|
|
15
15
|
# * Updatable via API
|
16
16
|
#
|
17
17
|
# - timezone_id
|
18
|
-
# * Billing quota time zone ID; see
|
19
|
-
#
|
18
|
+
# * Billing quota time zone ID; see [List of tz database time zones Wikipedia
|
19
|
+
# article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
20
20
|
# * Updatable via API
|
21
21
|
#
|
22
22
|
class Organization < Entity
|
23
|
+
#
|
24
|
+
# Creates a new project.
|
25
|
+
#
|
26
|
+
# Some project settings are not currently possible to configure via
|
27
|
+
# the API, and can only be edited via the web app after the project is created.
|
28
|
+
#
|
29
|
+
# Arguments:
|
30
|
+
# - options (Hash)
|
31
|
+
# * Required
|
32
|
+
#
|
33
|
+
# - name (string)
|
34
|
+
# * Name of the project to create, which must be unique in the organization.
|
35
|
+
# * Required
|
36
|
+
#
|
37
|
+
# - timezone_id
|
38
|
+
# * Default TZ database timezone ID; see [List of tz database time zones Wikipedia
|
39
|
+
# article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones). This timezone
|
40
|
+
# is used when computing statistics by date.
|
41
|
+
#
|
42
|
+
# - url_slug
|
43
|
+
# * Unique string used as a component of the project's URL in the Telerivet web app.
|
44
|
+
# If not provided, a URL slug will be generated automatically.
|
45
|
+
#
|
46
|
+
# - auto_create_contacts (bool)
|
47
|
+
# * If true, a contact will be automatically created for each unique phone number that
|
48
|
+
# a message is sent to or received from. If false, contacts will not automatically be
|
49
|
+
# created (unless contact information is modified by an automated service). The
|
50
|
+
# Conversations tab in the web app will only show messages that are associated with a
|
51
|
+
# contact.
|
52
|
+
# * Default: 1
|
53
|
+
#
|
54
|
+
# - vars
|
55
|
+
# * Custom variables and values to set for this project
|
56
|
+
#
|
57
|
+
# Returns:
|
58
|
+
# Telerivet::Project
|
59
|
+
#
|
60
|
+
def create_project(options)
|
61
|
+
require_relative 'project'
|
62
|
+
Project.new(@api, @api.do_request("POST", get_base_api_path() + "/projects", options))
|
63
|
+
end
|
64
|
+
|
23
65
|
#
|
24
66
|
# Saves any fields that have changed for this organization.
|
25
67
|
#
|
@@ -98,6 +140,86 @@ class Organization < Entity
|
|
98
140
|
return @api.do_request("GET", get_base_api_path() + "/usage/#{usage_type}")
|
99
141
|
end
|
100
142
|
|
143
|
+
#
|
144
|
+
# Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
|
145
|
+
# historical data that is computed shortly after midnight each day in the project's time zone,
|
146
|
+
# and does not contain message statistics for the current day.
|
147
|
+
#
|
148
|
+
# Arguments:
|
149
|
+
# - options (Hash)
|
150
|
+
# * Required
|
151
|
+
#
|
152
|
+
# - start_date (string)
|
153
|
+
# * Start date of message statistics, in YYYY-MM-DD format
|
154
|
+
# * Required
|
155
|
+
#
|
156
|
+
# - end_date (string)
|
157
|
+
# * End date of message statistics (inclusive), in YYYY-MM-DD format
|
158
|
+
# * Required
|
159
|
+
#
|
160
|
+
# - rollup (string)
|
161
|
+
# * Date interval to group by
|
162
|
+
# * Allowed values: day, week, month, year, all
|
163
|
+
# * Default: day
|
164
|
+
#
|
165
|
+
# - properties (string)
|
166
|
+
# * Comma separated list of properties to group by
|
167
|
+
# * Allowed values: org_id, org_name, org_industry, project_id, project_name, user_id,
|
168
|
+
# user_email, user_name, phone_id, phone_name, phone_type, direction, source, status,
|
169
|
+
# network_code, network_name, message_type, service_id, service_name, simulated, link
|
170
|
+
#
|
171
|
+
# - metrics (string)
|
172
|
+
# * Comma separated list of metrics to return (summed for each distinct value of the
|
173
|
+
# requested properties)
|
174
|
+
# * Allowed values: count, num_parts, duration, price
|
175
|
+
# * Required
|
176
|
+
#
|
177
|
+
# - currency (string)
|
178
|
+
# * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
|
179
|
+
# original price was in a different currency, it will be converted to the requested
|
180
|
+
# currency using the approximate current exchange rate.
|
181
|
+
# * Default: USD
|
182
|
+
#
|
183
|
+
# - filters (Hash)
|
184
|
+
# * Key-value pairs of properties and corresponding values; the returned statistics
|
185
|
+
# will only include messages where the property matches the provided value. Only the
|
186
|
+
# following properties are supported for filters: `user_id`, `phone_id`, `direction`,
|
187
|
+
# `source`, `status`, `service_id`, `simulated`, `message_type`, `network_code`
|
188
|
+
#
|
189
|
+
# Returns:
|
190
|
+
# (associative array)
|
191
|
+
# - intervals (array)
|
192
|
+
# * List of objects representing each date interval containing at least one message
|
193
|
+
# matching the filters.
|
194
|
+
# Each object has the following properties:
|
195
|
+
#
|
196
|
+
# <table>
|
197
|
+
# <tr><td> start_time </td> <td> The UNIX timestamp of the start
|
198
|
+
# of the interval (int) </td></tr>
|
199
|
+
# <tr><td> end_time </td> <td> The UNIX timestamp of the end of
|
200
|
+
# the interval, exclusive (int) </td></tr>
|
201
|
+
# <tr><td> start_date </td> <td> The date of the start of the
|
202
|
+
# interval in YYYY-MM-DD format (string) </td></tr>
|
203
|
+
# <tr><td> end_date </td> <td> The date of the end of the
|
204
|
+
# interval in YYYY-MM-DD format, inclusive (string) </td></tr>
|
205
|
+
# <tr><td> groups </td> <td> Array of groups for each
|
206
|
+
# combination of requested property values matching the filters (array)
|
207
|
+
# <br /><br />
|
208
|
+
# Each object has the following properties:
|
209
|
+
# <table>
|
210
|
+
# <tr><td> properties </td> <td> An object of key/value
|
211
|
+
# pairs for each distinct value of the requested properties (object) </td></tr>
|
212
|
+
# <tr><td> metrics </td> <td> An object of key/value pairs
|
213
|
+
# for each requested metric (object) </td></tr>
|
214
|
+
# </table>
|
215
|
+
# </td></tr>
|
216
|
+
# </table>
|
217
|
+
#
|
218
|
+
def get_message_stats(options)
|
219
|
+
data = @api.do_request("GET", get_base_api_path() + "/message_stats", options)
|
220
|
+
return data
|
221
|
+
end
|
222
|
+
|
101
223
|
#
|
102
224
|
# Queries projects in this organization.
|
103
225
|
#
|
data/lib/telerivet/phone.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
module Telerivet
|
3
3
|
|
4
4
|
#
|
5
|
-
# Represents a phone or gateway that you use to send/receive messages via
|
5
|
+
# Represents a basic route (i.e. a phone or gateway) that you use to send/receive messages via
|
6
|
+
# Telerivet.
|
6
7
|
#
|
7
8
|
# Basic Routes were formerly referred to as "Phones" within Telerivet. API
|
8
9
|
# methods, parameters, and properties related to Basic Routes continue to use the term "Phone"
|
@@ -73,15 +74,16 @@ module Telerivet
|
|
73
74
|
#
|
74
75
|
# - android_sdk (int)
|
75
76
|
# * Android SDK level, indicating the approximate version of the Android OS installed on
|
76
|
-
# this phone; see
|
77
|
-
#
|
77
|
+
# this phone; see [list of Android SDK
|
78
|
+
# levels](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)
|
78
79
|
# (only present for Android phones)
|
79
80
|
# * Read-only
|
80
81
|
#
|
81
82
|
# - mccmnc
|
82
83
|
# * Code indicating the Android phone's current country (MCC) and mobile network
|
83
|
-
# operator (MNC); see
|
84
|
-
#
|
84
|
+
# operator (MNC); see [Mobile country code Wikipedia
|
85
|
+
# article](https://en.wikipedia.org/wiki/Mobile_country_code) (only present for Android
|
86
|
+
# phones). Note this is a string containing numeric digits, not an integer.
|
85
87
|
# * Read-only
|
86
88
|
#
|
87
89
|
# - manufacturer
|
@@ -100,7 +102,7 @@ module Telerivet
|
|
100
102
|
#
|
101
103
|
class Phone < Entity
|
102
104
|
#
|
103
|
-
# Queries messages sent or received by this
|
105
|
+
# Queries messages sent or received by this basic route.
|
104
106
|
#
|
105
107
|
# Arguments:
|
106
108
|
# - options (Hash)
|
@@ -111,7 +113,7 @@ class Phone < Entity
|
|
111
113
|
#
|
112
114
|
# - message_type
|
113
115
|
# * Filter messages by message_type
|
114
|
-
# * Allowed values: sms, mms, ussd, call, service
|
116
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
115
117
|
#
|
116
118
|
# - source
|
117
119
|
# * Filter messages by source
|
@@ -124,7 +126,7 @@ class Phone < Entity
|
|
124
126
|
# - status
|
125
127
|
# * Filter messages by status
|
126
128
|
# * Allowed values: ignored, processing, received, sent, queued, failed,
|
127
|
-
# failed_queued, cancelled, delivered, not_delivered
|
129
|
+
# failed_queued, cancelled, delivered, not_delivered, read
|
128
130
|
#
|
129
131
|
# - time_created[min] (UNIX timestamp)
|
130
132
|
# * Filter messages created on or after a particular time
|
@@ -134,18 +136,26 @@ class Phone < Entity
|
|
134
136
|
#
|
135
137
|
# - external_id
|
136
138
|
# * Filter messages by ID from an external provider
|
139
|
+
# * Allowed modifiers: external_id[ne], external_id[exists]
|
137
140
|
#
|
138
141
|
# - contact_id
|
139
142
|
# * ID of the contact who sent/received the message
|
143
|
+
# * Allowed modifiers: contact_id[ne], contact_id[exists]
|
140
144
|
#
|
141
145
|
# - phone_id
|
142
146
|
# * ID of the phone (basic route) that sent/received the message
|
143
147
|
#
|
144
148
|
# - broadcast_id
|
145
149
|
# * ID of the broadcast containing the message
|
150
|
+
# * Allowed modifiers: broadcast_id[ne], broadcast_id[exists]
|
146
151
|
#
|
147
152
|
# - scheduled_id
|
148
153
|
# * ID of the scheduled message that created this message
|
154
|
+
# * Allowed modifiers: scheduled_id[ne], scheduled_id[exists]
|
155
|
+
#
|
156
|
+
# - group_id
|
157
|
+
# * Filter messages sent or received by contacts in a particular group. The group must
|
158
|
+
# be a normal group, not a dynamic group.
|
149
159
|
#
|
150
160
|
# - sort
|
151
161
|
# * Sort the results based on a field
|
@@ -174,7 +184,7 @@ class Phone < Entity
|
|
174
184
|
end
|
175
185
|
|
176
186
|
#
|
177
|
-
# Saves any fields or custom variables that have changed for this
|
187
|
+
# Saves any fields or custom variables that have changed for this basic route.
|
178
188
|
#
|
179
189
|
def save()
|
180
190
|
super
|