class TwitterAds::Tweet

Constants

RESOURCE_CREATE

Public Class Methods

create(account, opts = {}) click to toggle source

Creates a “Promoted-Only” Tweet using the specialized Ads API end point.

@param opts [Hash] A hash of options.

@option opts [String] :text The main Tweet body. @option opts [Array] :media_keys A list of media keys (up to 4) to associate with the Tweet. @option opts [Integer] :as_user_id The user ID whom you are posting the Tweet on behalf of. @option opts [Boolean] :trim_user Excludes the user object from the hydrated Tweet response. @option opts [String] :video_title An optional title to be included. @option opts [String] :video_description An optional description to be included. @option opts [String] :video_cta An optional CTA value for the associated video. @option opts [String] :video_cta_value The value for the corresponding CTA.

@since 0.3.0

@see dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/tweet

@return [Hash] A hash containing the newly created Tweet object.

# File lib/twitter-ads/campaign/tweet.rb, line 30
def create(account, opts = {})
  resource = RESOURCE_CREATE % { account_id: account.id }
  response = TwitterAds::Request.new(account.client, :post, resource, params: opts).perform
  response.body[:data]
end