restcomm-ruby 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/AUTHORS.md +38 -0
  2. data/CHANGES.md +171 -0
  3. data/Gemfile +11 -0
  4. data/LICENSE +662 -0
  5. data/LICENSE.md +19 -0
  6. data/Makefile +12 -0
  7. data/README.md +155 -0
  8. data/Rakefile +10 -0
  9. data/conf/cacert.pem +3376 -0
  10. data/docs/Makefile +130 -0
  11. data/docs/_themes/LICENSE +45 -0
  12. data/docs/_themes/README.rst +25 -0
  13. data/docs/_themes/flask_theme_support.py +86 -0
  14. data/docs/_themes/kr/layout.html +32 -0
  15. data/docs/_themes/kr/relations.html +19 -0
  16. data/docs/_themes/kr/static/flasky.css_t +469 -0
  17. data/docs/_themes/kr/static/small_flask.css +70 -0
  18. data/docs/_themes/kr/theme.conf +7 -0
  19. data/docs/_themes/kr_small/layout.html +22 -0
  20. data/docs/_themes/kr_small/static/flasky.css_t +287 -0
  21. data/docs/_themes/kr_small/theme.conf +10 -0
  22. data/docs/changelog.rst +1 -0
  23. data/docs/conf.py +266 -0
  24. data/docs/faq.rst +42 -0
  25. data/docs/getting-started.rst +100 -0
  26. data/docs/index.rst +109 -0
  27. data/docs/make.bat +170 -0
  28. data/docs/src/pip-delete-this-directory.txt +5 -0
  29. data/docs/usage/accounts.rst +96 -0
  30. data/docs/usage/addresses.rst +102 -0
  31. data/docs/usage/applications.rst +111 -0
  32. data/docs/usage/basics.rst +120 -0
  33. data/docs/usage/caller-ids.rst +47 -0
  34. data/docs/usage/conferences.rst +112 -0
  35. data/docs/usage/errors.rst +31 -0
  36. data/docs/usage/messages.rst +142 -0
  37. data/docs/usage/notifications.rst +72 -0
  38. data/docs/usage/phone-calls.rst +193 -0
  39. data/docs/usage/phone-numbers.rst +192 -0
  40. data/docs/usage/queues.rst +117 -0
  41. data/docs/usage/recordings.rst +102 -0
  42. data/docs/usage/sip.rst +108 -0
  43. data/docs/usage/token-generation.rst +96 -0
  44. data/docs/usage/transcriptions.rst +34 -0
  45. data/docs/usage/twiml.rst +69 -0
  46. data/docs/usage/validation.rst +107 -0
  47. data/examples/examples.rb +200 -0
  48. data/examples/print-call-log.rb +25 -0
  49. data/lib/rack/restcomm_webhook_authentication.rb +47 -0
  50. data/lib/restcomm-ruby.rb +103 -0
  51. data/lib/restcomm-ruby/rest/accounts.rb +17 -0
  52. data/lib/restcomm-ruby/rest/addresses.rb +12 -0
  53. data/lib/restcomm-ruby/rest/addresses/dependent_phone_numbers.rb +6 -0
  54. data/lib/restcomm-ruby/rest/applications.rb +6 -0
  55. data/lib/restcomm-ruby/rest/authorized_connect_apps.rb +6 -0
  56. data/lib/restcomm-ruby/rest/available_phone_numbers.rb +13 -0
  57. data/lib/restcomm-ruby/rest/available_phone_numbers/country.rb +10 -0
  58. data/lib/restcomm-ruby/rest/available_phone_numbers/local.rb +11 -0
  59. data/lib/restcomm-ruby/rest/available_phone_numbers/mobile.rb +11 -0
  60. data/lib/restcomm-ruby/rest/available_phone_numbers/toll_free.rb +11 -0
  61. data/lib/restcomm-ruby/rest/call_feedback.rb +28 -0
  62. data/lib/restcomm-ruby/rest/call_feedback_summary.rb +13 -0
  63. data/lib/restcomm-ruby/rest/calls.rb +37 -0
  64. data/lib/restcomm-ruby/rest/client.rb +555 -0
  65. data/lib/restcomm-ruby/rest/conferences.rb +12 -0
  66. data/lib/restcomm-ruby/rest/conferences/participants.rb +23 -0
  67. data/lib/restcomm-ruby/rest/connect_apps.rb +6 -0
  68. data/lib/restcomm-ruby/rest/errors.rb +14 -0
  69. data/lib/restcomm-ruby/rest/incoming_phone_numbers.rb +17 -0
  70. data/lib/restcomm-ruby/rest/incoming_phone_numbers/local.rb +13 -0
  71. data/lib/restcomm-ruby/rest/incoming_phone_numbers/mobile.rb +13 -0
  72. data/lib/restcomm-ruby/rest/incoming_phone_numbers/toll_free.rb +13 -0
  73. data/lib/restcomm-ruby/rest/instance_resource.rb +88 -0
  74. data/lib/restcomm-ruby/rest/list_resource.rb +132 -0
  75. data/lib/restcomm-ruby/rest/media.rb +14 -0
  76. data/lib/restcomm-ruby/rest/messages.rb +23 -0
  77. data/lib/restcomm-ruby/rest/next_gen_list_resource.rb +29 -0
  78. data/lib/restcomm-ruby/rest/notifications.rb +6 -0
  79. data/lib/restcomm-ruby/rest/outgoing_caller_ids.rb +25 -0
  80. data/lib/restcomm-ruby/rest/queues.rb +12 -0
  81. data/lib/restcomm-ruby/rest/queues/members.rb +29 -0
  82. data/lib/restcomm-ruby/rest/recordings.rb +35 -0
  83. data/lib/restcomm-ruby/rest/sandbox.rb +5 -0
  84. data/lib/restcomm-ruby/rest/sip.rb +10 -0
  85. data/lib/restcomm-ruby/rest/sip/credential_lists.rb +11 -0
  86. data/lib/restcomm-ruby/rest/sip/credential_lists/credentials.rb +6 -0
  87. data/lib/restcomm-ruby/rest/sip/domains.rb +12 -0
  88. data/lib/restcomm-ruby/rest/sip/domains/credential_list_mappings.rb +6 -0
  89. data/lib/restcomm-ruby/rest/sip/domains/ip_access_control_list_mappings.rb +6 -0
  90. data/lib/restcomm-ruby/rest/sip/ip_access_control_lists.rb +11 -0
  91. data/lib/restcomm-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb +6 -0
  92. data/lib/restcomm-ruby/rest/sms.rb +11 -0
  93. data/lib/restcomm-ruby/rest/sms/messages.rb +39 -0
  94. data/lib/restcomm-ruby/rest/sms/short_codes.rb +8 -0
  95. data/lib/restcomm-ruby/rest/task_router/activities.rb +8 -0
  96. data/lib/restcomm-ruby/rest/task_router/events.rb +8 -0
  97. data/lib/restcomm-ruby/rest/task_router/reservations.rb +8 -0
  98. data/lib/restcomm-ruby/rest/task_router/task_queues.rb +8 -0
  99. data/lib/restcomm-ruby/rest/task_router/task_queues_statistics.rb +15 -0
  100. data/lib/restcomm-ruby/rest/task_router/tasks.rb +15 -0
  101. data/lib/restcomm-ruby/rest/task_router/workers.rb +8 -0
  102. data/lib/restcomm-ruby/rest/task_router/workers_statistics.rb +8 -0
  103. data/lib/restcomm-ruby/rest/task_router/workflow_statistics.rb +7 -0
  104. data/lib/restcomm-ruby/rest/task_router/workflows.rb +8 -0
  105. data/lib/restcomm-ruby/rest/task_router/workspace_statistics.rb +7 -0
  106. data/lib/restcomm-ruby/rest/task_router/workspaces.rb +15 -0
  107. data/lib/restcomm-ruby/rest/tokens.rb +7 -0
  108. data/lib/restcomm-ruby/rest/transcriptions.rb +6 -0
  109. data/lib/restcomm-ruby/rest/usage.rb +10 -0
  110. data/lib/restcomm-ruby/rest/usage/records.rb +21 -0
  111. data/lib/restcomm-ruby/rest/usage/triggers.rb +12 -0
  112. data/lib/restcomm-ruby/rest/utils.rb +49 -0
  113. data/lib/restcomm-ruby/task_router.rb +0 -0
  114. data/lib/restcomm-ruby/task_router/capability.rb +87 -0
  115. data/lib/restcomm-ruby/twiml/response.rb +16 -0
  116. data/lib/restcomm-ruby/util.rb +15 -0
  117. data/lib/restcomm-ruby/util/capability.rb +64 -0
  118. data/lib/restcomm-ruby/util/configuration.rb +7 -0
  119. data/lib/restcomm-ruby/util/request_validator.rb +37 -0
  120. data/lib/restcomm-ruby/version.rb +3 -0
  121. data/restcomm-ruby.gemspec +34 -0
  122. data/spec/rack/twilio_webhook_authentication_spec.rb +110 -0
  123. data/spec/rest/account_spec.rb +89 -0
  124. data/spec/rest/address_spec.rb +11 -0
  125. data/spec/rest/call_feedback_spec.rb +12 -0
  126. data/spec/rest/call_feedback_summary_spec.rb +9 -0
  127. data/spec/rest/call_spec.rb +22 -0
  128. data/spec/rest/client_spec.rb +258 -0
  129. data/spec/rest/conference_spec.rb +11 -0
  130. data/spec/rest/instance_resource_spec.rb +15 -0
  131. data/spec/rest/message_spec.rb +12 -0
  132. data/spec/rest/numbers_spec.rb +58 -0
  133. data/spec/rest/queue_spec.rb +11 -0
  134. data/spec/rest/recording_spec.rb +11 -0
  135. data/spec/rest/sms/message_spec.rb +37 -0
  136. data/spec/rest/sms/messages_spec.rb +36 -0
  137. data/spec/rest/task_router/reservation_spec.rb +9 -0
  138. data/spec/rest/task_router/task_queue_spec.rb +9 -0
  139. data/spec/rest/token_spec.rb +7 -0
  140. data/spec/rest/utils_spec.rb +45 -0
  141. data/spec/spec_helper.rb +15 -0
  142. data/spec/support/fakeweb.rb +2 -0
  143. data/spec/task_router_spec.rb +114 -0
  144. data/spec/twilio_spec.rb +15 -0
  145. data/spec/util/capability_spec.rb +186 -0
  146. data/spec/util/configuration_spec.rb +13 -0
  147. data/spec/util/request_validator_spec.rb +93 -0
  148. data/spec/util/url_encode_spec.rb +12 -0
  149. metadata +298 -0
