Class: Twilio::REST::Page
- Inherits:
-
Object
- Object
- Twilio::REST::Page
show all
- Includes:
- Enumerable
- Defined in:
- lib/twilio-ruby/framework/page.rb
Overview
Direct Known Subclasses
Accounts::V1::CredentialList::PublicKeyPage, Accounts::V1::CredentialPage, Api::V2010::AccountContext::AddressContext::DependentPhoneNumberPage, Api::V2010::AccountContext::AddressPage, Api::V2010::AccountContext::ApplicationPage, Api::V2010::AccountContext::AuthorizedConnectAppPage, Api::V2010::AccountContext::AvailablePhoneNumberCountryContext::LocalPage, Api::V2010::AccountContext::AvailablePhoneNumberCountryContext::MobilePage, Api::V2010::AccountContext::AvailablePhoneNumberCountryContext::TollFreePage, Api::V2010::AccountContext::AvailablePhoneNumberCountryPage, Api::V2010::AccountContext::CallContext::FeedbackPage, Api::V2010::AccountContext::CallContext::NotificationPage, Api::V2010::AccountContext::CallContext::RecordingPage, Api::V2010::AccountContext::CallList::FeedbackSummaryPage, Api::V2010::AccountContext::CallPage, Api::V2010::AccountContext::ConferenceContext::ParticipantPage, Api::V2010::AccountContext::ConferencePage, Api::V2010::AccountContext::ConnectAppPage, Api::V2010::AccountContext::IncomingPhoneNumberContext::AssignedAddOnContext::AssignedAddOnExtensionPage, Api::V2010::AccountContext::IncomingPhoneNumberContext::AssignedAddOnPage, Api::V2010::AccountContext::IncomingPhoneNumberList::LocalPage, Api::V2010::AccountContext::IncomingPhoneNumberList::MobilePage, Api::V2010::AccountContext::IncomingPhoneNumberList::TollFreePage, Api::V2010::AccountContext::IncomingPhoneNumberPage, Api::V2010::AccountContext::KeyPage, Api::V2010::AccountContext::MessageContext::FeedbackPage, Api::V2010::AccountContext::MessageContext::MediaPage, Api::V2010::AccountContext::MessagePage, Api::V2010::AccountContext::NewKeyPage, Api::V2010::AccountContext::NewSigningKeyPage, Api::V2010::AccountContext::NotificationPage, Api::V2010::AccountContext::OutgoingCallerIdPage, Api::V2010::AccountContext::QueueContext::MemberPage, Api::V2010::AccountContext::QueuePage, Api::V2010::AccountContext::RecordingContext::AddOnResultContext::PayloadPage, Api::V2010::AccountContext::RecordingContext::AddOnResultPage, Api::V2010::AccountContext::RecordingContext::TranscriptionPage, Api::V2010::AccountContext::RecordingPage, Api::V2010::AccountContext::ShortCodePage, Api::V2010::AccountContext::SigningKeyPage, Api::V2010::AccountContext::SipList::CredentialListContext::CredentialPage, Api::V2010::AccountContext::SipList::CredentialListPage, Api::V2010::AccountContext::SipList::DomainContext::CredentialListMappingPage, Api::V2010::AccountContext::SipList::DomainContext::IpAccessControlListMappingPage, Api::V2010::AccountContext::SipList::DomainPage, Api::V2010::AccountContext::SipList::IpAccessControlListContext::IpAddressPage, Api::V2010::AccountContext::SipList::IpAccessControlListPage, Api::V2010::AccountContext::SipPage, Api::V2010::AccountContext::TokenPage, Api::V2010::AccountContext::TranscriptionPage, Api::V2010::AccountContext::UsageList::RecordList::AllTimePage, Api::V2010::AccountContext::UsageList::RecordList::DailyPage, Api::V2010::AccountContext::UsageList::RecordList::LastMonthPage, Api::V2010::AccountContext::UsageList::RecordList::MonthlyPage, Api::V2010::AccountContext::UsageList::RecordList::ThisMonthPage, Api::V2010::AccountContext::UsageList::RecordList::TodayPage, Api::V2010::AccountContext::UsageList::RecordList::YearlyPage, Api::V2010::AccountContext::UsageList::RecordList::YesterdayPage, Api::V2010::AccountContext::UsageList::RecordPage, Api::V2010::AccountContext::UsageList::TriggerPage, Api::V2010::AccountContext::UsagePage, Api::V2010::AccountContext::ValidationRequestPage, Api::V2010::AccountPage, Chat::V1::CredentialPage, Chat::V1::ServiceContext::ChannelContext::InvitePage, Chat::V1::ServiceContext::ChannelContext::MemberPage, Chat::V1::ServiceContext::ChannelContext::MessagePage, Chat::V1::ServiceContext::ChannelPage, Chat::V1::ServiceContext::RolePage, Chat::V1::ServiceContext::UserContext::UserChannelPage, Chat::V1::ServiceContext::UserPage, Chat::V1::ServicePage, Chat::V2::CredentialPage, Chat::V2::ServiceContext::ChannelContext::InvitePage, Chat::V2::ServiceContext::ChannelContext::MemberPage, Chat::V2::ServiceContext::ChannelContext::MessagePage, Chat::V2::ServiceContext::ChannelPage, Chat::V2::ServiceContext::RolePage, Chat::V2::ServiceContext::UserContext::UserChannelPage, Chat::V2::ServiceContext::UserPage, Chat::V2::ServicePage, Fax::V1::FaxContext::FaxMediaPage, Fax::V1::FaxPage, IpMessaging::V1::CredentialPage, IpMessaging::V1::ServiceContext::ChannelContext::InvitePage, IpMessaging::V1::ServiceContext::ChannelContext::MemberPage, IpMessaging::V1::ServiceContext::ChannelContext::MessagePage, IpMessaging::V1::ServiceContext::ChannelPage, IpMessaging::V1::ServiceContext::RolePage, IpMessaging::V1::ServiceContext::UserContext::UserChannelPage, IpMessaging::V1::ServiceContext::UserPage, IpMessaging::V1::ServicePage, IpMessaging::V2::CredentialPage, IpMessaging::V2::ServiceContext::ChannelContext::InvitePage, IpMessaging::V2::ServiceContext::ChannelContext::MemberPage, IpMessaging::V2::ServiceContext::ChannelContext::MessagePage, IpMessaging::V2::ServiceContext::ChannelPage, IpMessaging::V2::ServiceContext::RolePage, IpMessaging::V2::ServiceContext::UserContext::UserChannelPage, IpMessaging::V2::ServiceContext::UserPage, IpMessaging::V2::ServicePage, Lookups::V1::PhoneNumberPage, Messaging::V1::ServiceContext::AlphaSenderPage, Messaging::V1::ServiceContext::PhoneNumberPage, Messaging::V1::ServiceContext::ShortCodePage, Messaging::V1::ServicePage, Monitor::V1::AlertPage, Monitor::V1::EventPage, Notify::V1::CredentialPage, Notify::V1::ServiceContext::BindingPage, Notify::V1::ServiceContext::NotificationPage, Notify::V1::ServiceContext::SegmentPage, Notify::V1::ServiceContext::UserContext::SegmentMembershipPage, Notify::V1::ServiceContext::UserContext::UserBindingPage, Notify::V1::ServiceContext::UserPage, Notify::V1::ServicePage, Twilio::REST::Preview::AccSecurity::ServiceContext::VerificationCheckPage, Twilio::REST::Preview::AccSecurity::ServiceContext::VerificationPage, Twilio::REST::Preview::AccSecurity::ServicePage, Twilio::REST::Preview::BulkExports::ExportConfigurationPage, Twilio::REST::Preview::BulkExports::ExportContext::DayPage, Twilio::REST::Preview::BulkExports::ExportPage, Twilio::REST::Preview::DeployedDevices::FleetContext::CertificatePage, Twilio::REST::Preview::DeployedDevices::FleetContext::DeploymentPage, Twilio::REST::Preview::DeployedDevices::FleetContext::DevicePage, Twilio::REST::Preview::DeployedDevices::FleetContext::KeyPage, Twilio::REST::Preview::DeployedDevices::FleetPage, Twilio::REST::Preview::HostedNumbers::HostedNumberOrderPage, Twilio::REST::Preview::Marketplace::AvailableAddOnContext::AvailableAddOnExtensionPage, Twilio::REST::Preview::Marketplace::AvailableAddOnPage, Twilio::REST::Preview::Marketplace::InstalledAddOnContext::InstalledAddOnExtensionPage, Twilio::REST::Preview::Marketplace::InstalledAddOnPage, Twilio::REST::Preview::Proxy::ServiceContext::PhoneNumberPage, Twilio::REST::Preview::Proxy::ServiceContext::SessionContext::InteractionPage, Twilio::REST::Preview::Proxy::ServiceContext::SessionContext::ParticipantContext::MessageInteractionPage, Twilio::REST::Preview::Proxy::ServiceContext::SessionContext::ParticipantPage, Twilio::REST::Preview::Proxy::ServiceContext::SessionPage, Twilio::REST::Preview::Proxy::ServiceContext::ShortCodePage, Twilio::REST::Preview::Proxy::ServicePage, Twilio::REST::Preview::Sync::ServiceContext::DocumentContext::DocumentPermissionPage, Twilio::REST::Preview::Sync::ServiceContext::DocumentPage, Twilio::REST::Preview::Sync::ServiceContext::SyncListContext::SyncListItemPage, Twilio::REST::Preview::Sync::ServiceContext::SyncListContext::SyncListPermissionPage, Twilio::REST::Preview::Sync::ServiceContext::SyncListPage, Twilio::REST::Preview::Sync::ServiceContext::SyncMapContext::SyncMapItemPage, Twilio::REST::Preview::Sync::ServiceContext::SyncMapContext::SyncMapPermissionPage, Twilio::REST::Preview::Sync::ServiceContext::SyncMapPage, Twilio::REST::Preview::Sync::ServicePage, Twilio::REST::Preview::Wireless::CommandPage, Twilio::REST::Preview::Wireless::RatePlanPage, Twilio::REST::Preview::Wireless::SimContext::UsagePage, Twilio::REST::Preview::Wireless::SimPage, Twilio::REST::Pricing::V1::MessagingList::CountryPage, Twilio::REST::Pricing::V1::MessagingPage, Twilio::REST::Pricing::V1::PhoneNumberList::CountryPage, Twilio::REST::Pricing::V1::PhoneNumberPage, Twilio::REST::Pricing::V1::VoiceList::CountryPage, Twilio::REST::Pricing::V1::VoiceList::NumberPage, Twilio::REST::Pricing::V1::VoicePage, Sync::V1::ServiceContext::DocumentContext::DocumentPermissionPage, Sync::V1::ServiceContext::DocumentPage, Sync::V1::ServiceContext::SyncListContext::SyncListItemPage, Sync::V1::ServiceContext::SyncListContext::SyncListPermissionPage, Sync::V1::ServiceContext::SyncListPage, Sync::V1::ServiceContext::SyncMapContext::SyncMapItemPage, Sync::V1::ServiceContext::SyncMapContext::SyncMapPermissionPage, Sync::V1::ServiceContext::SyncMapPage, Sync::V1::ServiceContext::SyncStreamContext::StreamMessagePage, Sync::V1::ServiceContext::SyncStreamPage, Sync::V1::ServicePage, Taskrouter::V1::WorkspaceContext::ActivityPage, Taskrouter::V1::WorkspaceContext::EventPage, Taskrouter::V1::WorkspaceContext::TaskChannelPage, Taskrouter::V1::WorkspaceContext::TaskContext::ReservationPage, Taskrouter::V1::WorkspaceContext::TaskPage, Taskrouter::V1::WorkspaceContext::TaskQueueContext::TaskQueueCumulativeStatisticsPage, Taskrouter::V1::WorkspaceContext::TaskQueueContext::TaskQueueRealTimeStatisticsPage, Taskrouter::V1::WorkspaceContext::TaskQueueContext::TaskQueueStatisticsPage, Taskrouter::V1::WorkspaceContext::TaskQueueList::TaskQueuesStatisticsPage, Taskrouter::V1::WorkspaceContext::TaskQueuePage, Taskrouter::V1::WorkspaceContext::WorkerContext::ReservationPage, Taskrouter::V1::WorkspaceContext::WorkerContext::WorkerChannelPage, Taskrouter::V1::WorkspaceContext::WorkerContext::WorkerStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkerContext::WorkersCumulativeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkerContext::WorkersRealTimeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkerList::WorkersStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkerPage, Taskrouter::V1::WorkspaceContext::WorkflowContext::WorkflowCumulativeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkflowContext::WorkflowRealTimeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkflowContext::WorkflowStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkflowPage, Taskrouter::V1::WorkspaceContext::WorkspaceCumulativeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkspaceRealTimeStatisticsPage, Taskrouter::V1::WorkspaceContext::WorkspaceStatisticsPage, Taskrouter::V1::WorkspacePage, Trunking::V1::TrunkContext::CredentialListPage, Trunking::V1::TrunkContext::IpAccessControlListPage, Trunking::V1::TrunkContext::OriginationUrlPage, Trunking::V1::TrunkContext::PhoneNumberPage, Trunking::V1::TrunkPage, Video::V1::RecordingPage, Video::V1::RoomContext::RoomRecordingPage, Video::V1::RoomPage, Wireless::V1::CommandPage, Wireless::V1::RatePlanPage, Wireless::V1::SimContext::DataSessionPage, Wireless::V1::SimContext::UsageRecordPage, Wireless::V1::SimPage
Constant Summary
collapse
- META_KEYS =
[
'end',
'first_page_uri',
'next_page_uri',
'last_page_uri',
'page',
'page_size',
'previous_page_uri',
'total',
'num_pages',
'start',
'uri'
].freeze
Instance Method Summary
collapse
Constructor Details
#initialize(version, response) ⇒ Page
Returns a new instance of Page.
21
22
23
24
25
26
27
28
|
# File 'lib/twilio-ruby/framework/page.rb', line 21
def initialize(version, response)
payload = process_response(response)
@version = version
@payload = payload
@solution = {}
@records = load_page(payload)
end
|
Instance Method Details
#each ⇒ Object
90
91
92
93
94
|
# File 'lib/twilio-ruby/framework/page.rb', line 90
def each
@records.each do |record|
yield get_instance(record)
end
end
|
#get_instance(payload) ⇒ Object
70
71
72
|
# File 'lib/twilio-ruby/framework/page.rb', line 70
def get_instance(payload)
raise Twilio::REST::TwilioError, 'Page.get_instance() must be implemented in the derived class'
end
|
#load_page(payload) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/twilio-ruby/framework/page.rb', line 38
def load_page(payload)
if payload['meta'] && payload['meta']['key']
return payload[payload['meta']['key']]
else
keys = payload.keys
key = keys - META_KEYS
return payload[key.first] if key.size == 1
end
raise Twilio::REST::TwilioError, 'Page Records can not be deserialized'
end
|
#next_page ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/twilio-ruby/framework/page.rb', line 82
def next_page
return nil unless next_page_url
response = @version.domain.request('GET', next_page_url)
self.class.new(@version, response, @solution)
end
|
#next_page_url ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/twilio-ruby/framework/page.rb', line 60
def next_page_url
if @payload['meta'] && @payload['meta']['next_page_url']
return @version.domain.absolute_url(URI.parse(@payload['meta']['next_page_url']).request_uri)
elsif @payload['next_page_uri']
return @version.domain.absolute_url(@payload['next_page_uri'])
end
nil
end
|
#previous_page ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/twilio-ruby/framework/page.rb', line 74
def previous_page
return nil unless previous_page_url
response = @version.domain.request('GET', previous_page_url)
self.class.new(@version, response, @solution)
end
|
#previous_page_url ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/twilio-ruby/framework/page.rb', line 50
def previous_page_url
if @payload['meta'] && @payload['meta']['previous_page_url']
return @version.domain.absolute_url(URI.parse(@payload['meta']['previous_page_url']).request_uri)
elsif @payload['previous_page_uri']
return @version.domain.absolute_url(@payload['previous_page_uri'])
end
nil
end
|
#process_response(response) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/twilio-ruby/framework/page.rb', line 30
def process_response(response)
if response.status_code != 200
raise Twilio::REST::TwilioError.new('Unable to fetch page', response)
end
response.body
end
|
#to_s ⇒ Object
96
97
98
|
# File 'lib/twilio-ruby/framework/page.rb', line 96
def to_s
'#<Page>'
end
|