Class: TiktokBusinessApi::Resources::Ad
- Inherits:
-
CrudResource
- Object
- BaseResource
- CrudResource
- TiktokBusinessApi::Resources::Ad
- Defined in:
- lib/tiktok_business_api/resources/ad.rb
Overview
Ad resource for the TikTok Business API
Constant Summary collapse
- RESOURCE_NAME =
'ad'
Instance Attribute Summary
Attributes inherited from BaseResource
Instance Method Summary collapse
-
#create(advertiser_id:, adgroup_id:, creatives:) ⇒ Hash
Create a new ad.
-
#create_aco(advertiser_id:, adgroup_id:, creatives:) ⇒ Hash
Create Smart Creative ads.
-
#delete(advertiser_id:, ad_id:) ⇒ Hash
Delete an ad.
- #get(advertiser_id:, ad_id:) ⇒ Object
- #list(advertiser_id:, campaign_id: nil, adgroup_id: nil, filtering: {}, page_size: nil, page: nil, **other_params, &block) ⇒ Object
-
#update(advertiser_id:, ad_id:, **params) ⇒ Hash
Update an ad.
-
#update_status(advertiser_id:, ad_id:, status:) ⇒ Hash
Update ad status (enable/disable).
Methods inherited from CrudResource
#create_path, #delete_path, #id_param_name, #ids_param_name, #list_all, #list_path, #resource_name, #status_update_path, #update_path
Methods inherited from BaseResource
#_http_get, #_http_post, #api_version, #base_path, #initialize, #paginate, #resource_name
Constructor Details
This class inherits a constructor from TiktokBusinessApi::Resources::BaseResource
Instance Method Details
#create(advertiser_id:, adgroup_id:, creatives:) ⇒ Hash
Create a new ad
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 19 def create(advertiser_id:, adgroup_id:, creatives:) params = { advertiser_id: advertiser_id, adgroup_id: adgroup_id, creatives: creatives } response = _http_post(create_path, params) response['data'] end |
#create_aco(advertiser_id:, adgroup_id:, creatives:) ⇒ Hash
Create Smart Creative ads
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 90 def create_aco(advertiser_id:, adgroup_id:, creatives:) params = { advertiser_id: advertiser_id, adgroup_id: adgroup_id, creatives: creatives } response = _http_post('aco/create/', params) response['data'] end |
#delete(advertiser_id:, ad_id:) ⇒ Hash
Delete an ad
74 75 76 77 78 79 80 81 82 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 74 def delete(advertiser_id:, ad_id:) params = { advertiser_id: advertiser_id, ad_ids: [ad_id] } response = _http_post(delete_path, params) response['data'] end |
#get(advertiser_id:, ad_id:) ⇒ Object
9 10 11 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 9 def get(advertiser_id:, ad_id:) list(advertiser_id: advertiser_id, filtering: {ad_ids: [ad_id]}).first end |
#list(advertiser_id:, campaign_id: nil, adgroup_id: nil, filtering: {}, page_size: nil, page: nil, **other_params, &block) ⇒ Object
30 31 32 33 34 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 30 def list(advertiser_id:, campaign_id: nil, adgroup_id: nil, filtering: {}, page_size: nil, page: nil, **other_params, &block) filtering[:campaign_ids] = [campaign_id] if campaign_id filtering[:adgroup_ids] = [adgroup_id] if adgroup_id super(filtering: filtering, page_size: page_size, page: page, **other_params.merge(advertiser_id: advertiser_id), &block) end |
#update(advertiser_id:, ad_id:, **params) ⇒ Hash
Update an ad
42 43 44 45 46 47 48 49 50 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 42 def update(advertiser_id:, ad_id:, **params) params = params.merge( advertiser_id: advertiser_id, ad_id: ad_id ) response = _http_post(update_path, params) response['data'] end |
#update_status(advertiser_id:, ad_id:, status:) ⇒ Hash
Update ad status (enable/disable)
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tiktok_business_api/resources/ad.rb', line 58 def update_status(advertiser_id:, ad_id:, status:) params = { advertiser_id: advertiser_id, ad_ids: [ad_id], operation_status: status } response = _http_post('status/update/', params) response['data'] end |