Class: Whop_sdk::AdGroups::Client
- Inherits:
-
Object
- Object
- Whop_sdk::AdGroups::Client
- Defined in:
- lib/whop_sdk/ad_groups/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Creates an ad group (ad set) in a campaign.
-
#delete(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::DeleteAdGroupsResponse
Deletes an ad group.
-
#duplicate(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::DuplicateAdGroupsResponse
Creates copies of the ad group in
duplicatingstatus and returns them — into its own campaign, or into target_ad_campaign_id (which must belong to the same account and be compatible with the ad group's targeting and goals); each copy transitions to its final status (matching the source's active/paused state) once duplication completes. -
#estimate_reach(request_options: {}, **params) ⇒ Whop_sdk::Types::ReachEstimate
Estimates how many people a draft targeting spec can reach, before an ad group is created.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::ListAdGroupsResponse
Lists ad groups for the account, newest first.
-
#pause(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Pauses delivery of an ad group.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Retrieves a single ad group.
-
#search_targeting_options(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::SearchTargetingOptionsAdGroupsResponse
Searches the ad platform's targeting taxonomy for options to target an ad group with.
-
#unpause(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Resumes delivery of a paused ad group.
-
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Updates an ad group's editable fields.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Creates an ad group (ad set) in a campaign.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 108 def create(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ad_groups", body: Whop_sdk::AdGroups::Types::CreateAdGroupsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::AdGroup.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::DeleteAdGroupsResponse
Deletes an ad group.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 291 def delete(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::AdGroups::Types::DeleteAdGroupsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#duplicate(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::DuplicateAdGroupsResponse
Creates copies of the ad group in duplicating status and returns them — into its own campaign, or into
target_ad_campaign_id (which must belong to the same account and be compatible with the ad group's targeting and
goals); each copy transitions to its final status (matching the source's active/paused state) once duplication
completes. Poll each returned ad group until it leaves duplicating — a copy that could not be completed is
deleted and returns 404.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 374 def duplicate(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request_data = Whop_sdk::AdGroups::Types::DuplicateAdGroupsRequest.new(params).to_h non_body_param_names = %w[id] body = request_data.except(*non_body_param_names) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}/duplicate", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::AdGroups::Types::DuplicateAdGroupsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#estimate_reach(request_options: {}, **params) ⇒ Whop_sdk::Types::ReachEstimate
Estimates how many people a draft targeting spec can reach, before an ad group is created. The body takes the
same targeting fields as creating an ad group — regions, demographics, detailed_targeting, audiences,
languages, and devices — and nothing is persisted.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 147 def estimate_reach(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ad_groups/estimate_reach", body: Whop_sdk::AdGroups::Types::EstimateReachAdGroupsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::ReachEstimate.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::ListAdGroupsResponse
Lists ad groups for the account, newest first.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 44 def list(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["ad_campaign_id"] = params[:ad_campaign_id] if params.key?(:ad_campaign_id) query_params["ad_campaign_ids"] = params[:ad_campaign_ids] if params.key?(:ad_campaign_ids) query_params["status"] = params[:status] if params.key?(:status) query_params["query"] = params[:query] if params.key?(:query) query_params["order"] = params[:order] if params.key?(:order) query_params["direction"] = params[:direction] if params.key?(:direction) query_params["created_before"] = params[:created_before] if params.key?(:created_before) query_params["created_after"] = params[:created_after] if params.key?(:created_after) query_params["stats_from"] = params[:stats_from] if params.key?(:stats_from) query_params["stats_to"] = params[:stats_to] if params.key?(:stats_to) query_params["time_zone"] = params[:time_zone] if params.key?(:time_zone) query_params["attribution_model"] = params[:attribution_model] if params.key?(:attribution_model) query_params["first"] = params[:first] if params.key?(:first) query_params["after"] = params[:after] if params.key?(:after) query_params["last"] = params[:last] if params.key?(:last) query_params["before"] = params[:before] if params.key?(:before) Whop_sdk::Internal::CursorItemIterator.new( cursor_field: :end_cursor, item_field: :data, initial_cursor: query_params["after"] ) do |next_cursor| query_params["after"] = next_cursor request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ad_groups", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = Whop_sdk::AdGroups::Types::ListAdGroupsResponse.load(response.body) [parsed_response, response] else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#pause(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Pauses delivery of an ad group.
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 416 def pause(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}/pause", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::AdGroup.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Retrieves a single ad group.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 247 def retrieve(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["stats_from"] = params[:stats_from] if params.key?(:stats_from) query_params["stats_to"] = params[:stats_to] if params.key?(:stats_to) query_params["time_zone"] = params[:time_zone] if params.key?(:time_zone) query_params["attribution_model"] = params[:attribution_model] if params.key?(:attribution_model) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::AdGroup.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#search_targeting_options(request_options: {}, **params) ⇒ Whop_sdk::AdGroups::Types::SearchTargetingOptionsAdGroupsResponse
Searches the ad platform's targeting taxonomy for options to target an ad group with. Each result comes back in
the exact shape the ad-group body accepts for its type, so it can be used in detailed_targeting, regions,
or languages as-is. A blank query browses the small fixed lists (behaviors, browse demographic categories,
languages); interests, work employers, job titles, schools, majors, and locations need a search term.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 195 def (request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["platform"] = params[:platform] if params.key?(:platform) query_params["query"] = params[:query] if params.key?(:query) query_params["types"] = params[:types] if params.key?(:types) query_params["location_types"] = params[:location_types] if params.key?(:location_types) query_params["country"] = params[:country] if params.key?(:country) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["special_ad_categories"] = params[:special_ad_categories] if params.key?(:special_ad_categories) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ad_groups/targeting_options", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::AdGroups::Types::SearchTargetingOptionsAdGroupsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#unpause(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Resumes delivery of a paused ad group.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 453 def unpause(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}/unpause", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::AdGroup.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Whop_sdk::Types::AdGroup
Updates an ad group's editable fields. Only the keys you send are changed.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/whop_sdk/ad_groups/client.rb', line 328 def update(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request_data = Whop_sdk::AdGroups::Types::UpdateAdGroupsRequest.new(params).to_h non_body_param_names = %w[id] body = request_data.except(*non_body_param_names) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "ad_groups/#{URI.encode_uri_component(params[:id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::AdGroup.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |