twilio-ruby 5.0.0.rc26 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +187 -0
- data/.travis.yml +13 -0
- data/CHANGES.md +4 -0
- data/Gemfile +2 -2
- data/Makefile +8 -1
- data/Rakefile +3 -7
- data/examples/examples.rb +12 -10
- data/examples/{print-call-log.rb → print_call_log.rb} +4 -4
- data/lib/rack/twilio_webhook_authentication.rb +2 -3
- data/lib/twilio-ruby/framework/domain.rb +2 -6
- data/lib/twilio-ruby/framework/error.rb +0 -1
- data/lib/twilio-ruby/framework/helper.rb +1 -1
- data/lib/twilio-ruby/framework/page.rb +23 -25
- data/lib/twilio-ruby/framework/resource.rb +2 -2
- data/lib/twilio-ruby/framework/serialize.rb +5 -12
- data/lib/twilio-ruby/framework/twilio_response.rb +1 -1
- data/lib/twilio-ruby/framework/values.rb +2 -2
- data/lib/twilio-ruby/framework/version.rb +19 -37
- data/lib/twilio-ruby/http/http_client.rb +5 -6
- data/lib/twilio-ruby/jwt/access_token.rb +27 -41
- data/lib/twilio-ruby/jwt/client_capability.rb +11 -16
- data/lib/twilio-ruby/jwt/jwt.rb +7 -13
- data/lib/twilio-ruby/jwt/task_router.rb +40 -38
- data/lib/twilio-ruby/rest/accounts.rb +2 -0
- data/lib/twilio-ruby/rest/accounts/v1.rb +2 -0
- data/lib/twilio-ruby/rest/accounts/v1/credential.rb +2 -2
- data/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb +12 -7
- data/lib/twilio-ruby/rest/api.rb +96 -0
- data/lib/twilio-ruby/rest/api/v2010.rb +5 -0
- data/lib/twilio-ruby/rest/api/v2010/account.rb +66 -56
- data/lib/twilio-ruby/rest/api/v2010/account/address.rb +30 -13
- data/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb +22 -8
- data/lib/twilio-ruby/rest/api/v2010/account/application.rb +40 -11
- data/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb +20 -9
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +16 -15
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +26 -28
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +26 -28
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +26 -28
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +64 -34
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +12 -4
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb +28 -3
- data/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb +37 -16
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +25 -15
- data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +28 -27
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +28 -19
- data/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +22 -9
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +62 -58
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +52 -12
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +52 -12
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +52 -12
- data/lib/twilio-ruby/rest/api/v2010/account/key.rb +8 -9
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +47 -20
- data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +12 -2
- data/lib/twilio-ruby/rest/api/v2010/account/message/media.rb +17 -17
- data/lib/twilio-ruby/rest/api/v2010/account/new_key.rb +10 -2
- data/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb +10 -2
- data/lib/twilio-ruby/rest/api/v2010/account/notification.rb +37 -16
- data/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb +14 -13
- data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +20 -10
- data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +10 -10
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +37 -21
- data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb +22 -13
- data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb +22 -13
- data/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb +26 -9
- data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +24 -13
- data/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb +8 -9
- data/lib/twilio-ruby/rest/api/v2010/account/sip.rb +8 -10
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +16 -11
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +14 -9
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +36 -13
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +14 -10
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +14 -10
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +16 -11
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb +16 -9
- data/lib/twilio-ruby/rest/api/v2010/account/token.rb +14 -2
- data/lib/twilio-ruby/rest/api/v2010/account/transcription.rb +26 -9
- data/lib/twilio-ruby/rest/api/v2010/account/usage.rb +4 -6
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +44 -33
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb +28 -11
- data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +32 -15
- data/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +10 -1
- data/lib/twilio-ruby/rest/chat.rb +8 -0
- data/lib/twilio-ruby/rest/chat/v1.rb +8 -0
- data/lib/twilio-ruby/rest/chat/v1/credential.rb +16 -7
- data/lib/twilio-ruby/rest/chat/v1/service.rb +48 -13
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +34 -15
- data/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb +20 -10
- data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +22 -10
- data/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb +26 -10
- data/lib/twilio-ruby/rest/chat/v1/service/role.rb +18 -8
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +30 -10
- data/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb +16 -8
- data/lib/twilio-ruby/rest/chat/v2.rb +8 -0
- data/lib/twilio-ruby/rest/chat/v2/credential.rb +16 -7
- data/lib/twilio-ruby/rest/chat/v2/service.rb +46 -13
- data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +34 -15
- data/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb +20 -10
- data/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb +22 -10
- data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +26 -10
- data/lib/twilio-ruby/rest/chat/v2/service/role.rb +18 -8
- data/lib/twilio-ruby/rest/chat/v2/service/user.rb +30 -10
- data/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb +16 -8
- data/lib/twilio-ruby/rest/client.rb +94 -45
- data/lib/twilio-ruby/rest/ip_messaging.rb +8 -0
- data/lib/twilio-ruby/rest/ip_messaging/v1.rb +8 -0
- data/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb +16 -7
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +48 -13
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +34 -15
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb +20 -10
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb +22 -10
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +26 -10
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +18 -8
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +30 -10
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb +16 -8
- data/lib/twilio-ruby/rest/ip_messaging/v2.rb +8 -0
- data/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb +16 -7
- data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +46 -13
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +34 -15
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb +20 -10
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb +22 -10
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +26 -10
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb +18 -8
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +30 -10
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb +16 -8
- data/lib/twilio-ruby/rest/lookups.rb +4 -0
- data/lib/twilio-ruby/rest/lookups/v1.rb +9 -5
- data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +14 -1
- data/lib/twilio-ruby/rest/monitor.rb +8 -0
- data/lib/twilio-ruby/rest/monitor/v1.rb +8 -0
- data/lib/twilio-ruby/rest/monitor/v1/alert.rb +34 -10
- data/lib/twilio-ruby/rest/monitor/v1/event.rb +28 -13
- data/lib/twilio-ruby/rest/pricing.rb +6 -0
- data/lib/twilio-ruby/rest/pricing/v1.rb +6 -0
- data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +8 -2
- data/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +12 -7
- data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +8 -2
- data/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +10 -7
- data/lib/twilio-ruby/rest/pricing/v1/voice.rb +10 -4
- data/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +12 -7
- data/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +14 -1
- data/lib/twilio-ruby/rest/taskrouter.rb +4 -0
- data/lib/twilio-ruby/rest/taskrouter/v1.rb +4 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +46 -24
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +16 -10
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb +30 -17
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +42 -19
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +22 -10
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +16 -8
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +34 -15
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb +12 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb +10 -11
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +34 -23
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +22 -10
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +28 -9
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb +10 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb +10 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +28 -11
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb +12 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb +10 -2
- data/lib/twilio-ruby/rest/trunking.rb +4 -0
- data/lib/twilio-ruby/rest/trunking/v1.rb +4 -0
- data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +36 -15
- data/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb +14 -8
- data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +14 -8
- data/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb +22 -8
- data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +52 -8
- data/lib/twilio-ruby/rest/video.rb +8 -0
- data/lib/twilio-ruby/rest/video/v1.rb +8 -0
- data/lib/twilio-ruby/rest/video/v1/recording.rb +26 -12
- data/lib/twilio-ruby/rest/video/v1/room.rb +34 -13
- data/lib/twilio-ruby/rest/video/v1/room/recording.rb +28 -12
- data/lib/twilio-ruby/security/request_validator.rb +1 -2
- data/lib/twilio-ruby/twiml/messaging_response.rb +7 -19
- data/lib/twilio-ruby/twiml/twiml.rb +8 -14
- data/lib/twilio-ruby/twiml/voice_response.rb +157 -169
- data/lib/twilio-ruby/util.rb +1 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/framework/serialize_spec.rb +17 -30
- data/spec/holodeck/holodeck.rb +6 -6
- data/spec/jwt/access_token_spec.rb +0 -6
- data/spec/jwt/client_capability_spec.rb +3 -3
- data/spec/jwt/task_router_spec.rb +16 -21
- data/spec/rack/twilio_webhook_authentication_spec.rb +12 -16
- data/spec/spec_helper.rb +2 -2
- data/spec/support/fakeweb.rb +1 -1
- data/spec/twiml/voice_response_spec.rb +33 -20
- data/twilio-ruby.gemspec +7 -3
- metadata +21 -193
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +0 -420
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb +0 -345
- data/lib/twilio-ruby/rest/fax.rb +0 -40
- data/lib/twilio-ruby/rest/fax/v1.rb +0 -37
- data/lib/twilio-ruby/rest/fax/v1/fax.rb +0 -520
- data/lib/twilio-ruby/rest/fax/v1/fax/fax_media.rb +0 -321
- data/lib/twilio-ruby/rest/messaging.rb +0 -40
- data/lib/twilio-ruby/rest/messaging/v1.rb +0 -37
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +0 -604
- data/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb +0 -344
- data/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb +0 -349
- data/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb +0 -349
- data/lib/twilio-ruby/rest/notify.rb +0 -44
- data/lib/twilio-ruby/rest/notify/v1.rb +0 -48
- data/lib/twilio-ruby/rest/notify/v1/credential.rb +0 -394
- data/lib/twilio-ruby/rest/notify/v1/service.rb +0 -611
- data/lib/twilio-ruby/rest/notify/v1/service/binding.rb +0 -414
- data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +0 -249
- data/lib/twilio-ruby/rest/notify/v1/service/segment.rb +0 -219
- data/lib/twilio-ruby/rest/notify/v1/service/user.rb +0 -437
- data/lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb +0 -247
- data/lib/twilio-ruby/rest/notify/v1/service/user/user_binding.rb +0 -418
- data/lib/twilio-ruby/rest/preview.rb +0 -107
- data/lib/twilio-ruby/rest/preview/bulk_exports.rb +0 -48
- data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +0 -198
- data/lib/twilio-ruby/rest/preview/bulk_exports/export/day.rb +0 -209
- data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +0 -232
- data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +0 -37
- data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +0 -539
- data/lib/twilio-ruby/rest/preview/marketplace.rb +0 -48
- data/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +0 -326
- data/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb +0 -297
- data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +0 -427
- data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb +0 -335
- data/lib/twilio-ruby/rest/preview/proxy.rb +0 -37
- data/lib/twilio-ruby/rest/preview/proxy/service.rb +0 -489
- data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +0 -349
- data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +0 -525
- data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +0 -406
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +0 -495
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +0 -422
- data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +0 -349
- data/lib/twilio-ruby/rest/preview/sync.rb +0 -37
- data/lib/twilio-ruby/rest/preview/sync/service.rb +0 -491
- data/lib/twilio-ruby/rest/preview/sync/service/document.rb +0 -431
- data/lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb +0 -390
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +0 -426
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +0 -422
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_permission.rb +0 -390
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +0 -426
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +0 -424
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_permission.rb +0 -390
- data/lib/twilio-ruby/rest/preview/wireless.rb +0 -59
- data/lib/twilio-ruby/rest/preview/wireless/command.rb +0 -371
- data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +0 -414
- data/lib/twilio-ruby/rest/preview/wireless/sim.rb +0 -512
- data/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb +0 -220
- data/lib/twilio-ruby/rest/sync.rb +0 -40
- data/lib/twilio-ruby/rest/sync/v1.rb +0 -37
- data/lib/twilio-ruby/rest/sync/v1/service.rb +0 -491
- data/lib/twilio-ruby/rest/sync/v1/service/document.rb +0 -431
- data/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb +0 -390
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +0 -426
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +0 -422
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb +0 -390
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +0 -426
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +0 -424
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb +0 -390
- data/lib/twilio-ruby/rest/wireless.rb +0 -48
- data/lib/twilio-ruby/rest/wireless/v1.rb +0 -59
- data/lib/twilio-ruby/rest/wireless/v1/command.rb +0 -357
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +0 -427
- data/lib/twilio-ruby/rest/wireless/v1/sim.rb +0 -516
- data/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb +0 -235
- data/spec/integration/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension_spec.rb +0 -135
- data/spec/integration/api/v2010/account/incoming_phone_number/assigned_add_on_spec.rb +0 -223
- data/spec/integration/fax/v1/fax/fax_media_spec.rb +0 -126
- data/spec/integration/fax/v1/fax_spec.rb +0 -272
- data/spec/integration/messaging/v1/service/alpha_sender_spec.rb +0 -170
- data/spec/integration/messaging/v1/service/phone_number_spec.rb +0 -201
- data/spec/integration/messaging/v1/service/short_code_spec.rb +0 -173
- data/spec/integration/messaging/v1/service_spec.rb +0 -263
- data/spec/integration/notify/v1/credential_spec.rb +0 -223
- data/spec/integration/notify/v1/service/binding_spec.rb +0 -227
- data/spec/integration/notify/v1/service/notification_spec.rb +0 -97
- data/spec/integration/notify/v1/service/segment_spec.rb +0 -84
- data/spec/integration/notify/v1/service/user/segment_memberships_spec.rb +0 -118
- data/spec/integration/notify/v1/service/user/user_binding_spec.rb +0 -269
- data/spec/integration/notify/v1/service/user_spec.rb +0 -213
- data/spec/integration/notify/v1/service_spec.rb +0 -280
- data/spec/integration/preview/bulk_exports/export/day_spec.rb +0 -56
- data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +0 -79
- data/spec/integration/preview/bulk_exports/export_spec.rb +0 -43
- data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +0 -276
- data/spec/integration/preview/marketplace/available_add_on/available_add_on_extension_spec.rb +0 -121
- data/spec/integration/preview/marketplace/available_add_on_spec.rb +0 -142
- data/spec/integration/preview/marketplace/installed_add_on/installed_add_on_extension_spec.rb +0 -164
- data/spec/integration/preview/marketplace/installed_add_on_spec.rb +0 -252
- data/spec/integration/preview/proxy/service/phone_number_spec.rb +0 -173
- data/spec/integration/preview/proxy/service/session/interaction_spec.rb +0 -104
- data/spec/integration/preview/proxy/service/session/participant/message_interaction_spec.rb +0 -164
- data/spec/integration/preview/proxy/service/session/participant_spec.rb +0 -226
- data/spec/integration/preview/proxy/service/session_spec.rb +0 -216
- data/spec/integration/preview/proxy/service/short_code_spec.rb +0 -173
- data/spec/integration/preview/proxy/service_spec.rb +0 -200
- data/spec/integration/preview/sync/service/document/document_permission_spec.rb +0 -206
- data/spec/integration/preview/sync/service/document_spec.rb +0 -254
- data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +0 -256
- data/spec/integration/preview/sync/service/sync_list/sync_list_permission_spec.rb +0 -206
- data/spec/integration/preview/sync/service/sync_list_spec.rb +0 -207
- data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +0 -257
- data/spec/integration/preview/sync/service/sync_map/sync_map_permission_spec.rb +0 -206
- data/spec/integration/preview/sync/service/sync_map_spec.rb +0 -207
- data/spec/integration/preview/sync/service_spec.rb +0 -244
- data/spec/integration/preview/wireless/command_spec.rb +0 -169
- data/spec/integration/preview/wireless/rate_plan_spec.rb +0 -260
- data/spec/integration/preview/wireless/sim/usage_spec.rb +0 -49
- data/spec/integration/preview/wireless/sim_spec.rb +0 -208
- data/spec/integration/sync/v1/service/document/document_permission_spec.rb +0 -206
- data/spec/integration/sync/v1/service/document_spec.rb +0 -254
- data/spec/integration/sync/v1/service/sync_list/sync_list_item_spec.rb +0 -256
- data/spec/integration/sync/v1/service/sync_list/sync_list_permission_spec.rb +0 -206
- data/spec/integration/sync/v1/service/sync_list_spec.rb +0 -207
- data/spec/integration/sync/v1/service/sync_map/sync_map_item_spec.rb +0 -257
- data/spec/integration/sync/v1/service/sync_map/sync_map_permission_spec.rb +0 -206
- data/spec/integration/sync/v1/service/sync_map_spec.rb +0 -207
- data/spec/integration/sync/v1/service_spec.rb +0 -244
- data/spec/integration/wireless/v1/command_spec.rb +0 -166
- data/spec/integration/wireless/v1/rate_plan_spec.rb +0 -268
- data/spec/integration/wireless/v1/sim/usage_record_spec.rb +0 -65
- data/spec/integration/wireless/v1/sim_spec.rb +0 -208
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a6f5e9d921db6048332ae4913809af14e3ea8a
|
4
|
+
data.tar.gz: 6a3634728a3446a9bbe70d4da8cbaf5df29e00f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f866e4c93cc5bd0f58648eda34acf840b4859052f4e26967001b4fd5874accdda13a198f61bb1c5c50bcea968cb8071b9bddbcd528c0e922dcd7ca39640531d
|
7
|
+
data.tar.gz: e28c9d8b3f51a160ed850ff21a3cf9720b1604fe2e9b580326ee71faf0cf177d343f160c49ce055242cb6f98a82d939a3a26828dd8a886b6058f33efaddd6b6a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.0
|
5
|
+
Exclude:
|
6
|
+
- 'lib/twilio-ruby/rest/**/*'
|
7
|
+
- 'spec/integration/**/*'
|
8
|
+
|
9
|
+
Metrics/LineLength:
|
10
|
+
Max: 120
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 175
|
16
|
+
|
17
|
+
Metrics/MethodLength:
|
18
|
+
Max: 25
|
19
|
+
|
20
|
+
Metrics/ParameterLists:
|
21
|
+
Max: 20
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-07-07 14:30:20 -0700 using RuboCop version 0.49.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
12
|
+
Layout/ExtraSpacing:
|
13
|
+
Exclude:
|
14
|
+
- 'twilio-ruby.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
19
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
20
|
+
Layout/IndentHeredoc:
|
21
|
+
Exclude:
|
22
|
+
- 'Rakefile'
|
23
|
+
|
24
|
+
# Offense count: 2
|
25
|
+
# Cop supports --auto-correct.
|
26
|
+
# Configuration parameters: AllowForAlignment.
|
27
|
+
Layout/SpaceAroundOperators:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/jwt/client_capability_spec.rb'
|
30
|
+
|
31
|
+
# Offense count: 8
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
|
34
|
+
# SupportedStyles: space, no_space, compact
|
35
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
36
|
+
Layout/SpaceInsideHashLiteralBraces:
|
37
|
+
Exclude:
|
38
|
+
- 'spec/jwt/access_token_spec.rb'
|
39
|
+
- 'spec/jwt/client_capability_spec.rb'
|
40
|
+
|
41
|
+
# Offense count: 1
|
42
|
+
# Cop supports --auto-correct.
|
43
|
+
Layout/TrailingWhitespace:
|
44
|
+
Exclude:
|
45
|
+
- 'lib/twilio-ruby/jwt/jwt.rb'
|
46
|
+
|
47
|
+
# Offense count: 2
|
48
|
+
# Cop supports --auto-correct.
|
49
|
+
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
50
|
+
Lint/UnusedBlockArgument:
|
51
|
+
Exclude:
|
52
|
+
- 'Rakefile'
|
53
|
+
- 'spec/rack/twilio_webhook_authentication_spec.rb'
|
54
|
+
|
55
|
+
# Offense count: 4
|
56
|
+
# Cop supports --auto-correct.
|
57
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
58
|
+
Lint/UnusedMethodArgument:
|
59
|
+
Exclude:
|
60
|
+
- 'lib/twilio-ruby.rb'
|
61
|
+
- 'lib/twilio-ruby/framework/page.rb'
|
62
|
+
- 'spec/holodeck/holodeck.rb'
|
63
|
+
|
64
|
+
# Offense count: 1
|
65
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
66
|
+
Lint/UselessAccessModifier:
|
67
|
+
Exclude:
|
68
|
+
- 'lib/twilio-ruby/jwt/access_token.rb'
|
69
|
+
|
70
|
+
# Offense count: 14
|
71
|
+
Lint/UselessAssignment:
|
72
|
+
Exclude:
|
73
|
+
- 'spec/rack/twilio_webhook_authentication_spec.rb'
|
74
|
+
|
75
|
+
# Offense count: 3
|
76
|
+
Metrics/AbcSize:
|
77
|
+
Max: 28
|
78
|
+
|
79
|
+
# Offense count: 24
|
80
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
81
|
+
Metrics/BlockLength:
|
82
|
+
Max: 349
|
83
|
+
|
84
|
+
# Offense count: 53
|
85
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
86
|
+
# URISchemes: http, https
|
87
|
+
Metrics/LineLength:
|
88
|
+
Max: 249
|
89
|
+
|
90
|
+
# Offense count: 1
|
91
|
+
# Cop supports --auto-correct.
|
92
|
+
Performance/RedundantMatch:
|
93
|
+
Exclude:
|
94
|
+
- 'lib/twilio-ruby/framework/domain.rb'
|
95
|
+
|
96
|
+
# Offense count: 7
|
97
|
+
# Cop supports --auto-correct.
|
98
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
99
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
100
|
+
Style/BracesAroundHashParameters:
|
101
|
+
Exclude:
|
102
|
+
- 'spec/framework/serialize_spec.rb'
|
103
|
+
- 'spec/jwt/access_token_spec.rb'
|
104
|
+
- 'spec/jwt/client_capability_spec.rb'
|
105
|
+
- 'spec/rack/twilio_webhook_authentication_spec.rb'
|
106
|
+
- 'spec/twiml/voice_response_spec.rb'
|
107
|
+
|
108
|
+
# Offense count: 35
|
109
|
+
Style/Documentation:
|
110
|
+
Enabled: false
|
111
|
+
|
112
|
+
# Offense count: 1
|
113
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
114
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
115
|
+
Style/FileName:
|
116
|
+
Exclude:
|
117
|
+
- 'lib/twilio-ruby.rb'
|
118
|
+
|
119
|
+
# Offense count: 3
|
120
|
+
# Configuration parameters: MinBodyLength.
|
121
|
+
Style/GuardClause:
|
122
|
+
Exclude:
|
123
|
+
- 'lib/twilio-ruby/framework/page.rb'
|
124
|
+
|
125
|
+
# Offense count: 1
|
126
|
+
# Cop supports --auto-correct.
|
127
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
128
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
129
|
+
Style/HashSyntax:
|
130
|
+
Exclude:
|
131
|
+
- 'spec/jwt/access_token_spec.rb'
|
132
|
+
|
133
|
+
# Offense count: 2
|
134
|
+
# Cop supports --auto-correct.
|
135
|
+
Style/RedundantSelf:
|
136
|
+
Exclude:
|
137
|
+
- 'lib/twilio-ruby/framework/serialize.rb'
|
138
|
+
|
139
|
+
# Offense count: 16
|
140
|
+
# Cop supports --auto-correct.
|
141
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
142
|
+
# SupportedStyles: slashes, percent_r, mixed
|
143
|
+
Style/RegexpLiteral:
|
144
|
+
Exclude:
|
145
|
+
- 'lib/twilio-ruby/framework/domain.rb'
|
146
|
+
- 'lib/twilio-ruby/framework/helper.rb'
|
147
|
+
- 'lib/twilio-ruby/framework/version.rb'
|
148
|
+
- 'spec/rack/twilio_webhook_authentication_spec.rb'
|
149
|
+
|
150
|
+
# Offense count: 3
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
153
|
+
# SupportedStyles: single_quotes, double_quotes
|
154
|
+
Style/StringLiterals:
|
155
|
+
Exclude:
|
156
|
+
- 'spec/framework/serialize_spec.rb'
|
157
|
+
|
158
|
+
# Offense count: 1
|
159
|
+
# Cop supports --auto-correct.
|
160
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
161
|
+
# SupportedStyles: percent, brackets
|
162
|
+
Style/SymbolArray:
|
163
|
+
EnforcedStyle: brackets
|
164
|
+
|
165
|
+
# Offense count: 13
|
166
|
+
# Cop supports --auto-correct.
|
167
|
+
# Configuration parameters: AllowNamedUnderscoreVariables.
|
168
|
+
Style/TrailingUnderscoreVariable:
|
169
|
+
Exclude:
|
170
|
+
- 'spec/jwt/access_token_spec.rb'
|
171
|
+
- 'spec/jwt/client_capability_spec.rb'
|
172
|
+
- 'spec/jwt/task_router_spec.rb'
|
173
|
+
|
174
|
+
# Offense count: 15
|
175
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
176
|
+
# SupportedStyles: snake_case, camelCase
|
177
|
+
Style/VariableName:
|
178
|
+
Exclude:
|
179
|
+
- 'spec/jwt/client_capability_spec.rb'
|
180
|
+
- 'spec/jwt/task_router_spec.rb'
|
181
|
+
|
182
|
+
# Offense count: 3
|
183
|
+
# Cop supports --auto-correct.
|
184
|
+
# Configuration parameters: SupportedStyles, MinSize, WordRegex.
|
185
|
+
# SupportedStyles: percent, brackets
|
186
|
+
Style/WordArray:
|
187
|
+
EnforcedStyle: brackets
|
data/.travis.yml
ADDED
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
data/Makefile
CHANGED
@@ -1,15 +1,22 @@
|
|
1
|
+
.PHONY: test lint-changed lint
|
2
|
+
|
3
|
+
CHANGED_RUBY_FILES = $(shell git status --porcelain | grep ".rb" | awk -F ' ' '{print $2}' | tr '\n' ' ')
|
4
|
+
|
1
5
|
install:
|
2
6
|
bundle install; bundle exec rake install
|
3
7
|
|
4
8
|
test-install:
|
5
9
|
bundle install
|
6
10
|
|
7
|
-
test:
|
11
|
+
test: lint
|
8
12
|
bundle exec rake spec
|
9
13
|
|
10
14
|
docs:
|
11
15
|
yard doc
|
12
16
|
|
17
|
+
lint:
|
18
|
+
rubocop --cache true --parallel
|
19
|
+
|
13
20
|
authors:
|
14
21
|
echo "Authors\n=======\n\nA huge thanks to all of our contributors:\n\n" > AUTHORS.md
|
15
22
|
git log --raw | grep "^Author: " | cut -d ' ' -f2- | cut -d '<' -f1 | sed 's/^/- /' | sort | uniq >> AUTHORS.md
|
data/Rakefile
CHANGED
@@ -22,14 +22,10 @@ task :deploy, [:version] => [:spec, :authors] do |t, args|
|
|
22
22
|
increment = version_parts.pop
|
23
23
|
increment_prefix = increment.split(/\d/)[0]
|
24
24
|
|
25
|
-
if increment_prefix
|
26
|
-
increment = increment[increment_prefix.length..-1]
|
27
|
-
end
|
25
|
+
increment = increment[increment_prefix.length..-1] if increment_prefix
|
28
26
|
|
29
27
|
increment = increment.to_i + 1
|
30
|
-
if increment_prefix
|
31
|
-
increment = "#{increment_prefix}#{increment}"
|
32
|
-
end
|
28
|
+
increment = "#{increment_prefix}#{increment}" if increment_prefix
|
33
29
|
|
34
30
|
version = [*version_parts, increment].join('.')
|
35
31
|
else
|
@@ -65,4 +61,4 @@ SRC
|
|
65
61
|
|
66
62
|
# Push the tags
|
67
63
|
`git push --tags`
|
68
|
-
end
|
64
|
+
end
|
data/examples/examples.rb
CHANGED
@@ -31,7 +31,7 @@ end
|
|
31
31
|
|
32
32
|
# get a particular call and list its recording urls
|
33
33
|
@client.calls('CAXXXXXXX').recordings.each do |r|
|
34
|
-
|
34
|
+
puts r.wav
|
35
35
|
end
|
36
36
|
|
37
37
|
# make a new outgoing call. returns a call object just like calls.get
|
@@ -79,7 +79,7 @@ puts @client.messages('SMXXXXXXXX').fetch.body
|
|
79
79
|
|
80
80
|
# print some available numbers
|
81
81
|
@client.available_phone_numbers('US').local.list.each do |num|
|
82
|
-
|
82
|
+
puts num
|
83
83
|
end
|
84
84
|
|
85
85
|
@numbers = @client.available_phone_numbers('US').local.list(area_code: '908')
|
@@ -89,9 +89,7 @@ end
|
|
89
89
|
@client.incoming_phone_numbers.create(phone_number: @numbers[0].phone_number)
|
90
90
|
|
91
91
|
# update an existing phone number's voice url
|
92
|
-
@client.incoming_phone_numbers('PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(
|
93
|
-
voice_url: 'http://example.com/voice'
|
94
|
-
)
|
92
|
+
@client.incoming_phone_numbers('PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(voice_url: 'http://example.com/voice')
|
95
93
|
|
96
94
|
# decommission an existing phone number
|
97
95
|
numbers = @client.incoming_phone_numbers.list(friendly_name: 'A Fabulous Friendly Name')
|
@@ -110,8 +108,10 @@ conference = @client.conferences('CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').fetch
|
|
110
108
|
end
|
111
109
|
|
112
110
|
# update a conference participant
|
113
|
-
@client
|
114
|
-
|
111
|
+
@client
|
112
|
+
.conferences('CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
113
|
+
.participants('CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
114
|
+
.update(muted: 'true')
|
115
115
|
|
116
116
|
################ QUEUES ###################
|
117
117
|
|
@@ -125,11 +125,13 @@ end
|
|
125
125
|
@queue = @client.queues('QQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').fetch
|
126
126
|
@members = @queue.members
|
127
127
|
|
128
|
-
#list members
|
128
|
+
# list members
|
129
129
|
@members.list.each do |m|
|
130
130
|
puts m.wait_time
|
131
131
|
end
|
132
132
|
|
133
133
|
# dequeue a particular user and run twiml at a specific url
|
134
|
-
@client
|
135
|
-
|
134
|
+
@client
|
135
|
+
.queues('QQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
136
|
+
.members('CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
137
|
+
.update(url: 'http://myapp.com/deque', method: 'POST')
|
@@ -12,13 +12,13 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
|
12
12
|
# set up a client
|
13
13
|
client = Twilio::REST::Client.new(account_sid, auth_token)
|
14
14
|
|
15
|
-
calls = client.calls.page
|
15
|
+
calls = client.calls.page
|
16
16
|
|
17
|
-
|
17
|
+
loop do
|
18
18
|
calls.each do |call|
|
19
19
|
price = call.price || '0.00' # since apparently prices can be nil...
|
20
20
|
puts call.sid + "\t" + call.from + "\t" + call.to + "\t" + price.to_s
|
21
21
|
end
|
22
22
|
calls = calls.next_page
|
23
|
-
|
24
|
-
|
23
|
+
break if calls.nil?
|
24
|
+
end
|
@@ -31,17 +31,16 @@ module Rack
|
|
31
31
|
params = request.post? ? request.POST : {}
|
32
32
|
auth_token = @auth_token || get_auth_token(params['AccountSid'])
|
33
33
|
validator = Twilio::Security::RequestValidator.new(auth_token)
|
34
|
-
signature = env['HTTP_X_TWILIO_SIGNATURE'] ||
|
34
|
+
signature = env['HTTP_X_TWILIO_SIGNATURE'] || ''
|
35
35
|
if validator.validate(original_url, params, signature)
|
36
36
|
@app.call(env)
|
37
37
|
else
|
38
38
|
[
|
39
39
|
403,
|
40
|
-
{'Content-Type' => 'text/plain'},
|
40
|
+
{ 'Content-Type' => 'text/plain' },
|
41
41
|
['Twilio Request Validation Failed.']
|
42
42
|
]
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
46
|
end
|
@@ -14,12 +14,8 @@ module Twilio
|
|
14
14
|
"#{@base_url.chomp('/')}/#{uri.chomp('/').gsub(/^\//, '')}"
|
15
15
|
end
|
16
16
|
|
17
|
-
def request(method, uri, params={}, data={}, headers={}, auth=nil, timeout=nil)
|
18
|
-
|
19
|
-
url = uri
|
20
|
-
else
|
21
|
-
url = self.absolute_url(uri)
|
22
|
-
end
|
17
|
+
def request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
|
18
|
+
url = uri.match(/^http/) ? uri : absolute_url(uri)
|
23
19
|
|
24
20
|
@client.request(
|
25
21
|
@host,
|
@@ -1,29 +1,30 @@
|
|
1
1
|
module Twilio
|
2
2
|
module REST
|
3
|
+
# Page Base Class
|
3
4
|
class Page
|
4
5
|
include Enumerable
|
5
6
|
|
6
7
|
META_KEYS = [
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
]
|
8
|
+
'end',
|
9
|
+
'first_page_uri',
|
10
|
+
'next_page_uri',
|
11
|
+
'last_page_uri',
|
12
|
+
'page',
|
13
|
+
'page_size',
|
14
|
+
'previous_page_uri',
|
15
|
+
'total',
|
16
|
+
'num_pages',
|
17
|
+
'start',
|
18
|
+
'uri'
|
19
|
+
].freeze
|
19
20
|
|
20
21
|
def initialize(version, response)
|
21
|
-
payload =
|
22
|
+
payload = process_response(response)
|
22
23
|
|
23
24
|
@version = version
|
24
25
|
@payload = payload
|
25
26
|
@solution = {}
|
26
|
-
@records =
|
27
|
+
@records = load_page(payload)
|
27
28
|
end
|
28
29
|
|
29
30
|
def process_response(response)
|
@@ -40,12 +41,10 @@ module Twilio
|
|
40
41
|
else
|
41
42
|
keys = payload.keys
|
42
43
|
key = keys - META_KEYS
|
43
|
-
if key.size == 1
|
44
|
-
return payload[key.first]
|
45
|
-
end
|
44
|
+
return payload[key.first] if key.size == 1
|
46
45
|
end
|
47
46
|
|
48
|
-
raise Twilio::REST::TwilioError
|
47
|
+
raise Twilio::REST::TwilioError, 'Page Records can not be deserialized'
|
49
48
|
end
|
50
49
|
|
51
50
|
def previous_page_url
|
@@ -69,28 +68,28 @@ module Twilio
|
|
69
68
|
end
|
70
69
|
|
71
70
|
def get_instance(payload)
|
72
|
-
raise Twilio::REST::TwilioError
|
71
|
+
raise Twilio::REST::TwilioError, 'Page.get_instance() must be implemented in the derived class'
|
73
72
|
end
|
74
73
|
|
75
74
|
def previous_page
|
76
|
-
return nil unless
|
75
|
+
return nil unless previous_page_url
|
77
76
|
|
78
|
-
response = @version.domain.request('GET',
|
77
|
+
response = @version.domain.request('GET', previous_page_url)
|
79
78
|
|
80
79
|
self.class.new(@version, response, @solution)
|
81
80
|
end
|
82
81
|
|
83
82
|
def next_page
|
84
|
-
return nil unless
|
83
|
+
return nil unless next_page_url
|
85
84
|
|
86
|
-
response = @version.domain.request('GET',
|
85
|
+
response = @version.domain.request('GET', next_page_url)
|
87
86
|
|
88
87
|
self.class.new(@version, response, @solution)
|
89
88
|
end
|
90
89
|
|
91
90
|
def each
|
92
91
|
@records.each do |record|
|
93
|
-
yield
|
92
|
+
yield get_instance(record)
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|
@@ -100,4 +99,3 @@ module Twilio
|
|
100
99
|
end
|
101
100
|
end
|
102
101
|
end
|
103
|
-
|