google-ads-googleads 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +2 -0
  3. data/README.md +107 -0
  4. data/Rakefile +7 -0
  5. data/googleads_config.rb +10 -0
  6. data/lib/google/ads/googleads.rb +25 -0
  7. data/lib/google/ads/googleads/config.rb +42 -0
  8. data/lib/google/ads/googleads/errors.rb +40 -0
  9. data/lib/google/ads/googleads/field_mask_util.rb +159 -0
  10. data/lib/google/ads/googleads/googleads_client.rb +177 -0
  11. data/lib/google/ads/googleads/patches.rb +45 -0
  12. data/lib/google/ads/googleads/path_lookup_util.rb +84 -0
  13. data/lib/google/ads/googleads/proto_lookup_util.rb +249 -0
  14. data/lib/google/ads/googleads/v0/common/ad_pb.rb +80 -0
  15. data/lib/google/ads/googleads/v0/common/bidding_pb.rb +71 -0
  16. data/lib/google/ads/googleads/v0/common/criteria_pb.rb +25 -0
  17. data/lib/google/ads/googleads/v0/common/custom_parameter_pb.rb +24 -0
  18. data/lib/google/ads/googleads/v0/common/metrics_pb.rb +65 -0
  19. data/lib/google/ads/googleads/v0/common/policy_pb.rb +24 -0
  20. data/lib/google/ads/googleads/v0/common/value_pb.rb +28 -0
  21. data/lib/google/ads/googleads/v0/enums/ad_group_ad_status_pb.rb +29 -0
  22. data/lib/google/ads/googleads/v0/enums/ad_group_criterion_status_pb.rb +29 -0
  23. data/lib/google/ads/googleads/v0/enums/ad_group_status_pb.rb +29 -0
  24. data/lib/google/ads/googleads/v0/enums/ad_group_type_pb.rb +27 -0
  25. data/lib/google/ads/googleads/v0/enums/ad_network_type_pb.rb +31 -0
  26. data/lib/google/ads/googleads/v0/enums/ad_serving_optimization_status_pb.rb +31 -0
  27. data/lib/google/ads/googleads/v0/enums/ad_type_pb.rb +32 -0
  28. data/lib/google/ads/googleads/v0/enums/advertising_channel_sub_type_pb.rb +28 -0
  29. data/lib/google/ads/googleads/v0/enums/advertising_channel_type_pb.rb +27 -0
  30. data/lib/google/ads/googleads/v0/enums/bid_source_pb.rb +29 -0
  31. data/lib/google/ads/googleads/v0/enums/bidding_strategy_type_pb.rb +36 -0
  32. data/lib/google/ads/googleads/v0/enums/budget_delivery_method_pb.rb +28 -0
  33. data/lib/google/ads/googleads/v0/enums/budget_status_pb.rb +28 -0
  34. data/lib/google/ads/googleads/v0/enums/campaign_serving_status_pb.rb +31 -0
  35. data/lib/google/ads/googleads/v0/enums/campaign_status_pb.rb +29 -0
  36. data/lib/google/ads/googleads/v0/enums/criterion_type_pb.rb +27 -0
  37. data/lib/google/ads/googleads/v0/enums/day_of_week_pb.rb +33 -0
  38. data/lib/google/ads/googleads/v0/enums/device_pb.rb +29 -0
  39. data/lib/google/ads/googleads/v0/enums/google_ads_field_category_pb.rb +30 -0
  40. data/lib/google/ads/googleads/v0/enums/google_ads_field_data_type_pb.rb +36 -0
  41. data/lib/google/ads/googleads/v0/enums/keyword_match_type_pb.rb +29 -0
  42. data/lib/google/ads/googleads/v0/enums/page_one_promoted_strategy_goal_pb.rb +28 -0
  43. data/lib/google/ads/googleads/v0/enums/quality_score_bucket_pb.rb +29 -0
  44. data/lib/google/ads/googleads/v0/enums/slot_pb.rb +32 -0
  45. data/lib/google/ads/googleads/v0/errors/ad_customizer_error_pb.rb +31 -0
  46. data/lib/google/ads/googleads/v0/errors/ad_error_pb.rb +154 -0
  47. data/lib/google/ads/googleads/v0/errors/ad_group_ad_error_pb.rb +34 -0
  48. data/lib/google/ads/googleads/v0/errors/ad_group_criterion_error_pb.rb +63 -0
  49. data/lib/google/ads/googleads/v0/errors/ad_group_error_pb.rb +38 -0
  50. data/lib/google/ads/googleads/v0/errors/ad_sharing_error_pb.rb +29 -0
  51. data/lib/google/ads/googleads/v0/errors/adx_error_pb.rb +27 -0
  52. data/lib/google/ads/googleads/v0/errors/authentication_error_pb.rb +47 -0
  53. data/lib/google/ads/googleads/v0/errors/authorization_error_pb.rb +30 -0
  54. data/lib/google/ads/googleads/v0/errors/bidding_error_pb.rb +46 -0
  55. data/lib/google/ads/googleads/v0/errors/bidding_strategy_error_pb.rb +30 -0
  56. data/lib/google/ads/googleads/v0/errors/campaign_budget_error_pb.rb +40 -0
  57. data/lib/google/ads/googleads/v0/errors/campaign_criterion_error_pb.rb +36 -0
  58. data/lib/google/ads/googleads/v0/errors/campaign_error_pb.rb +60 -0
  59. data/lib/google/ads/googleads/v0/errors/collection_size_error_pb.rb +28 -0
  60. data/lib/google/ads/googleads/v0/errors/criterion_error_pb.rb +106 -0
  61. data/lib/google/ads/googleads/v0/errors/date_error_pb.rb +34 -0
  62. data/lib/google/ads/googleads/v0/errors/date_range_error_pb.rb +31 -0
  63. data/lib/google/ads/googleads/v0/errors/distinct_error_pb.rb +28 -0
  64. data/lib/google/ads/googleads/v0/errors/errors_pb.rb +154 -0
  65. data/lib/google/ads/googleads/v0/errors/feed_attribute_reference_error_pb.rb +29 -0
  66. data/lib/google/ads/googleads/v0/errors/field_mask_error_pb.rb +30 -0
  67. data/lib/google/ads/googleads/v0/errors/function_error_pb.rb +42 -0
  68. data/lib/google/ads/googleads/v0/errors/function_parsing_error_pb.rb +37 -0
  69. data/lib/google/ads/googleads/v0/errors/id_error_pb.rb +27 -0
  70. data/lib/google/ads/googleads/v0/errors/image_error_pb.rb +63 -0
  71. data/lib/google/ads/googleads/v0/errors/internal_error_pb.rb +28 -0
  72. data/lib/google/ads/googleads/v0/errors/list_operation_error_pb.rb +28 -0
  73. data/lib/google/ads/googleads/v0/errors/media_bundle_error_pb.rb +48 -0
  74. data/lib/google/ads/googleads/v0/errors/media_error_pb.rb +50 -0
  75. data/lib/google/ads/googleads/v0/errors/multiplier_error_pb.rb +38 -0
  76. data/lib/google/ads/googleads/v0/errors/mutate_error_pb.rb +31 -0
  77. data/lib/google/ads/googleads/v0/errors/new_resource_creation_error_pb.rb +29 -0
  78. data/lib/google/ads/googleads/v0/errors/not_empty_error_pb.rb +27 -0
  79. data/lib/google/ads/googleads/v0/errors/null_error_pb.rb +27 -0
  80. data/lib/google/ads/googleads/v0/errors/operation_access_denied_error_pb.rb +35 -0
  81. data/lib/google/ads/googleads/v0/errors/operator_error_pb.rb +27 -0
  82. data/lib/google/ads/googleads/v0/errors/query_error_pb.rb +72 -0
  83. data/lib/google/ads/googleads/v0/errors/quota_error_pb.rb +28 -0
  84. data/lib/google/ads/googleads/v0/errors/range_error_pb.rb +28 -0
  85. data/lib/google/ads/googleads/v0/errors/region_code_error_pb.rb +27 -0
  86. data/lib/google/ads/googleads/v0/errors/request_error_pb.rb +41 -0
  87. data/lib/google/ads/googleads/v0/errors/resource_access_denied_error_pb.rb +27 -0
  88. data/lib/google/ads/googleads/v0/errors/resource_count_limit_exceeded_error_pb.rb +33 -0
  89. data/lib/google/ads/googleads/v0/errors/setting_error_pb.rb +43 -0
  90. data/lib/google/ads/googleads/v0/errors/string_format_error_pb.rb +28 -0
  91. data/lib/google/ads/googleads/v0/errors/string_length_error_pb.rb +28 -0
  92. data/lib/google/ads/googleads/v0/errors/url_field_error_pb.rb +70 -0
  93. data/lib/google/ads/googleads/v0/resources/ad_group_ad_pb.rb +28 -0
  94. data/lib/google/ads/googleads/v0/resources/ad_group_criterion_pb.rb +64 -0
  95. data/lib/google/ads/googleads/v0/resources/ad_group_pb.rb +38 -0
  96. data/lib/google/ads/googleads/v0/resources/bidding_strategy_pb.rb +36 -0
  97. data/lib/google/ads/googleads/v0/resources/campaign_budget_pb.rb +32 -0
  98. data/lib/google/ads/googleads/v0/resources/campaign_criterion_pb.rb +32 -0
  99. data/lib/google/ads/googleads/v0/resources/campaign_pb.rb +70 -0
  100. data/lib/google/ads/googleads/v0/resources/customer_pb.rb +29 -0
  101. data/lib/google/ads/googleads/v0/resources/google_ads_field_pb.rb +38 -0
  102. data/lib/google/ads/googleads/v0/resources/keyword_view_pb.rb +22 -0
  103. data/lib/google/ads/googleads/v0/services/ad_group_ad_service_client.rb +262 -0
  104. data/lib/google/ads/googleads/v0/services/ad_group_ad_service_client_config.json +36 -0
  105. data/lib/google/ads/googleads/v0/services/ad_group_ad_service_pb.rb +47 -0
  106. data/lib/google/ads/googleads/v0/services/ad_group_ad_service_services_pb.rb +51 -0
  107. data/lib/google/ads/googleads/v0/services/ad_group_criterion_service_client.rb +262 -0
  108. data/lib/google/ads/googleads/v0/services/ad_group_criterion_service_client_config.json +36 -0
  109. data/lib/google/ads/googleads/v0/services/ad_group_criterion_service_pb.rb +47 -0
  110. data/lib/google/ads/googleads/v0/services/ad_group_criterion_service_services_pb.rb +51 -0
  111. data/lib/google/ads/googleads/v0/services/ad_group_service_client.rb +262 -0
  112. data/lib/google/ads/googleads/v0/services/ad_group_service_client_config.json +36 -0
  113. data/lib/google/ads/googleads/v0/services/ad_group_service_pb.rb +47 -0
  114. data/lib/google/ads/googleads/v0/services/ad_group_service_services_pb.rb +51 -0
  115. data/lib/google/ads/googleads/v0/services/bidding_strategy_service_client.rb +263 -0
  116. data/lib/google/ads/googleads/v0/services/bidding_strategy_service_client_config.json +36 -0
  117. data/lib/google/ads/googleads/v0/services/bidding_strategy_service_pb.rb +47 -0
  118. data/lib/google/ads/googleads/v0/services/bidding_strategy_service_services_pb.rb +52 -0
  119. data/lib/google/ads/googleads/v0/services/campaign_budget_service_client.rb +263 -0
  120. data/lib/google/ads/googleads/v0/services/campaign_budget_service_client_config.json +36 -0
  121. data/lib/google/ads/googleads/v0/services/campaign_budget_service_pb.rb +47 -0
  122. data/lib/google/ads/googleads/v0/services/campaign_budget_service_services_pb.rb +52 -0
  123. data/lib/google/ads/googleads/v0/services/campaign_criterion_service_client.rb +262 -0
  124. data/lib/google/ads/googleads/v0/services/campaign_criterion_service_client_config.json +36 -0
  125. data/lib/google/ads/googleads/v0/services/campaign_criterion_service_pb.rb +47 -0
  126. data/lib/google/ads/googleads/v0/services/campaign_criterion_service_services_pb.rb +51 -0
  127. data/lib/google/ads/googleads/v0/services/campaign_service_client.rb +262 -0
  128. data/lib/google/ads/googleads/v0/services/campaign_service_client_config.json +36 -0
  129. data/lib/google/ads/googleads/v0/services/campaign_service_pb.rb +47 -0
  130. data/lib/google/ads/googleads/v0/services/campaign_service_services_pb.rb +51 -0
  131. data/lib/google/ads/googleads/v0/services/credentials.rb +33 -0
  132. data/lib/google/ads/googleads/v0/services/customer_service_client.rb +214 -0
  133. data/lib/google/ads/googleads/v0/services/customer_service_client_config.json +31 -0
  134. data/lib/google/ads/googleads/v0/services/customer_service_pb.rb +24 -0
  135. data/lib/google/ads/googleads/v0/services/customer_service_services_pb.rb +49 -0
  136. data/lib/google/ads/googleads/v0/services/google_ads_field_service_client.rb +285 -0
  137. data/lib/google/ads/googleads/v0/services/google_ads_field_service_client_config.json +36 -0
  138. data/lib/google/ads/googleads/v0/services/google_ads_field_service_pb.rb +36 -0
  139. data/lib/google/ads/googleads/v0/services/google_ads_field_service_services_pb.rb +51 -0
  140. data/lib/google/ads/googleads/v0/services/google_ads_service_client.rb +242 -0
  141. data/lib/google/ads/googleads/v0/services/google_ads_service_client_config.json +31 -0
  142. data/lib/google/ads/googleads/v0/services/google_ads_service_pb.rb +72 -0
  143. data/lib/google/ads/googleads/v0/services/google_ads_service_services_pb.rb +49 -0
  144. data/lib/google/ads/googleads/v0/services/keyword_view_service_client.rb +216 -0
  145. data/lib/google/ads/googleads/v0/services/keyword_view_service_client_config.json +31 -0
  146. data/lib/google/ads/googleads/v0/services/keyword_view_service_pb.rb +24 -0
  147. data/lib/google/ads/googleads/v0/services/keyword_view_service_services_pb.rb +49 -0
  148. data/lib/google/ads/googleads/version.rb +25 -0
  149. data/lib/google/ads/googleads/wrapper_util.rb +48 -0
  150. metadata +248 -0
