Skip to content

Commit

Permalink
Replace deprecated UploadIO constant
Browse files Browse the repository at this point in the history
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]: socketry/multipart-post@cb18a32
[2]: lostisland/faraday-multipart@2127a0c

X-link: facebook/facebook-ruby-business-sdk#204

Reviewed By: mengxuanzhangz

Differential Revision: D52926662

Pulled By: stcheng

fbshipit-source-id: b999d59c992b0351924bdfb10d33ab34de788c69
  • Loading branch information
thomasmarshall authored and facebook-github-bot committed Jan 22, 2024
1 parent 3c210a3 commit a35eaab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions templates/ruby/lib/facebook_ads/api_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions templates/ruby/lib/facebook_ads/field_types/upload_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion templates/ruby/lib/facebook_ads/videos/video_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'faraday/multipart'

module FacebookAds
class VideoIO < ::UploadIO
class VideoIO < Faraday::UploadIO
def is_video?
true
end
Expand Down

0 comments on commit a35eaab

Please sign in to comment.