@@ -0,0 +1,102 @@
1
+ .. module:: restcomm.rest.resources
2
+
3
+ =========
4
+ Addresses
5
+ =========
6
+
7
+ An Address instance resource represents your or your customer’s physical
8
+ location within a country. Around the world, some local authorities require the
9
+ name and address of the user to be on file with Restcomm to purchase and own a
10
+ phone number.
11
+
12
+ For more information, see the `Address REST Resource
13
+ <http://docs.telestax.com/restcomm-pages/`_ documentation.
14
+
15
+ Creating an Address
16
+ -------------------
17
+
18
+ Addresses contain the name of your company or your customer’s company in
19
+ addition to location information and an optional friendly name.
20
+
21
+ .. code-block:: ruby
22
+
23
+ require 'restcomm-ruby'
24
+
25
+ # To find these visit http://docs.telestax.com/restcomm-pages/
26
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
27
+ auth_token = "YYYYYYYYYYYYYYYYYY"
28
+ host = "XXX.XXX.XXX.XXX"
29
+
30
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
31
+ @address = @client.addresses.create(
32
+ friendly_name: "Homer",
33
+ customer_name: "Homer Simpson",
34
+ street: "742 Evergreen Terrace",
35
+ city: "Springfield",
36
+ region "IL",
37
+ postal_code: "62701",
38
+ iso_country: "US"
39
+ )
40
+
41
+ Listing Addresses
42
+ -----------------
43
+
44
+ The following code will print out the :attr:`customer_name` for each :class:`Address`.
45
+
46
+ .. code-block:: ruby
47
+
48
+ @addresses = @client.addresses.list()
49
+ @addresses.each do |address|
50
+ puts address.customer_name
51
+ end
52
+
53
+ Filtering Addresses
54
+ -------------------
55
+
56
+ The list of Addresses can be filtered on :attr:`friendly_name`,
57
+ :attr:`customer_name`, and/or :attr:`iso_country`.
58
+
59
+ .. code-block:: ruby
60
+
61
+ @addresses = @client.addresses.list(iso_country: 'AU')
62
+ @addresses.each do |address|
63
+ puts address.customer_name
64
+ end
65
+
66
+ Updating an Address
67
+ -------------------
68
+
69
+ All Address attributes other than :attr:`iso_country` can be updated.
70
+ To create an Address with a different country, see the "Creating an Address" section.
71
+
72
+ .. code-block:: ruby
73
+
74
+ @sid = 'AD123' # the address you'd like to update
75
+ @address = @client.addresses.get(@sid)
76
+ @address.update(customer_name: "Marge Simpson")
77
+
78
+ Deleting an Address
79
+ -------------------
80
+
81
+ .. code-block:: ruby
82
+
83
+ address_sid = 'AD123'
84
+ @address = @client.addresses.get(address_sid)
85
+ @address.delete()
86
+
87
+ Listing Dependent Phone Numbers
88
+ -------------------------------
89
+
90
+ Restcomm will not permit you to delete an Address if it is the sole
91
+ Address resource on your account that satisfies the address requirements
92
+ for one or more of your purchased phone numbers.
93
+
94
+ To see which phone numbers depend on a given address:
95
+
96
+ .. code-block:: ruby
97
+
98
+ address_sid = 'AD123'
99
+ @address = @client.addresses.get(address_sid)
100
+ @address.dependent_phone_numbers.list.each do |number|
101
+ puts number.sid
102
+ end
@@ -0,0 +1,111 @@
1
+ .. module:: restcomm.rest.resources
2
+
3
+ =================
4
+ Applications
5
+ =================
6
+
7
+ An application inside of Restcomm is just a set of URLs and other configuration
8
+ data that tells Restcomm how to behave when one of your Restcomm numbers receives
9
+ a call or message.
10
+
11
+ For more information, see the `Application REST Resource
12
+ <http://docs.telestax.com/restcomm-pages/>`_ documentation.
13
+
14
+
15
+ Listing Your Applications
16
+ --------------------------
17
+
18
+ The following code will print out the :attr:`friendly_name` for each :class:`Application`.
19
+
20
+ .. code-block:: ruby
21
+
22
+ require 'restcomm-ruby'
23
+
24
+ # To find these visit http://docs.telestax.com/restcomm-pages/
25
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
26
+ auth_token = "YYYYYYYYYYYYYYYYYY"
27
+ host = "XXX.XXX.XXX.XXX"
28
+
29
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
30
+ @client.applications.each do |app|
31
+ puts app.friendly_name
32
+ end
33
+
34
+
35
+ Filtering Applications
36
+ ---------------------------
37
+
38
+ You can filter applications by FriendlyName
39
+
40
+ .. code-block:: ruby
41
+
42
+ require 'restcomm-ruby'
43
+
44
+ # To find these visit http://docs.telestax.com/restcomm-pages/
45
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
46
+ auth_token = "YYYYYYYYYYYYYYYYYY"
47
+
48
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
49
+ @client.applications.list(friendly_name: 'FOO').each do |app|
50
+ puts app.sid
51
+ end
52
+
53
+
54
+ Creating an Application
55
+ -------------------------
56
+
57
+ When creating an application, no fields are required. We create an application
58
+ with only a :attr:`friendly_name`. The :meth:`Applications.create()` method
59
+ accepts many other arguments for url configuration.
60
+
61
+ .. code-block:: ruby
62
+
63
+ require 'restcomm-ruby'
64
+
65
+ # To find these visit http://docs.telestax.com/restcomm-pages/
66
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
67
+ auth_token = "YYYYYYYYYYYYYYYYYY"
68
+ host = "XXX.XXX.XXX.XXX"
69
+
70
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
71
+ @application = @client.applications.create(
72
+ friendly_name: "My New App"
73
+ )
74
+
75
+ Updating an Application
76
+ ------------------------
77
+
78
+ .. code-block:: ruby
79
+
80
+ require 'restcomm-ruby'
81
+
82
+ # To find these visit http://docs.telestax.com/restcomm-pages/
83
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
84
+ auth_token = "YYYYYYYYYYYYYYYYYY"
85
+ host = "XXX.XXX.XXX.XXX"
86
+
87
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
88
+
89
+
90
+
91
+ @application = @client.applications.get(app_sid)
92
+ @application.update(voice_url: url)
93
+
94
+ Deleting an Application
95
+ -------------------------
96
+
97
+ .. code-block:: ruby
98
+
99
+ require 'restcomm-ruby'
100
+
101
+ # To find these visit http://docs.telestax.com/restcomm-pages/
102
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
103
+ auth_token = "YYYYYYYYYYYYYYYYYY"
104
+ host = "XXX.XXX.XXX.XXX"
105
+
106
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
107
+
108
+ app_sid = 'AP123' # the app you'd like to delete
109
+ @client.applications.get(app_sid)
110
+ @application.delete()
111
+
@@ -0,0 +1,120 @@
1
+ .. module:: restcomm.rest
2
+
3
+ =========================
4
+ Accessing REST Resources
5
+ =========================
6
+
7
+ To access Restcomm REST resources, you'll first need to instantiate a
8
+ :class:`Restcomm::REST::Client`.
9
+
10
+ Authentication
11
+ --------------------------
12
+
13
+ The :class:`Restcomm::REST::Client` needs your Restcomm credentials. To get
14
+ your credentials, visit `your Restcomm account portal
15
+ <http://docs.telestax.com/restcomm-pages/>`_. If you don't have a Restcomm account
16
+ yet, go `here <http://docs.telestax.com/restcomm-pages/>`_ to get started.
17
+
18
+ Once you have your credentials, you can create create a new :class:`Client` and get started.
19
+
20
+ .. code-block:: ruby
21
+
22
+ require 'restcomm-ruby'
23
+
24
+ # To find these visit https://www.restcomm.com/user/account
25
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
26
+ auth_token = "YYYYYYYYYYYYYYYYYY"
27
+ host = "XXX.XXX.XXX.XXX"
28
+
29
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
30
+
31
+ You can also configure the client using the top level configure method, like so:
32
+
33
+ .. code-block:: ruby
34
+
35
+ require 'restcomm-ruby'
36
+
37
+ Restcomm.configure do |config|
38
+ config.account_sid = "ACXXXXXXXXXXXXXXXXX"
39
+ config.auth_token = "YYYYYYYYYYYYYYYYYY"
40
+ host = "XXX.XXX.XXX.XXX"
41
+ end
42
+
43
+ @client = Restcomm::REST::Client.new
44
+
45
+
46
+ Listing Resources
47
+ -------------------
48
+
49
+ The :class:`Client` gives you access to various list resources.
50
+ :meth:`ListResource.list`, by default, returns the most recent 50 instance resources.
51
+
52
+ .. code-block:: ruby
53
+
54
+ require 'restcomm-ruby'
55
+
56
+ # To find these visit https://www.restcomm.com/user/account
57
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
58
+ auth_token = "YYYYYYYYYYYYYYYYYY"
59
+ host = "XXX.XXX.XXX.XXX"
60
+
61
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
62
+ @calls = @client.calls.list()
63
+
64
+ :meth:`ListResource.list` accepts paging arguments.
65
+ The following will return page 3 with page size of 25.
66
+
67
+ .. code-block:: ruby
68
+
69
+ require 'restcomm-ruby'
70
+
71
+ # To find these visit https://www.restcomm.com/user/account
72
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
73
+ auth_token = "YYYYYYYYYYYYYYYYYY"
74
+
75
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
76
+ @calls = @client.calls.list(page: 3, page_size: 25)
77
+
78
+
79
+ Get an Individual Resource
80
+ -----------------------------
81
+
82
+ To get an individual instance resource, use :meth:`ListResource.get`.
83
+ Provide the :attr:`sid` of the resource you'd like to get.
84
+
85
+ .. code-block:: ruby
86
+
87
+ require 'restcomm-ruby'
88
+
89
+ # To find these visit https://www.restcomm.com/user/account
90
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
91
+ auth_token = "YYYYYYYYYYYYYYYYYY"
92
+ host = "XXX.XXX.XXX.XXX"
93
+
94
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
95
+
96
+ @call = @client.calls.get("CA123")
97
+ puts @call.to
98
+
99
+
100
+ Deleting a Resource
101
+ -------------------------------
102
+
103
+ Resources can only be deleted via their instance object. This means
104
+ you must instantiate an instance object using :meth:`ListResource.get`
105
+ and then call :meth:`delete` on it.
106
+
107
+ .. code-block:: ruby
108
+
109
+ require 'restcomm-ruby'
110
+
111
+ # To find these visit https://www.restcomm.com/user/account
112
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
113
+ auth_token = "YYYYYYYYYYYYYYYYYY"
114
+ host = "XXX.XXX.XXX.XXX"
115
+
116
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
117
+
118
+ @recording = @client.recordings.get("RC123")
119
+ @recording.delete()
120
+
@@ -0,0 +1,47 @@
1
+ .. module:: restcomm.rest.resources
2
+
3
+ =================
4
+ Caller Ids
5
+ =================
6
+
7
+
8
+ Validate a Phone Number
9
+ -----------------------
10
+
11
+ Validating a phone number is quick and easy.
12
+
13
+ .. code-block:: ruby
14
+
15
+ require 'restcomm-ruby'
16
+
17
+ # To find these visit https://www.restcomm.com/user/account
18
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
19
+ auth_token = "YYYYYYYYYYYYYYYYYY"
20
+
21
+ @client = Restcomm::REST::Client.new account_sid, auth_token
22
+ @response = @client.outgoing_caller_ids.create(
23
+ phone_number: "+44 9876543212"
24
+ )
25
+ puts @response.validation_code
26
+
27
+ Restcomm will call the provided number and wait for the validation code to be
28
+ entered.
29
+
30
+ Delete a Phone Number
31
+ ---------------------
32
+
33
+ Deleting a phone number is quick and easy.
34
+
35
+ .. code-block:: ruby
36
+
37
+ require 'restcomm-ruby'
38
+
39
+ # To find these visit https://www.restcomm.com/user/account
40
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
41
+ auth_token = "YYYYYYYYYYYYYYYYYY"
42
+
43
+ @client = Restcomm::REST::Client.new account_sid, auth_token
44
+
45
+ @response = @client.outgoing_caller_ids.list(phone_number: "+15555555555")
46
+ @callerid = response[0]
47
+ @callerid.delete()
@@ -0,0 +1,112 @@
1
+ .. module:: restcomm.rest.resources
2
+
3
+ ==============================
4
+ Conferences and Participants
5
+ ==============================
6
+
7
+ For more information, see the `Conference REST Resource <http://docs.telestax.com/restcomm-pages/>`_
8
+ and `Participant REST Resource <http://docs.telestax.com/restcomm-pages/>`_ documentation.
9
+
10
+
11
+ Listing Conferences
12
+ -----------------------
13
+
14
+ .. code-block:: ruby
15
+
16
+ require 'restcomm-ruby'
17
+
18
+ # To find these visit http://docs.telestax.com/restcomm-pages/
19
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
20
+ auth_token = "YYYYYYYYYYYYYYYYYY"
21
+ host = "XXX.XXX.XXX.XXX"
22
+
23
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
24
+ @conferences = @client.conferences.list()
25
+
26
+ @conferences.each do |conference|
27
+ puts conference.sid
28
+ end
29
+
30
+
31
+ Filtering Conferences
32
+ -----------------------
33
+
34
+ The :meth:`Restcomm::REST::Conferences.list` method supports filtering on :attr:`status`,
35
+ :attr:`date_updated`, :attr:`date_created` and :attr:`friendly_name`. The following code
36
+ will return a list of all in-progress conferences and print their friendly name.
37
+
38
+ .. code-block:: ruby
39
+
40
+ require 'restcomm-ruby'
41
+
42
+ # To find these visit http://docs.telestax.com/restcomm-pages/
43
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
44
+ auth_token = "YYYYYYYYYYYYYYYYYY"
45
+ host = "XXX.XXX.XXX.XXX"
46
+
47
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
48
+ @conferences = @client.conferences.list(status: "in-progress")
49
+
50
+ @conference.each do |conference|
51
+ puts conference.friendly_name
52
+ end
53
+
54
+
55
+ Listing Participants
56
+ ----------------------
57
+
58
+ Each :class:`Conference` has a :attr:`participants` instance which represents all current users in the conference
59
+
60
+ .. code-block:: ruby
61
+
62
+ require 'restcomm-ruby'
63
+
64
+ # To find these visit http://docs.telestax.com/restcomm-pages/
65
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
66
+ auth_token = "YYYYYYYYYYYYYYYYYY"
67
+ host = "XXX.XXX.XXX.XXX"
68
+
69
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
70
+ @conference = @client.conferences.get("CF123")
71
+
72
+ @conference.participants.list.each.do |paricipant|
73
+ puts participant.sid
74
+ end
75
+
76
+ :class:`Conferences` and :class:`Participants` are subclasses of :class:`ListResource`.
77
+ Therefore, their instances have the inherited methods such as :meth:`count`.
78
+
79
+
80
+ Managing Participants
81
+ ----------------------
82
+
83
+ Each :class:`Conference` has a :attr:`participants` function that returns a
84
+ :class:`Participants` instance. This behavior differs from other list resources
85
+ because :class:`Participants` needs a participant sid AND a conference sid to
86
+ access the participants resource.
87
+
88
+ Participants can be either muted or kicked out of the conference. The following
89
+ code kicks out the first participant and mutes the rest.
90
+
91
+ .. code-block:: ruby
92
+
93
+ require 'restcomm-ruby'
94
+
95
+ # To find these visit http://docs.telestax.com/restcomm-pages/
96
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
97
+ auth_token = "YYYYYYYYYYYYYYYYYY"
98
+ host = "XXX.XXX.XXX.XXX"
99
+
100
+ @client = Restcomm::REST::Client.new account_sid, auth_token, host
101
+ @participants = @client.conferences.get("CF123").participants.list()
102
+
103
+ return if @participants.empty?
104
+
105
+ # Kick the first person out
106
+ @participants.pop().kick()
107
+
108
+ # And mute the rest
109
+ @participants.each do |participant|
110
+ participant.mute()
111
+ end
112
+