module TwitterAds::Resource::ClassMethods
Public Instance Methods
Returns a Cursor
instance for a given resource.
@param account [Account] The Account
object instance. @param opts [Hash] An optional Hash of extended options. @option opts [Boolean] :with_deleted Indicates if deleted items should be included. @option opts [String] :sort_by The object param to sort the API response by.
@return [Cursor] A Cusor object ready to iterate through the API response.
@since 0.1.0 @see Cursor
@see dev.twitter.com/ads/basics/sorting Sorting
# File lib/twitter-ads/resources/resource.rb, line 65 def all(account, opts = {}) resource = self::RESOURCE_COLLECTION % { account_id: account.id } request = Request.new(account.client, :get, resource, params: opts) Cursor.new(self, request, init_with: [account]) end
Returns an object instance for a given resource.
@param account [Account] The Account
object instance. @param id [String] The ID of the specific object to be loaded. @param opts [Hash] An optional Hash of extended options. @option opts [Boolean] :with_deleted Indicates if deleted items should be included. @option opts [String] :sort_by The object param to sort the API response by.
@return [self] The object instance for the specified resource.
@since 0.1.0
# File lib/twitter-ads/resources/resource.rb, line 82 def load(account, id, opts = {}) params = { with_deleted: true }.merge!(opts) resource = self::RESOURCE % { account_id: account.id, id: id } response = Request.new(account.client, :get, resource, params: params).perform new(account).from_response(response.body[:data]) end