From a35eaab6555cdb5e7ca17f4ecb583a8f9a1e1ddc Mon Sep 17 00:00:00 2001 From: Thomas Marshall Date: Mon, 22 Jan 2024 14:51:06 -0800 Subject: [PATCH] Replace deprecated UploadIO constant Summary: This constant was deprecated in `multipart-post` v2.2.0 [1] but `faraday-multipart` v1.0.4 introduced a workaround to avoid the deprecated constant warning [2]. This commit switches out `UploadIO` references to use the `Faraday` namespaced one. [1]: https://github.com/socketry/multipart-post/commit/cb18a32ed9522af9e4072195d0411a8281c6a061 [2]: https://github.com/lostisland/faraday-multipart/commit/2127a0c3863669c2b77bf855b17eee8ed0c10c8f X-link: https://github.com/facebook/facebook-ruby-business-sdk/pull/204 Reviewed By: mengxuanzhangz Differential Revision: D52926662 Pulled By: stcheng fbshipit-source-id: b999d59c992b0351924bdfb10d33ab34de788c69 --- templates/ruby/lib/facebook_ads/api_request.rb | 4 ++-- templates/ruby/lib/facebook_ads/field_types/upload_file.rb | 6 +++--- templates/ruby/lib/facebook_ads/videos/video_io.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/ruby/lib/facebook_ads/api_request.rb b/templates/ruby/lib/facebook_ads/api_request.rb index 370f01c7..82afef41 100644 --- a/templates/ruby/lib/facebook_ads/api_request.rb +++ b/templates/ruby/lib/facebook_ads/api_request.rb @@ -97,14 +97,14 @@ def batch_body # For Batch API def params_without_files params.reject do |_,v| - v.is_a?(UploadIO) + v.is_a?(Faraday::UploadIO) end end # For Batch API def files params.select do |_,v| - v.is_a?(UploadIO) + v.is_a?(Faraday::UploadIO) end end end diff --git a/templates/ruby/lib/facebook_ads/field_types/upload_file.rb b/templates/ruby/lib/facebook_ads/field_types/upload_file.rb index 378644de..540c3a76 100644 --- a/templates/ruby/lib/facebook_ads/field_types/upload_file.rb +++ b/templates/ruby/lib/facebook_ads/field_types/upload_file.rb @@ -77,9 +77,9 @@ def serialize(value) if category == :video FacebookAds::VideoIO.new(value, content_type) else - ::UploadIO.new(value, content_type) + Faraday::UploadIO.new(value, content_type) end - when UploadIO + when Faraday::UploadIO value # when etc etc TODO Rails/Sinatra Upload else @@ -98,7 +98,7 @@ def content_type_for(ext) end def self.acceptable?(value) - [File, Tempfile, UploadIO].each do |type| + [File, Tempfile, Faraday::UploadIO].each do |type| return true if value.is_a?(type) end diff --git a/templates/ruby/lib/facebook_ads/videos/video_io.rb b/templates/ruby/lib/facebook_ads/videos/video_io.rb index 41755bbe..ebcb6de0 100644 --- a/templates/ruby/lib/facebook_ads/videos/video_io.rb +++ b/templates/ruby/lib/facebook_ads/videos/video_io.rb @@ -7,7 +7,7 @@ require 'faraday/multipart' module FacebookAds - class VideoIO < ::UploadIO + class VideoIO < Faraday::UploadIO def is_video? true end