Class: TaboolaApi::Resources::MotionAds
- Defined in:
- lib/taboola_api/resources/motion_ads.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #create(account_id, campaign_id, video_file:, fallback_file:, params: {}) ⇒ Object
- #get(account_id, campaign_id, item_id) ⇒ Object
- #list_all(account_id, campaign_id, params: {}) ⇒ Object
- #update(account_id, campaign_id, item_id, params: {}) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from TaboolaApi::Resources::Base
Instance Method Details
#create(account_id, campaign_id, video_file:, fallback_file:, params: {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/taboola_api/resources/motion_ads.rb', line 16 def create(account_id, campaign_id, video_file:, fallback_file:, params: {}) raise ArgumentError, "Video file must be provided" unless video_file.is_a?(File) || video_file.is_a?(Tempfile) raise ArgumentError, "Fallback image file must be provided" unless fallback_file.is_a?(File) || fallback_file.is_a?(Tempfile) video_mime_type = MIME::Types.type_for(video_file.path).first.to_s fallback_mime_type = MIME::Types.type_for(fallback_file.path).first.to_s payload = { new_item: Faraday::Multipart::ParamPart.new( JSON.generate(params), "application/json" ), video_file: Faraday::Multipart::FilePart.new( video_file, video_mime_type ), fallback_file: Faraday::Multipart::FilePart.new( fallback_file, fallback_mime_type ) } headers = {"Content-Type" => "multipart/form-data"} response = client.request(:post, "#{account_id}/campaigns/#{campaign_id}/performance-video/items", payload, headers) response.body end |
#get(account_id, campaign_id, item_id) ⇒ Object
6 7 8 9 |
# File 'lib/taboola_api/resources/motion_ads.rb', line 6 def get(account_id, campaign_id, item_id) response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/performance-video/items/#{item_id}") response.body end |
#list_all(account_id, campaign_id, params: {}) ⇒ Object
11 12 13 14 |
# File 'lib/taboola_api/resources/motion_ads.rb', line 11 def list_all(account_id, campaign_id, params: {}) response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/performance-video/items", params) response.body end |
#update(account_id, campaign_id, item_id, params: {}) ⇒ Object
42 43 44 45 |
# File 'lib/taboola_api/resources/motion_ads.rb', line 42 def update(account_id, campaign_id, item_id, params: {}) response = client.request(:put, "#{account_id}/campaigns/#{campaign_id}/performance-video/items/#{item_id}", params) response.body end |