From 1aeafcceea66468a0af4258237fe46a81105ad34 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 05:46:14 +0000 Subject: [PATCH 1/3] Initial plan From 6957e10441255404aee1c2132bd5dbb40b60d24d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 05:56:16 +0000 Subject: [PATCH 2/3] Implement autoload for REST service modules to reduce memory usage Co-authored-by: kridai <16255022+kridai@users.noreply.github.com> --- lib/twilio-ruby/rest.rb | 88 ++++++++++++++++++++++++++++--- lib/twilio-ruby/rest/api.rb | 3 ++ lib/twilio-ruby/rest/messaging.rb | 4 ++ 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/lib/twilio-ruby/rest.rb b/lib/twilio-ruby/rest.rb index f5a76e483..bcde94dca 100644 --- a/lib/twilio-ruby/rest.rb +++ b/lib/twilio-ruby/rest.rb @@ -1,14 +1,90 @@ # frozen_string_literal: true +# Load framework/rest files (these are core and should be loaded immediately) Dir[File.join(__dir__, 'framework/rest/*.rb')].sort.each do |file| require file end -Dir[File.join(__dir__, 'rest/*.rb')].sort.each do |file| - require file.gsub(/\.rb$/, '_base.rb') unless file.end_with?('client.rb') || file.end_with?('_base.rb') - require file -end +# Load base client classes that are always needed +require_relative 'rest/client' -Dir[File.join(__dir__, 'rest/**/*.rb')].sort.each do |file| - require file +# Use autoload for REST service modules to reduce memory usage +module Twilio + module REST + # Autoload all REST service classes + autoload :Accounts, File.join(__dir__, 'rest', 'accounts.rb') + autoload :AccountsBase, File.join(__dir__, 'rest', 'accounts_base.rb') + autoload :Api, File.join(__dir__, 'rest', 'api.rb') + autoload :ApiBase, File.join(__dir__, 'rest', 'api_base.rb') + autoload :Assistants, File.join(__dir__, 'rest', 'assistants.rb') + autoload :AssistantsBase, File.join(__dir__, 'rest', 'assistants_base.rb') + autoload :Bulkexports, File.join(__dir__, 'rest', 'bulkexports.rb') + autoload :BulkexportsBase, File.join(__dir__, 'rest', 'bulkexports_base.rb') + autoload :Chat, File.join(__dir__, 'rest', 'chat.rb') + autoload :ChatBase, File.join(__dir__, 'rest', 'chat_base.rb') + autoload :Content, File.join(__dir__, 'rest', 'content.rb') + autoload :ContentBase, File.join(__dir__, 'rest', 'content_base.rb') + autoload :Conversations, File.join(__dir__, 'rest', 'conversations.rb') + autoload :ConversationsBase, File.join(__dir__, 'rest', 'conversations_base.rb') + autoload :Events, File.join(__dir__, 'rest', 'events.rb') + autoload :EventsBase, File.join(__dir__, 'rest', 'events_base.rb') + autoload :FlexApi, File.join(__dir__, 'rest', 'flex_api.rb') + autoload :FlexApiBase, File.join(__dir__, 'rest', 'flex_api_base.rb') + autoload :FrontlineApi, File.join(__dir__, 'rest', 'frontline_api.rb') + autoload :FrontlineApiBase, File.join(__dir__, 'rest', 'frontline_api_base.rb') + autoload :Iam, File.join(__dir__, 'rest', 'iam.rb') + autoload :IamBase, File.join(__dir__, 'rest', 'iam_base.rb') + autoload :Insights, File.join(__dir__, 'rest', 'insights.rb') + autoload :InsightsBase, File.join(__dir__, 'rest', 'insights_base.rb') + autoload :Intelligence, File.join(__dir__, 'rest', 'intelligence.rb') + autoload :IntelligenceBase, File.join(__dir__, 'rest', 'intelligence_base.rb') + autoload :IpMessaging, File.join(__dir__, 'rest', 'ip_messaging.rb') + autoload :IpMessagingBase, File.join(__dir__, 'rest', 'ip_messaging_base.rb') + autoload :Lookups, File.join(__dir__, 'rest', 'lookups.rb') + autoload :LookupsBase, File.join(__dir__, 'rest', 'lookups_base.rb') + autoload :Marketplace, File.join(__dir__, 'rest', 'marketplace.rb') + autoload :MarketplaceBase, File.join(__dir__, 'rest', 'marketplace_base.rb') + autoload :Messaging, File.join(__dir__, 'rest', 'messaging.rb') + autoload :MessagingBase, File.join(__dir__, 'rest', 'messaging_base.rb') + autoload :Monitor, File.join(__dir__, 'rest', 'monitor.rb') + autoload :MonitorBase, File.join(__dir__, 'rest', 'monitor_base.rb') + autoload :Notify, File.join(__dir__, 'rest', 'notify.rb') + autoload :NotifyBase, File.join(__dir__, 'rest', 'notify_base.rb') + autoload :Numbers, File.join(__dir__, 'rest', 'numbers.rb') + autoload :NumbersBase, File.join(__dir__, 'rest', 'numbers_base.rb') + autoload :Oauth, File.join(__dir__, 'rest', 'oauth.rb') + autoload :OauthBase, File.join(__dir__, 'rest', 'oauth_base.rb') + autoload :Preview, File.join(__dir__, 'rest', 'preview.rb') + autoload :PreviewBase, File.join(__dir__, 'rest', 'preview_base.rb') + autoload :PreviewIam, File.join(__dir__, 'rest', 'preview_iam.rb') + autoload :PreviewIamBase, File.join(__dir__, 'rest', 'preview_iam_base.rb') + autoload :Pricing, File.join(__dir__, 'rest', 'pricing.rb') + autoload :PricingBase, File.join(__dir__, 'rest', 'pricing_base.rb') + autoload :Proxy, File.join(__dir__, 'rest', 'proxy.rb') + autoload :ProxyBase, File.join(__dir__, 'rest', 'proxy_base.rb') + autoload :Routes, File.join(__dir__, 'rest', 'routes.rb') + autoload :RoutesBase, File.join(__dir__, 'rest', 'routes_base.rb') + autoload :Serverless, File.join(__dir__, 'rest', 'serverless.rb') + autoload :ServerlessBase, File.join(__dir__, 'rest', 'serverless_base.rb') + autoload :Studio, File.join(__dir__, 'rest', 'studio.rb') + autoload :StudioBase, File.join(__dir__, 'rest', 'studio_base.rb') + autoload :Supersim, File.join(__dir__, 'rest', 'supersim.rb') + autoload :SupersimBase, File.join(__dir__, 'rest', 'supersim_base.rb') + autoload :Sync, File.join(__dir__, 'rest', 'sync.rb') + autoload :SyncBase, File.join(__dir__, 'rest', 'sync_base.rb') + autoload :Taskrouter, File.join(__dir__, 'rest', 'taskrouter.rb') + autoload :TaskrouterBase, File.join(__dir__, 'rest', 'taskrouter_base.rb') + autoload :Trunking, File.join(__dir__, 'rest', 'trunking.rb') + autoload :TrunkingBase, File.join(__dir__, 'rest', 'trunking_base.rb') + autoload :Trusthub, File.join(__dir__, 'rest', 'trusthub.rb') + autoload :TrusthubBase, File.join(__dir__, 'rest', 'trusthub_base.rb') + autoload :Verify, File.join(__dir__, 'rest', 'verify.rb') + autoload :VerifyBase, File.join(__dir__, 'rest', 'verify_base.rb') + autoload :Video, File.join(__dir__, 'rest', 'video.rb') + autoload :VideoBase, File.join(__dir__, 'rest', 'video_base.rb') + autoload :Voice, File.join(__dir__, 'rest', 'voice.rb') + autoload :VoiceBase, File.join(__dir__, 'rest', 'voice_base.rb') + autoload :Wireless, File.join(__dir__, 'rest', 'wireless.rb') + autoload :WirelessBase, File.join(__dir__, 'rest', 'wireless_base.rb') + end end diff --git a/lib/twilio-ruby/rest/api.rb b/lib/twilio-ruby/rest/api.rb index a313692c4..01c514f54 100644 --- a/lib/twilio-ruby/rest/api.rb +++ b/lib/twilio-ruby/rest/api.rb @@ -1,6 +1,9 @@ module Twilio module REST class Api < ApiBase + # Autoload version classes + autoload :V2010, File.join(__dir__, 'api', 'v2010.rb') + ## # Account provided as the authenticating account def account diff --git a/lib/twilio-ruby/rest/messaging.rb b/lib/twilio-ruby/rest/messaging.rb index bde07ab3f..2ad7df7dd 100644 --- a/lib/twilio-ruby/rest/messaging.rb +++ b/lib/twilio-ruby/rest/messaging.rb @@ -1,6 +1,10 @@ module Twilio module REST class Messaging < MessagingBase + # Autoload version classes + autoload :V1, File.join(__dir__, 'messaging', 'v1.rb') + autoload :V2, File.join(__dir__, 'messaging', 'v2.rb') + ## # @param [String] sid The unique string to identify Brand Registration. # @return [Twilio::REST::Messaging::V1::BrandRegistrationInstance] if sid was passed. From a31e66567c9bb5e9b249c882397b90eadaf1a189 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 06:00:14 +0000 Subject: [PATCH 3/3] Complete autoload implementation for HTTP and additional REST services Co-authored-by: kridai <16255022+kridai@users.noreply.github.com> --- lib/twilio-ruby/http.rb | 9 +++++++-- lib/twilio-ruby/rest/chat.rb | 5 +++++ lib/twilio-ruby/rest/notify.rb | 2 ++ lib/twilio-ruby/rest/sync.rb | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/twilio-ruby/http.rb b/lib/twilio-ruby/http.rb index c5bab1dd3..b5c6076c5 100644 --- a/lib/twilio-ruby/http.rb +++ b/lib/twilio-ruby/http.rb @@ -1,5 +1,10 @@ # frozen_string_literal: true -Dir[File.join(__dir__, 'http/**/*.rb')].sort.each do |file| - require file +# Use autoload for HTTP modules to reduce memory usage +module Twilio + module HTTP + autoload :ClientTokenManager, File.join(__dir__, 'http', 'client_token_manager.rb') + autoload :Client, File.join(__dir__, 'http', 'http_client.rb') + autoload :OrgTokenManager, File.join(__dir__, 'http', 'org_token_manager.rb') + end end diff --git a/lib/twilio-ruby/rest/chat.rb b/lib/twilio-ruby/rest/chat.rb index 2931f3413..362b0d529 100644 --- a/lib/twilio-ruby/rest/chat.rb +++ b/lib/twilio-ruby/rest/chat.rb @@ -1,6 +1,11 @@ module Twilio module REST class Chat < ChatBase + # Autoload version classes + autoload :V1, File.join(__dir__, 'chat', 'v1.rb') + autoload :V2, File.join(__dir__, 'chat', 'v2.rb') + autoload :V3, File.join(__dir__, 'chat', 'v3.rb') + ## # @param [String] sid The unique string that we created to identify the Credential # resource. diff --git a/lib/twilio-ruby/rest/notify.rb b/lib/twilio-ruby/rest/notify.rb index d45225bed..f2ea8e848 100644 --- a/lib/twilio-ruby/rest/notify.rb +++ b/lib/twilio-ruby/rest/notify.rb @@ -1,6 +1,8 @@ module Twilio module REST class Notify < NotifyBase + # Autoload version classes + autoload :V1, File.join(__dir__, 'notify', 'v1.rb') ## # @param [String] sid The unique string that we created to identify the Credential # resource. diff --git a/lib/twilio-ruby/rest/sync.rb b/lib/twilio-ruby/rest/sync.rb index a78c12832..cb29a310a 100644 --- a/lib/twilio-ruby/rest/sync.rb +++ b/lib/twilio-ruby/rest/sync.rb @@ -1,6 +1,8 @@ module Twilio module REST class Sync < SyncBase + # Autoload version classes + autoload :V1, File.join(__dir__, 'sync', 'v1.rb') ## # @param [String] sid The unique string that we created to identify the Service # resource.