telerivet 1.0.2

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.
@@ -0,0 +1,919 @@
1
+
2
+ module Telerivet
3
+
4
+ #
5
+ # Represents a Telerivet project.
6
+ #
7
+ # Provides methods for sending and scheduling messages, as well as
8
+ # accessing, creating and updating a variety of entities, including contacts, messages,
9
+ # scheduled messages, groups, labels, phones, services, and data tables.
10
+ #
11
+ # Fields:
12
+ #
13
+ # - id (string, max 34 characters)
14
+ # * ID of the project
15
+ # * Read-only
16
+ #
17
+ # - name
18
+ # * Name of the project
19
+ # * Updatable via API
20
+ #
21
+ # - timezone_id
22
+ # * Default TZ database timezone ID; see
23
+ # <http://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
24
+ # * Read-only
25
+ #
26
+ # - vars (Hash)
27
+ # * Custom variables stored for this project
28
+ # * Updatable via API
29
+ #
30
+ class Project < Entity
31
+ #
32
+ # Sends one message (SMS or USSD request).
33
+ #
34
+ # Arguments:
35
+ # - options (Hash)
36
+ # * Required
37
+ #
38
+ # - content
39
+ # * Content of the message to send
40
+ # * Required if sending SMS message
41
+ #
42
+ # - to_number (string)
43
+ # * Phone number to send the message to
44
+ # * Required if contact_id not set
45
+ #
46
+ # - contact_id
47
+ # * ID of the contact to send the message to
48
+ # * Required if to_number not set
49
+ #
50
+ # - route_id
51
+ # * ID of the phone or route to send the message from
52
+ # * Default: default sender phone ID for your project
53
+ #
54
+ # - status_url
55
+ # * Webhook callback URL to be notified when message status changes
56
+ #
57
+ # - status_secret
58
+ # * POST parameter 'secret' passed to status_url
59
+ #
60
+ # - is_template (bool)
61
+ # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
62
+ # available variables)](#variables)
63
+ # * Default: false
64
+ #
65
+ # - label_ids (array)
66
+ # * List of IDs of labels to add to this message
67
+ #
68
+ # - message_type
69
+ # * Type of message to send
70
+ # * Allowed values: sms, ussd
71
+ # * Default: sms
72
+ #
73
+ # - vars (Hash)
74
+ # * Custom variables to store with the message
75
+ #
76
+ # - priority (int)
77
+ # * Priority of the message (currently only observed for Android phones). Telerivet
78
+ # will attempt to send messages with higher priority numbers first (for example, so
79
+ # you can prioritize an auto-reply ahead of a bulk message to a large group).
80
+ # * Default: 1
81
+ #
82
+ # Returns:
83
+ # Telerivet::Message
84
+ #
85
+ def send_message(options)
86
+ require_relative 'message'
87
+ Message.new(@api, @api.do_request("POST", get_base_api_path() + "/messages/send", options))
88
+ end
89
+
90
+ #
91
+ # Sends an SMS message (optionally with mail-merge templates) to a group or a list of up to
92
+ # 500 phone numbers
93
+ #
94
+ # Arguments:
95
+ # - options (Hash)
96
+ # * Required
97
+ #
98
+ # - content
99
+ # * Content of the message to send
100
+ # * Required
101
+ #
102
+ # - group_id
103
+ # * ID of the group to send the message to
104
+ # * Required if to_numbers not set
105
+ #
106
+ # - to_numbers (array of strings)
107
+ # * List of up to 500 phone numbers to send the message to
108
+ # * Required if group_id not set
109
+ #
110
+ # - route_id
111
+ # * ID of the phone or route to send the message from
112
+ # * Default: default sender phone ID
113
+ #
114
+ # - status_url
115
+ # * Webhook callback URL to be notified when message status changes
116
+ #
117
+ # - label_ids (array)
118
+ # * Array of IDs of labels to add to all messages sent (maximum 5)
119
+ #
120
+ # - status_secret
121
+ # * POST parameter 'secret' passed to status_url
122
+ #
123
+ # - exclude_contact_id
124
+ # * Optionally excludes one contact from receiving the message (only when group_id is
125
+ # set)
126
+ #
127
+ # - is_template (bool)
128
+ # * Set to true to evaluate variables like [[contact.name]] in message content [(See
129
+ # available variables)](#variables)
130
+ # * Default: false
131
+ #
132
+ # - vars (Hash)
133
+ # * Custom variables to set for each message
134
+ #
135
+ # Returns:
136
+ # (associative array)
137
+ # - count_queued (int)
138
+ # * Number of messages queued to send
139
+ #
140
+ def send_messages(options)
141
+ return @api.do_request("POST", get_base_api_path() + "/messages/send_batch", options)
142
+ end
143
+
144
+ #
145
+ # Schedules an SMS message to a group or single contact. Note that Telerivet only sends
146
+ # scheduled messages approximately once per minute, so it is not possible to control the exact
147
+ # second at which a scheduled message is sent.
148
+ #
149
+ # Arguments:
150
+ # - options (Hash)
151
+ # * Required
152
+ #
153
+ # - content
154
+ # * Content of the message to schedule
155
+ # * Required
156
+ #
157
+ # - group_id
158
+ # * ID of the group to send the message to
159
+ # * Required if to_number not set
160
+ #
161
+ # - to_number (string)
162
+ # * Phone number to send the message to
163
+ # * Required if group_id not set
164
+ #
165
+ # - start_time (UNIX timestamp)
166
+ # * The time that the message will be sent (or first sent for recurring messages)
167
+ # * Required if start_time_offset not set
168
+ #
169
+ # - start_time_offset (int)
170
+ # * Number of seconds from now until the message is sent
171
+ # * Required if start_time not set
172
+ #
173
+ # - rrule
174
+ # * A recurrence rule describing the how the schedule repeats, e.g. 'FREQ=MONTHLY' or
175
+ # 'FREQ=WEEKLY;INTERVAL=2'; see <https://tools.ietf.org/html/rfc2445#section-4.3.10>.
176
+ # (UNTIL is ignored; use end_time parameter instead).
177
+ # * Default: COUNT=1 (one-time scheduled message, does not repeat)
178
+ #
179
+ # - route_id
180
+ # * ID of the phone or route to send the message from
181
+ # * Default: default sender phone ID
182
+ #
183
+ # - message_type
184
+ # * Type of message to send
185
+ # * Allowed values: sms, ussd
186
+ # * Default: sms
187
+ #
188
+ # - is_template (bool)
189
+ # * Set to true to evaluate variables like [[contact.name]] in message content
190
+ # * Default: false
191
+ #
192
+ # - label_ids (array)
193
+ # * Array of IDs of labels to add to the sent messages (maximum 5)
194
+ #
195
+ # - timezone_id
196
+ # * TZ database timezone ID; see
197
+ # <http://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
198
+ # * Default: project default timezone
199
+ #
200
+ # - end_time (UNIX timestamp)
201
+ # * Time after which a recurring message will stop (not applicable to non-recurring
202
+ # scheduled messages)
203
+ #
204
+ # - end_time_offset (int)
205
+ # * Number of seconds from now until the recurring message will stop
206
+ #
207
+ # Returns:
208
+ # Telerivet::ScheduledMessage
209
+ #
210
+ def schedule_message(options)
211
+ require_relative 'scheduledmessage'
212
+ ScheduledMessage.new(@api, @api.do_request("POST", get_base_api_path() + "/scheduled", options))
213
+ end
214
+
215
+ #
216
+ # Retrieves OR creates and possibly updates a contact by name or phone number.
217
+ #
218
+ # If a phone number is provided, Telerivet will search for an existing
219
+ # contact with that phone number (including suffix matches to allow finding contacts with
220
+ # phone numbers in a different format).
221
+ #
222
+ # If a phone number is not provided but a name is provided, Telerivet
223
+ # will search for a contact with that exact name (case insensitive).
224
+ #
225
+ # If no existing contact is found, a new contact will be created.
226
+ #
227
+ # Then that contact will be updated with any parameters provided
228
+ # (name, phone_number, and vars).
229
+ #
230
+ # Arguments:
231
+ # - options (Hash)
232
+ # * Required
233
+ #
234
+ # - name
235
+ # * Name of the contact
236
+ # * Required if phone_number not set
237
+ #
238
+ # - phone_number
239
+ # * Phone number of the contact
240
+ # * Required if name not set
241
+ #
242
+ # - vars (Hash)
243
+ # * Custom variables and values to update on the contact
244
+ #
245
+ # Returns:
246
+ # Telerivet::Contact
247
+ #
248
+ def get_or_create_contact(options)
249
+ require_relative 'contact'
250
+ Contact.new(@api, @api.do_request("POST", get_base_api_path() + "/contacts", options))
251
+ end
252
+
253
+ #
254
+ # Queries contacts within the given project.
255
+ #
256
+ # Arguments:
257
+ # - options (Hash)
258
+ #
259
+ # - name
260
+ # * Filter contacts by name
261
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
262
+ # name[lt], name[lte]
263
+ #
264
+ # - phone_number
265
+ # * Filter contacts by phone number
266
+ # * Allowed modifiers: phone_number[ne], phone_number[prefix],
267
+ # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
268
+ # phone_number[lte]
269
+ #
270
+ # - time_created (UNIX timestamp)
271
+ # * Filter contacts by time created
272
+ # * Allowed modifiers: time_created[ne], time_created[min], time_created[max]
273
+ #
274
+ # - last_message_time (UNIX timestamp)
275
+ # * Filter contacts by last time a message was sent or received
276
+ # * Allowed modifiers: last_message_time[exists], last_message_time[ne],
277
+ # last_message_time[min], last_message_time[max]
278
+ #
279
+ # - vars (Hash)
280
+ # * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
281
+ # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
282
+ # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
283
+ # vars[foo][min], vars[foo][max]
284
+ #
285
+ # - sort
286
+ # * Sort the results based on a field
287
+ # * Allowed values: default, name, phone_number, last_message_time
288
+ # * Default: default
289
+ #
290
+ # - sort_dir
291
+ # * Sort the results in ascending or descending order
292
+ # * Allowed values: asc, desc
293
+ # * Default: asc
294
+ #
295
+ # - page_size (int)
296
+ # * Number of results returned per page (max 200)
297
+ # * Default: 50
298
+ #
299
+ # - offset (int)
300
+ # * Number of items to skip from beginning of result set
301
+ # * Default: 0
302
+ #
303
+ # Returns:
304
+ # Telerivet::APICursor (of Telerivet::Contact)
305
+ #
306
+ def query_contacts(options = nil)
307
+ require_relative 'contact'
308
+ @api.cursor(Contact, get_base_api_path() + "/contacts", options)
309
+ end
310
+
311
+ #
312
+ # Retrieves the contact with the given ID.
313
+ #
314
+ # Note: This does not make any API requests until you access a property of the Contact.
315
+ #
316
+ # Arguments:
317
+ # - id
318
+ # * ID of the contact
319
+ # * Required
320
+ #
321
+ # Returns:
322
+ # Telerivet::Contact
323
+ #
324
+ def get_contact_by_id(id)
325
+ require_relative 'contact'
326
+ return Contact.new(@api, {'project_id' => self.id, 'id' => id}, false)
327
+ end
328
+
329
+ #
330
+ # Queries phones within the given project.
331
+ #
332
+ # Arguments:
333
+ # - options (Hash)
334
+ #
335
+ # - name
336
+ # * Filter phones by name
337
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
338
+ # name[lt], name[lte]
339
+ #
340
+ # - phone_number
341
+ # * Filter phones by phone number
342
+ # * Allowed modifiers: phone_number[ne], phone_number[prefix],
343
+ # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
344
+ # phone_number[lte]
345
+ #
346
+ # - last_active_time (UNIX timestamp)
347
+ # * Filter phones by last active time
348
+ # * Allowed modifiers: last_active_time[exists], last_active_time[ne],
349
+ # last_active_time[min], last_active_time[max]
350
+ #
351
+ # - sort
352
+ # * Sort the results based on a field
353
+ # * Allowed values: default, name, phone_number
354
+ # * Default: default
355
+ #
356
+ # - sort_dir
357
+ # * Sort the results in ascending or descending order
358
+ # * Allowed values: asc, desc
359
+ # * Default: asc
360
+ #
361
+ # - page_size (int)
362
+ # * Number of results returned per page (max 200)
363
+ # * Default: 50
364
+ #
365
+ # - offset (int)
366
+ # * Number of items to skip from beginning of result set
367
+ # * Default: 0
368
+ #
369
+ # Returns:
370
+ # Telerivet::APICursor (of Telerivet::Phone)
371
+ #
372
+ def query_phones(options = nil)
373
+ require_relative 'phone'
374
+ @api.cursor(Phone, get_base_api_path() + "/phones", options)
375
+ end
376
+
377
+ #
378
+ # Retrieves the phone with the given ID.
379
+ #
380
+ # Note: This does not make any API requests until you access a property of the Phone.
381
+ #
382
+ # Arguments:
383
+ # - id
384
+ # * ID of the phone - see <https://telerivet.com/dashboard/api>
385
+ # * Required
386
+ #
387
+ # Returns:
388
+ # Telerivet::Phone
389
+ #
390
+ def get_phone_by_id(id)
391
+ require_relative 'phone'
392
+ return Phone.new(@api, {'project_id' => self.id, 'id' => id}, false)
393
+ end
394
+
395
+ #
396
+ # Queries messages within the given project.
397
+ #
398
+ # Arguments:
399
+ # - options (Hash)
400
+ #
401
+ # - direction
402
+ # * Filter messages by direction
403
+ # * Allowed values: incoming, outgoing
404
+ #
405
+ # - message_type
406
+ # * Filter messages by message_type
407
+ # * Allowed values: sms, mms, ussd, call
408
+ #
409
+ # - source
410
+ # * Filter messages by source
411
+ # * Allowed values: phone, provider, web, api, service, webhook, scheduled
412
+ #
413
+ # - starred (bool)
414
+ # * Filter messages by starred/unstarred
415
+ #
416
+ # - status
417
+ # * Filter messages by status
418
+ # * Allowed values: ignored, processing, received, sent, queued, failed,
419
+ # failed_queued, cancelled, delivered, not_delivered
420
+ #
421
+ # - time_created[min] (UNIX timestamp)
422
+ # * Filter messages created on or after a particular time
423
+ #
424
+ # - time_created[max] (UNIX timestamp)
425
+ # * Filter messages created before a particular time
426
+ #
427
+ # - contact_id
428
+ # * ID of the contact who sent/received the message
429
+ #
430
+ # - phone_id
431
+ # * ID of the phone that sent/received the message
432
+ #
433
+ # - sort
434
+ # * Sort the results based on a field
435
+ # * Allowed values: default
436
+ # * Default: default
437
+ #
438
+ # - sort_dir
439
+ # * Sort the results in ascending or descending order
440
+ # * Allowed values: asc, desc
441
+ # * Default: asc
442
+ #
443
+ # - page_size (int)
444
+ # * Number of results returned per page (max 200)
445
+ # * Default: 50
446
+ #
447
+ # - offset (int)
448
+ # * Number of items to skip from beginning of result set
449
+ # * Default: 0
450
+ #
451
+ # Returns:
452
+ # Telerivet::APICursor (of Telerivet::Message)
453
+ #
454
+ def query_messages(options = nil)
455
+ require_relative 'message'
456
+ @api.cursor(Message, get_base_api_path() + "/messages", options)
457
+ end
458
+
459
+ #
460
+ # Retrieves the message with the given ID.
461
+ #
462
+ # Note: This does not make any API requests until you access a property of the Message.
463
+ #
464
+ # Arguments:
465
+ # - id
466
+ # * ID of the message
467
+ # * Required
468
+ #
469
+ # Returns:
470
+ # Telerivet::Message
471
+ #
472
+ def get_message_by_id(id)
473
+ require_relative 'message'
474
+ return Message.new(@api, {'project_id' => self.id, 'id' => id}, false)
475
+ end
476
+
477
+ #
478
+ # Queries groups within the given project.
479
+ #
480
+ # Arguments:
481
+ # - options (Hash)
482
+ #
483
+ # - name
484
+ # * Filter groups by name
485
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
486
+ # name[lt], name[lte]
487
+ #
488
+ # - sort
489
+ # * Sort the results based on a field
490
+ # * Allowed values: default, name
491
+ # * Default: default
492
+ #
493
+ # - sort_dir
494
+ # * Sort the results in ascending or descending order
495
+ # * Allowed values: asc, desc
496
+ # * Default: asc
497
+ #
498
+ # - page_size (int)
499
+ # * Number of results returned per page (max 200)
500
+ # * Default: 50
501
+ #
502
+ # - offset (int)
503
+ # * Number of items to skip from beginning of result set
504
+ # * Default: 0
505
+ #
506
+ # Returns:
507
+ # Telerivet::APICursor (of Telerivet::Group)
508
+ #
509
+ def query_groups(options = nil)
510
+ require_relative 'group'
511
+ @api.cursor(Group, get_base_api_path() + "/groups", options)
512
+ end
513
+
514
+ #
515
+ # Retrieves or creates a group by name.
516
+ #
517
+ # Arguments:
518
+ # - name
519
+ # * Name of the group
520
+ # * Required
521
+ #
522
+ # Returns:
523
+ # Telerivet::Group
524
+ #
525
+ def get_or_create_group(name)
526
+ require_relative 'group'
527
+ Group.new(@api, @api.do_request("POST", get_base_api_path() + "/groups", {'name' => name}))
528
+ end
529
+
530
+ #
531
+ # Retrieves the group with the given ID.
532
+ #
533
+ # Note: This does not make any API requests until you access a property of the Group.
534
+ #
535
+ # Arguments:
536
+ # - id
537
+ # * ID of the group
538
+ # * Required
539
+ #
540
+ # Returns:
541
+ # Telerivet::Group
542
+ #
543
+ def get_group_by_id(id)
544
+ require_relative 'group'
545
+ return Group.new(@api, {'project_id' => self.id, 'id' => id}, false)
546
+ end
547
+
548
+ #
549
+ # Queries labels within the given project.
550
+ #
551
+ # Arguments:
552
+ # - options (Hash)
553
+ #
554
+ # - name
555
+ # * Filter labels by name
556
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
557
+ # name[lt], name[lte]
558
+ #
559
+ # - sort
560
+ # * Sort the results based on a field
561
+ # * Allowed values: default, name
562
+ # * Default: default
563
+ #
564
+ # - sort_dir
565
+ # * Sort the results in ascending or descending order
566
+ # * Allowed values: asc, desc
567
+ # * Default: asc
568
+ #
569
+ # - page_size (int)
570
+ # * Number of results returned per page (max 200)
571
+ # * Default: 50
572
+ #
573
+ # - offset (int)
574
+ # * Number of items to skip from beginning of result set
575
+ # * Default: 0
576
+ #
577
+ # Returns:
578
+ # Telerivet::APICursor (of Telerivet::Label)
579
+ #
580
+ def query_labels(options = nil)
581
+ require_relative 'label'
582
+ @api.cursor(Label, get_base_api_path() + "/labels", options)
583
+ end
584
+
585
+ #
586
+ # Gets or creates a label by name.
587
+ #
588
+ # Arguments:
589
+ # - name
590
+ # * Name of the label
591
+ # * Required
592
+ #
593
+ # Returns:
594
+ # Telerivet::Label
595
+ #
596
+ def get_or_create_label(name)
597
+ require_relative 'label'
598
+ Label.new(@api, @api.do_request("POST", get_base_api_path() + "/labels", {'name' => name}))
599
+ end
600
+
601
+ #
602
+ # Retrieves the label with the given ID.
603
+ #
604
+ # Note: This does not make any API requests until you access a property of the Label.
605
+ #
606
+ # Arguments:
607
+ # - id
608
+ # * ID of the label
609
+ # * Required
610
+ #
611
+ # Returns:
612
+ # Telerivet::Label
613
+ #
614
+ def get_label_by_id(id)
615
+ require_relative 'label'
616
+ return Label.new(@api, {'project_id' => self.id, 'id' => id}, false)
617
+ end
618
+
619
+ #
620
+ # Queries data tables within the given project.
621
+ #
622
+ # Arguments:
623
+ # - options (Hash)
624
+ #
625
+ # - name
626
+ # * Filter data tables by name
627
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
628
+ # name[lt], name[lte]
629
+ #
630
+ # - sort
631
+ # * Sort the results based on a field
632
+ # * Allowed values: default, name
633
+ # * Default: default
634
+ #
635
+ # - sort_dir
636
+ # * Sort the results in ascending or descending order
637
+ # * Allowed values: asc, desc
638
+ # * Default: asc
639
+ #
640
+ # - page_size (int)
641
+ # * Number of results returned per page (max 200)
642
+ # * Default: 50
643
+ #
644
+ # - offset (int)
645
+ # * Number of items to skip from beginning of result set
646
+ # * Default: 0
647
+ #
648
+ # Returns:
649
+ # Telerivet::APICursor (of Telerivet::DataTable)
650
+ #
651
+ def query_data_tables(options = nil)
652
+ require_relative 'datatable'
653
+ @api.cursor(DataTable, get_base_api_path() + "/tables", options)
654
+ end
655
+
656
+ #
657
+ # Gets or creates a data table by name.
658
+ #
659
+ # Arguments:
660
+ # - name
661
+ # * Name of the data table
662
+ # * Required
663
+ #
664
+ # Returns:
665
+ # Telerivet::DataTable
666
+ #
667
+ def get_or_create_data_table(name)
668
+ require_relative 'datatable'
669
+ DataTable.new(@api, @api.do_request("POST", get_base_api_path() + "/tables", {'name' => name}))
670
+ end
671
+
672
+ #
673
+ # Retrieves the data table with the given ID.
674
+ #
675
+ # Note: This does not make any API requests until you access a property of the DataTable.
676
+ #
677
+ # Arguments:
678
+ # - id
679
+ # * ID of the data table
680
+ # * Required
681
+ #
682
+ # Returns:
683
+ # Telerivet::DataTable
684
+ #
685
+ def get_data_table_by_id(id)
686
+ require_relative 'datatable'
687
+ return DataTable.new(@api, {'project_id' => self.id, 'id' => id}, false)
688
+ end
689
+
690
+ #
691
+ # Queries scheduled messages within the given project.
692
+ #
693
+ # Arguments:
694
+ # - options (Hash)
695
+ #
696
+ # - message_type
697
+ # * Filter scheduled messages by message_type
698
+ # * Allowed values: sms, mms, ussd, call
699
+ #
700
+ # - time_created (UNIX timestamp)
701
+ # * Filter scheduled messages by time_created
702
+ # * Allowed modifiers: time_created[ne], time_created[min], time_created[max]
703
+ #
704
+ # - next_time (UNIX timestamp)
705
+ # * Filter scheduled messages by next_time
706
+ # * Allowed modifiers: next_time[exists], next_time[ne], next_time[min],
707
+ # next_time[max]
708
+ #
709
+ # - sort
710
+ # * Sort the results based on a field
711
+ # * Allowed values: default, name
712
+ # * Default: default
713
+ #
714
+ # - sort_dir
715
+ # * Sort the results in ascending or descending order
716
+ # * Allowed values: asc, desc
717
+ # * Default: asc
718
+ #
719
+ # - page_size (int)
720
+ # * Number of results returned per page (max 200)
721
+ # * Default: 50
722
+ #
723
+ # - offset (int)
724
+ # * Number of items to skip from beginning of result set
725
+ # * Default: 0
726
+ #
727
+ # Returns:
728
+ # Telerivet::APICursor (of Telerivet::ScheduledMessage)
729
+ #
730
+ def query_scheduled_messages(options = nil)
731
+ require_relative 'scheduledmessage'
732
+ @api.cursor(ScheduledMessage, get_base_api_path() + "/scheduled", options)
733
+ end
734
+
735
+ #
736
+ # Retrieves the scheduled message with the given ID.
737
+ #
738
+ # Note: This does not make any API requests until you access a property of the
739
+ # ScheduledMessage.
740
+ #
741
+ # Arguments:
742
+ # - id
743
+ # * ID of the scheduled message
744
+ # * Required
745
+ #
746
+ # Returns:
747
+ # Telerivet::ScheduledMessage
748
+ #
749
+ def get_scheduled_message_by_id(id)
750
+ require_relative 'scheduledmessage'
751
+ return ScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
752
+ end
753
+
754
+ #
755
+ # Queries services within the given project.
756
+ #
757
+ # Arguments:
758
+ # - options (Hash)
759
+ #
760
+ # - name
761
+ # * Filter services by name
762
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
763
+ # name[lt], name[lte]
764
+ #
765
+ # - active (bool)
766
+ # * Filter services by active/inactive state
767
+ #
768
+ # - context
769
+ # * Filter services that can be invoked in a particular context
770
+ # * Allowed values: message, contact, project, receipt
771
+ #
772
+ # - sort
773
+ # * Sort the results based on a field
774
+ # * Allowed values: default, priority, name
775
+ # * Default: default
776
+ #
777
+ # - sort_dir
778
+ # * Sort the results in ascending or descending order
779
+ # * Allowed values: asc, desc
780
+ # * Default: asc
781
+ #
782
+ # - page_size (int)
783
+ # * Number of results returned per page (max 200)
784
+ # * Default: 50
785
+ #
786
+ # - offset (int)
787
+ # * Number of items to skip from beginning of result set
788
+ # * Default: 0
789
+ #
790
+ # Returns:
791
+ # Telerivet::APICursor (of Telerivet::Service)
792
+ #
793
+ def query_services(options = nil)
794
+ require_relative 'service'
795
+ @api.cursor(Service, get_base_api_path() + "/services", options)
796
+ end
797
+
798
+ #
799
+ # Retrieves the service with the given ID.
800
+ #
801
+ # Note: This does not make any API requests until you access a property of the Service.
802
+ #
803
+ # Arguments:
804
+ # - id
805
+ # * ID of the service
806
+ # * Required
807
+ #
808
+ # Returns:
809
+ # Telerivet::Service
810
+ #
811
+ def get_service_by_id(id)
812
+ require_relative 'service'
813
+ return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)
814
+ end
815
+
816
+ #
817
+ # Queries mobile money receipts within the given project.
818
+ #
819
+ # Arguments:
820
+ # - options (Hash)
821
+ #
822
+ # - tx_id
823
+ # * Filter receipts by transaction ID
824
+ #
825
+ # - tx_type
826
+ # * Filter receipts by transaction type
827
+ # * Allowed values: receive_money, send_money, pay_bill, deposit, withdrawal,
828
+ # airtime_purchase, balance_inquiry, reversal
829
+ #
830
+ # - tx_time (UNIX timestamp)
831
+ # * Filter receipts by transaction time
832
+ # * Allowed modifiers: tx_time[ne], tx_time[min], tx_time[max]
833
+ #
834
+ # - name
835
+ # * Filter receipts by other person's name
836
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
837
+ # name[lt], name[lte]
838
+ #
839
+ # - phone_number
840
+ # * Filter receipts by other person's phone number
841
+ # * Allowed modifiers: phone_number[ne], phone_number[prefix],
842
+ # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
843
+ # phone_number[lte]
844
+ #
845
+ # - sort
846
+ # * Sort the results based on a field
847
+ # * Allowed values: default
848
+ # * Default: default
849
+ #
850
+ # - sort_dir
851
+ # * Sort the results in ascending or descending order
852
+ # * Allowed values: asc, desc
853
+ # * Default: asc
854
+ #
855
+ # - page_size (int)
856
+ # * Number of results returned per page (max 200)
857
+ # * Default: 50
858
+ #
859
+ # - offset (int)
860
+ # * Number of items to skip from beginning of result set
861
+ # * Default: 0
862
+ #
863
+ # Returns:
864
+ # Telerivet::APICursor (of Telerivet::MobileMoneyReceipt)
865
+ #
866
+ def query_receipts(options = nil)
867
+ require_relative 'mobilemoneyreceipt'
868
+ @api.cursor(MobileMoneyReceipt, get_base_api_path() + "/receipts", options)
869
+ end
870
+
871
+ #
872
+ # Retrieves the mobile money receipt with the given ID.
873
+ #
874
+ # Note: This does not make any API requests until you access a property of the
875
+ # MobileMoneyReceipt.
876
+ #
877
+ # Arguments:
878
+ # - id
879
+ # * ID of the mobile money receipt
880
+ # * Required
881
+ #
882
+ # Returns:
883
+ # Telerivet::MobileMoneyReceipt
884
+ #
885
+ def get_receipt_by_id(id)
886
+ require_relative 'mobilemoneyreceipt'
887
+ return MobileMoneyReceipt.new(@api, {'project_id' => self.id, 'id' => id}, false)
888
+ end
889
+
890
+ #
891
+ # Saves any fields or custom variables that have changed for the project.
892
+ #
893
+ def save()
894
+ super
895
+ end
896
+
897
+ def id
898
+ get('id')
899
+ end
900
+
901
+ def name
902
+ get('name')
903
+ end
904
+
905
+ def name=(value)
906
+ set('name', value)
907
+ end
908
+
909
+ def timezone_id
910
+ get('timezone_id')
911
+ end
912
+
913
+ def get_base_api_path()
914
+ "/projects/#{get('id')}"
915
+ end
916
+
917
+ end
918
+
919
+ end