@@ -0,0 +1,45 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ # Here we gather custom patches we want to make the lib more usable.
18
+
19
+ require 'google/protobuf/wrappers_pb'
20
+
21
+ module Google
22
+ module Protobuf
23
+ class StringValue
24
+ def to_s; return value; end
25
+ end
26
+
27
+ class Int64Value
28
+ def to_s; return value.to_s; end
29
+ def to_i; return value.to_i; end
30
+ def to_f; return value.to_f; end
31
+ end
32
+
33
+ class Int32Value
34
+ def to_s; return value.to_s; end
35
+ def to_i; return value.to_i; end
36
+ def to_f; return value.to_f; end
37
+ end
38
+
39
+ class DoubleValue
40
+ def to_s; return value.to_s; end
41
+ def to_i; return value.to_i; end
42
+ def to_f; return value.to_f; end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,84 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ # Utility that generates up resource names for entities given IDs.
18
+
19
+ module Google
20
+ module Ads
21
+ module Googleads
22
+ class PathLookupUtil
23
+ def initialize(proto_lookup_util)
24
+ @proto_lookup_util = proto_lookup_util
25
+ end
26
+
27
+ def ad_group_ad(customer_id, ad_group_id, ad_id)
28
+ @proto_lookup_util.service(:AdGroupAd).ad_group_ad_path(
29
+ customer_id.to_s, sprintf('%s_%s', ad_group_id.to_s, ad_id.to_s))
30
+ end
31
+
32
+ def ad_group_criterion(customer_id, ad_group_id, criterion_id)
33
+ @proto_lookup_util.service(:AdGroupCriterion).ad_group_criteria_path(
34
+ customer_id.to_s,
35
+ sprintf('%s_%s', ad_group_id.to_s, criterion_id.to_s)
36
+ )
37
+ end
38
+
39
+ def ad_group(customer_id, ad_group_id)
40
+ @proto_lookup_util.service(:AdGroup).ad_group_path(
41
+ customer_id.to_s, ad_group_id.to_s)
42
+ end
43
+
44
+ def bidding_strategy(customer_id, bidding_strategy_id)
45
+ @proto_lookup_util.service(:BiddingStrategy).bidding_strategy_path(
46
+ customer_id.to_s, bidding_strategy_id.to_s)
47
+ end
48
+
49
+ def campaign_budget(customer_id, campaign_budget_id)
50
+ @proto_lookup_util.service(:CampaignBudget).campaign_budget_path(
51
+ customer_id.to_s, campaign_budget_id.to_s)
52
+ end
53
+
54
+ def campaign_criterion(customer_id, campaign_id, criterion_id)
55
+ @proto_lookup_util.service(:CampaignCriterion).campaign_criteria_path(
56
+ customer_id.to_s,
57
+ sprintf('%s_%s', campaign_id.to_s, criterion_id.to_s)
58
+ )
59
+ end
60
+
61
+ def campaign(customer_id, campaign_id)
62
+ @proto_lookup_util.service(:Campaign).campaign_path(
63
+ customer_id.to_s, campaign_id.to_s)
64
+ end
65
+
66
+ def customer(customer_id)
67
+ @proto_lookup_util.service(:Customer).customer_path(customer_id.to_s)
68
+ end
69
+
70
+ def google_ads_field(google_ads_field)
71
+ @proto_lookup_util.service(:GoogleAdsField).google_ads_field_path(
72
+ google_ads_field.to_s)
73
+ end
74
+
75
+ def keyword_view(customer_id, ad_group_id, criterion_id)
76
+ @proto_lookup_util.service(:KeywordView).keyword_view_path(
77
+ customer_id.to_s,
78
+ sprintf('%s_%s', ad_group_id.to_s, criterion_id.to_s)
79
+ )
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,249 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ # Utility that looks up references to generated classes for proto objects.
18
+
19
+ module Google
20
+ module Ads
21
+ module Googleads
22
+ class ProtoLookupUtil
23
+ # Variables: Version, folder (resources/common), filename
24
+ RESOURCE_PATH = 'google/ads/googleads/%s/%s/%s'.freeze
25
+ # Variables: Version, class name
26
+ RESOURCE_CLASS_PATH = 'Google::Ads::Googleads::%s::Resources::%s'.freeze
27
+ # Variables: Version, class name
28
+ COMMON_CLASS_PATH = 'Google::Ads::Googleads::%s::Common::%s'.freeze
29
+
30
+ # Variables: Version, filename
31
+ ENUM_PATH = 'google/ads/googleads/%s/enums/%s'.freeze
32
+ # Variables: Version, enum name, enum name (again)
33
+ ENUM_CLASS_PATH = 'Google::Ads::Googleads::%s::Enums::%sEnum::%s'.freeze
34
+
35
+ # Variables: Version, filename
36
+ SERVICE_PATH = 'google/ads/googleads/%s/services/%s'.freeze
37
+ # Variables: Version, entity name
38
+ SERVICE_CLASS_PATH =
39
+ 'Google::Ads::Googleads::%s::Services::%s'.freeze
40
+
41
+ RESOURCES = {
42
+ AdGroupAd: ['resources', 'ad_group_ad_pb', 'AdGroupAd'],
43
+ AdGroupCriterion: ['resources', 'ad_group_criterion_pb',
44
+ 'AdGroupCriterion'],
45
+ QualityInfo: ['resources', 'ad_group_criterion_pb',
46
+ 'AdGroupCriterion::QualityInfo'],
47
+ PositionEstimates: ['resources', 'ad_group_criterion_pb',
48
+ 'AdGroupCriterion::PositionEstimates'],
49
+ AdGroup: ['resources', 'ad_group_pb', 'AdGroup'],
50
+ BiddingStrategy: ['resources', 'bidding_strategy_pb',
51
+ 'BiddingStrategy'],
52
+ CampaignBudget: ['resources', 'campaign_budget_pb', 'CampaignBudget'],
53
+ CampaignCriterion: ['resources', 'campaign_criterion_pb',
54
+ 'CampaignCriterion'],
55
+ Campaign: ['resources', 'campaign_pb', 'Campaign'],
56
+ NetworkSettings: ['resources', 'campaign_pb',
57
+ 'Campaign::NetworkSettings'],
58
+ DynamicSearchAdsSetting: ['resources', 'campaign_pb',
59
+ 'Campaign::DynamicSearchAdsSetting'],
60
+ Customer: ['resources', 'customer_pb', 'Customer'],
61
+ GoogleAdsField: ['resources', 'google_ads_field_pb',
62
+ 'GoogleAdsField'],
63
+ KeywordView: ['resources', 'keyword_view_pb', 'KeywordView'],
64
+ Ad: ['common', 'ad_pb', 'Ad'],
65
+ TextAdInfo: ['common', 'ad_pb', 'TextAdInfo'],
66
+ ExpandedTextAdInfo: ['common', 'ad_pb', 'ExpandedTextAdInfo'],
67
+ DynamicSearchAdInfo: ['common', 'ad_pb', 'DynamicSearchAdInfo'],
68
+ ResponsiveDisplayAdInfo: ['common', 'ad_pb',
69
+ 'ResponsiveDisplayAdInfo'],
70
+ CallOnlyAdInfo: ['common', 'ad_pb', 'CallOnlyAdInfo'],
71
+ ExpandedDynamicSearchAdInfo: ['common', 'ad_pb',
72
+ 'ExpandedDynamicSearchAdInfo'],
73
+ EnhancedCpc: ['common', 'bidding_pb', 'EnhancedCpc'],
74
+ ManualCpc: ['common', 'bidding_pb', 'ManualCpc'],
75
+ ManualCpm: ['common', 'bidding_pb', 'ManualCpm'],
76
+ MaximizeConversions: ['common', 'bidding_pb', 'MaximizeConversions'],
77
+ MaximizeConversionValue: ['common', 'bidding_pb',
78
+ 'MaximizeConversionValue'],
79
+ PageOnePromoted: ['common', 'bidding_pb', 'PageOnePromoted'],
80
+ TargetCpa: ['common', 'bidding_pb', 'TargetCpa'],
81
+ TargetOutrankShare: ['common', 'bidding_pb', 'TargetOutrankShare'],
82
+ TargetRoas: ['common', 'bidding_pb', 'TargetRoas'],
83
+ TargetSpend: ['common', 'bidding_pb', 'TargetSpend'],
84
+ KeywordInfo: ['common', 'criteria_pb', 'KeywordInfo'],
85
+ CustomParameter: ['common', 'custom_parameter_pb', 'CustomParameter'],
86
+ Metrics: ['common', 'metrics_pb', 'Metrics'],
87
+ PolicyViolationKey: ['common', 'policy_pb', 'PolicyViolationKey'],
88
+ Value: ['common', 'value_pb', 'Value']
89
+ }.freeze
90
+
91
+ ENUMS = {
92
+ AdGroupAdStatus: ['ad_group_ad_status_pb', 'AdGroupAdStatus'],
93
+ AdGroupCriterionStatus: ['ad_group_criterion_status_pb',
94
+ 'AdGroupCriterionStatus'],
95
+ AdGroupStatus: ['ad_group_status_pb', 'AdGroupStatus'],
96
+ AdGroupType: ['ad_group_type_pb', 'AdGroupType'],
97
+ AdNetworkType: ['ad_network_type_pb', 'AdNetworkType'],
98
+ AdServingOptimizationStatus: ['ad_serving_optimization_status_pb',
99
+ 'AdServingOptimizationStatus'],
100
+ AdType: ['ad_type_pb', 'AdType'],
101
+ AdvertisingChannelSubType: ['advertising_channel_sub_type_pb',
102
+ 'AdvertisingChannelSubType'],
103
+ AdvertisingChannelType: ['advertising_channel_type_pb',
104
+ 'AdvertisingChannelType'],
105
+ BidSource: ['bid_source_pb', 'BidSource'],
106
+ BiddingStrategyType: ['bidding_strategy_type_pb',
107
+ 'BiddingStrategyType'],
108
+ BudgetDeliveryMethod: ['budget_delivery_method_pb',
109
+ 'BudgetDeliveryMethod'],
110
+ BudgetStatus: ['budget_status_pb', 'BudgetStatus'],
111
+ CampaignServingStatus: ['campaign_serving_status_pb',
112
+ 'CampaignServingStatus'],
113
+ CampaignStatus: ['campaign_status_pb', 'CampaignStatus'],
114
+ DayOfWeek: ['day_of_week_pb', 'DayOfWeek'],
115
+ Device: ['device_pb', 'Device'],
116
+ GoogleAdsFieldCategory: ['google_ads_field_category_pb',
117
+ 'GoogleAdsFieldCategory'],
118
+ GoogleAdsFieldDataType: ['google_ads_field_data_type_pb',
119
+ 'GoogleAdsFieldDataType'],
120
+ KeywordMatchType: ['keyword_match_type_pb', 'KeywordMatchType'],
121
+ PageOnePromotedStrategyGoal: ['page_one_promoted_strategy_goal_pb',
122
+ 'PageOnePromotedStrategyGoal'],
123
+ QualityScoreBucket: ['quality_score_bucket_pb', 'QualityScoreBucket'],
124
+ Slot: ['slot_pb', 'Slot']
125
+ }.freeze
126
+
127
+ SERVICES = {
128
+ AdGroupAd: ['ad_group_ad_service_client', 'AdGroupAdServiceClient'],
129
+ AdGroupCriterion: ['ad_group_criterion_service_client',
130
+ 'AdGroupCriterionServiceClient'],
131
+ AdGroup: ['ad_group_service_client', 'AdGroupServiceClient'],
132
+ BiddingStrategy: ['bidding_strategy_service_client',
133
+ 'BiddingStrategyServiceClient'],
134
+ CampaignBudget: ['campaign_budget_service_client',
135
+ 'CampaignBudgetServiceClient'],
136
+ CampaignCriterion: ['campaign_criterion_service_client',
137
+ 'CampaignCriterionServiceClient'],
138
+ Campaign: ['campaign_service_client', 'CampaignServiceClient'],
139
+ Customer: ['customer_service_client', 'CustomerServiceClient'],
140
+ GoogleAdsField: ['google_ads_field_service_client',
141
+ 'GoogleAdsFieldServiceClient'],
142
+ GoogleAds: ['google_ads_service_client', 'GoogleAdsServiceClient'],
143
+ KeywordView: ['keyword_view_service_client',
144
+ 'KeywordViewServiceClient']
145
+ }
146
+
147
+ OPERATIONS = {
148
+ AdGroupAd: ['ad_group_ad_service_pb', 'AdGroupAdOperation'],
149
+ AdGroupCriterion: ['ad_group_criterion_service_pb',
150
+ 'AdGroupCriterionOperation'],
151
+ AdGroup: ['ad_group_service_pb', 'AdGroupOperation'],
152
+ BiddingStrategy: ['bidding_strategy_service_pb',
153
+ 'BiddingStrategyOperation'],
154
+ CampaignBudget: ['campaign_budget_service_pb',
155
+ 'CampaignBudgetOperation'],
156
+ CampaignCriterion: ['campaign_criterion_service_pb',
157
+ 'CampaignCriterionOperation'],
158
+ Campaign: ['campaign_service_pb', 'CampaignOperation'],
159
+ }
160
+
161
+ def initialize(version)
162
+ @version = version
163
+ @path_version = version.downcase
164
+ end
165
+
166
+ # Look up the class for a resource by name.
167
+ def resource(name)
168
+ name = name.to_sym
169
+
170
+ resource_info = RESOURCES[name]
171
+ if resource_info.nil?
172
+ raise ArgumentError, sprintf('No resource found with name %s', name)
173
+ end
174
+
175
+ require_path = sprintf(RESOURCE_PATH, @path_version, resource_info[0],
176
+ resource_info[1])
177
+ require require_path
178
+
179
+ class_path = resource_info.first == 'resources' ?
180
+ RESOURCE_CLASS_PATH : COMMON_CLASS_PATH
181
+ class_path = sprintf(class_path, @version, resource_info[2])
182
+ return class_for_path(class_path)
183
+ end
184
+
185
+ # Look up the class for an enum by name.
186
+ def enum(name)
187
+ name = name.to_sym
188
+
189
+ enum_info = ENUMS[name]
190
+ if enum_info.nil?
191
+ raise ArgumentError, sprintf('No enum found with name %s', name)
192
+ end
193
+
194
+ require_path = sprintf(ENUM_PATH, @path_version, enum_info.first)
195
+ require require_path
196
+
197
+ class_path = sprintf(ENUM_CLASS_PATH, @version, enum_info.last,
198
+ enum_info.last)
199
+ return class_for_path(class_path)
200
+ end
201
+
202
+ # Look up the class for a service by name.
203
+ def service(name)
204
+ name = name.to_sym
205
+
206
+ service_info = SERVICES[name]
207
+ if service_info.nil?
208
+ raise ArgumentError, sprintf('No service found with name %s', name)
209
+ end
210
+
211
+ require_path = sprintf(SERVICE_PATH, @path_version,
212
+ service_info.first)
213
+ require require_path
214
+
215
+ class_path = sprintf(SERVICE_CLASS_PATH, @version, service_info.last)
216
+ return class_for_path(class_path)
217
+ end
218
+
219
+ # Look up the class for an operation by name.
220
+ def operation(name)
221
+ name = name.to_sym
222
+
223
+ operation_info = OPERATIONS[name]
224
+ if operation_info.nil?
225
+ raise ArgumentError,
226
+ sprintf('No operation found with name %s', name)
227
+ end
228
+
229
+ require_path = sprintf(SERVICE_PATH, @path_version,
230
+ operation_info.first)
231
+ require require_path
232
+
233
+ class_path = sprintf(SERVICE_CLASS_PATH, @version,
234
+ operation_info.last)
235
+ return class_for_path(class_path)
236
+ end
237
+
238
+ private
239
+
240
+ # Converts complete class path into class object.
241
+ def class_for_path(path)
242
+ path.split('::').inject(Kernel) do |scope, const_name|
243
+ scope.const_get(const_name)
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
249
+ end
@@ -0,0 +1,80 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/ads/googleads/v0/common/ad.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/ads/googleads/v0/common/custom_parameter_pb'
7
+ require 'google/ads/googleads/v0/enums/ad_type_pb'
8
+ require 'google/protobuf/wrappers_pb'
9
+ Google::Protobuf::DescriptorPool.generated_pool.build do
10
+ add_message "google.ads.googleads.v0.common.Ad" do
11
+ optional :id, :message, 1, "google.protobuf.Int64Value"
12
+ repeated :final_urls, :message, 2, "google.protobuf.StringValue"
13
+ repeated :final_mobile_urls, :message, 16, "google.protobuf.StringValue"
14
+ optional :tracking_url_template, :message, 12, "google.protobuf.StringValue"
15
+ repeated :url_custom_parameters, :message, 10, "google.ads.googleads.v0.common.CustomParameter"
16
+ optional :display_url, :message, 4, "google.protobuf.StringValue"
17
+ optional :type, :enum, 5, "google.ads.googleads.v0.enums.AdTypeEnum.AdType"
18
+ oneof :ad_data do
19
+ optional :text_ad, :message, 6, "google.ads.googleads.v0.common.TextAdInfo"
20
+ optional :expanded_text_ad, :message, 7, "google.ads.googleads.v0.common.ExpandedTextAdInfo"
21
+ optional :dynamic_search_ad, :message, 8, "google.ads.googleads.v0.common.DynamicSearchAdInfo"
22
+ optional :responsive_display_ad, :message, 9, "google.ads.googleads.v0.common.ResponsiveDisplayAdInfo"
23
+ optional :call_only_ad, :message, 13, "google.ads.googleads.v0.common.CallOnlyAdInfo"
24
+ optional :expanded_dynamic_search_ad, :message, 14, "google.ads.googleads.v0.common.ExpandedDynamicSearchAdInfo"
25
+ end
26
+ end
27
+ add_message "google.ads.googleads.v0.common.TextAdInfo" do
28
+ optional :headline, :message, 1, "google.protobuf.StringValue"
29
+ optional :description1, :message, 2, "google.protobuf.StringValue"
30
+ optional :description2, :message, 3, "google.protobuf.StringValue"
31
+ end
32
+ add_message "google.ads.googleads.v0.common.ExpandedTextAdInfo" do
33
+ optional :headline_part1, :message, 1, "google.protobuf.StringValue"
34
+ optional :headline_part2, :message, 2, "google.protobuf.StringValue"
35
+ optional :description, :message, 3, "google.protobuf.StringValue"
36
+ optional :path1, :message, 4, "google.protobuf.StringValue"
37
+ optional :path2, :message, 5, "google.protobuf.StringValue"
38
+ end
39
+ add_message "google.ads.googleads.v0.common.DynamicSearchAdInfo" do
40
+ optional :description1, :message, 1, "google.protobuf.StringValue"
41
+ optional :description2, :message, 2, "google.protobuf.StringValue"
42
+ end
43
+ add_message "google.ads.googleads.v0.common.ResponsiveDisplayAdInfo" do
44
+ optional :short_headline, :message, 1, "google.protobuf.StringValue"
45
+ optional :long_headline, :message, 2, "google.protobuf.StringValue"
46
+ optional :description, :message, 3, "google.protobuf.StringValue"
47
+ optional :business_name, :message, 4, "google.protobuf.StringValue"
48
+ end
49
+ add_message "google.ads.googleads.v0.common.CallOnlyAdInfo" do
50
+ optional :country_code, :message, 1, "google.protobuf.StringValue"
51
+ optional :phone_number, :message, 2, "google.protobuf.StringValue"
52
+ optional :business_name, :message, 3, "google.protobuf.StringValue"
53
+ optional :description1, :message, 4, "google.protobuf.StringValue"
54
+ optional :description2, :message, 5, "google.protobuf.StringValue"
55
+ optional :call_tracked, :message, 6, "google.protobuf.BoolValue"
56
+ optional :disable_call_conversion, :message, 7, "google.protobuf.BoolValue"
57
+ optional :phone_number_verification_url, :message, 8, "google.protobuf.StringValue"
58
+ end
59
+ add_message "google.ads.googleads.v0.common.ExpandedDynamicSearchAdInfo" do
60
+ optional :description, :message, 1, "google.protobuf.StringValue"
61
+ end
62
+ end
63
+
64
+ module Google
65
+ module Ads
66
+ module Googleads
67
+ module V0
68
+ module Common
69
+ Ad = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.Ad").msgclass
70
+ TextAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.TextAdInfo").msgclass
71
+ ExpandedTextAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.ExpandedTextAdInfo").msgclass
72
+ DynamicSearchAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.DynamicSearchAdInfo").msgclass
73
+ ResponsiveDisplayAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.ResponsiveDisplayAdInfo").msgclass
74
+ CallOnlyAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.CallOnlyAdInfo").msgclass
75
+ ExpandedDynamicSearchAdInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v0.common.ExpandedDynamicSearchAdInfo").msgclass
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end