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)


19
20
21
22
23
24
25
26
27
# File 'lib/facebook_ads/videos/video_request.rb', line 19

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



12
13
14
15
16
17
# File 'lib/facebook_ads/videos/video_request.rb', line 12

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