twilio-ruby 5.0.0.rc19 → 5.0.0.rc20

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.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +8 -0
  3. data/README.md +2 -2
  4. data/VERSIONS.md +64 -0
  5. data/lib/twilio-ruby/framework/{exception.rb → error.rb} +3 -2
  6. data/lib/twilio-ruby/framework/page.rb +3 -3
  7. data/lib/twilio-ruby/framework/serialize.rb +9 -0
  8. data/lib/twilio-ruby/framework/version.rb +1 -1
  9. data/lib/twilio-ruby/http/http_client.rb +1 -0
  10. data/lib/twilio-ruby/jwt/access_token.rb +28 -0
  11. data/lib/twilio-ruby/rest/client.rb +64 -42
  12. data/lib/twilio-ruby/rest/fax/v1/fax/fax_media.rb +303 -0
  13. data/lib/twilio-ruby/rest/fax/v1/fax.rb +80 -6
  14. data/lib/twilio-ruby/rest/messaging/v1/service.rb +50 -3
  15. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +1 -1
  16. data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +2 -2
  17. data/lib/twilio-ruby/rest/preview/sync/service/document.rb +2 -2
  18. data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +2 -2
  19. data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +2 -2
  20. data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +38 -17
  21. data/lib/twilio-ruby/rest/preview/wireless/sim.rb +74 -2
  22. data/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb +377 -0
  23. data/lib/twilio-ruby/rest/sync/v1/service/document.rb +415 -0
  24. data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +409 -0
  25. data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb +377 -0
  26. data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +407 -0
  27. data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +411 -0
  28. data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb +377 -0
  29. data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +407 -0
  30. data/lib/twilio-ruby/rest/sync/v1/service.rb +469 -0
  31. data/lib/twilio-ruby/rest/sync/v1.rb +35 -0
  32. data/lib/twilio-ruby/rest/sync.rb +40 -0
  33. data/lib/twilio-ruby/rest/video/v1/room/recording.rb +324 -0
  34. data/lib/twilio-ruby/rest/video/v1/room.rb +37 -0
  35. data/lib/twilio-ruby/rest/wireless/v1/command.rb +344 -0
  36. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +399 -0
  37. data/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb +222 -0
  38. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +502 -0
  39. data/lib/twilio-ruby/rest/wireless/v1.rb +53 -0
  40. data/lib/twilio-ruby/rest/wireless.rb +48 -0
  41. data/lib/twilio-ruby/security/request_validator.rb +19 -1
  42. data/lib/twilio-ruby/version.rb +1 -1
  43. data/spec/framework/serialize_spec.rb +20 -1
  44. data/spec/integration/accounts/v1/credential/public_key_spec.rb +5 -5
  45. data/spec/integration/api/v2010/account/address/dependent_phone_number_spec.rb +1 -1
  46. data/spec/integration/api/v2010/account/address_spec.rb +5 -5
  47. data/spec/integration/api/v2010/account/application_spec.rb +5 -5
  48. data/spec/integration/api/v2010/account/authorized_connect_app_spec.rb +2 -2
  49. data/spec/integration/api/v2010/account/available_phone_number/local_spec.rb +1 -1
  50. data/spec/integration/api/v2010/account/available_phone_number/mobile_spec.rb +1 -1
  51. data/spec/integration/api/v2010/account/available_phone_number/toll_free_spec.rb +1 -1
  52. data/spec/integration/api/v2010/account/available_phone_number_spec.rb +2 -2
  53. data/spec/integration/api/v2010/account/call/feedback_spec.rb +3 -3
  54. data/spec/integration/api/v2010/account/call/feedback_summary_spec.rb +3 -3
  55. data/spec/integration/api/v2010/account/call/notification_spec.rb +3 -3
  56. data/spec/integration/api/v2010/account/call/recording_spec.rb +3 -3
  57. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  58. data/spec/integration/api/v2010/account/conference/participant_spec.rb +5 -5
  59. data/spec/integration/api/v2010/account/conference_spec.rb +3 -3
  60. data/spec/integration/api/v2010/account/connect_app_spec.rb +3 -3
  61. data/spec/integration/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension_spec.rb +2 -2
  62. data/spec/integration/api/v2010/account/incoming_phone_number/assigned_add_on_spec.rb +4 -4
  63. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +2 -2
  64. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +2 -2
  65. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +2 -2
  66. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +5 -5
  67. data/spec/integration/api/v2010/account/key_spec.rb +4 -4
  68. data/spec/integration/api/v2010/account/message/feedback_spec.rb +1 -1
  69. data/spec/integration/api/v2010/account/message/media_spec.rb +3 -3
  70. data/spec/integration/api/v2010/account/message_spec.rb +5 -5
  71. data/spec/integration/api/v2010/account/new_key_spec.rb +1 -1
  72. data/spec/integration/api/v2010/account/new_signing_key_spec.rb +1 -1
  73. data/spec/integration/api/v2010/account/notification_spec.rb +3 -3
  74. data/spec/integration/api/v2010/account/outgoing_caller_id_spec.rb +4 -4
  75. data/spec/integration/api/v2010/account/queue/member_spec.rb +3 -3
  76. data/spec/integration/api/v2010/account/queue_spec.rb +5 -5
  77. data/spec/integration/api/v2010/account/recording/add_on_result/payload_spec.rb +3 -3
  78. data/spec/integration/api/v2010/account/recording/add_on_result_spec.rb +3 -3
  79. data/spec/integration/api/v2010/account/recording/transcription_spec.rb +3 -3
  80. data/spec/integration/api/v2010/account/recording_spec.rb +3 -3
  81. data/spec/integration/api/v2010/account/short_code_spec.rb +3 -3
  82. data/spec/integration/api/v2010/account/signing_key_spec.rb +4 -4
  83. data/spec/integration/api/v2010/account/sip/credential_list/credential_spec.rb +5 -5
  84. data/spec/integration/api/v2010/account/sip/credential_list_spec.rb +5 -5
  85. data/spec/integration/api/v2010/account/sip/domain/credential_list_mapping_spec.rb +4 -4
  86. data/spec/integration/api/v2010/account/sip/domain/ip_access_control_list_mapping_spec.rb +4 -4
  87. data/spec/integration/api/v2010/account/sip/domain_spec.rb +5 -5
  88. data/spec/integration/api/v2010/account/sip/ip_access_control_list/ip_address_spec.rb +5 -5
  89. data/spec/integration/api/v2010/account/sip/ip_access_control_list_spec.rb +5 -5
  90. data/spec/integration/api/v2010/account/token_spec.rb +1 -1
  91. data/spec/integration/api/v2010/account/transcription_spec.rb +3 -3
  92. data/spec/integration/api/v2010/account/usage/record/all_time_spec.rb +1 -1
  93. data/spec/integration/api/v2010/account/usage/record/daily_spec.rb +1 -1
  94. data/spec/integration/api/v2010/account/usage/record/last_month_spec.rb +1 -1
  95. data/spec/integration/api/v2010/account/usage/record/monthly_spec.rb +1 -1
  96. data/spec/integration/api/v2010/account/usage/record/this_month_spec.rb +1 -1
  97. data/spec/integration/api/v2010/account/usage/record/today_spec.rb +1 -1
  98. data/spec/integration/api/v2010/account/usage/record/yearly_spec.rb +1 -1
  99. data/spec/integration/api/v2010/account/usage/record/yesterday_spec.rb +1 -1
  100. data/spec/integration/api/v2010/account/usage/record_spec.rb +1 -1
  101. data/spec/integration/api/v2010/account/usage/trigger_spec.rb +5 -5
  102. data/spec/integration/api/v2010/account/validation_request_spec.rb +1 -1
  103. data/spec/integration/api/v2010/account_spec.rb +4 -4
  104. data/spec/integration/chat/v1/credential_spec.rb +5 -5
  105. data/spec/integration/chat/v1/service/channel/invite_spec.rb +4 -4
  106. data/spec/integration/chat/v1/service/channel/member_spec.rb +5 -5
  107. data/spec/integration/chat/v1/service/channel/message_spec.rb +5 -5
  108. data/spec/integration/chat/v1/service/channel_spec.rb +5 -5
  109. data/spec/integration/chat/v1/service/role_spec.rb +5 -5
  110. data/spec/integration/chat/v1/service/user/user_channel_spec.rb +1 -1
  111. data/spec/integration/chat/v1/service/user_spec.rb +5 -5
  112. data/spec/integration/chat/v1/service_spec.rb +5 -5
  113. data/spec/integration/chat/v2/credential_spec.rb +5 -5
  114. data/spec/integration/chat/v2/service/channel/invite_spec.rb +4 -4
  115. data/spec/integration/chat/v2/service/channel/member_spec.rb +5 -5
  116. data/spec/integration/chat/v2/service/channel/message_spec.rb +5 -5
  117. data/spec/integration/chat/v2/service/channel_spec.rb +5 -5
  118. data/spec/integration/chat/v2/service/role_spec.rb +5 -5
  119. data/spec/integration/chat/v2/service/user/user_channel_spec.rb +1 -1
  120. data/spec/integration/chat/v2/service/user_spec.rb +5 -5
  121. data/spec/integration/chat/v2/service_spec.rb +5 -5
  122. data/spec/integration/fax/v1/fax/fax_media_spec.rb +126 -0
  123. data/spec/integration/fax/v1/fax_spec.rb +48 -7
  124. data/spec/integration/ip_messaging/v1/credential_spec.rb +5 -5
  125. data/spec/integration/ip_messaging/v1/service/channel/invite_spec.rb +4 -4
  126. data/spec/integration/ip_messaging/v1/service/channel/member_spec.rb +5 -5
  127. data/spec/integration/ip_messaging/v1/service/channel/message_spec.rb +5 -5
  128. data/spec/integration/ip_messaging/v1/service/channel_spec.rb +5 -5
  129. data/spec/integration/ip_messaging/v1/service/role_spec.rb +5 -5
  130. data/spec/integration/ip_messaging/v1/service/user/user_channel_spec.rb +1 -1
  131. data/spec/integration/ip_messaging/v1/service/user_spec.rb +5 -5
  132. data/spec/integration/ip_messaging/v1/service_spec.rb +5 -5
  133. data/spec/integration/ip_messaging/v2/credential_spec.rb +5 -5
  134. data/spec/integration/ip_messaging/v2/service/channel/invite_spec.rb +4 -4
  135. data/spec/integration/ip_messaging/v2/service/channel/member_spec.rb +5 -5
  136. data/spec/integration/ip_messaging/v2/service/channel/message_spec.rb +5 -5
  137. data/spec/integration/ip_messaging/v2/service/channel_spec.rb +5 -5
  138. data/spec/integration/ip_messaging/v2/service/role_spec.rb +5 -5
  139. data/spec/integration/ip_messaging/v2/service/user/user_channel_spec.rb +1 -1
  140. data/spec/integration/ip_messaging/v2/service/user_spec.rb +5 -5
  141. data/spec/integration/ip_messaging/v2/service_spec.rb +5 -5
  142. data/spec/integration/lookups/v1/phone_number_spec.rb +1 -1
  143. data/spec/integration/messaging/v1/service/alpha_sender_spec.rb +4 -4
  144. data/spec/integration/messaging/v1/service/phone_number_spec.rb +4 -4
  145. data/spec/integration/messaging/v1/service/short_code_spec.rb +4 -4
  146. data/spec/integration/messaging/v1/service_spec.rb +21 -5
  147. data/spec/integration/monitor/v1/alert_spec.rb +3 -3
  148. data/spec/integration/monitor/v1/event_spec.rb +2 -2
  149. data/spec/integration/notify/v1/credential_spec.rb +5 -5
  150. data/spec/integration/notify/v1/service/binding_spec.rb +4 -4
  151. data/spec/integration/notify/v1/service/notification_spec.rb +1 -1
  152. data/spec/integration/notify/v1/service/segment_spec.rb +1 -1
  153. data/spec/integration/notify/v1/service/user/segment_memberships_spec.rb +3 -3
  154. data/spec/integration/notify/v1/service/user/user_binding_spec.rb +4 -4
  155. data/spec/integration/notify/v1/service/user_spec.rb +4 -4
  156. data/spec/integration/notify/v1/service_spec.rb +5 -5
  157. data/spec/integration/preview/marketplace/available_add_on/available_add_on_extension_spec.rb +2 -2
  158. data/spec/integration/preview/marketplace/available_add_on_spec.rb +2 -2
  159. data/spec/integration/preview/marketplace/installed_add_on/installed_add_on_extension_spec.rb +3 -3
  160. data/spec/integration/preview/marketplace/installed_add_on_spec.rb +5 -5
  161. data/spec/integration/preview/sync/service/document/document_permission_spec.rb +4 -4
  162. data/spec/integration/preview/sync/service/document_spec.rb +6 -6
  163. data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +7 -7
  164. data/spec/integration/preview/sync/service/sync_list/sync_list_permission_spec.rb +4 -4
  165. data/spec/integration/preview/sync/service/sync_list_spec.rb +4 -4
  166. data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +7 -7
  167. data/spec/integration/preview/sync/service/sync_map/sync_map_permission_spec.rb +4 -4
  168. data/spec/integration/preview/sync/service/sync_map_spec.rb +4 -4
  169. data/spec/integration/preview/sync/service_spec.rb +5 -5
  170. data/spec/integration/preview/wireless/command_spec.rb +3 -3
  171. data/spec/integration/preview/wireless/rate_plan_spec.rb +45 -45
  172. data/spec/integration/preview/wireless/sim/usage_spec.rb +1 -1
  173. data/spec/integration/preview/wireless/sim_spec.rb +27 -3
  174. data/spec/integration/pricing/v1/messaging/country_spec.rb +2 -2
  175. data/spec/integration/pricing/v1/phone_number/country_spec.rb +2 -2
  176. data/spec/integration/pricing/v1/voice/country_spec.rb +2 -2
  177. data/spec/integration/pricing/v1/voice/number_spec.rb +1 -1
  178. data/spec/integration/sync/v1/service/document/document_permission_spec.rb +206 -0
  179. data/spec/integration/sync/v1/service/document_spec.rb +254 -0
  180. data/spec/integration/sync/v1/service/sync_list/sync_list_item_spec.rb +256 -0
  181. data/spec/integration/sync/v1/service/sync_list/sync_list_permission_spec.rb +206 -0
  182. data/spec/integration/sync/v1/service/sync_list_spec.rb +207 -0
  183. data/spec/integration/sync/v1/service/sync_map/sync_map_item_spec.rb +257 -0
  184. data/spec/integration/sync/v1/service/sync_map/sync_map_permission_spec.rb +206 -0
  185. data/spec/integration/sync/v1/service/sync_map_spec.rb +207 -0
  186. data/spec/integration/sync/v1/service_spec.rb +244 -0
  187. data/spec/integration/taskrouter/v1/workspace/activity_spec.rb +5 -5
  188. data/spec/integration/taskrouter/v1/workspace/event_spec.rb +2 -2
  189. data/spec/integration/taskrouter/v1/workspace/task/reservation_spec.rb +3 -3
  190. data/spec/integration/taskrouter/v1/workspace/task_channel_spec.rb +2 -2
  191. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queue_statistics_spec.rb +1 -1
  192. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queues_statistics_spec.rb +1 -1
  193. data/spec/integration/taskrouter/v1/workspace/task_queue_spec.rb +5 -5
  194. data/spec/integration/taskrouter/v1/workspace/task_spec.rb +5 -5
  195. data/spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb +3 -3
  196. data/spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb +3 -3
  197. data/spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb +1 -1
  198. data/spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb +1 -1
  199. data/spec/integration/taskrouter/v1/workspace/worker_spec.rb +5 -5
  200. data/spec/integration/taskrouter/v1/workspace/workflow/workflow_statistics_spec.rb +1 -1
  201. data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +5 -5
  202. data/spec/integration/taskrouter/v1/workspace/workspace_statistics_spec.rb +1 -1
  203. data/spec/integration/taskrouter/v1/workspace_spec.rb +5 -5
  204. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +4 -4
  205. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +4 -4
  206. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +5 -5
  207. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +4 -4
  208. data/spec/integration/trunking/v1/trunk_spec.rb +5 -5
  209. data/spec/integration/video/v1/recording_spec.rb +3 -3
  210. data/spec/integration/video/v1/room/recording_spec.rb +145 -0
  211. data/spec/integration/video/v1/room_spec.rb +20 -8
  212. data/spec/integration/wireless/v1/command_spec.rb +166 -0
  213. data/spec/integration/wireless/v1/rate_plan_spec.rb +260 -0
  214. data/spec/integration/wireless/v1/sim/usage_record_spec.rb +65 -0
  215. data/spec/integration/wireless/v1/sim_spec.rb +208 -0
  216. data/twilio-ruby.gemspec +1 -1
  217. metadata +55 -5
