Add incentives examples - #554
Conversation
Change-Id: I57fa8a776fb8a1cbd43f6c1d3a1a71c3c63bdd19
Change-Id: I2f4db5b40ddc0494f631b62d60b6992f786cbf57
Code Vetting & Review RecommendationsOverall, the implementation for adding incentive examples ( 1.
|
Change-Id: I19de34550a54efaa8095b503bd5e8c449930e9d4
|
|
||
| response = client.service.incentive.apply_incentive(request_args) | ||
|
|
||
| # Processes the response. |
There was a problem hiding this comment.
Sanitize Customer ID in method & use .compact: Hyphens are only stripped when passed via CLI flags (-C), failing if called directly in Ruby code. Also simplify request hash building with .compact.
| apply_incentive(options[:customer_id], options[:incentive_id], options[:country_code]) | ||
| rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e | ||
| e.failure.errors.each do |error| | ||
| STDERR.printf("Error with message: %s\n", error.message) |
There was a problem hiding this comment.
Print OptionParser banner on missing args: Output the full OptionParser usage banner (puts opts) instead of just a generic one-liner error.
| return | ||
| end | ||
|
|
||
| # If the offer type is CHOOSE_YOUR_OWN_INCENTIVE, there will be 3 incentives in the |
There was a problem hiding this comment.
Add fallback for non-CYO offers & DRY loop: If an offer type is not cyo_incentives, the script silently prints nothing. Add an else branch and iterate over [low_offer, medium_offer, high_offer].
| end | ||
| end | ||
|
|
||
| def format_money(money) |
There was a problem hiding this comment.
Defensive Coding: Handle potential nil/empty proto fields in format_money: Guard against nil values in money.units, money.nanos, and money.currency_code.
| end | ||
| end.parse! | ||
|
|
||
| # Check if required parameters are present. |
There was a problem hiding this comment.
Usability: Print OptionParser banner on missing email: Display the command line options (puts opts) when INSERT_EMAIL_HERE is left unchanged.
Change-Id: I57fa8a776fb8a1cbd43f6c1d3a1a71c3c63bdd19