Class: FacebookAds::HTTPService::VideoRequest

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/facebook_ads/videos/video_request.rb

Instance Method Summary collapse

Instance Method Details

#body_has_video?(body) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
# File 'lib/facebook_ads/videos/video_request.rb', line 31

def body_has_video?(body)
  if body.respond_to?(:each) && !body.is_a?(String)
    (body.respond_to?(:values) ? body.values : body).any? do |val|
      val.is_a?(FacebookAds::VideoIO)
    end
  else
    false
  end
end

#call(env) ⇒ Object



24
25
26
27
28
29
# File 'lib/facebook_ads/videos/video_request.rb', line 24

def call(env)
  if env.body && body_has_video?(env.body)
    env.url.host = env.url.host.gsub(/^graph/, 'graph-video')
  end
  @app.call env
end