@@ -0,0 +1,415 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Sync < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class DocumentList < ListResource
13
+ ##
14
+ # Initialize the DocumentList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] service_sid The service_sid
17
+ # @return [DocumentList] DocumentList
18
+ def initialize(version, service_sid: nil)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {
23
+ service_sid: service_sid
24
+ }
25
+ @uri = "/Services/#{@solution[:service_sid]}/Documents"
26
+ end
27
+
28
+ ##
29
+ # Retrieve a single page of DocumentInstance records from the API.
30
+ # Request is executed immediately.
31
+ # @param [String] unique_name The unique_name
32
+ # @param [Hash] data The data
33
+ # @return [DocumentInstance] Newly created DocumentInstance
34
+ def create(unique_name: nil, data: nil)
35
+ data = {
36
+ 'UniqueName' => unique_name,
37
+ 'Data' => Twilio.serialize_object(data),
38
+ }
39
+
40
+ payload = @version.create(
41
+ 'POST',
42
+ @uri,
43
+ data: data
44
+ )
45
+
46
+ return DocumentInstance.new(
47
+ @version,
48
+ payload,
49
+ service_sid: @solution[:service_sid],
50
+ )
51
+ end
52
+
53
+ ##
54
+ # Lists DocumentInstance records from the API as a list.
55
+ # Unlike stream(), this operation is eager and will load `limit` records into
56
+ # memory before returning.
57
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
58
+ # guarantees to never return more than limit. Default is no limit
59
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
60
+ # the default value of 50 records. If no page_size is defined
61
+ # but a limit is defined, stream() will attempt to read the
62
+ # limit with the most efficient page size, i.e. min(limit, 1000)
63
+ # @return [Array] Array of up to limit results
64
+ def list(limit: nil, page_size: nil)
65
+ self.stream(
66
+ limit: limit,
67
+ page_size: page_size
68
+ ).entries
69
+ end
70
+
71
+ ##
72
+ # Streams DocumentInstance records from the API as an Enumerable.
73
+ # This operation lazily loads records as efficiently as possible until the limit
74
+ # is reached.
75
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
76
+ # guarantees to never return more than limit. Default is no limit
77
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
78
+ # the default value of 50 records. If no page_size is defined
79
+ # but a limit is defined, stream() will attempt to read the
80
+ # limit with the most efficient page size, i.e. min(limit, 1000)
81
+ # @return [Enumerable] Enumerable that will yield up to limit results
82
+ def stream(limit: nil, page_size: nil)
83
+ limits = @version.read_limits(limit, page_size)
84
+
85
+ page = self.page(
86
+ page_size: limits[:page_size],
87
+ )
88
+
89
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
90
+ end
91
+
92
+ ##
93
+ # When passed a block, yields DocumentInstance records from the API.
94
+ # This operation lazily loads records as efficiently as possible until the limit
95
+ # is reached.
96
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
97
+ # guarantees to never return more than limit. Default is no limit
98
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
99
+ # the default value of 50 records. If no page_size is defined
100
+ # but a limit is defined, stream() will attempt to read the
101
+ # limit with the most efficient page size, i.e. min(limit, 1000)
102
+ def each
103
+ limits = @version.read_limits
104
+
105
+ page = self.page(
106
+ page_size: limits[:page_size],
107
+ )
108
+
109
+ @version.stream(page,
110
+ limit: limits[:limit],
111
+ page_limit: limits[:page_limit]).each {|x| yield x}
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of DocumentInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] page_token PageToken provided by the API
118
+ # @param [Integer] page_number Page Number, this value is simply for client state
119
+ # @param [Integer] page_size Number of records to return, defaults to 50
120
+ # @return [Page] Page of DocumentInstance
121
+ def page(page_token: nil, page_number: nil, page_size: nil)
122
+ params = {
123
+ 'PageToken' => page_token,
124
+ 'Page' => page_number,
125
+ 'PageSize' => page_size,
126
+ }
127
+ response = @version.page(
128
+ 'GET',
129
+ @uri,
130
+ params
131
+ )
132
+ return DocumentPage.new(@version, response, @solution)
133
+ end
134
+
135
+ ##
136
+ # Provide a user friendly representation
137
+ def to_s
138
+ '#<Twilio.Sync.V1.DocumentList>'
139
+ end
140
+ end
141
+
142
+ class DocumentPage < Page
143
+ ##
144
+ # Initialize the DocumentPage
145
+ # @param [Version] version Version that contains the resource
146
+ # @param [Response] response Response from the API
147
+ # @param [Hash] solution Path solution for the resource
148
+ # @param [String] service_sid The service_sid
149
+ # @return [DocumentPage] DocumentPage
150
+ def initialize(version, response, solution)
151
+ super(version, response)
152
+
153
+ # Path Solution
154
+ @solution = solution
155
+ end
156
+
157
+ ##
158
+ # Build an instance of DocumentInstance
159
+ # @param [Hash] payload Payload response from the API
160
+ # @return [DocumentInstance] DocumentInstance
161
+ def get_instance(payload)
162
+ return DocumentInstance.new(
163
+ @version,
164
+ payload,
165
+ service_sid: @solution[:service_sid],
166
+ )
167
+ end
168
+
169
+ ##
170
+ # Provide a user friendly representation
171
+ def to_s
172
+ '<Twilio.Sync.V1.DocumentPage>'
173
+ end
174
+ end
175
+
176
+ class DocumentContext < InstanceContext
177
+ ##
178
+ # Initialize the DocumentContext
179
+ # @param [Version] version Version that contains the resource
180
+ # @param [String] service_sid The service_sid
181
+ # @param [String] sid The sid
182
+ # @return [DocumentContext] DocumentContext
183
+ def initialize(version, service_sid, sid)
184
+ super(version)
185
+
186
+ # Path Solution
187
+ @solution = {
188
+ service_sid: service_sid,
189
+ sid: sid,
190
+ }
191
+ @uri = "/Services/#{@solution[:service_sid]}/Documents/#{@solution[:sid]}"
192
+
193
+ # Dependents
194
+ @document_permissions = nil
195
+ end
196
+
197
+ ##
198
+ # Fetch a DocumentInstance
199
+ # @return [DocumentInstance] Fetched DocumentInstance
200
+ def fetch
201
+ params = {}
202
+
203
+ payload = @version.fetch(
204
+ 'GET',
205
+ @uri,
206
+ params,
207
+ )
208
+
209
+ return DocumentInstance.new(
210
+ @version,
211
+ payload,
212
+ service_sid: @solution[:service_sid],
213
+ sid: @solution[:sid],
214
+ )
215
+ end
216
+
217
+ ##
218
+ # Deletes the DocumentInstance
219
+ # @return [Boolean] true if delete succeeds, true otherwise
220
+ def delete
221
+ return @version.delete('delete', @uri)
222
+ end
223
+
224
+ ##
225
+ # Update the DocumentInstance
226
+ # @param [Hash] data The data
227
+ # @return [DocumentInstance] Updated DocumentInstance
228
+ def update(data: nil)
229
+ data = {
230
+ 'Data' => Twilio.serialize_object(data),
231
+ }
232
+
233
+ payload = @version.update(
234
+ 'POST',
235
+ @uri,
236
+ data: data,
237
+ )
238
+
239
+ return DocumentInstance.new(
240
+ @version,
241
+ payload,
242
+ service_sid: @solution[:service_sid],
243
+ sid: @solution[:sid],
244
+ )
245
+ end
246
+
247
+ ##
248
+ # Access the document_permissions
249
+ # @return [DocumentPermissionList] DocumentPermissionList
250
+ def document_permissions(identity=:unset)
251
+ if identity != :unset
252
+ return DocumentPermissionContext.new(
253
+ @version,
254
+ @solution[:service_sid],
255
+ @solution[:sid],
256
+ identity,
257
+ )
258
+ end
259
+
260
+ unless @document_permissions
261
+ @document_permissions = DocumentPermissionList.new(
262
+ @version,
263
+ service_sid: @solution[:service_sid],
264
+ document_sid: @solution[:sid],
265
+ )
266
+ end
267
+
268
+ @document_permissions
269
+ end
270
+
271
+ ##
272
+ # Provide a user friendly representation
273
+ def to_s
274
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
275
+ "#<Twilio.Sync.V1.DocumentContext #{context}>"
276
+ end
277
+ end
278
+
279
+ class DocumentInstance < InstanceResource
280
+ ##
281
+ # Initialize the DocumentInstance
282
+ # @param [Version] version Version that contains the resource
283
+ # @param [Hash] payload payload that contains response from Twilio
284
+ # @param [String] service_sid The service_sid
285
+ # @param [String] sid The sid
286
+ # @return [DocumentInstance] DocumentInstance
287
+ def initialize(version, payload, service_sid: nil, sid: nil)
288
+ super(version)
289
+
290
+ # Marshaled Properties
291
+ @properties = {
292
+ 'sid' => payload['sid'],
293
+ 'unique_name' => payload['unique_name'],
294
+ 'account_sid' => payload['account_sid'],
295
+ 'service_sid' => payload['service_sid'],
296
+ 'url' => payload['url'],
297
+ 'links' => payload['links'],
298
+ 'revision' => payload['revision'],
299
+ 'data' => payload['data'],
300
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
301
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
302
+ 'created_by' => payload['created_by'],
303
+ }
304
+
305
+ # Context
306
+ @instance_context = nil
307
+ @params = {
308
+ 'service_sid' => service_sid,
309
+ 'sid' => sid || @properties['sid'],
310
+ }
311
+ end
312
+
313
+ ##
314
+ # Generate an instance context for the instance, the context is capable of
315
+ # performing various actions. All instance actions are proxied to the context
316
+ # @param [Version] version Version that contains the resource
317
+ # @return [DocumentContext] DocumentContext for this DocumentInstance
318
+ def context
319
+ unless @instance_context
320
+ @instance_context = DocumentContext.new(
321
+ @version,
322
+ @params['service_sid'],
323
+ @params['sid'],
324
+ )
325
+ end
326
+ @instance_context
327
+ end
328
+
329
+ def sid
330
+ @properties['sid']
331
+ end
332
+
333
+ def unique_name
334
+ @properties['unique_name']
335
+ end
336
+
337
+ def account_sid
338
+ @properties['account_sid']
339
+ end
340
+
341
+ def service_sid
342
+ @properties['service_sid']
343
+ end
344
+
345
+ def url
346
+ @properties['url']
347
+ end
348
+
349
+ def links
350
+ @properties['links']
351
+ end
352
+
353
+ def revision
354
+ @properties['revision']
355
+ end
356
+
357
+ def data
358
+ @properties['data']
359
+ end
360
+
361
+ def date_created
362
+ @properties['date_created']
363
+ end
364
+
365
+ def date_updated
366
+ @properties['date_updated']
367
+ end
368
+
369
+ def created_by
370
+ @properties['created_by']
371
+ end
372
+
373
+ ##
374
+ # Fetch a DocumentInstance
375
+ # @return [DocumentInstance] Fetched DocumentInstance
376
+ def fetch
377
+ context.fetch
378
+ end
379
+
380
+ ##
381
+ # Deletes the DocumentInstance
382
+ # @return [Boolean] true if delete succeeds, true otherwise
383
+ def delete
384
+ context.delete
385
+ end
386
+
387
+ ##
388
+ # Update the DocumentInstance
389
+ # @param [Hash] data The data
390
+ # @return [DocumentInstance] Updated DocumentInstance
391
+ def update(data: nil)
392
+ context.update(
393
+ data: data,
394
+ )
395
+ end
396
+
397
+ ##
398
+ # Access the document_permissions
399
+ # @return [document_permissions] document_permissions
400
+ def document_permissions
401
+ context.document_permissions
402
+ end
403
+
404
+ ##
405
+ # Provide a user friendly representation
406
+ def to_s
407
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
408
+ "<Twilio.Sync.V1.DocumentInstance #{values}>"
409
+ end
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
@@ -0,0 +1,409 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Sync < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class SyncListContext < InstanceContext
13
+ class SyncListItemList < ListResource
14
+ ##
15
+ # Initialize the SyncListItemList
16
+ # @param [Version] version Version that contains the resource
17
+ # @param [String] service_sid The service_sid
18
+ # @param [String] list_sid The list_sid
19
+ # @return [SyncListItemList] SyncListItemList
20
+ def initialize(version, service_sid: nil, list_sid: nil)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {
25
+ service_sid: service_sid,
26
+ list_sid: list_sid
27
+ }
28
+ @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Items"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of SyncListItemInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [Hash] data The data
35
+ # @return [SyncListItemInstance] Newly created SyncListItemInstance
36
+ def create(data: nil)
37
+ data = {
38
+ 'Data' => Twilio.serialize_object(data),
39
+ }
40
+
41
+ payload = @version.create(
42
+ 'POST',
43
+ @uri,
44
+ data: data
45
+ )
46
+
47
+ return SyncListItemInstance.new(
48
+ @version,
49
+ payload,
50
+ service_sid: @solution[:service_sid],
51
+ list_sid: @solution[:list_sid],
52
+ )
53
+ end
54
+
55
+ ##
56
+ # Lists SyncListItemInstance records from the API as a list.
57
+ # Unlike stream(), this operation is eager and will load `limit` records into
58
+ # memory before returning.
59
+ # @param [sync_list_item.QueryResultOrder] order The order
60
+ # @param [String] from The from
61
+ # @param [sync_list_item.QueryFromBoundType] bounds The bounds
62
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
63
+ # guarantees to never return more than limit. Default is no limit
64
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
65
+ # the default value of 50 records. If no page_size is defined
66
+ # but a limit is defined, stream() will attempt to read the
67
+ # limit with the most efficient page size, i.e. min(limit, 1000)
68
+ # @return [Array] Array of up to limit results
69
+ def list(order: nil, from: nil, bounds: nil, limit: nil, page_size: nil)
70
+ self.stream(
71
+ order: order,
72
+ from: from,
73
+ bounds: bounds,
74
+ limit: limit,
75
+ page_size: page_size
76
+ ).entries
77
+ end
78
+
79
+ ##
80
+ # Streams SyncListItemInstance records from the API as an Enumerable.
81
+ # This operation lazily loads records as efficiently as possible until the limit
82
+ # is reached.
83
+ # @param [sync_list_item.QueryResultOrder] order The order
84
+ # @param [String] from The from
85
+ # @param [sync_list_item.QueryFromBoundType] bounds The bounds
86
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
87
+ # guarantees to never return more than limit. Default is no limit
88
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
89
+ # the default value of 50 records. If no page_size is defined
90
+ # but a limit is defined, stream() will attempt to read the
91
+ # limit with the most efficient page size, i.e. min(limit, 1000)
92
+ # @return [Enumerable] Enumerable that will yield up to limit results
93
+ def stream(order: nil, from: nil, bounds: nil, limit: nil, page_size: nil)
94
+ limits = @version.read_limits(limit, page_size)
95
+
96
+ page = self.page(
97
+ order: order,
98
+ from: from,
99
+ bounds: bounds,
100
+ page_size: limits[:page_size],
101
+ )
102
+
103
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
104
+ end
105
+
106
+ ##
107
+ # When passed a block, yields SyncListItemInstance records from the API.
108
+ # This operation lazily loads records as efficiently as possible until the limit
109
+ # is reached.
110
+ # @param [sync_list_item.QueryResultOrder] order The order
111
+ # @param [String] from The from
112
+ # @param [sync_list_item.QueryFromBoundType] bounds The bounds
113
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
114
+ # guarantees to never return more than limit. Default is no limit
115
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
116
+ # the default value of 50 records. If no page_size is defined
117
+ # but a limit is defined, stream() will attempt to read the
118
+ # limit with the most efficient page size, i.e. min(limit, 1000)
119
+ def each
120
+ limits = @version.read_limits
121
+
122
+ page = self.page(
123
+ page_size: limits[:page_size],
124
+ )
125
+
126
+ @version.stream(page,
127
+ limit: limits[:limit],
128
+ page_limit: limits[:page_limit]).each {|x| yield x}
129
+ end
130
+
131
+ ##
132
+ # Retrieve a single page of SyncListItemInstance records from the API.
133
+ # Request is executed immediately.
134
+ # @param [sync_list_item.QueryResultOrder] order The order
135
+ # @param [String] from The from
136
+ # @param [sync_list_item.QueryFromBoundType] bounds The bounds
137
+ # @param [String] page_token PageToken provided by the API
138
+ # @param [Integer] page_number Page Number, this value is simply for client state
139
+ # @param [Integer] page_size Number of records to return, defaults to 50
140
+ # @return [Page] Page of SyncListItemInstance
141
+ def page(order: nil, from: nil, bounds: nil, page_token: nil, page_number: nil, page_size: nil)
142
+ params = {
143
+ 'Order' => order,
144
+ 'From' => from,
145
+ 'Bounds' => bounds,
146
+ 'PageToken' => page_token,
147
+ 'Page' => page_number,
148
+ 'PageSize' => page_size,
149
+ }
150
+ response = @version.page(
151
+ 'GET',
152
+ @uri,
153
+ params
154
+ )
155
+ return SyncListItemPage.new(@version, response, @solution)
156
+ end
157
+
158
+ ##
159
+ # Provide a user friendly representation
160
+ def to_s
161
+ '#<Twilio.Sync.V1.SyncListItemList>'
162
+ end
163
+ end
164
+
165
+ class SyncListItemPage < Page
166
+ ##
167
+ # Initialize the SyncListItemPage
168
+ # @param [Version] version Version that contains the resource
169
+ # @param [Response] response Response from the API
170
+ # @param [Hash] solution Path solution for the resource
171
+ # @param [String] service_sid The service_sid
172
+ # @param [String] list_sid The list_sid
173
+ # @return [SyncListItemPage] SyncListItemPage
174
+ def initialize(version, response, solution)
175
+ super(version, response)
176
+
177
+ # Path Solution
178
+ @solution = solution
179
+ end
180
+
181
+ ##
182
+ # Build an instance of SyncListItemInstance
183
+ # @param [Hash] payload Payload response from the API
184
+ # @return [SyncListItemInstance] SyncListItemInstance
185
+ def get_instance(payload)
186
+ return SyncListItemInstance.new(
187
+ @version,
188
+ payload,
189
+ service_sid: @solution[:service_sid],
190
+ list_sid: @solution[:list_sid],
191
+ )
192
+ end
193
+
194
+ ##
195
+ # Provide a user friendly representation
196
+ def to_s
197
+ '<Twilio.Sync.V1.SyncListItemPage>'
198
+ end
199
+ end
200
+
201
+ class SyncListItemContext < InstanceContext
202
+ ##
203
+ # Initialize the SyncListItemContext
204
+ # @param [Version] version Version that contains the resource
205
+ # @param [String] service_sid The service_sid
206
+ # @param [String] list_sid The list_sid
207
+ # @param [String] index The index
208
+ # @return [SyncListItemContext] SyncListItemContext
209
+ def initialize(version, service_sid, list_sid, index)
210
+ super(version)
211
+
212
+ # Path Solution
213
+ @solution = {
214
+ service_sid: service_sid,
215
+ list_sid: list_sid,
216
+ index: index,
217
+ }
218
+ @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Items/#{@solution[:index]}"
219
+ end
220
+
221
+ ##
222
+ # Fetch a SyncListItemInstance
223
+ # @return [SyncListItemInstance] Fetched SyncListItemInstance
224
+ def fetch
225
+ params = {}
226
+
227
+ payload = @version.fetch(
228
+ 'GET',
229
+ @uri,
230
+ params,
231
+ )
232
+
233
+ return SyncListItemInstance.new(
234
+ @version,
235
+ payload,
236
+ service_sid: @solution[:service_sid],
237
+ list_sid: @solution[:list_sid],
238
+ index: @solution[:index],
239
+ )
240
+ end
241
+
242
+ ##
243
+ # Deletes the SyncListItemInstance
244
+ # @return [Boolean] true if delete succeeds, true otherwise
245
+ def delete
246
+ return @version.delete('delete', @uri)
247
+ end
248
+
249
+ ##
250
+ # Update the SyncListItemInstance
251
+ # @param [Hash] data The data
252
+ # @return [SyncListItemInstance] Updated SyncListItemInstance
253
+ def update(data: nil)
254
+ data = {
255
+ 'Data' => Twilio.serialize_object(data),
256
+ }
257
+
258
+ payload = @version.update(
259
+ 'POST',
260
+ @uri,
261
+ data: data,
262
+ )
263
+
264
+ return SyncListItemInstance.new(
265
+ @version,
266
+ payload,
267
+ service_sid: @solution[:service_sid],
268
+ list_sid: @solution[:list_sid],
269
+ index: @solution[:index],
270
+ )
271
+ end
272
+
273
+ ##
274
+ # Provide a user friendly representation
275
+ def to_s
276
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
277
+ "#<Twilio.Sync.V1.SyncListItemContext #{context}>"
278
+ end
279
+ end
280
+
281
+ class SyncListItemInstance < InstanceResource
282
+ ##
283
+ # Initialize the SyncListItemInstance
284
+ # @param [Version] version Version that contains the resource
285
+ # @param [Hash] payload payload that contains response from Twilio
286
+ # @param [String] service_sid The service_sid
287
+ # @param [String] list_sid The list_sid
288
+ # @param [String] index The index
289
+ # @return [SyncListItemInstance] SyncListItemInstance
290
+ def initialize(version, payload, service_sid: nil, list_sid: nil, index: nil)
291
+ super(version)
292
+
293
+ # Marshaled Properties
294
+ @properties = {
295
+ 'index' => payload['index'].to_i,
296
+ 'account_sid' => payload['account_sid'],
297
+ 'service_sid' => payload['service_sid'],
298
+ 'list_sid' => payload['list_sid'],
299
+ 'url' => payload['url'],
300
+ 'revision' => payload['revision'],
301
+ 'data' => payload['data'],
302
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
303
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
304
+ 'created_by' => payload['created_by'],
305
+ }
306
+
307
+ # Context
308
+ @instance_context = nil
309
+ @params = {
310
+ 'service_sid' => service_sid,
311
+ 'list_sid' => list_sid,
312
+ 'index' => index || @properties['index'],
313
+ }
314
+ end
315
+
316
+ ##
317
+ # Generate an instance context for the instance, the context is capable of
318
+ # performing various actions. All instance actions are proxied to the context
319
+ # @param [Version] version Version that contains the resource
320
+ # @return [SyncListItemContext] SyncListItemContext for this SyncListItemInstance
321
+ def context
322
+ unless @instance_context
323
+ @instance_context = SyncListItemContext.new(
324
+ @version,
325
+ @params['service_sid'],
326
+ @params['list_sid'],
327
+ @params['index'],
328
+ )
329
+ end
330
+ @instance_context
331
+ end
332
+
333
+ def index
334
+ @properties['index']
335
+ end
336
+
337
+ def account_sid
338
+ @properties['account_sid']
339
+ end
340
+
341
+ def service_sid
342
+ @properties['service_sid']
343
+ end
344
+
345
+ def list_sid
346
+ @properties['list_sid']
347
+ end
348
+
349
+ def url
350
+ @properties['url']
351
+ end
352
+
353
+ def revision
354
+ @properties['revision']
355
+ end
356
+
357
+ def data
358
+ @properties['data']
359
+ end
360
+
361
+ def date_created
362
+ @properties['date_created']
363
+ end
364
+
365
+ def date_updated
366
+ @properties['date_updated']
367
+ end
368
+
369
+ def created_by
370
+ @properties['created_by']
371
+ end
372
+
373
+ ##
374
+ # Fetch a SyncListItemInstance
375
+ # @return [SyncListItemInstance] Fetched SyncListItemInstance
376
+ def fetch
377
+ context.fetch
378
+ end
379
+
380
+ ##
381
+ # Deletes the SyncListItemInstance
382
+ # @return [Boolean] true if delete succeeds, true otherwise
383
+ def delete
384
+ context.delete
385
+ end
386
+
387
+ ##
388
+ # Update the SyncListItemInstance
389
+ # @param [Hash] data The data
390
+ # @return [SyncListItemInstance] Updated SyncListItemInstance
391
+ def update(data: nil)
392
+ context.update(
393
+ data: data,
394
+ )
395
+ end
396
+
397
+ ##
398
+ # Provide a user friendly representation
399
+ def to_s
400
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
401
+ "<Twilio.Sync.V1.SyncListItemInstance #{values}>"
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
408
+ end
409
+ end