diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0ee76515ee84..6a8ae5b0305a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -817,6 +817,8 @@ "google-maps-fleet_engine-delivery-v1+FILLER": "0.0.0", "google-maps-fleet_engine-v1": "0.2.1", "google-maps-fleet_engine-v1+FILLER": "0.0.0", + "google-shopping-merchant-accounts-v1beta": "0.0.1", + "google-shopping-merchant-accounts-v1beta+FILLER": "0.0.0", "google-shopping-merchant-conversions": "0.1.0", "google-shopping-merchant-conversions+FILLER": "0.0.0", "google-shopping-merchant-conversions-v1beta": "0.1.0", diff --git a/google-shopping-merchant-accounts-v1beta/.OwlBot.yaml b/google-shopping-merchant-accounts-v1beta/.OwlBot.yaml new file mode 100644 index 000000000000..bb2c95c3522d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.OwlBot.yaml @@ -0,0 +1,3 @@ +deep-copy-regex: + - source: /google/shopping/merchant/accounts/v1beta/[^/]+-ruby/(.*) + dest: /owl-bot-staging/google-shopping-merchant-accounts-v1beta/$1 diff --git a/google-shopping-merchant-accounts-v1beta/.gitignore b/google-shopping-merchant-accounts-v1beta/.gitignore new file mode 100644 index 000000000000..0135b6bc6cfc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.gitignore @@ -0,0 +1,22 @@ +# Ignore bundler lockfiles +Gemfile.lock +gems.locked + +# Ignore documentation output +doc/* +.yardoc/* + +# Ignore test output +coverage/* + +# Ignore build artifacts +pkg/* + +# Ignore files commonly present in certain dev environments +.vagrant +.DS_STORE +.idea +*.iml + +# Ignore synth output +__pycache__ diff --git a/google-shopping-merchant-accounts-v1beta/.owlbot-manifest.json b/google-shopping-merchant-accounts-v1beta/.owlbot-manifest.json new file mode 100644 index 000000000000..d99473137b1c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.owlbot-manifest.json @@ -0,0 +1,278 @@ +{ + "generated": [ + ".gitignore", + ".repo-metadata.json", + ".rubocop.yml", + ".toys.rb", + ".yardopts", + "AUTHENTICATION.md", + "CHANGELOG.md", + "Gemfile", + "LICENSE.md", + "README.md", + "Rakefile", + "gapic_metadata.json", + "google-shopping-merchant-accounts-v1beta.gemspec", + "lib/google-shopping-merchant-accounts-v1beta.rb", + "lib/google/shopping/merchant/accounts/v1beta.rb", + "lib/google/shopping/merchant/accounts/v1beta/accessright_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/account_tax_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/accountissue_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/accountissue_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/accounts_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/businessidentity_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/businessidentity_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/businessinfo_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/businessinfo_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/customerservice_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/emailpreferences_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/homepage_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/phoneverificationstate_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/programs_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/regions_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/shippingsettings_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/shippingsettings_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/tax_rule_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/termsofservice_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/termsofservice_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/termsofservicekind_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/credentials.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/paths.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/rest.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/rest/client.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_service/rest/service_stub.rb", + "lib/google/shopping/merchant/accounts/v1beta/user_services_pb.rb", + "lib/google/shopping/merchant/accounts/v1beta/version.rb", + "proto_docs/README.md", + "proto_docs/google/api/client.rb", + "proto_docs/google/api/field_behavior.rb", + "proto_docs/google/api/launch_stage.rb", + "proto_docs/google/api/resource.rb", + "proto_docs/google/protobuf/duration.rb", + "proto_docs/google/protobuf/empty.rb", + "proto_docs/google/protobuf/field_mask.rb", + "proto_docs/google/protobuf/timestamp.rb", + "proto_docs/google/protobuf/wrappers.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/accessright.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/account_tax.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/accountissue.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/accounts.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/businessidentity.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/businessinfo.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/customerservice.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/emailpreferences.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/homepage.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/online_return_policy.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/phoneverificationstate.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/programs.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/regions.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/shippingsettings.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/tax_rule.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/termsofservice.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/termsofservicekind.rb", + "proto_docs/google/shopping/merchant/accounts/v1beta/user.rb", + "proto_docs/google/shopping/type/types.rb", + "proto_docs/google/type/date.rb", + "proto_docs/google/type/datetime.rb", + "proto_docs/google/type/interval.rb", + "proto_docs/google/type/phone_number.rb", + "proto_docs/google/type/postal_address.rb", + "snippets/Gemfile", + "snippets/account_issue_service/list_account_issues.rb", + "snippets/account_tax_service/get_account_tax.rb", + "snippets/account_tax_service/list_account_tax.rb", + "snippets/account_tax_service/update_account_tax.rb", + "snippets/accounts_service/create_and_configure_account.rb", + "snippets/accounts_service/delete_account.rb", + "snippets/accounts_service/get_account.rb", + "snippets/accounts_service/list_accounts.rb", + "snippets/accounts_service/list_sub_accounts.rb", + "snippets/accounts_service/update_account.rb", + "snippets/business_identity_service/get_business_identity.rb", + "snippets/business_identity_service/update_business_identity.rb", + "snippets/business_info_service/get_business_info.rb", + "snippets/business_info_service/update_business_info.rb", + "snippets/email_preferences_service/get_email_preferences.rb", + "snippets/email_preferences_service/update_email_preferences.rb", + "snippets/homepage_service/claim_homepage.rb", + "snippets/homepage_service/get_homepage.rb", + "snippets/homepage_service/unclaim_homepage.rb", + "snippets/homepage_service/update_homepage.rb", + "snippets/online_return_policy_service/get_online_return_policy.rb", + "snippets/online_return_policy_service/list_online_return_policies.rb", + "snippets/programs_service/disable_program.rb", + "snippets/programs_service/enable_program.rb", + "snippets/programs_service/get_program.rb", + "snippets/programs_service/list_programs.rb", + "snippets/regions_service/create_region.rb", + "snippets/regions_service/delete_region.rb", + "snippets/regions_service/get_region.rb", + "snippets/regions_service/list_regions.rb", + "snippets/regions_service/update_region.rb", + "snippets/shipping_settings_service/get_shipping_settings.rb", + "snippets/shipping_settings_service/insert_shipping_settings.rb", + "snippets/snippet_metadata_google.shopping.merchant.accounts.v1beta.json", + "snippets/terms_of_service_agreement_state_service/get_terms_of_service_agreement_state.rb", + "snippets/terms_of_service_agreement_state_service/retrieve_for_application_terms_of_service_agreement_state.rb", + "snippets/terms_of_service_service/accept_terms_of_service.rb", + "snippets/terms_of_service_service/get_terms_of_service.rb", + "snippets/terms_of_service_service/retrieve_latest_terms_of_service.rb", + "snippets/user_service/create_user.rb", + "snippets/user_service/delete_user.rb", + "snippets/user_service/get_user.rb", + "snippets/user_service/list_users.rb", + "snippets/user_service/update_user.rb", + "test/google/shopping/merchant/accounts/v1beta/account_issue_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/account_issue_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/account_issue_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/account_tax_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/account_tax_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/account_tax_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/accounts_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/accounts_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/accounts_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_identity_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_identity_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_identity_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_info_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_info_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/business_info_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/email_preferences_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/email_preferences_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/email_preferences_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/homepage_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/homepage_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/homepage_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/programs_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/programs_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/programs_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/regions_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/regions_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/regions_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_test.rb", + "test/google/shopping/merchant/accounts/v1beta/user_service_paths_test.rb", + "test/google/shopping/merchant/accounts/v1beta/user_service_rest_test.rb", + "test/google/shopping/merchant/accounts/v1beta/user_service_test.rb", + "test/helper.rb" + ], + "static": [ + ".OwlBot.yaml" + ] +} diff --git a/google-shopping-merchant-accounts-v1beta/.repo-metadata.json b/google-shopping-merchant-accounts-v1beta/.repo-metadata.json new file mode 100644 index 000000000000..40529e3a8548 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.repo-metadata.json @@ -0,0 +1,17 @@ +{ + "api_id": "merchantapi.googleapis.com", + "api_shortname": "merchantapi", + "client_documentation": "https://rubydoc.info/gems/google-shopping-merchant-accounts-v1beta", + "distribution_name": "google-shopping-merchant-accounts-v1beta", + "is_cloud": false, + "language": "ruby", + "name": "merchantapi", + "name_pretty": "Merchant V1BETA API", + "product_documentation": "https://developers.google.com/merchant/api", + "release_level": "unreleased", + "repo": "googleapis/google-cloud-ruby", + "requires_billing": true, + "ruby-cloud-description": "Programmatically manage your Merchant Center accounts. Note that google-shopping-merchant-accounts-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-accounts instead. See the readme for more details.", + "ruby-cloud-product-url": "https://developers.google.com/merchant/api", + "library_type": "GAPIC_AUTO" +} diff --git a/google-shopping-merchant-accounts-v1beta/.rubocop.yml b/google-shopping-merchant-accounts-v1beta/.rubocop.yml new file mode 100644 index 000000000000..5fa9eb10ddf1 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.rubocop.yml @@ -0,0 +1,33 @@ +inherit_gem: + google-style: google-style.yml + +AllCops: + Exclude: + - "google-shopping-merchant-accounts-v1beta.gemspec" + - "lib/**/*_pb.rb" + - "proto_docs/**/*" + - "test/**/*" + - "acceptance/**/*" + - "samples/acceptance/**/*" + - "Rakefile" + +Layout/LineLength: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Naming/AccessorMethodName: + Exclude: + - "snippets/**/*.rb" +Naming/FileName: + Exclude: + - "lib/google-shopping-merchant-accounts-v1beta.rb" diff --git a/google-shopping-merchant-accounts-v1beta/.toys.rb b/google-shopping-merchant-accounts-v1beta/.toys.rb new file mode 100644 index 000000000000..23434bdd5d5b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.toys.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +toys_version! ">= 0.15.3" + +if ENV["RUBY_COMMON_TOOLS"] + common_tools_dir = File.expand_path ENV["RUBY_COMMON_TOOLS"] + load File.join(common_tools_dir, "toys", "gapic") +else + load_git remote: "https://github.com/googleapis/ruby-common-tools.git", + path: "toys/gapic", + update: true +end diff --git a/google-shopping-merchant-accounts-v1beta/.yardopts b/google-shopping-merchant-accounts-v1beta/.yardopts new file mode 100644 index 000000000000..3ddd15e0cf87 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/.yardopts @@ -0,0 +1,12 @@ +--no-private +--title="Merchant V1BETA API" +--exclude _pb\.rb$ +--markup markdown +--markup-provider redcarpet + +./lib/**/*.rb +./proto_docs/**/*.rb +- +README.md +LICENSE.md +AUTHENTICATION.md diff --git a/google-shopping-merchant-accounts-v1beta/AUTHENTICATION.md b/google-shopping-merchant-accounts-v1beta/AUTHENTICATION.md new file mode 100644 index 000000000000..456fb36054bb --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/AUTHENTICATION.md @@ -0,0 +1,122 @@ +# Authentication + +The recommended way to authenticate to the google-shopping-merchant-accounts-v1beta library is to use +[Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials). +To review all of your authentication options, see [Credentials lookup](#credential-lookup). + +## Quickstart + +The following example shows how to set up authentication for a local development +environment with your user credentials. + +**NOTE:** This method is _not_ recommended for running in production. User credentials +should be used only during development. + +1. [Download and install the Google Cloud CLI](https://cloud.google.com/sdk). +2. Set up a local ADC file with your user credentials: + +```sh +gcloud auth application-default login +``` + +3. Write code as if already authenticated. + +For more information about setting up authentication for a local development environment, see +[Set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev). + +## Credential Lookup + +The google-shopping-merchant-accounts-v1beta library provides several mechanisms to configure your system. +Generally, using Application Default Credentials to facilitate automatic +credentials discovery is the easist method. But if you need to explicitly specify +credentials, there are several methods available to you. + +Credentials are accepted in the following ways, in the following order or precedence: + +1. Credentials specified in method arguments +2. Credentials specified in configuration +3. Credentials pointed to or included in environment variables +4. Credentials found in local ADC file +5. Credentials returned by the metadata server for the attached service account (GCP) + +### Configuration + +You can configure a path to a JSON credentials file, either for an individual client object or +globally, for all client objects. The JSON file can contain credentials created for +[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation), +[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a +[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key). + +Note: Service account keys are a security risk if not managed correctly. You should +[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree) +whenever possible. + +To configure a credentials file for an individual client initialization: + +```ruby +require "google/shopping/merchant/accounts/v1beta" + +client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = "path/to/credentialfile.json" +end +``` + +To configure a credentials file globally for all clients: + +```ruby +require "google/shopping/merchant/accounts/v1beta" + +::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.configure do |config| + config.credentials = "path/to/credentialfile.json" +end + +client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new +``` + +### Environment Variables + +You can also use an environment variable to provide a JSON credentials file. +The environment variable can contain a path to the credentials file or, for +environments such as Docker containers where writing files is not encouraged, +you can include the credentials file itself. + +The JSON file can contain credentials created for +[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation), +[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a +[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key). + +Note: Service account keys are a security risk if not managed correctly. You should +[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree) +whenever possible. + +The environment variables that google-shopping-merchant-accounts-v1beta +checks for credentials are: + +* `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents +* `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file + +```ruby +require "google/shopping/merchant/accounts/v1beta" + +ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json" + +client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new +``` + +### Local ADC file + +You can set up a local ADC file with your user credentials for authentication during +development. If credentials are not provided in code or in environment variables, +then the local ADC credentials are discovered. + +Follow the steps in [Quickstart](#quickstart) to set up a local ADC file. + +### Google Cloud Platform environments + +When running on Google Cloud Platform (GCP), including Google Compute Engine +(GCE), Google Kubernetes Engine (GKE), Google App Engine (GAE), Google Cloud +Functions (GCF) and Cloud Run, credentials are retrieved from the attached +service account automatically. Code should be written as if already authenticated. + +For more information, see +[Set up ADC for Google Cloud services](https://cloud.google.com/docs/authentication/provide-credentials-adc#attached-sa). diff --git a/google-shopping-merchant-accounts-v1beta/CHANGELOG.md b/google-shopping-merchant-accounts-v1beta/CHANGELOG.md new file mode 100644 index 000000000000..f88957a62ba2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/CHANGELOG.md @@ -0,0 +1,2 @@ +# Release History + diff --git a/google-shopping-merchant-accounts-v1beta/Gemfile b/google-shopping-merchant-accounts-v1beta/Gemfile new file mode 100644 index 000000000000..95163a6d11f8 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/Gemfile @@ -0,0 +1,11 @@ +source "https://rubygems.org" + +gemspec + +gem "google-style", "~> 1.27.1" +gem "minitest", "~> 5.22" +gem "minitest-focus", "~> 1.4" +gem "minitest-rg", "~> 5.3" +gem "rake", ">= 13.0" +gem "redcarpet", "~> 3.6" +gem "yard", "~> 0.9" diff --git a/google-shopping-merchant-accounts-v1beta/LICENSE.md b/google-shopping-merchant-accounts-v1beta/LICENSE.md new file mode 100644 index 000000000000..c261857ba6ad --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/google-shopping-merchant-accounts-v1beta/README.md b/google-shopping-merchant-accounts-v1beta/README.md new file mode 100644 index 000000000000..fc8bcef07158 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/README.md @@ -0,0 +1,144 @@ +# Ruby Client for the Merchant V1BETA API + +Programmatically manage your Merchant Center accounts. + +Programmatically manage your Merchant Center accounts. + +https://github.com/googleapis/google-cloud-ruby + +This gem is a _versioned_ client. It provides basic client classes for a +specific version of the Merchant V1BETA API. Most users should consider using +the main client gem, +[google-shopping-merchant-accounts](https://rubygems.org/gems/google-shopping-merchant-accounts). +See the section below titled *Which client should I use?* for more information. + +## Installation + +``` +$ gem install google-shopping-merchant-accounts-v1beta +``` + +## Before You Begin + +In order to use this library, you first need to go through the following steps: + +1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) +1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) +1. [Enable the API.](https://console.cloud.google.com/apis/library/merchantapi.googleapis.com) +1. [Set up authentication.](AUTHENTICATION.md) + +## Quick Start + +```ruby +require "google/shopping/merchant/accounts/v1beta" + +client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new +request = ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new # (request fields as keyword arguments...) +response = client.get_account_tax request +``` + +View the [Client Library Documentation](https://rubydoc.info/gems/google-shopping-merchant-accounts-v1beta) +for class and method documentation. + +See also the [Product Documentation](https://developers.google.com/merchant/api) +for general usage information. + +## Enabling Logging + +To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. +The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below, +or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest) +that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) +and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. + +Configuring a Ruby stdlib logger: + +```ruby +require "logger" + +module MyLogger + LOGGER = Logger.new $stderr, level: Logger::WARN + def logger + LOGGER + end +end + +# Define a gRPC module-level logger method before grpc/logconfig.rb loads. +module GRPC + extend MyLogger +end +``` + + +## Google Cloud Samples + +To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples). + +## Supported Ruby Versions + +This library is supported on Ruby 2.7+. + +Google provides official support for Ruby versions that are actively supported +by Ruby Core—that is, Ruby versions that are either in normal maintenance or +in security maintenance, and not end of life. Older versions of Ruby _may_ +still work, but are unsupported and not recommended. See +https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby +support schedule. + +## Which client should I use? + +Most modern Ruby client libraries for Google APIs come in two flavors: the main +client library with a name such as `google-shopping-merchant-accounts`, +and lower-level _versioned_ client libraries with names such as +`google-shopping-merchant-accounts-v1beta`. +_In most cases, you should install the main client._ + +### What's the difference between the main client and a versioned client? + +A _versioned client_ provides a basic set of data types and client classes for +a _single version_ of a specific service. (That is, for a service with multiple +versions, there might be a separate versioned client for each service version.) +Most versioned clients are written and maintained by a code generator. + +The _main client_ is designed to provide you with the _recommended_ client +interfaces for the service. There will be only one main client for any given +service, even a service with multiple versions. The main client includes +factory methods for constructing the client objects we recommend for most +users. In some cases, those will be classes provided by an underlying versioned +client; in other cases, they will be handwritten higher-level client objects +with additional capabilities, convenience methods, or best practices built in. +Generally, the main client will default to a recommended service version, +although in some cases you can override this if you need to talk to a specific +service version. + +### Why would I want to use the main client? + +We recommend that most users install the main client gem for a service. You can +identify this gem as the one _without_ a version in its name, e.g. +`google-shopping-merchant-accounts`. +The main client is recommended because it will embody the best practices for +accessing the service, and may also provide more convenient interfaces or +tighter integration into frameworks and third-party libraries. In addition, the +documentation and samples published by Google will generally demonstrate use of +the main client. + +### Why would I want to use a versioned client? + +You can use a versioned client if you are content with a possibly lower-level +class interface, you explicitly want to avoid features provided by the main +client, or you want to access a specific service version not be covered by the +main client. You can identify versioned client gems because the service version +is part of the name, e.g. `google-shopping-merchant-accounts-v1beta`. + +### What about the google-apis- clients? + +Client library gems with names that begin with `google-apis-` are based on an +older code generation technology. They talk to a REST/JSON backend (whereas +most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may +not offer the same performance, features, and ease of use provided by more +modern clients. + +The `google-apis-` clients have wide coverage across Google services, so you +might need to use one if there is no modern client available for the service. +However, if a modern client is available, we generally recommend it over the +older `google-apis-` clients. diff --git a/google-shopping-merchant-accounts-v1beta/Rakefile b/google-shopping-merchant-accounts-v1beta/Rakefile new file mode 100644 index 000000000000..4ba241983ce6 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/Rakefile @@ -0,0 +1,169 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "bundler/setup" +require "bundler/gem_tasks" + +require "rubocop/rake_task" +RuboCop::RakeTask.new + +require "rake/testtask" +desc "Run tests." +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList["test/**/*_test.rb"] + t.warning = false +end + +desc "Runs the smoke tests." +Rake::TestTask.new :smoke_test do |t| + t.test_files = FileList["acceptance/**/*smoke_test.rb"] + t.warning = false +end + +# Acceptance tests +desc "Run the google-shopping-merchant-accounts-v1beta acceptance tests." +task :acceptance, :project, :keyfile do |t, args| + project = args[:project] + project ||= + ENV["GOOGLE_CLOUD_TEST_PROJECT"] || + ENV["GCLOUD_TEST_PROJECT"] + keyfile = args[:keyfile] + keyfile ||= + ENV["GOOGLE_CLOUD_TEST_KEYFILE"] || + ENV["GCLOUD_TEST_KEYFILE"] + if keyfile + keyfile = File.read keyfile + else + keyfile ||= + ENV["GOOGLE_CLOUD_TEST_KEYFILE_JSON"] || + ENV["GCLOUD_TEST_KEYFILE_JSON"] + end + if project.nil? || keyfile.nil? + fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or GOOGLE_CLOUD_TEST_PROJECT=test123 GOOGLE_CLOUD_TEST_KEYFILE=/path/to/keyfile.json rake acceptance" + end + require "google/shopping/merchant/accounts/v1beta/account_tax_service/credentials" + ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Credentials.env_vars.each do |path| + ENV[path] = nil + end + ENV["GOOGLE_CLOUD_PROJECT"] = project + ENV["GOOGLE_CLOUD_TEST_PROJECT"] = project + ENV["GOOGLE_CLOUD_KEYFILE_JSON"] = keyfile + + Rake::Task["acceptance:run"].invoke +end + +namespace :acceptance do + task :run do + if File.directory? "acceptance" + Rake::Task[:smoke_test].invoke + else + puts "The google-shopping-merchant-accounts-v1beta gem has no acceptance tests." + end + end + + desc "Run acceptance cleanup." + task :cleanup do + end +end + +task :samples do + Rake::Task["samples:latest"].invoke +end + +namespace :samples do + task :latest do + if File.directory? "samples" + Dir.chdir "samples" do + Bundler.with_clean_env do + ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "not_master" + sh "bundle update" + sh "bundle exec rake test" + end + end + else + puts "The google-shopping-merchant-accounts-v1beta gem has no samples to test." + end + end + + task :master do + if File.directory? "samples" + Dir.chdir "samples" do + Bundler.with_clean_env do + ENV["GOOGLE_CLOUD_SAMPLES_TEST"] = "master" + sh "bundle update" + sh "bundle exec rake test" + end + end + else + puts "The google-shopping-merchant-accounts-v1beta gem has no samples to test." + end + end +end + +require "yard" +require "yard/rake/yardoc_task" +YARD::Rake::YardocTask.new do |y| + y.options << "--fail-on-warning" +end + +desc "Run yard-doctest example tests." +task :doctest do + puts "The google-shopping-merchant-accounts-v1beta gem does not have doctest tests." +end + +desc "Run the CI build" +task :ci do + header "BUILDING google-shopping-merchant-accounts-v1beta" + header "google-shopping-merchant-accounts-v1beta rubocop", "*" + Rake::Task[:rubocop].invoke + header "google-shopping-merchant-accounts-v1beta yard", "*" + Rake::Task[:yard].invoke + header "google-shopping-merchant-accounts-v1beta test", "*" + Rake::Task[:test].invoke +end + +namespace :ci do + desc "Run the CI build, with smoke tests." + task :smoke_test do + Rake::Task[:ci].invoke + header "google-shopping-merchant-accounts-v1beta smoke_test", "*" + Rake::Task[:smoke_test].invoke + end + desc "Run the CI build, with acceptance tests." + task :acceptance do + Rake::Task[:ci].invoke + header "google-shopping-merchant-accounts-v1beta acceptance", "*" + Rake::Task[:acceptance].invoke + end + task :a do + # This is a handy shortcut to save typing + Rake::Task["ci:acceptance"].invoke + end +end + +task default: :test + +def header str, token = "#" + line_length = str.length + 8 + puts "" + puts token * line_length + puts "#{token * 3} #{str} #{token * 3}" + puts token * line_length + puts "" +end diff --git a/google-shopping-merchant-accounts-v1beta/gapic_metadata.json b/google-shopping-merchant-accounts-v1beta/gapic_metadata.json new file mode 100644 index 000000000000..03e99a4ba8e8 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/gapic_metadata.json @@ -0,0 +1,350 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "ruby", + "protoPackage": "google.shopping.merchant.accounts.v1beta", + "libraryPackage": "::Google::Shopping::Merchant::Accounts::V1beta", + "services": { + "AccountTaxService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client", + "rpcs": { + "GetAccountTax": { + "methods": [ + "get_account_tax" + ] + }, + "ListAccountTax": { + "methods": [ + "list_account_tax" + ] + }, + "UpdateAccountTax": { + "methods": [ + "update_account_tax" + ] + } + } + } + } + }, + "AccountIssueService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client", + "rpcs": { + "ListAccountIssues": { + "methods": [ + "list_account_issues" + ] + } + } + } + } + }, + "UserService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client", + "rpcs": { + "GetUser": { + "methods": [ + "get_user" + ] + }, + "CreateUser": { + "methods": [ + "create_user" + ] + }, + "DeleteUser": { + "methods": [ + "delete_user" + ] + }, + "UpdateUser": { + "methods": [ + "update_user" + ] + }, + "ListUsers": { + "methods": [ + "list_users" + ] + } + } + } + } + }, + "AccountsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client", + "rpcs": { + "GetAccount": { + "methods": [ + "get_account" + ] + }, + "CreateAndConfigureAccount": { + "methods": [ + "create_and_configure_account" + ] + }, + "DeleteAccount": { + "methods": [ + "delete_account" + ] + }, + "UpdateAccount": { + "methods": [ + "update_account" + ] + }, + "ListAccounts": { + "methods": [ + "list_accounts" + ] + }, + "ListSubAccounts": { + "methods": [ + "list_sub_accounts" + ] + } + } + } + } + }, + "BusinessIdentityService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client", + "rpcs": { + "GetBusinessIdentity": { + "methods": [ + "get_business_identity" + ] + }, + "UpdateBusinessIdentity": { + "methods": [ + "update_business_identity" + ] + } + } + } + } + }, + "BusinessInfoService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client", + "rpcs": { + "GetBusinessInfo": { + "methods": [ + "get_business_info" + ] + }, + "UpdateBusinessInfo": { + "methods": [ + "update_business_info" + ] + } + } + } + } + }, + "EmailPreferencesService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client", + "rpcs": { + "GetEmailPreferences": { + "methods": [ + "get_email_preferences" + ] + }, + "UpdateEmailPreferences": { + "methods": [ + "update_email_preferences" + ] + } + } + } + } + }, + "HomepageService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client", + "rpcs": { + "GetHomepage": { + "methods": [ + "get_homepage" + ] + }, + "UpdateHomepage": { + "methods": [ + "update_homepage" + ] + }, + "ClaimHomepage": { + "methods": [ + "claim_homepage" + ] + }, + "UnclaimHomepage": { + "methods": [ + "unclaim_homepage" + ] + } + } + } + } + }, + "OnlineReturnPolicyService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client", + "rpcs": { + "GetOnlineReturnPolicy": { + "methods": [ + "get_online_return_policy" + ] + }, + "ListOnlineReturnPolicies": { + "methods": [ + "list_online_return_policies" + ] + } + } + } + } + }, + "ProgramsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client", + "rpcs": { + "GetProgram": { + "methods": [ + "get_program" + ] + }, + "ListPrograms": { + "methods": [ + "list_programs" + ] + }, + "EnableProgram": { + "methods": [ + "enable_program" + ] + }, + "DisableProgram": { + "methods": [ + "disable_program" + ] + } + } + } + } + }, + "RegionsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client", + "rpcs": { + "GetRegion": { + "methods": [ + "get_region" + ] + }, + "CreateRegion": { + "methods": [ + "create_region" + ] + }, + "UpdateRegion": { + "methods": [ + "update_region" + ] + }, + "DeleteRegion": { + "methods": [ + "delete_region" + ] + }, + "ListRegions": { + "methods": [ + "list_regions" + ] + } + } + } + } + }, + "ShippingSettingsService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client", + "rpcs": { + "GetShippingSettings": { + "methods": [ + "get_shipping_settings" + ] + }, + "InsertShippingSettings": { + "methods": [ + "insert_shipping_settings" + ] + } + } + } + } + }, + "TermsOfServiceService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client", + "rpcs": { + "GetTermsOfService": { + "methods": [ + "get_terms_of_service" + ] + }, + "RetrieveLatestTermsOfService": { + "methods": [ + "retrieve_latest_terms_of_service" + ] + }, + "AcceptTermsOfService": { + "methods": [ + "accept_terms_of_service" + ] + } + } + } + } + }, + "TermsOfServiceAgreementStateService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client", + "rpcs": { + "GetTermsOfServiceAgreementState": { + "methods": [ + "get_terms_of_service_agreement_state" + ] + }, + "RetrieveForApplicationTermsOfServiceAgreementState": { + "methods": [ + "retrieve_for_application_terms_of_service_agreement_state" + ] + } + } + } + } + } + } +} diff --git a/google-shopping-merchant-accounts-v1beta/google-shopping-merchant-accounts-v1beta.gemspec b/google-shopping-merchant-accounts-v1beta/google-shopping-merchant-accounts-v1beta.gemspec new file mode 100644 index 000000000000..f1fd75ad0680 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/google-shopping-merchant-accounts-v1beta.gemspec @@ -0,0 +1,29 @@ +# -*- ruby -*- +# encoding: utf-8 + +require File.expand_path("lib/google/shopping/merchant/accounts/v1beta/version", __dir__) + +Gem::Specification.new do |gem| + gem.name = "google-shopping-merchant-accounts-v1beta" + gem.version = Google::Shopping::Merchant::Accounts::V1beta::VERSION + + gem.authors = ["Google LLC"] + gem.email = "googleapis-packages@google.com" + gem.description = "Programmatically manage your Merchant Center accounts. Note that google-shopping-merchant-accounts-v1beta is a version-specific client library. For most uses, we recommend installing the main client library google-shopping-merchant-accounts instead. See the readme for more details." + gem.summary = "Programmatically manage your Merchant Center accounts." + gem.homepage = "https://github.com/googleapis/google-cloud-ruby" + gem.license = "Apache-2.0" + + gem.platform = Gem::Platform::RUBY + + gem.files = `git ls-files -- lib/*`.split("\n") + + `git ls-files -- proto_docs/*`.split("\n") + + ["README.md", "LICENSE.md", "AUTHENTICATION.md", ".yardopts"] + gem.require_paths = ["lib"] + + gem.required_ruby_version = ">= 2.7" + + gem.add_dependency "gapic-common", ">= 0.21.1", "< 2.a" + gem.add_dependency "google-cloud-errors", "~> 1.0" + gem.add_dependency "google-shopping-type", "> 0.0", "< 2.a" +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google-shopping-merchant-accounts-v1beta.rb b/google-shopping-merchant-accounts-v1beta/lib/google-shopping-merchant-accounts-v1beta.rb new file mode 100644 index 000000000000..70d9c54980cc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google-shopping-merchant-accounts-v1beta.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# This gem does not autoload during Bundler.require. To load this gem, +# issue explicit require statements for the packages desired, e.g.: +# require "google/shopping/merchant/accounts/v1beta" diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta.rb new file mode 100644 index 000000000000..716e61bbfc5a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/account_tax_service" +require "google/shopping/merchant/accounts/v1beta/account_issue_service" +require "google/shopping/merchant/accounts/v1beta/user_service" +require "google/shopping/merchant/accounts/v1beta/accounts_service" +require "google/shopping/merchant/accounts/v1beta/business_identity_service" +require "google/shopping/merchant/accounts/v1beta/business_info_service" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service" +require "google/shopping/merchant/accounts/v1beta/homepage_service" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service" +require "google/shopping/merchant/accounts/v1beta/programs_service" +require "google/shopping/merchant/accounts/v1beta/regions_service" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service" +require "google/shopping/merchant/accounts/v1beta/version" + +module Google + module Shopping + module Merchant + module Accounts + ## + # API client module. + # + # @example Load this package, including all its services, and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # @example Load this package, including all its services, and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + module V1beta + end + end + end + end +end + +helper_path = ::File.join __dir__, "v1beta", "_helpers.rb" +require "google/shopping/merchant/accounts/v1beta/_helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accessright_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accessright_pb.rb new file mode 100644 index 000000000000..f684f7b2e855 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accessright_pb.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/accessright.proto + +require 'google/protobuf' + + +descriptor_data = "\n:google/shopping/merchant/accounts/v1beta/accessright.proto\x12(google.shopping.merchant.accounts.v1beta*_\n\x0b\x41\x63\x63\x65ssRight\x12\x1c\n\x18\x41\x43\x43\x45SS_RIGHT_UNSPECIFIED\x10\x00\x12\x0c\n\x08STANDARD\x10\x01\x12\t\n\x05\x41\x44MIN\x10\x02\x12\x19\n\x15PERFORMANCE_REPORTING\x10\x03\x42\x92\x01\n,com.google.shopping.merchant.accounts.v1betaB\x10\x41\x63\x63\x65ssRightProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + AccessRight = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccessRight").enummodule + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service.rb new file mode 100644 index 000000000000..63e648ba67f6 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/account_issue_service/credentials" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/paths" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/client" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support `AccountIssueService` API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/account_issue_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new + # + module AccountIssueService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "account_issue_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/client.rb new file mode 100644 index 000000000000..48eab79aadb3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/client.rb @@ -0,0 +1,452 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/accountissue_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + ## + # Client for the AccountIssueService service. + # + # Service to support `AccountIssueService` API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_issue_service_stub + + ## + # Configure the AccountIssueService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountIssueService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountIssueService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_issue_service_stub.universe_domain + end + + ## + # Create a new AccountIssueService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountIssueService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/accountissue_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_issue_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Lists all account issues of a Merchant Center account. + # + # @overload list_account_issues(request, options = nil) + # Pass arguments to `list_account_issues` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_account_issues(parent: nil, page_size: nil, page_token: nil, language_code: nil, time_zone: nil) + # Pass arguments to `list_account_issues` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of issues. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of issues to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccountIssues` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountIssues` must + # match the call that provided the page token. + # @param language_code [::String] + # Optional. The issues in the response will have human-readable fields in the + # given language. The format is [BCP-47](https://tools.ietf.org/html/bcp47), + # such as `en-US` or `sr-Latn`. If not value is provided, `en-US` will be + # used. + # @param time_zone [::Google::Type::TimeZone, ::Hash] + # Optional. The [IANA](https://www.iana.org/time-zones) timezone used to + # localize times in human-readable fields. For example 'America/Los_Angeles'. + # If not set, 'America/Los_Angeles' will be used. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new + # + # # Call the list_account_issues method. + # result = client.list_account_issues request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue. + # p item + # end + # + def list_account_issues request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_account_issues.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_account_issues.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_account_issues.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_issue_service_stub.call_rpc :list_account_issues, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @account_issue_service_stub, :list_account_issues, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountIssueService API. + # + # This class represents the configuration for AccountIssueService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_account_issues to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_issues.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_issues.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the AccountIssueService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_account_issues` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_issues + + # @private + def initialize parent_rpcs = nil + list_account_issues_config = parent_rpcs.list_account_issues if parent_rpcs.respond_to? :list_account_issues + @list_account_issues = ::Gapic::Config::Method.new list_account_issues_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/credentials.rb new file mode 100644 index 000000000000..822d3c10c7e5 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + # Credentials for the AccountIssueService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/paths.rb new file mode 100644 index 000000000000..6fd99f57526b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/paths.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + # Path helper methods for the AccountIssueService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest.rb new file mode 100644 index 000000000000..965fcdbc71b7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/account_issue_service/credentials" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/paths" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support `AccountIssueService` API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new + # + module AccountIssueService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/client.rb new file mode 100644 index 000000000000..7bfe6eb936c2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/client.rb @@ -0,0 +1,419 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/accountissue_pb" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + module Rest + ## + # REST client for the AccountIssueService service. + # + # Service to support `AccountIssueService` API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_issue_service_stub + + ## + # Configure the AccountIssueService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountIssueService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountIssueService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_issue_service_stub.universe_domain + end + + ## + # Create a new AccountIssueService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountIssueService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_issue_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Lists all account issues of a Merchant Center account. + # + # @overload list_account_issues(request, options = nil) + # Pass arguments to `list_account_issues` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_account_issues(parent: nil, page_size: nil, page_token: nil, language_code: nil, time_zone: nil) + # Pass arguments to `list_account_issues` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of issues. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of issues to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccountIssues` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountIssues` must + # match the call that provided the page token. + # @param language_code [::String] + # Optional. The issues in the response will have human-readable fields in the + # given language. The format is [BCP-47](https://tools.ietf.org/html/bcp47), + # such as `en-US` or `sr-Latn`. If not value is provided, `en-US` will be + # used. + # @param time_zone [::Google::Type::TimeZone, ::Hash] + # Optional. The [IANA](https://www.iana.org/time-zones) timezone used to + # localize times in human-readable fields. For example 'America/Los_Angeles'. + # If not set, 'America/Los_Angeles' will be used. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new + # + # # Call the list_account_issues method. + # result = client.list_account_issues request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue. + # p item + # end + # + def list_account_issues request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_account_issues.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_account_issues.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_account_issues.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_issue_service_stub.list_account_issues request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @account_issue_service_stub, :list_account_issues, "account_issues", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountIssueService REST API. + # + # This class represents the configuration for AccountIssueService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_account_issues to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_issues.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_account_issues.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the AccountIssueService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_account_issues` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_issues + + # @private + def initialize parent_rpcs = nil + list_account_issues_config = parent_rpcs.list_account_issues if parent_rpcs.respond_to? :list_account_issues + @list_account_issues = ::Gapic::Config::Method.new list_account_issues_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/service_stub.rb new file mode 100644 index 000000000000..ce0da5ea2506 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_issue_service/rest/service_stub.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/accountissue_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + module Rest + ## + # REST service stub for the AccountIssueService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the list_account_issues REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse] + # A result object deserialized from the server's reply + def list_account_issues request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_account_issues_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the list_account_issues REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_account_issues_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/issues", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_pb.rb new file mode 100644 index 000000000000..c5f602ee88fc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_pb.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/account_tax.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/field_mask_pb' +require 'google/shopping/merchant/accounts/v1beta/tax_rule_pb' + + +descriptor_data = "\n:google/shopping/merchant/accounts/v1beta/account_tax.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/protobuf/field_mask.proto\x1a\x37google/shopping/merchant/accounts/v1beta/tax_rule.proto\"\xe6\x01\n\nAccountTax\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x14\n\x07\x61\x63\x63ount\x18\x02 \x01(\x03\x42\x03\xe0\x41\x03\x12\x44\n\ttax_rules\x18\x03 \x03(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.TaxRule:i\xea\x41\x66\n%merchantapi.googleapis.com/AccountTax\x12#accounts/{account}/accounttax/{tax}*\x0c\x61\x63\x63ountTaxes2\naccountTax\"S\n\x14GetAccountTaxRequest\x12;\n\x04name\x18\x01 \x01(\tB-\xe0\x41\x02\xfa\x41\'\n%merchantapi.googleapis.com/AccountTax\"\x9a\x01\n\x17UpdateAccountTaxRequest\x12N\n\x0b\x61\x63\x63ount_tax\x18\x01 \x01(\x0b\x32\x34.google.shopping.merchant.accounts.v1beta.AccountTaxB\x03\xe0\x41\x02\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\"}\n\x15ListAccountTaxRequest\x12=\n\x06parent\x18\x01 \x01(\tB-\xe0\x41\x02\xfa\x41\'\x12%merchantapi.googleapis.com/AccountTax\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"~\n\x16ListAccountTaxResponse\x12K\n\raccount_taxes\x18\x01 \x03(\x0b\x32\x34.google.shopping.merchant.accounts.v1beta.AccountTax\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\x84\x06\n\x11\x41\x63\x63ountTaxService\x12\xc5\x01\n\rGetAccountTax\x12>.google.shopping.merchant.accounts.v1beta.GetAccountTaxRequest\x1a\x34.google.shopping.merchant.accounts.v1beta.AccountTax\">\xda\x41\x04name\x82\xd3\xe4\x93\x02\x31\x12//accounts/v1beta/{name=accounts/*/accounttax/*}\x12\xd5\x01\n\x0eListAccountTax\x12?.google.shopping.merchant.accounts.v1beta.ListAccountTaxRequest\x1a@.google.shopping.merchant.accounts.v1beta.ListAccountTaxResponse\"@\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x31\x12//accounts/v1beta/{parent=accounts/*}/accounttax\x12\x85\x02\n\x10UpdateAccountTax\x12\x41.google.shopping.merchant.accounts.v1beta.UpdateAccountTaxRequest\x1a\x34.google.shopping.merchant.accounts.v1beta.AccountTax\"x\xda\x41\x17\x61\x63\x63ount_tax,update_mask\xda\x41\x0b\x61\x63\x63ount_tax\x82\xd3\xe4\x93\x02J2;/accounts/v1beta/{account_tax.name=accounts/*/accounttax/*}:\x0b\x61\x63\x63ount_tax\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x91\x01\n,com.google.shopping.merchant.accounts.v1betaB\x0f\x41\x63\x63ountTaxProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.shopping.merchant.accounts.v1beta.TaxRule", "google/shopping/merchant/accounts/v1beta/tax_rule.proto"], + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + AccountTax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccountTax").msgclass + GetAccountTaxRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetAccountTaxRequest").msgclass + UpdateAccountTaxRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateAccountTaxRequest").msgclass + ListAccountTaxRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountTaxRequest").msgclass + ListAccountTaxResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountTaxResponse").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service.rb new file mode 100644 index 000000000000..11f45584b92c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/account_tax_service/credentials" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/paths" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/client" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Manages account level tax setting data. + # + # This API defines the following resource model: + # + # - [AccountTax][google.shopping.merchant.accounts.v1main.AccountTax] + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/account_tax_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + module AccountTaxService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "account_tax_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/client.rb new file mode 100644 index 000000000000..5027728dc4e9 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/client.rb @@ -0,0 +1,633 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/account_tax_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + ## + # Client for the AccountTaxService service. + # + # Manages account level tax setting data. + # + # This API defines the following resource model: + # + # - [AccountTax][google.shopping.merchant.accounts.v1main.AccountTax] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_tax_service_stub + + ## + # Configure the AccountTaxService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountTaxService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountTaxService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_tax_service_stub.universe_domain + end + + ## + # Create a new AccountTaxService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountTaxService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/account_tax_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_tax_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Returns the tax rules that match the conditions of GetAccountTaxRequest + # + # @overload get_account_tax(request, options = nil) + # Pass arguments to `get_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_account_tax(name: nil) + # Pass arguments to `get_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name from which tax settings will be retrieved + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new + # + # # Call the get_account_tax method. + # result = client.get_account_tax request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p result + # + def get_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_account_tax.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.call_rpc :get_account_tax, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the tax settings of the sub-accounts only in your + # Merchant Center account. + # This method can only be called on a multi-client account, otherwise it'll + # return an error. + # + # @overload list_account_tax(request, options = nil) + # Pass arguments to `list_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_account_tax(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of account tax. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of tax settings to return in the response, used for + # paging. + # @param page_token [::String] + # The token returned by the previous request. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountTax>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountTax>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new + # + # # Call the list_account_tax method. + # result = client.list_account_tax request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p item + # end + # + def list_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_account_tax.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.call_rpc :list_account_tax, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @account_tax_service_stub, :list_account_tax, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the tax settings of the account. + # + # @overload update_account_tax(request, options = nil) + # Pass arguments to `update_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_account_tax(account_tax: nil, update_mask: nil) + # Pass arguments to `update_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account_tax [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax, ::Hash] + # Required. The tax setting that will be updated + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # The list of fields to be updated + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new + # + # # Call the update_account_tax method. + # result = client.update_account_tax request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p result + # + def update_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.account_tax&.name + header_params["account_tax.name"] = request.account_tax.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_account_tax.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.call_rpc :update_account_tax, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountTaxService API. + # + # This class represents the configuration for AccountTaxService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_account_tax to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_account_tax.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_account_tax.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the AccountTaxService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account_tax + ## + # RPC-specific configuration for `list_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_tax + ## + # RPC-specific configuration for `update_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account_tax + + # @private + def initialize parent_rpcs = nil + get_account_tax_config = parent_rpcs.get_account_tax if parent_rpcs.respond_to? :get_account_tax + @get_account_tax = ::Gapic::Config::Method.new get_account_tax_config + list_account_tax_config = parent_rpcs.list_account_tax if parent_rpcs.respond_to? :list_account_tax + @list_account_tax = ::Gapic::Config::Method.new list_account_tax_config + update_account_tax_config = parent_rpcs.update_account_tax if parent_rpcs.respond_to? :update_account_tax + @update_account_tax = ::Gapic::Config::Method.new update_account_tax_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/credentials.rb new file mode 100644 index 000000000000..e4b7a26c3834 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + # Credentials for the AccountTaxService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/paths.rb new file mode 100644 index 000000000000..1e4c7de13b23 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + # Path helper methods for the AccountTaxService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified AccountTax resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/accounttax/{tax}` + # + # @param account [String] + # @param tax [String] + # + # @return [::String] + def account_tax_path account:, tax: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/accounttax/#{tax}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest.rb new file mode 100644 index 000000000000..90fff6e5108e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/account_tax_service/credentials" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/paths" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Manages account level tax setting data. + # + # This API defines the following resource model: + # + # - [AccountTax][google.shopping.merchant.accounts.v1main.AccountTax] + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + module AccountTaxService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/client.rb new file mode 100644 index 000000000000..954f09b138a0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/client.rb @@ -0,0 +1,586 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/account_tax_pb" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + module Rest + ## + # REST client for the AccountTaxService service. + # + # Manages account level tax setting data. + # + # This API defines the following resource model: + # + # - [AccountTax][google.shopping.merchant.accounts.v1main.AccountTax] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :account_tax_service_stub + + ## + # Configure the AccountTaxService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountTaxService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountTaxService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @account_tax_service_stub.universe_domain + end + + ## + # Create a new AccountTaxService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountTaxService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @account_tax_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Returns the tax rules that match the conditions of GetAccountTaxRequest + # + # @overload get_account_tax(request, options = nil) + # Pass arguments to `get_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_account_tax(name: nil) + # Pass arguments to `get_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name from which tax settings will be retrieved + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new + # + # # Call the get_account_tax method. + # result = client.get_account_tax request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p result + # + def get_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_account_tax.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.get_account_tax request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the tax settings of the sub-accounts only in your + # Merchant Center account. + # This method can only be called on a multi-client account, otherwise it'll + # return an error. + # + # @overload list_account_tax(request, options = nil) + # Pass arguments to `list_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_account_tax(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of account tax. + # Format: accounts/\\{account} + # @param page_size [::Integer] + # The maximum number of tax settings to return in the response, used for + # paging. + # @param page_token [::String] + # The token returned by the previous request. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountTax>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::AccountTax>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new + # + # # Call the list_account_tax method. + # result = client.list_account_tax request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p item + # end + # + def list_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_account_tax.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.list_account_tax request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @account_tax_service_stub, :list_account_tax, "account_taxes", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the tax settings of the account. + # + # @overload update_account_tax(request, options = nil) + # Pass arguments to `update_account_tax` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_account_tax(account_tax: nil, update_mask: nil) + # Pass arguments to `update_account_tax` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account_tax [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax, ::Hash] + # Required. The tax setting that will be updated + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # The list of fields to be updated + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new + # + # # Call the update_account_tax method. + # result = client.update_account_tax request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + # p result + # + def update_account_tax request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_account_tax.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_account_tax.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_account_tax.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @account_tax_service_stub.update_account_tax request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountTaxService REST API. + # + # This class represents the configuration for AccountTaxService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_account_tax to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_account_tax.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_account_tax.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the AccountTaxService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account_tax + ## + # RPC-specific configuration for `list_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :list_account_tax + ## + # RPC-specific configuration for `update_account_tax` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account_tax + + # @private + def initialize parent_rpcs = nil + get_account_tax_config = parent_rpcs.get_account_tax if parent_rpcs.respond_to? :get_account_tax + @get_account_tax = ::Gapic::Config::Method.new get_account_tax_config + list_account_tax_config = parent_rpcs.list_account_tax if parent_rpcs.respond_to? :list_account_tax + @list_account_tax = ::Gapic::Config::Method.new list_account_tax_config + update_account_tax_config = parent_rpcs.update_account_tax if parent_rpcs.respond_to? :update_account_tax + @update_account_tax = ::Gapic::Config::Method.new update_account_tax_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/service_stub.rb new file mode 100644 index 000000000000..6af2246761a3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_service/rest/service_stub.rb @@ -0,0 +1,249 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/account_tax_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + module Rest + ## + # REST service stub for the AccountTaxService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # A result object deserialized from the server's reply + def get_account_tax request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_account_tax_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse] + # A result object deserialized from the server's reply + def list_account_tax request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_account_tax_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # A result object deserialized from the server's reply + def update_account_tax request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_account_tax_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_account_tax_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/accounttax/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_account_tax_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/accounttax", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_account_tax REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_account_tax_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{account_tax.name}", + body: "account_tax", + matches: [ + ["account_tax.name", %r{^accounts/[^/]+/accounttax/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_services_pb.rb new file mode 100644 index 000000000000..b81fe97a8b32 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/account_tax_services_pb.rb @@ -0,0 +1,58 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/account_tax.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/account_tax_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountTaxService + # Manages account level tax setting data. + # + # This API defines the following resource model: + # + # - [AccountTax][google.shopping.merchant.accounts.v1main.AccountTax] + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.AccountTaxService' + + # Returns the tax rules that match the conditions of GetAccountTaxRequest + rpc :GetAccountTax, ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest, ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax + # Lists the tax settings of the sub-accounts only in your + # Merchant Center account. + # This method can only be called on a multi-client account, otherwise it'll + # return an error. + rpc :ListAccountTax, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse + # Updates the tax settings of the account. + rpc :UpdateAccountTax, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest, ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_pb.rb new file mode 100644 index 000000000000..9c19d3848d1d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_pb.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/accountissue.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/shopping/type/types_pb' +require 'google/type/datetime_pb' + + +descriptor_data = "\n;google/shopping/merchant/accounts/v1beta/accountissue.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/shopping/type/types.proto\x1a\x1agoogle/type/datetime.proto\"\xb7\x06\n\x0c\x41\x63\x63ountIssue\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\r\n\x05title\x18\x02 \x01(\t\x12Q\n\x08severity\x18\x03 \x01(\x0e\x32?.google.shopping.merchant.accounts.v1beta.AccountIssue.Severity\x12i\n\x15impacted_destinations\x18\x04 \x03(\x0b\x32J.google.shopping.merchant.accounts.v1beta.AccountIssue.ImpactedDestination\x12\x0e\n\x06\x64\x65tail\x18\x05 \x01(\t\x12\x19\n\x11\x64ocumentation_uri\x18\x06 \x01(\t\x1a\xde\x02\n\x13ImpactedDestination\x12[\n\x11reporting_context\x18\x01 \x01(\x0e\x32;.google.shopping.type.ReportingContext.ReportingContextEnumH\x00\x88\x01\x01\x12\x62\n\x07impacts\x18\x02 \x03(\x0b\x32Q.google.shopping.merchant.accounts.v1beta.AccountIssue.ImpactedDestination.Impact\x1ap\n\x06Impact\x12\x13\n\x0bregion_code\x18\x01 \x01(\t\x12Q\n\x08severity\x18\x02 \x01(\x0e\x32?.google.shopping.merchant.accounts.v1beta.AccountIssue.SeverityB\x14\n\x12_reporting_context\"M\n\x08Severity\x12\x18\n\x14SEVERITY_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43RITICAL\x10\x01\x12\t\n\x05\x45RROR\x10\x02\x12\x0e\n\nSUGGESTION\x10\x03:l\xea\x41i\n\'merchantapi.googleapis.com/AccountIssue\x12!accounts/{account}/issues/{issue}*\raccountIssues2\x0c\x61\x63\x63ountIssue\"\xd2\x01\n\x18ListAccountIssuesRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\x12\x1a\n\rlanguage_code\x18\x04 \x01(\tB\x03\xe0\x41\x01\x12-\n\ttime_zone\x18\x05 \x01(\x0b\x32\x15.google.type.TimeZoneB\x03\xe0\x41\x01\"\x84\x01\n\x19ListAccountIssuesResponse\x12N\n\x0e\x61\x63\x63ount_issues\x18\x01 \x03(\x0b\x32\x36.google.shopping.merchant.accounts.v1beta.AccountIssue\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xbb\x02\n\x13\x41\x63\x63ountIssueService\x12\xda\x01\n\x11ListAccountIssues\x12\x42.google.shopping.merchant.accounts.v1beta.ListAccountIssuesRequest\x1a\x43.google.shopping.merchant.accounts.v1beta.ListAccountIssuesResponse\"<\xda\x41\x06parent\x82\xd3\xe4\x93\x02-\x12+/accounts/v1beta/{parent=accounts/*}/issues\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x93\x01\n,com.google.shopping.merchant.accounts.v1betaB\x11\x41\x63\x63ountIssueProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.type.TimeZone", "google/type/datetime.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + AccountIssue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccountIssue").msgclass + AccountIssue::ImpactedDestination = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccountIssue.ImpactedDestination").msgclass + AccountIssue::ImpactedDestination::Impact = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccountIssue.ImpactedDestination.Impact").msgclass + AccountIssue::Severity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AccountIssue.Severity").enummodule + ListAccountIssuesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountIssuesRequest").msgclass + ListAccountIssuesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountIssuesResponse").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_services_pb.rb new file mode 100644 index 000000000000..beb0389991ad --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accountissue_services_pb.rb @@ -0,0 +1,47 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/accountissue.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/accountissue_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountIssueService + # Service to support `AccountIssueService` API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.AccountIssueService' + + # Lists all account issues of a Merchant Center account. + rpc :ListAccountIssues, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_pb.rb new file mode 100644 index 000000000000..62ac2a0815a4 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_pb.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/accounts.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' +require 'google/protobuf/field_mask_pb' +require 'google/shopping/merchant/accounts/v1beta/user_pb' +require 'google/type/datetime_pb' + + +descriptor_data = "\n7google/shopping/merchant/accounts/v1beta/accounts.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x33google/shopping/merchant/accounts/v1beta/user.proto\x1a\x1agoogle/type/datetime.proto\"\x8a\x02\n\x07\x41\x63\x63ount\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x17\n\naccount_id\x18\x02 \x01(\x03\x42\x03\xe0\x41\x03\x12\x19\n\x0c\x61\x63\x63ount_name\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\x15\n\radult_content\x18\x04 \x01(\x08\x12\x19\n\x0ctest_account\x18\x05 \x01(\x08\x42\x03\xe0\x41\x03\x12-\n\ttime_zone\x18\x06 \x01(\x0b\x32\x15.google.type.TimeZoneB\x03\xe0\x41\x02\x12\x1a\n\rlanguage_code\x18\x07 \x01(\tB\x03\xe0\x41\x02:;\xea\x41\x38\n\"merchantapi.googleapis.com/Account\x12\x12\x61\x63\x63ounts/{account}\"M\n\x11GetAccountRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\"\xf9\x05\n CreateAndConfigureAccountRequest\x12G\n\x07\x61\x63\x63ount\x18\x01 \x01(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.AccountB\x03\xe0\x41\x02\x12O\n\x05users\x18\x02 \x03(\x0b\x32;.google.shopping.merchant.accounts.v1beta.CreateUserRequestB\x03\xe0\x41\x01\x12\x8a\x01\n\x17\x61\x63\x63\x65pt_terms_of_service\x18\x03 \x01(\x0b\x32_.google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest.AcceptTermsOfServiceB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12r\n\x07service\x18\x04 \x03(\x0b\x32\\.google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest.AddAccountServiceB\x03\xe0\x41\x01\x1aq\n\x14\x41\x63\x63\x65ptTermsOfService\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\x12\x18\n\x0bregion_code\x18\x03 \x01(\tB\x03\xe0\x41\x02\x1a\xaa\x01\n\x11\x41\x64\x64\x41\x63\x63ountService\x12\x35\n\x13\x61\x63\x63ount_aggregation\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x41\n\x08provider\x18\x01 \x01(\tB*\xe0\x41\x01\xfa\x41$\n\"merchantapi.googleapis.com/AccountH\x01\x88\x01\x01\x42\x0e\n\x0cservice_typeB\x0b\n\t_providerB\x1a\n\x18_accept_terms_of_service\"P\n\x14\x44\x65leteAccountRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\"\x95\x01\n\x14UpdateAccountRequest\x12G\n\x07\x61\x63\x63ount\x18\x01 \x01(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.AccountB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\"[\n\x13ListAccountsRequest\x12\x16\n\tpage_size\x18\x01 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x13\n\x06\x66ilter\x18\x03 \x01(\tB\x03\xe0\x41\x01\"t\n\x14ListAccountsResponse\x12\x43\n\x08\x61\x63\x63ounts\x18\x01 \x03(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.Account\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x87\x01\n\x16ListSubAccountsRequest\x12<\n\x08provider\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\"w\n\x17ListSubAccountsResponse\x12\x43\n\x08\x61\x63\x63ounts\x18\x01 \x03(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.Account\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xee\t\n\x0f\x41\x63\x63ountsService\x12\xaf\x01\n\nGetAccount\x12;.google.shopping.merchant.accounts.v1beta.GetAccountRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Account\"1\xda\x41\x04name\x82\xd3\xe4\x93\x02$\x12\"/accounts/v1beta/{name=accounts/*}\x12\xd3\x01\n\x19\x43reateAndConfigureAccount\x12J.google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Account\"7\x82\xd3\xe4\x93\x02\x31\",/accounts/v1beta/accounts:createAndConfigure:\x01*\x12\x9a\x01\n\rDeleteAccount\x12>.google.shopping.merchant.accounts.v1beta.DeleteAccountRequest\x1a\x16.google.protobuf.Empty\"1\xda\x41\x04name\x82\xd3\xe4\x93\x02$*\"/accounts/v1beta/{name=accounts/*}\x12\xd5\x01\n\rUpdateAccount\x12>.google.shopping.merchant.accounts.v1beta.UpdateAccountRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Account\"Q\xda\x41\x13\x61\x63\x63ount,update_mask\x82\xd3\xe4\x93\x02\x35\x32*/accounts/v1beta/{account.name=accounts/*}:\x07\x61\x63\x63ount\x12\xb0\x01\n\x0cListAccounts\x12=.google.shopping.merchant.accounts.v1beta.ListAccountsRequest\x1a>.google.shopping.merchant.accounts.v1beta.ListAccountsResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/accounts/v1beta/accounts\x12\xe1\x01\n\x0fListSubAccounts\x12@.google.shopping.merchant.accounts.v1beta.ListSubAccountsRequest\x1a\x41.google.shopping.merchant.accounts.v1beta.ListSubAccountsResponse\"I\xda\x41\x08provider\x82\xd3\xe4\x93\x02\x38\x12\x36/accounts/v1beta/{provider=accounts/*}:listSubaccounts\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x8f\x01\n,com.google.shopping.merchant.accounts.v1betaB\rAccountsProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.type.TimeZone", "google/type/datetime.proto"], + ["google.shopping.merchant.accounts.v1beta.CreateUserRequest", "google/shopping/merchant/accounts/v1beta/user.proto"], + ["google.protobuf.Empty", "google/protobuf/empty.proto"], + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + Account = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Account").msgclass + GetAccountRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetAccountRequest").msgclass + CreateAndConfigureAccountRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest").msgclass + CreateAndConfigureAccountRequest::AcceptTermsOfService = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest.AcceptTermsOfService").msgclass + CreateAndConfigureAccountRequest::AddAccountService = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CreateAndConfigureAccountRequest.AddAccountService").msgclass + DeleteAccountRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.DeleteAccountRequest").msgclass + UpdateAccountRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateAccountRequest").msgclass + ListAccountsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountsRequest").msgclass + ListAccountsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListAccountsResponse").msgclass + ListSubAccountsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListSubAccountsRequest").msgclass + ListSubAccountsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListSubAccountsResponse").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service.rb new file mode 100644 index 000000000000..18f1e2339d92 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/accounts_service/credentials" +require "google/shopping/merchant/accounts/v1beta/accounts_service/paths" +require "google/shopping/merchant/accounts/v1beta/accounts_service/client" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support Accounts API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/accounts_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/accounts_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + module AccountsService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "accounts_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/accounts_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/client.rb new file mode 100644 index 000000000000..3fc57934153f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/client.rb @@ -0,0 +1,942 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/accounts_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + ## + # Client for the AccountsService service. + # + # Service to support Accounts API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :accounts_service_stub + + ## + # Configure the AccountsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @accounts_service_stub.universe_domain + end + + ## + # Create a new AccountsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/accounts_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @accounts_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves an account from your Merchant Center account. + # After inserting, updating, or deleting an account, it may take several + # minutes before changes take effect. + # + # @overload get_account(request, options = nil) + # Pass arguments to `get_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_account(name: nil) + # Pass arguments to `get_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the account to retrieve. + # Format: `accounts/{account}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new + # + # # Call the get_account method. + # result = client.get_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def get_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_account.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :get_account, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a standalone Merchant Center account with additional configuration. + # Adds the user that makes the request as an admin for the new account. + # + # @overload create_and_configure_account(request, options = nil) + # Pass arguments to `create_and_configure_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload create_and_configure_account(account: nil, users: nil, accept_terms_of_service: nil, service: nil) + # Pass arguments to `create_and_configure_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account [::Google::Shopping::Merchant::Accounts::V1beta::Account, ::Hash] + # Required. The account to be created. + # @param users [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, ::Hash>] + # Optional. Users to be added to the account. + # @param accept_terms_of_service [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AcceptTermsOfService, ::Hash] + # Optional. The Terms of Service (ToS) to be accepted immediately upon + # account creation. + # @param service [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AddAccountService, ::Hash>] + # Optional. If specified, an account service between the account to be + # created and the provider account is initialized as part of the + # creation. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new + # + # # Call the create_and_configure_account method. + # result = client.create_and_configure_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def create_and_configure_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.create_and_configure_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.create_and_configure_account.timeout, + metadata: metadata, + retry_policy: @config.rpcs.create_and_configure_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :create_and_configure_account, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes the specified account regardless of its type: standalone, MCA or + # sub-account. Deleting an MCA leads to the deletion of all of its + # sub-accounts. Executing this method requires admin access. + # + # @overload delete_account(request, options = nil) + # Pass arguments to `delete_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload delete_account(name: nil) + # Pass arguments to `delete_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the account to delete. + # Format: `accounts/{account}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new + # + # # Call the delete_account method. + # result = client.delete_account request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.delete_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.delete_account.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :delete_account, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates an account regardless of its type: standalone, MCA or sub-account. + # Executing this method requires admin access. + # + # @overload update_account(request, options = nil) + # Pass arguments to `update_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_account(account: nil, update_mask: nil) + # Pass arguments to `update_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account [::Google::Shopping::Merchant::Accounts::V1beta::Account, ::Hash] + # Required. The new version of the account. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new + # + # # Call the update_account method. + # result = client.update_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def update_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.account&.name + header_params["account.name"] = request.account.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_account.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :update_account, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists accounts accessible to the calling user and matching the + # constraints of the request such as page size or filters. + # This is not just listing the sub-accounts of an MCA, but all accounts the + # calling user has access to including other MCAs, linked accounts, + # standalone accounts and so on. + # + # @overload list_accounts(request, options = nil) + # Pass arguments to `list_accounts` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_accounts(page_size: nil, page_token: nil, filter: nil) + # Pass arguments to `list_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + # @param filter [::String] + # Optional. Returns only accounts that match the + # [filter](/merchant/api/guides/accounts/filter). + # For more details, see the + # [filter syntax reference](/merchant/api/guides/accounts/filter-syntax). + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new + # + # # Call the list_accounts method. + # result = client.list_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + # p item + # end + # + def list_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_accounts.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :list_accounts, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @accounts_service_stub, :list_accounts, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # List all sub-accounts for a given multi client account. This is a + # convenience wrapper for the more powerful `ListAccounts` method. This + # method will produce the same results as calling `ListsAccounts` with the + # following filter: + # `relationship(providerId={parent} AND service(type="ACCOUNT_AGGREGATION"))` + # + # @overload list_sub_accounts(request, options = nil) + # Pass arguments to `list_sub_accounts` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_sub_accounts(provider: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_sub_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param provider [::String] + # Required. The parent account. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new + # + # # Call the list_sub_accounts method. + # result = client.list_sub_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + # p item + # end + # + def list_sub_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_sub_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.provider + header_params["provider"] = request.provider + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_sub_accounts.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_sub_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.call_rpc :list_sub_accounts, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @accounts_service_stub, :list_sub_accounts, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountsService API. + # + # This class represents the configuration for AccountsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_account to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_account.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_account.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the AccountsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_account` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account + ## + # RPC-specific configuration for `create_and_configure_account` + # @return [::Gapic::Config::Method] + # + attr_reader :create_and_configure_account + ## + # RPC-specific configuration for `delete_account` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_account + ## + # RPC-specific configuration for `update_account` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account + ## + # RPC-specific configuration for `list_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_accounts + ## + # RPC-specific configuration for `list_sub_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_sub_accounts + + # @private + def initialize parent_rpcs = nil + get_account_config = parent_rpcs.get_account if parent_rpcs.respond_to? :get_account + @get_account = ::Gapic::Config::Method.new get_account_config + create_and_configure_account_config = parent_rpcs.create_and_configure_account if parent_rpcs.respond_to? :create_and_configure_account + @create_and_configure_account = ::Gapic::Config::Method.new create_and_configure_account_config + delete_account_config = parent_rpcs.delete_account if parent_rpcs.respond_to? :delete_account + @delete_account = ::Gapic::Config::Method.new delete_account_config + update_account_config = parent_rpcs.update_account if parent_rpcs.respond_to? :update_account + @update_account = ::Gapic::Config::Method.new update_account_config + list_accounts_config = parent_rpcs.list_accounts if parent_rpcs.respond_to? :list_accounts + @list_accounts = ::Gapic::Config::Method.new list_accounts_config + list_sub_accounts_config = parent_rpcs.list_sub_accounts if parent_rpcs.respond_to? :list_sub_accounts + @list_sub_accounts = ::Gapic::Config::Method.new list_sub_accounts_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/credentials.rb new file mode 100644 index 000000000000..22e14b80f71b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + # Credentials for the AccountsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/paths.rb new file mode 100644 index 000000000000..a6bf7fb49145 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/paths.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + # Path helper methods for the AccountsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified TermsOfService resource string. + # + # The resource will be in the following format: + # + # `termsOfService/{version}` + # + # @param version [String] + # + # @return [::String] + def terms_of_service_path version: + "termsOfService/#{version}" + end + + ## + # Create a fully-qualified User resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/users/{email}` + # + # @param account [String] + # @param email [String] + # + # @return [::String] + def user_path account:, email: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/users/#{email}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest.rb new file mode 100644 index 000000000000..08b13a530f7d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/accounts_service/credentials" +require "google/shopping/merchant/accounts/v1beta/accounts_service/paths" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support Accounts API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/accounts_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + module AccountsService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/client.rb new file mode 100644 index 000000000000..370db773cca5 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/client.rb @@ -0,0 +1,890 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/accounts_pb" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + module Rest + ## + # REST client for the AccountsService service. + # + # Service to support Accounts API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :accounts_service_stub + + ## + # Configure the AccountsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all AccountsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the AccountsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @accounts_service_stub.universe_domain + end + + ## + # Create a new AccountsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the AccountsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @accounts_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves an account from your Merchant Center account. + # After inserting, updating, or deleting an account, it may take several + # minutes before changes take effect. + # + # @overload get_account(request, options = nil) + # Pass arguments to `get_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_account(name: nil) + # Pass arguments to `get_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the account to retrieve. + # Format: `accounts/{account}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new + # + # # Call the get_account method. + # result = client.get_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def get_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_account.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.get_account request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a standalone Merchant Center account with additional configuration. + # Adds the user that makes the request as an admin for the new account. + # + # @overload create_and_configure_account(request, options = nil) + # Pass arguments to `create_and_configure_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload create_and_configure_account(account: nil, users: nil, accept_terms_of_service: nil, service: nil) + # Pass arguments to `create_and_configure_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account [::Google::Shopping::Merchant::Accounts::V1beta::Account, ::Hash] + # Required. The account to be created. + # @param users [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, ::Hash>] + # Optional. Users to be added to the account. + # @param accept_terms_of_service [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AcceptTermsOfService, ::Hash] + # Optional. The Terms of Service (ToS) to be accepted immediately upon + # account creation. + # @param service [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AddAccountService, ::Hash>] + # Optional. If specified, an account service between the account to be + # created and the provider account is initialized as part of the + # creation. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new + # + # # Call the create_and_configure_account method. + # result = client.create_and_configure_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def create_and_configure_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.create_and_configure_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.create_and_configure_account.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.create_and_configure_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.create_and_configure_account request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes the specified account regardless of its type: standalone, MCA or + # sub-account. Deleting an MCA leads to the deletion of all of its + # sub-accounts. Executing this method requires admin access. + # + # @overload delete_account(request, options = nil) + # Pass arguments to `delete_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload delete_account(name: nil) + # Pass arguments to `delete_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the account to delete. + # Format: `accounts/{account}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new + # + # # Call the delete_account method. + # result = client.delete_account request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.delete_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.delete_account.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.delete_account request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates an account regardless of its type: standalone, MCA or sub-account. + # Executing this method requires admin access. + # + # @overload update_account(request, options = nil) + # Pass arguments to `update_account` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_account(account: nil, update_mask: nil) + # Pass arguments to `update_account` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param account [::Google::Shopping::Merchant::Accounts::V1beta::Account, ::Hash] + # Required. The new version of the account. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new + # + # # Call the update_account method. + # result = client.update_account request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + # p result + # + def update_account request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_account.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_account.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_account.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.update_account request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists accounts accessible to the calling user and matching the + # constraints of the request such as page size or filters. + # This is not just listing the sub-accounts of an MCA, but all accounts the + # calling user has access to including other MCAs, linked accounts, + # standalone accounts and so on. + # + # @overload list_accounts(request, options = nil) + # Pass arguments to `list_accounts` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_accounts(page_size: nil, page_token: nil, filter: nil) + # Pass arguments to `list_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + # @param filter [::String] + # Optional. Returns only accounts that match the + # [filter](/merchant/api/guides/accounts/filter). + # For more details, see the + # [filter syntax reference](/merchant/api/guides/accounts/filter-syntax). + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new + # + # # Call the list_accounts method. + # result = client.list_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + # p item + # end + # + def list_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_accounts.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.list_accounts request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @accounts_service_stub, :list_accounts, "accounts", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # List all sub-accounts for a given multi client account. This is a + # convenience wrapper for the more powerful `ListAccounts` method. This + # method will produce the same results as calling `ListsAccounts` with the + # following filter: + # `relationship(providerId={parent} AND service(type="ACCOUNT_AGGREGATION"))` + # + # @overload list_sub_accounts(request, options = nil) + # Pass arguments to `list_sub_accounts` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_sub_accounts(provider: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_sub_accounts` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param provider [::String] + # Required. The parent account. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new + # + # # Call the list_sub_accounts method. + # result = client.list_sub_accounts request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + # p item + # end + # + def list_sub_accounts request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_sub_accounts.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_sub_accounts.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_sub_accounts.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @accounts_service_stub.list_sub_accounts request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @accounts_service_stub, :list_sub_accounts, "accounts", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the AccountsService REST API. + # + # This class represents the configuration for AccountsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_account to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_account.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_account.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the AccountsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_account` + # @return [::Gapic::Config::Method] + # + attr_reader :get_account + ## + # RPC-specific configuration for `create_and_configure_account` + # @return [::Gapic::Config::Method] + # + attr_reader :create_and_configure_account + ## + # RPC-specific configuration for `delete_account` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_account + ## + # RPC-specific configuration for `update_account` + # @return [::Gapic::Config::Method] + # + attr_reader :update_account + ## + # RPC-specific configuration for `list_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_accounts + ## + # RPC-specific configuration for `list_sub_accounts` + # @return [::Gapic::Config::Method] + # + attr_reader :list_sub_accounts + + # @private + def initialize parent_rpcs = nil + get_account_config = parent_rpcs.get_account if parent_rpcs.respond_to? :get_account + @get_account = ::Gapic::Config::Method.new get_account_config + create_and_configure_account_config = parent_rpcs.create_and_configure_account if parent_rpcs.respond_to? :create_and_configure_account + @create_and_configure_account = ::Gapic::Config::Method.new create_and_configure_account_config + delete_account_config = parent_rpcs.delete_account if parent_rpcs.respond_to? :delete_account + @delete_account = ::Gapic::Config::Method.new delete_account_config + update_account_config = parent_rpcs.update_account if parent_rpcs.respond_to? :update_account + @update_account = ::Gapic::Config::Method.new update_account_config + list_accounts_config = parent_rpcs.list_accounts if parent_rpcs.respond_to? :list_accounts + @list_accounts = ::Gapic::Config::Method.new list_accounts_config + list_sub_accounts_config = parent_rpcs.list_sub_accounts if parent_rpcs.respond_to? :list_sub_accounts + @list_sub_accounts = ::Gapic::Config::Method.new list_sub_accounts_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/service_stub.rb new file mode 100644 index 000000000000..a179094465b2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_service/rest/service_stub.rb @@ -0,0 +1,423 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/accounts_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + module Rest + ## + # REST service stub for the AccountsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # A result object deserialized from the server's reply + def get_account request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_account_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the create_and_configure_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # A result object deserialized from the server's reply + def create_and_configure_account request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_create_and_configure_account_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the delete_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_account request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_account_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # A result object deserialized from the server's reply + def update_account request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_account_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_accounts REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse] + # A result object deserialized from the server's reply + def list_accounts request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_accounts_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_sub_accounts REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse] + # A result object deserialized from the server's reply + def list_sub_accounts request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_sub_accounts_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_account_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the create_and_configure_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_create_and_configure_account_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/accounts:createAndConfigure", + body: "*", + matches: [] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_account_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_account REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_account_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{account.name}", + body: "account", + matches: [ + ["account.name", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_accounts REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_accounts_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/accounts", + matches: [] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_sub_accounts REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_sub_accounts_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{provider}:listSubaccounts", + matches: [ + ["provider", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_services_pb.rb new file mode 100644 index 000000000000..63e06cc0e17c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/accounts_services_pb.rb @@ -0,0 +1,71 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/accounts.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/accounts_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module AccountsService + # Service to support Accounts API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.AccountsService' + + # Retrieves an account from your Merchant Center account. + # After inserting, updating, or deleting an account, it may take several + # minutes before changes take effect. + rpc :GetAccount, ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Account + # Creates a standalone Merchant Center account with additional configuration. + # Adds the user that makes the request as an admin for the new account. + rpc :CreateAndConfigureAccount, ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Account + # Deletes the specified account regardless of its type: standalone, MCA or + # sub-account. Deleting an MCA leads to the deletion of all of its + # sub-accounts. Executing this method requires admin access. + rpc :DeleteAccount, ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest, ::Google::Protobuf::Empty + # Updates an account regardless of its type: standalone, MCA or sub-account. + # Executing this method requires admin access. + rpc :UpdateAccount, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Account + # Lists accounts accessible to the calling user and matching the + # constraints of the request such as page size or filters. + # This is not just listing the sub-accounts of an MCA, but all accounts the + # calling user has access to including other MCAs, linked accounts, + # standalone accounts and so on. + rpc :ListAccounts, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse + # List all sub-accounts for a given multi client account. This is a + # convenience wrapper for the more powerful `ListAccounts` method. This + # method will produce the same results as calling `ListsAccounts` with the + # following filter: + # `relationship(providerId={parent} AND service(type="ACCOUNT_AGGREGATION"))` + rpc :ListSubAccounts, ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service.rb new file mode 100644 index 000000000000..41f73b473560 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/business_identity_service/credentials" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/paths" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/client" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support [business + # identity](https://support.google.com/merchants/answer/12564247) API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/business_identity_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new + # + module BusinessIdentityService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "business_identity_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/client.rb new file mode 100644 index 000000000000..a5e2a6023340 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/client.rb @@ -0,0 +1,525 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/businessidentity_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + ## + # Client for the BusinessIdentityService service. + # + # Service to support [business + # identity](https://support.google.com/merchants/answer/12564247) API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :business_identity_service_stub + + ## + # Configure the BusinessIdentityService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BusinessIdentityService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BusinessIdentityService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @business_identity_service_stub.universe_domain + end + + ## + # Create a new BusinessIdentityService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BusinessIdentityService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/businessidentity_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @business_identity_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves the business identity of an account. + # + # @overload get_business_identity(request, options = nil) + # Pass arguments to `get_business_identity` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_business_identity(name: nil) + # Pass arguments to `get_business_identity` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the business identity. + # Format: `accounts/{account}/businessIdentity` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new + # + # # Call the get_business_identity method. + # result = client.get_business_identity request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + # p result + # + def get_business_identity request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_business_identity.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_business_identity.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_business_identity.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_identity_service_stub.call_rpc :get_business_identity, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the business identity of an account. Executing this method requires + # admin access. + # + # @overload update_business_identity(request, options = nil) + # Pass arguments to `update_business_identity` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_business_identity(business_identity: nil, update_mask: nil) + # Pass arguments to `update_business_identity` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param business_identity [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity, ::Hash] + # Required. The new version of the business identity. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new + # + # # Call the update_business_identity method. + # result = client.update_business_identity request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + # p result + # + def update_business_identity request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_business_identity.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.business_identity&.name + header_params["business_identity.name"] = request.business_identity.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_business_identity.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_business_identity.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_identity_service_stub.call_rpc :update_business_identity, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BusinessIdentityService API. + # + # This class represents the configuration for BusinessIdentityService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_business_identity to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_identity.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_identity.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the BusinessIdentityService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_business_identity` + # @return [::Gapic::Config::Method] + # + attr_reader :get_business_identity + ## + # RPC-specific configuration for `update_business_identity` + # @return [::Gapic::Config::Method] + # + attr_reader :update_business_identity + + # @private + def initialize parent_rpcs = nil + get_business_identity_config = parent_rpcs.get_business_identity if parent_rpcs.respond_to? :get_business_identity + @get_business_identity = ::Gapic::Config::Method.new get_business_identity_config + update_business_identity_config = parent_rpcs.update_business_identity if parent_rpcs.respond_to? :update_business_identity + @update_business_identity = ::Gapic::Config::Method.new update_business_identity_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/credentials.rb new file mode 100644 index 000000000000..5950a8fac1ae --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + # Credentials for the BusinessIdentityService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/paths.rb new file mode 100644 index 000000000000..6e2fab9b3345 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/paths.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + # Path helper methods for the BusinessIdentityService API. + module Paths + ## + # Create a fully-qualified BusinessIdentity resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/businessIdentity` + # + # @param account [String] + # + # @return [::String] + def business_identity_path account: + "accounts/#{account}/businessIdentity" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest.rb new file mode 100644 index 000000000000..682080fc9043 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/business_identity_service/credentials" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/paths" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support [business + # identity](https://support.google.com/merchants/answer/12564247) API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new + # + module BusinessIdentityService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/client.rb new file mode 100644 index 000000000000..9033d7cc6244 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/client.rb @@ -0,0 +1,485 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/businessidentity_pb" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + module Rest + ## + # REST client for the BusinessIdentityService service. + # + # Service to support [business + # identity](https://support.google.com/merchants/answer/12564247) API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :business_identity_service_stub + + ## + # Configure the BusinessIdentityService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BusinessIdentityService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BusinessIdentityService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @business_identity_service_stub.universe_domain + end + + ## + # Create a new BusinessIdentityService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BusinessIdentityService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @business_identity_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves the business identity of an account. + # + # @overload get_business_identity(request, options = nil) + # Pass arguments to `get_business_identity` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_business_identity(name: nil) + # Pass arguments to `get_business_identity` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the business identity. + # Format: `accounts/{account}/businessIdentity` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new + # + # # Call the get_business_identity method. + # result = client.get_business_identity request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + # p result + # + def get_business_identity request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_business_identity.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_business_identity.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_business_identity.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_identity_service_stub.get_business_identity request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the business identity of an account. Executing this method requires + # admin access. + # + # @overload update_business_identity(request, options = nil) + # Pass arguments to `update_business_identity` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_business_identity(business_identity: nil, update_mask: nil) + # Pass arguments to `update_business_identity` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param business_identity [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity, ::Hash] + # Required. The new version of the business identity. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new + # + # # Call the update_business_identity method. + # result = client.update_business_identity request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + # p result + # + def update_business_identity request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_business_identity.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_business_identity.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_business_identity.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_identity_service_stub.update_business_identity request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BusinessIdentityService REST API. + # + # This class represents the configuration for BusinessIdentityService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_business_identity to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_identity.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_identity.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the BusinessIdentityService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_business_identity` + # @return [::Gapic::Config::Method] + # + attr_reader :get_business_identity + ## + # RPC-specific configuration for `update_business_identity` + # @return [::Gapic::Config::Method] + # + attr_reader :update_business_identity + + # @private + def initialize parent_rpcs = nil + get_business_identity_config = parent_rpcs.get_business_identity if parent_rpcs.respond_to? :get_business_identity + @get_business_identity = ::Gapic::Config::Method.new get_business_identity_config + update_business_identity_config = parent_rpcs.update_business_identity if parent_rpcs.respond_to? :update_business_identity + @update_business_identity = ::Gapic::Config::Method.new update_business_identity_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/service_stub.rb new file mode 100644 index 000000000000..ce65d39c8e69 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_identity_service/rest/service_stub.rb @@ -0,0 +1,190 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/businessidentity_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + module Rest + ## + # REST service stub for the BusinessIdentityService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_business_identity REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # A result object deserialized from the server's reply + def get_business_identity request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_business_identity_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_business_identity REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # A result object deserialized from the server's reply + def update_business_identity request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_business_identity_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_business_identity REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_business_identity_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/businessIdentity/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_business_identity REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_business_identity_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{business_identity.name}", + body: "business_identity", + matches: [ + ["business_identity.name", %r{^accounts/[^/]+/businessIdentity/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service.rb new file mode 100644 index 000000000000..b64f8c7fe773 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/business_info_service/credentials" +require "google/shopping/merchant/accounts/v1beta/business_info_service/paths" +require "google/shopping/merchant/accounts/v1beta/business_info_service/client" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support business info API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/business_info_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/business_info_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new + # + module BusinessInfoService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "business_info_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/business_info_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/client.rb new file mode 100644 index 000000000000..944bd0d6020d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/client.rb @@ -0,0 +1,524 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/businessinfo_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + ## + # Client for the BusinessInfoService service. + # + # Service to support business info API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :business_info_service_stub + + ## + # Configure the BusinessInfoService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BusinessInfoService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BusinessInfoService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @business_info_service_stub.universe_domain + end + + ## + # Create a new BusinessInfoService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BusinessInfoService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/businessinfo_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @business_info_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves the business info of an account. + # + # @overload get_business_info(request, options = nil) + # Pass arguments to `get_business_info` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_business_info(name: nil) + # Pass arguments to `get_business_info` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the business info. + # Format: `accounts/{account}/businessInfo` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new + # + # # Call the get_business_info method. + # result = client.get_business_info request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + # p result + # + def get_business_info request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_business_info.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_business_info.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_business_info.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_info_service_stub.call_rpc :get_business_info, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the business info of an account. Executing this method requires + # admin access. + # + # @overload update_business_info(request, options = nil) + # Pass arguments to `update_business_info` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_business_info(business_info: nil, update_mask: nil) + # Pass arguments to `update_business_info` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param business_info [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo, ::Hash] + # Required. The new version of the business info. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new + # + # # Call the update_business_info method. + # result = client.update_business_info request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + # p result + # + def update_business_info request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_business_info.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.business_info&.name + header_params["business_info.name"] = request.business_info.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_business_info.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_business_info.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_info_service_stub.call_rpc :update_business_info, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BusinessInfoService API. + # + # This class represents the configuration for BusinessInfoService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_business_info to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_info.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_info.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the BusinessInfoService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_business_info` + # @return [::Gapic::Config::Method] + # + attr_reader :get_business_info + ## + # RPC-specific configuration for `update_business_info` + # @return [::Gapic::Config::Method] + # + attr_reader :update_business_info + + # @private + def initialize parent_rpcs = nil + get_business_info_config = parent_rpcs.get_business_info if parent_rpcs.respond_to? :get_business_info + @get_business_info = ::Gapic::Config::Method.new get_business_info_config + update_business_info_config = parent_rpcs.update_business_info if parent_rpcs.respond_to? :update_business_info + @update_business_info = ::Gapic::Config::Method.new update_business_info_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/credentials.rb new file mode 100644 index 000000000000..95026b624c5b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + # Credentials for the BusinessInfoService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/paths.rb new file mode 100644 index 000000000000..fcc6491afebe --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/paths.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + # Path helper methods for the BusinessInfoService API. + module Paths + ## + # Create a fully-qualified BusinessInfo resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/businessInfo` + # + # @param account [String] + # + # @return [::String] + def business_info_path account: + "accounts/#{account}/businessInfo" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest.rb new file mode 100644 index 000000000000..20d4007227f3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/business_info_service/credentials" +require "google/shopping/merchant/accounts/v1beta/business_info_service/paths" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support business info API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/business_info_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new + # + module BusinessInfoService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/client.rb new file mode 100644 index 000000000000..a9f4978f9eb2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/client.rb @@ -0,0 +1,484 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/businessinfo_pb" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + module Rest + ## + # REST client for the BusinessInfoService service. + # + # Service to support business info API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :business_info_service_stub + + ## + # Configure the BusinessInfoService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BusinessInfoService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BusinessInfoService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @business_info_service_stub.universe_domain + end + + ## + # Create a new BusinessInfoService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BusinessInfoService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @business_info_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves the business info of an account. + # + # @overload get_business_info(request, options = nil) + # Pass arguments to `get_business_info` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_business_info(name: nil) + # Pass arguments to `get_business_info` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the business info. + # Format: `accounts/{account}/businessInfo` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new + # + # # Call the get_business_info method. + # result = client.get_business_info request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + # p result + # + def get_business_info request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_business_info.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_business_info.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_business_info.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_info_service_stub.get_business_info request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the business info of an account. Executing this method requires + # admin access. + # + # @overload update_business_info(request, options = nil) + # Pass arguments to `update_business_info` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_business_info(business_info: nil, update_mask: nil) + # Pass arguments to `update_business_info` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param business_info [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo, ::Hash] + # Required. The new version of the business info. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new + # + # # Call the update_business_info method. + # result = client.update_business_info request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + # p result + # + def update_business_info request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_business_info.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_business_info.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_business_info.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @business_info_service_stub.update_business_info request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BusinessInfoService REST API. + # + # This class represents the configuration for BusinessInfoService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_business_info to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_info.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_business_info.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the BusinessInfoService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_business_info` + # @return [::Gapic::Config::Method] + # + attr_reader :get_business_info + ## + # RPC-specific configuration for `update_business_info` + # @return [::Gapic::Config::Method] + # + attr_reader :update_business_info + + # @private + def initialize parent_rpcs = nil + get_business_info_config = parent_rpcs.get_business_info if parent_rpcs.respond_to? :get_business_info + @get_business_info = ::Gapic::Config::Method.new get_business_info_config + update_business_info_config = parent_rpcs.update_business_info if parent_rpcs.respond_to? :update_business_info + @update_business_info = ::Gapic::Config::Method.new update_business_info_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/service_stub.rb new file mode 100644 index 000000000000..e5855a73e748 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/business_info_service/rest/service_stub.rb @@ -0,0 +1,190 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/businessinfo_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + module Rest + ## + # REST service stub for the BusinessInfoService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_business_info REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # A result object deserialized from the server's reply + def get_business_info request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_business_info_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_business_info REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # A result object deserialized from the server's reply + def update_business_info request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_business_info_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_business_info REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_business_info_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/businessInfo/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_business_info REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_business_info_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{business_info.name}", + body: "business_info", + matches: [ + ["business_info.name", %r{^accounts/[^/]+/businessInfo/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_pb.rb new file mode 100644 index 000000000000..d5ba19f9f209 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_pb.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/businessidentity.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/field_mask_pb' + + +descriptor_data = "\n?google/shopping/merchant/accounts/v1beta/businessidentity.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/protobuf/field_mask.proto\"\xa5\t\n\x10\x42usinessIdentity\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12m\n\x12promotions_consent\x18\x02 \x01(\x0e\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.PromotionsConsentB\x03\xe0\x41\x01\x12\x66\n\x0b\x62lack_owned\x18\x03 \x01(\x0b\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttributeB\x03\xe0\x41\x01\x12\x66\n\x0bwomen_owned\x18\x04 \x01(\x0b\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttributeB\x03\xe0\x41\x01\x12h\n\rveteran_owned\x18\x05 \x01(\x0b\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttributeB\x03\xe0\x41\x01\x12g\n\x0clatino_owned\x18\x06 \x01(\x0b\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttributeB\x03\xe0\x41\x01\x12i\n\x0esmall_business\x18\x07 \x01(\x0b\x32L.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttributeB\x03\xe0\x41\x01\x1a\x8d\x02\n\x11IdentityAttribute\x12\x83\x01\n\x14identity_declaration\x18\x01 \x01(\x0e\x32`.google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttribute.IdentityDeclarationB\x03\xe0\x41\x02\"r\n\x13IdentityDeclaration\x12$\n IDENTITY_DECLARATION_UNSPECIFIED\x10\x00\x12\x16\n\x12SELF_IDENTIFIES_AS\x10\x01\x12\x1d\n\x19\x44OES_NOT_SELF_IDENTIFY_AS\x10\x02\"t\n\x11PromotionsConsent\x12\"\n\x1ePROMOTIONS_CONSENT_UNSPECIFIED\x10\x00\x12\x1c\n\x18PROMOTIONS_CONSENT_GIVEN\x10\x01\x12\x1d\n\x19PROMOTIONS_CONSENT_DENIED\x10\x02:{\xea\x41x\n+merchantapi.googleapis.com/BusinessIdentity\x12#accounts/{account}/businessIdentity*\x12\x62usinessIdentities2\x10\x62usinessIdentity\"_\n\x1aGetBusinessIdentityRequest\x12\x41\n\x04name\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+merchantapi.googleapis.com/BusinessIdentity\"\xb1\x01\n\x1dUpdateBusinessIdentityRequest\x12Z\n\x11\x62usiness_identity\x18\x01 \x01(\x0b\x32:.google.shopping.merchant.accounts.v1beta.BusinessIdentityB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\x32\xe3\x04\n\x17\x42usinessIdentityService\x12\xdb\x01\n\x13GetBusinessIdentity\x12\x44.google.shopping.merchant.accounts.v1beta.GetBusinessIdentityRequest\x1a:.google.shopping.merchant.accounts.v1beta.BusinessIdentity\"B\xda\x41\x04name\x82\xd3\xe4\x93\x02\x35\x12\x33/accounts/v1beta/{name=accounts/*/businessIdentity}\x12\xa0\x02\n\x16UpdateBusinessIdentity\x12G.google.shopping.merchant.accounts.v1beta.UpdateBusinessIdentityRequest\x1a:.google.shopping.merchant.accounts.v1beta.BusinessIdentity\"\x80\x01\xda\x41\x1d\x62usiness_identity,update_mask\x82\xd3\xe4\x93\x02Z2E/accounts/v1beta/{business_identity.name=accounts/*/businessIdentity}:\x11\x62usiness_identity\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x97\x01\n,com.google.shopping.merchant.accounts.v1betaB\x15\x42usinessIdentityProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + BusinessIdentity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.BusinessIdentity").msgclass + BusinessIdentity::IdentityAttribute = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttribute").msgclass + BusinessIdentity::IdentityAttribute::IdentityDeclaration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.BusinessIdentity.IdentityAttribute.IdentityDeclaration").enummodule + BusinessIdentity::PromotionsConsent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.BusinessIdentity.PromotionsConsent").enummodule + GetBusinessIdentityRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetBusinessIdentityRequest").msgclass + UpdateBusinessIdentityRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateBusinessIdentityRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_services_pb.rb new file mode 100644 index 000000000000..958a16f2b7d7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessidentity_services_pb.rb @@ -0,0 +1,51 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/businessidentity.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/businessidentity_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessIdentityService + # Service to support [business + # identity](https://support.google.com/merchants/answer/12564247) API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.BusinessIdentityService' + + # Retrieves the business identity of an account. + rpc :GetBusinessIdentity, ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest, ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity + # Updates the business identity of an account. Executing this method requires + # admin access. + rpc :UpdateBusinessIdentity, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest, ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_pb.rb new file mode 100644 index 000000000000..0e256efaf5c3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_pb.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/businessinfo.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/field_mask_pb' +require 'google/shopping/merchant/accounts/v1beta/customerservice_pb' +require 'google/shopping/merchant/accounts/v1beta/phoneverificationstate_pb' +require 'google/type/phone_number_pb' +require 'google/type/postal_address_pb' + + +descriptor_data = "\n;google/shopping/merchant/accounts/v1beta/businessinfo.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/protobuf/field_mask.proto\x1a>google/shopping/merchant/accounts/v1beta/customerservice.proto\x1a\x45google/shopping/merchant/accounts/v1beta/phoneverificationstate.proto\x1a\x1egoogle/type/phone_number.proto\x1a google/type/postal_address.proto\"\x8c\x04\n\x0c\x42usinessInfo\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x35\n\x07\x61\x64\x64ress\x18\x02 \x01(\x0b\x32\x1a.google.type.PostalAddressB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12\x31\n\x05phone\x18\x03 \x01(\x0b\x32\x18.google.type.PhoneNumberB\x03\xe0\x41\x03H\x01\x88\x01\x01\x12l\n\x18phone_verification_state\x18\x04 \x01(\x0e\x32@.google.shopping.merchant.accounts.v1beta.PhoneVerificationStateB\x03\xe0\x41\x03H\x02\x88\x01\x01\x12]\n\x10\x63ustomer_service\x18\x05 \x01(\x0b\x32\x39.google.shopping.merchant.accounts.v1beta.CustomerServiceB\x03\xe0\x41\x01H\x03\x88\x01\x01:j\xea\x41g\n\'merchantapi.googleapis.com/BusinessInfo\x12\x1f\x61\x63\x63ounts/{account}/businessInfo*\rbusinessInfos2\x0c\x62usinessInfoB\n\n\x08_addressB\x08\n\x06_phoneB\x1b\n\x19_phone_verification_stateB\x13\n\x11_customer_service\"W\n\x16GetBusinessInfoRequest\x12=\n\x04name\x18\x01 \x01(\tB/\xe0\x41\x02\xfa\x41)\n\'merchantapi.googleapis.com/BusinessInfo\"\xa5\x01\n\x19UpdateBusinessInfoRequest\x12R\n\rbusiness_info\x18\x01 \x01(\x0b\x32\x36.google.shopping.merchant.accounts.v1beta.BusinessInfoB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\x32\xb2\x04\n\x13\x42usinessInfoService\x12\xcb\x01\n\x0fGetBusinessInfo\x12@.google.shopping.merchant.accounts.v1beta.GetBusinessInfoRequest\x1a\x36.google.shopping.merchant.accounts.v1beta.BusinessInfo\">\xda\x41\x04name\x82\xd3\xe4\x93\x02\x31\x12//accounts/v1beta/{name=accounts/*/businessInfo}\x12\x83\x02\n\x12UpdateBusinessInfo\x12\x43.google.shopping.merchant.accounts.v1beta.UpdateBusinessInfoRequest\x1a\x36.google.shopping.merchant.accounts.v1beta.BusinessInfo\"p\xda\x41\x19\x62usiness_info,update_mask\x82\xd3\xe4\x93\x02N2=/accounts/v1beta/{business_info.name=accounts/*/businessInfo}:\rbusiness_info\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x93\x01\n,com.google.shopping.merchant.accounts.v1betaB\x11\x42usinessInfoProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.type.PostalAddress", "google/type/postal_address.proto"], + ["google.type.PhoneNumber", "google/type/phone_number.proto"], + ["google.shopping.merchant.accounts.v1beta.CustomerService", "google/shopping/merchant/accounts/v1beta/customerservice.proto"], + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + BusinessInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.BusinessInfo").msgclass + GetBusinessInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetBusinessInfoRequest").msgclass + UpdateBusinessInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateBusinessInfoRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_services_pb.rb new file mode 100644 index 000000000000..e7446d2284e7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/businessinfo_services_pb.rb @@ -0,0 +1,50 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/businessinfo.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/businessinfo_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module BusinessInfoService + # Service to support business info API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.BusinessInfoService' + + # Retrieves the business info of an account. + rpc :GetBusinessInfo, ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest, ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo + # Updates the business info of an account. Executing this method requires + # admin access. + rpc :UpdateBusinessInfo, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest, ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/customerservice_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/customerservice_pb.rb new file mode 100644 index 000000000000..89f569124439 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/customerservice_pb.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/customerservice.proto + +require 'google/protobuf' + +require 'google/api/field_behavior_pb' +require 'google/type/phone_number_pb' + + +descriptor_data = "\n>google/shopping/merchant/accounts/v1beta/customerservice.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1egoogle/type/phone_number.proto\"\x90\x01\n\x0f\x43ustomerService\x12\x15\n\x03uri\x18\x01 \x01(\tB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12\x17\n\x05\x65mail\x18\x02 \x01(\tB\x03\xe0\x41\x01H\x01\x88\x01\x01\x12\x31\n\x05phone\x18\x03 \x01(\x0b\x32\x18.google.type.PhoneNumberB\x03\xe0\x41\x01H\x02\x88\x01\x01\x42\x06\n\x04_uriB\x08\n\x06_emailB\x08\n\x06_phoneB\x96\x01\n,com.google.shopping.merchant.accounts.v1betaB\x14\x43ustomerServiceProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.type.PhoneNumber", "google/type/phone_number.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + CustomerService = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CustomerService").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service.rb new file mode 100644 index 000000000000..c18219ca6abc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/paths" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/client" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support the `EmailPreferences` API. + # + # This service only permits retrieving and updating email preferences for the + # authenticated user. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/email_preferences_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new + # + module EmailPreferencesService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "email_preferences_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/client.rb new file mode 100644 index 000000000000..249f077edb3f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/client.rb @@ -0,0 +1,539 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/emailpreferences_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + ## + # Client for the EmailPreferencesService service. + # + # Service to support the `EmailPreferences` API. + # + # This service only permits retrieving and updating email preferences for the + # authenticated user. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :email_preferences_service_stub + + ## + # Configure the EmailPreferencesService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all EmailPreferencesService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the EmailPreferencesService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @email_preferences_service_stub.universe_domain + end + + ## + # Create a new EmailPreferencesService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the EmailPreferencesService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @email_preferences_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Returns the email preferences for a Merchant Center account user. + # + # Use the name=accounts/*/users/me/emailPreferences alias to get preferences + # for the authenticated user. + # + # @overload get_email_preferences(request, options = nil) + # Pass arguments to `get_email_preferences` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_email_preferences(name: nil) + # Pass arguments to `get_email_preferences` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the `EmailPreferences` resource. + # Format: `accounts/{account}/users/{email}/emailPreferences` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new + # + # # Call the get_email_preferences method. + # result = client.get_email_preferences request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + # p result + # + def get_email_preferences request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_email_preferences.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_email_preferences.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_email_preferences.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @email_preferences_service_stub.call_rpc :get_email_preferences, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the email preferences for a Merchant Center account user. MCA users + # should specify the MCA account rather than a sub-account of the MCA. + # + # Preferences which are not explicitly selected in the update mask will not + # be updated. + # + # It is invalid for updates to specify an UNCONFIRMED opt-in status value. + # + # Use the name=accounts/*/users/me/emailPreferences alias to update + # preferences + # for the authenticated user. + # + # @overload update_email_preferences(request, options = nil) + # Pass arguments to `update_email_preferences` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_email_preferences(email_preferences: nil, update_mask: nil) + # Pass arguments to `update_email_preferences` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param email_preferences [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences, ::Hash] + # Required. Email Preferences to be updated. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new + # + # # Call the update_email_preferences method. + # result = client.update_email_preferences request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + # p result + # + def update_email_preferences request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_email_preferences.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.email_preferences&.name + header_params["email_preferences.name"] = request.email_preferences.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_email_preferences.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_email_preferences.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @email_preferences_service_stub.call_rpc :update_email_preferences, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the EmailPreferencesService API. + # + # This class represents the configuration for EmailPreferencesService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_email_preferences to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_email_preferences.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_email_preferences.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the EmailPreferencesService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_email_preferences` + # @return [::Gapic::Config::Method] + # + attr_reader :get_email_preferences + ## + # RPC-specific configuration for `update_email_preferences` + # @return [::Gapic::Config::Method] + # + attr_reader :update_email_preferences + + # @private + def initialize parent_rpcs = nil + get_email_preferences_config = parent_rpcs.get_email_preferences if parent_rpcs.respond_to? :get_email_preferences + @get_email_preferences = ::Gapic::Config::Method.new get_email_preferences_config + update_email_preferences_config = parent_rpcs.update_email_preferences if parent_rpcs.respond_to? :update_email_preferences + @update_email_preferences = ::Gapic::Config::Method.new update_email_preferences_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials.rb new file mode 100644 index 000000000000..f2603469d9e9 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + # Credentials for the EmailPreferencesService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/paths.rb new file mode 100644 index 000000000000..216b33432035 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/paths.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + # Path helper methods for the EmailPreferencesService API. + module Paths + ## + # Create a fully-qualified EmailPreferences resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/users/{email}/emailPreferences` + # + # @param account [String] + # @param email [String] + # + # @return [::String] + def email_preferences_path account:, email: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/users/#{email}/emailPreferences" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest.rb new file mode 100644 index 000000000000..d492079bce0f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/credentials" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/paths" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support the `EmailPreferences` API. + # + # This service only permits retrieving and updating email preferences for the + # authenticated user. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new + # + module EmailPreferencesService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/client.rb new file mode 100644 index 000000000000..bbfeaa442359 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/client.rb @@ -0,0 +1,499 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/emailpreferences_pb" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + module Rest + ## + # REST client for the EmailPreferencesService service. + # + # Service to support the `EmailPreferences` API. + # + # This service only permits retrieving and updating email preferences for the + # authenticated user. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :email_preferences_service_stub + + ## + # Configure the EmailPreferencesService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all EmailPreferencesService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the EmailPreferencesService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @email_preferences_service_stub.universe_domain + end + + ## + # Create a new EmailPreferencesService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the EmailPreferencesService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @email_preferences_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Returns the email preferences for a Merchant Center account user. + # + # Use the name=accounts/*/users/me/emailPreferences alias to get preferences + # for the authenticated user. + # + # @overload get_email_preferences(request, options = nil) + # Pass arguments to `get_email_preferences` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_email_preferences(name: nil) + # Pass arguments to `get_email_preferences` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the `EmailPreferences` resource. + # Format: `accounts/{account}/users/{email}/emailPreferences` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new + # + # # Call the get_email_preferences method. + # result = client.get_email_preferences request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + # p result + # + def get_email_preferences request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_email_preferences.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_email_preferences.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_email_preferences.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @email_preferences_service_stub.get_email_preferences request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates the email preferences for a Merchant Center account user. MCA users + # should specify the MCA account rather than a sub-account of the MCA. + # + # Preferences which are not explicitly selected in the update mask will not + # be updated. + # + # It is invalid for updates to specify an UNCONFIRMED opt-in status value. + # + # Use the name=accounts/*/users/me/emailPreferences alias to update + # preferences + # for the authenticated user. + # + # @overload update_email_preferences(request, options = nil) + # Pass arguments to `update_email_preferences` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_email_preferences(email_preferences: nil, update_mask: nil) + # Pass arguments to `update_email_preferences` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param email_preferences [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences, ::Hash] + # Required. Email Preferences to be updated. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new + # + # # Call the update_email_preferences method. + # result = client.update_email_preferences request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + # p result + # + def update_email_preferences request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_email_preferences.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_email_preferences.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_email_preferences.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @email_preferences_service_stub.update_email_preferences request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the EmailPreferencesService REST API. + # + # This class represents the configuration for EmailPreferencesService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_email_preferences to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_email_preferences.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_email_preferences.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the EmailPreferencesService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_email_preferences` + # @return [::Gapic::Config::Method] + # + attr_reader :get_email_preferences + ## + # RPC-specific configuration for `update_email_preferences` + # @return [::Gapic::Config::Method] + # + attr_reader :update_email_preferences + + # @private + def initialize parent_rpcs = nil + get_email_preferences_config = parent_rpcs.get_email_preferences if parent_rpcs.respond_to? :get_email_preferences + @get_email_preferences = ::Gapic::Config::Method.new get_email_preferences_config + update_email_preferences_config = parent_rpcs.update_email_preferences if parent_rpcs.respond_to? :update_email_preferences + @update_email_preferences = ::Gapic::Config::Method.new update_email_preferences_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/service_stub.rb new file mode 100644 index 000000000000..d53ce5ebf9fa --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/email_preferences_service/rest/service_stub.rb @@ -0,0 +1,190 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/emailpreferences_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + module Rest + ## + # REST service stub for the EmailPreferencesService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_email_preferences REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # A result object deserialized from the server's reply + def get_email_preferences request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_email_preferences_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_email_preferences REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # A result object deserialized from the server's reply + def update_email_preferences request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_email_preferences_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_email_preferences REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_email_preferences_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/users/[^/]+/emailPreferences/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_email_preferences REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_email_preferences_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{email_preferences.name}", + body: "email_preferences", + matches: [ + ["email_preferences.name", %r{^accounts/[^/]+/users/[^/]+/emailPreferences/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_pb.rb new file mode 100644 index 000000000000..e94c85d6e35a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_pb.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/emailpreferences.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/field_mask_pb' + + +descriptor_data = "\n?google/shopping/merchant/accounts/v1beta/emailpreferences.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/protobuf/field_mask.proto\"\xed\x02\n\x10\x45mailPreferences\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x61\n\rnews_and_tips\x18\x02 \x01(\x0e\x32\x45.google.shopping.merchant.accounts.v1beta.EmailPreferences.OptInStateB\x03\xe0\x41\x01\"X\n\nOptInState\x12\x1c\n\x18OPT_IN_STATE_UNSPECIFIED\x10\x00\x12\r\n\tOPTED_OUT\x10\x01\x12\x0c\n\x08OPTED_IN\x10\x02\x12\x0f\n\x0bUNCONFIRMED\x10\x03:\x88\x01\xea\x41\x84\x01\n+merchantapi.googleapis.com/EmailPreferences\x12\x31\x61\x63\x63ounts/{account}/users/{email}/emailPreferences*\x10\x65mailPreferences2\x10\x65mailPreferences\"_\n\x1aGetEmailPreferencesRequest\x12\x41\n\x04name\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+merchantapi.googleapis.com/EmailPreferences\"\xb1\x01\n\x1dUpdateEmailPreferencesRequest\x12Z\n\x11\x65mail_preferences\x18\x01 \x01(\x0b\x32:.google.shopping.merchant.accounts.v1beta.EmailPreferencesB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\x32\xf3\x04\n\x17\x45mailPreferencesService\x12\xe3\x01\n\x13GetEmailPreferences\x12\x44.google.shopping.merchant.accounts.v1beta.GetEmailPreferencesRequest\x1a:.google.shopping.merchant.accounts.v1beta.EmailPreferences\"J\xda\x41\x04name\x82\xd3\xe4\x93\x02=\x12;/accounts/v1beta/{name=accounts/*/users/*/emailPreferences}\x12\xa8\x02\n\x16UpdateEmailPreferences\x12G.google.shopping.merchant.accounts.v1beta.UpdateEmailPreferencesRequest\x1a:.google.shopping.merchant.accounts.v1beta.EmailPreferences\"\x88\x01\xda\x41\x1d\x65mail_preferences,update_mask\x82\xd3\xe4\x93\x02\x62\x32M/accounts/v1beta/{email_preferences.name=accounts/*/users/*/emailPreferences}:\x11\x65mail_preferences\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x97\x01\n,com.google.shopping.merchant.accounts.v1betaB\x15\x45mailPreferencesProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + EmailPreferences = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.EmailPreferences").msgclass + EmailPreferences::OptInState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.EmailPreferences.OptInState").enummodule + GetEmailPreferencesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetEmailPreferencesRequest").msgclass + UpdateEmailPreferencesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateEmailPreferencesRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb.rb new file mode 100644 index 000000000000..49f7b65346bd --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb.rb @@ -0,0 +1,65 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/emailpreferences.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/emailpreferences_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module EmailPreferencesService + # Service to support the `EmailPreferences` API. + # + # This service only permits retrieving and updating email preferences for the + # authenticated user. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.EmailPreferencesService' + + # Returns the email preferences for a Merchant Center account user. + # + # Use the name=accounts/*/users/me/emailPreferences alias to get preferences + # for the authenticated user. + rpc :GetEmailPreferences, ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest, ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences + # Updates the email preferences for a Merchant Center account user. MCA users + # should specify the MCA account rather than a sub-account of the MCA. + # + # Preferences which are not explicitly selected in the update mask will not + # be updated. + # + # It is invalid for updates to specify an UNCONFIRMED opt-in status value. + # + # Use the name=accounts/*/users/me/emailPreferences alias to update + # preferences + # for the authenticated user. + rpc :UpdateEmailPreferences, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest, ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_pb.rb new file mode 100644 index 000000000000..d1f05ce6c342 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_pb.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/homepage.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/field_mask_pb' + + +descriptor_data = "\n7google/shopping/merchant/accounts/v1beta/homepage.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/protobuf/field_mask.proto\"\xae\x01\n\x08Homepage\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x15\n\x03uri\x18\x02 \x01(\tB\x03\xe0\x41\x02H\x00\x88\x01\x01\x12\x14\n\x07\x63laimed\x18\x03 \x01(\x08\x42\x03\xe0\x41\x03:Z\xea\x41W\n#merchantapi.googleapis.com/Homepage\x12\x1b\x61\x63\x63ounts/{account}/homepage*\thomepages2\x08homepageB\x06\n\x04_uri\"O\n\x12GetHomepageRequest\x12\x39\n\x04name\x18\x01 \x01(\tB+\xe0\x41\x02\xfa\x41%\n#merchantapi.googleapis.com/Homepage\"\x98\x01\n\x15UpdateHomepageRequest\x12I\n\x08homepage\x18\x01 \x01(\x0b\x32\x32.google.shopping.merchant.accounts.v1beta.HomepageB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\"Q\n\x14\x43laimHomepageRequest\x12\x39\n\x04name\x18\x01 \x01(\tB+\xe0\x41\x02\xfa\x41%\n#merchantapi.googleapis.com/Homepage\"S\n\x16UnclaimHomepageRequest\x12\x39\n\x04name\x18\x01 \x01(\tB+\xe0\x41\x02\xfa\x41%\n#merchantapi.googleapis.com/Homepage2\x8d\x07\n\x0fHomepageService\x12\xbb\x01\n\x0bGetHomepage\x12<.google.shopping.merchant.accounts.v1beta.GetHomepageRequest\x1a\x32.google.shopping.merchant.accounts.v1beta.Homepage\":\xda\x41\x04name\x82\xd3\xe4\x93\x02-\x12+/accounts/v1beta/{name=accounts/*/homepage}\x12\xe4\x01\n\x0eUpdateHomepage\x12?.google.shopping.merchant.accounts.v1beta.UpdateHomepageRequest\x1a\x32.google.shopping.merchant.accounts.v1beta.Homepage\"]\xda\x41\x14homepage,update_mask\x82\xd3\xe4\x93\x02@24/accounts/v1beta/{homepage.name=accounts/*/homepage}:\x08homepage\x12\xc1\x01\n\rClaimHomepage\x12>.google.shopping.merchant.accounts.v1beta.ClaimHomepageRequest\x1a\x32.google.shopping.merchant.accounts.v1beta.Homepage\"<\x82\xd3\xe4\x93\x02\x36\"1/accounts/v1beta/{name=accounts/*/homepage}:claim:\x01*\x12\xc7\x01\n\x0fUnclaimHomepage\x12@.google.shopping.merchant.accounts.v1beta.UnclaimHomepageRequest\x1a\x32.google.shopping.merchant.accounts.v1beta.Homepage\">\x82\xd3\xe4\x93\x02\x38\"3/accounts/v1beta/{name=accounts/*/homepage}:unclaim:\x01*\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x8f\x01\n,com.google.shopping.merchant.accounts.v1betaB\rHomepageProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + Homepage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Homepage").msgclass + GetHomepageRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetHomepageRequest").msgclass + UpdateHomepageRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateHomepageRequest").msgclass + ClaimHomepageRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ClaimHomepageRequest").msgclass + UnclaimHomepageRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UnclaimHomepageRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service.rb new file mode 100644 index 000000000000..2798bac25afb --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/homepage_service/credentials" +require "google/shopping/merchant/accounts/v1beta/homepage_service/paths" +require "google/shopping/merchant/accounts/v1beta/homepage_service/client" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support an API for a store's homepage. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/homepage_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/homepage_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + module HomepageService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "homepage_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/homepage_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/client.rb new file mode 100644 index 000000000000..0b6e23ce6109 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/client.rb @@ -0,0 +1,724 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/homepage_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + ## + # Client for the HomepageService service. + # + # Service to support an API for a store's homepage. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :homepage_service_stub + + ## + # Configure the HomepageService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all HomepageService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the HomepageService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @homepage_service_stub.universe_domain + end + + ## + # Create a new HomepageService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the HomepageService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/homepage_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @homepage_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves a store's homepage. + # + # @overload get_homepage(request, options = nil) + # Pass arguments to `get_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_homepage(name: nil) + # Pass arguments to `get_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to retrieve. + # Format: `accounts/{account}/homepage` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new + # + # # Call the get_homepage method. + # result = client.get_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def get_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_homepage.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.call_rpc :get_homepage, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a store's homepage. Executing this method requires admin access. + # + # @overload update_homepage(request, options = nil) + # Pass arguments to `update_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_homepage(homepage: nil, update_mask: nil) + # Pass arguments to `update_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param homepage [::Google::Shopping::Merchant::Accounts::V1beta::Homepage, ::Hash] + # Required. The new version of the homepage. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new + # + # # Call the update_homepage method. + # result = client.update_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def update_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.homepage&.name + header_params["homepage.name"] = request.homepage.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_homepage.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.call_rpc :update_homepage, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Claims a store's homepage. Executing this method requires admin access. + # + # If the homepage is already claimed, this will recheck the + # verification (unless the merchant is exempted from claiming, which also + # exempts from verification) and return a successful response. If ownership + # can no longer be verified, it will return an error, but it won't clear the + # claim. In case of failure, a canonical error message will be returned: + # * PERMISSION_DENIED: user doesn't have the necessary permissions on this + # MC account; + # * FAILED_PRECONDITION: + # - The account is not a Merchant Center account; + # - MC account doesn't have a homepage; + # - claiming failed (in this case the error message will contain more + # details). + # + # @overload claim_homepage(request, options = nil) + # Pass arguments to `claim_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload claim_homepage(name: nil) + # Pass arguments to `claim_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to claim. + # Format: `accounts/{account}/homepage` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new + # + # # Call the claim_homepage method. + # result = client.claim_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def claim_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.claim_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.claim_homepage.timeout, + metadata: metadata, + retry_policy: @config.rpcs.claim_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.call_rpc :claim_homepage, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Unclaims a store's homepage. Executing this method requires admin access. + # + # @overload unclaim_homepage(request, options = nil) + # Pass arguments to `unclaim_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload unclaim_homepage(name: nil) + # Pass arguments to `unclaim_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to unclaim. + # Format: `accounts/{account}/homepage` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new + # + # # Call the unclaim_homepage method. + # result = client.unclaim_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def unclaim_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.unclaim_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.unclaim_homepage.timeout, + metadata: metadata, + retry_policy: @config.rpcs.unclaim_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.call_rpc :unclaim_homepage, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the HomepageService API. + # + # This class represents the configuration for HomepageService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_homepage to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_homepage.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_homepage.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the HomepageService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :get_homepage + ## + # RPC-specific configuration for `update_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :update_homepage + ## + # RPC-specific configuration for `claim_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :claim_homepage + ## + # RPC-specific configuration for `unclaim_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :unclaim_homepage + + # @private + def initialize parent_rpcs = nil + get_homepage_config = parent_rpcs.get_homepage if parent_rpcs.respond_to? :get_homepage + @get_homepage = ::Gapic::Config::Method.new get_homepage_config + update_homepage_config = parent_rpcs.update_homepage if parent_rpcs.respond_to? :update_homepage + @update_homepage = ::Gapic::Config::Method.new update_homepage_config + claim_homepage_config = parent_rpcs.claim_homepage if parent_rpcs.respond_to? :claim_homepage + @claim_homepage = ::Gapic::Config::Method.new claim_homepage_config + unclaim_homepage_config = parent_rpcs.unclaim_homepage if parent_rpcs.respond_to? :unclaim_homepage + @unclaim_homepage = ::Gapic::Config::Method.new unclaim_homepage_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/credentials.rb new file mode 100644 index 000000000000..87c879493f7e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + # Credentials for the HomepageService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/paths.rb new file mode 100644 index 000000000000..d212dc95d103 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/paths.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + # Path helper methods for the HomepageService API. + module Paths + ## + # Create a fully-qualified Homepage resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/homepage` + # + # @param account [String] + # + # @return [::String] + def homepage_path account: + "accounts/#{account}/homepage" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest.rb new file mode 100644 index 000000000000..86b7e83e1782 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/homepage_service/credentials" +require "google/shopping/merchant/accounts/v1beta/homepage_service/paths" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support an API for a store's homepage. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/homepage_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + module HomepageService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/client.rb new file mode 100644 index 000000000000..687955336e8c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/client.rb @@ -0,0 +1,670 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/homepage_pb" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + module Rest + ## + # REST client for the HomepageService service. + # + # Service to support an API for a store's homepage. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :homepage_service_stub + + ## + # Configure the HomepageService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all HomepageService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the HomepageService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @homepage_service_stub.universe_domain + end + + ## + # Create a new HomepageService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the HomepageService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @homepage_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves a store's homepage. + # + # @overload get_homepage(request, options = nil) + # Pass arguments to `get_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_homepage(name: nil) + # Pass arguments to `get_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to retrieve. + # Format: `accounts/{account}/homepage` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new + # + # # Call the get_homepage method. + # result = client.get_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def get_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_homepage.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.get_homepage request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a store's homepage. Executing this method requires admin access. + # + # @overload update_homepage(request, options = nil) + # Pass arguments to `update_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_homepage(homepage: nil, update_mask: nil) + # Pass arguments to `update_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param homepage [::Google::Shopping::Merchant::Accounts::V1beta::Homepage, ::Hash] + # Required. The new version of the homepage. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new + # + # # Call the update_homepage method. + # result = client.update_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def update_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_homepage.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.update_homepage request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Claims a store's homepage. Executing this method requires admin access. + # + # If the homepage is already claimed, this will recheck the + # verification (unless the merchant is exempted from claiming, which also + # exempts from verification) and return a successful response. If ownership + # can no longer be verified, it will return an error, but it won't clear the + # claim. In case of failure, a canonical error message will be returned: + # * PERMISSION_DENIED: user doesn't have the necessary permissions on this + # MC account; + # * FAILED_PRECONDITION: + # - The account is not a Merchant Center account; + # - MC account doesn't have a homepage; + # - claiming failed (in this case the error message will contain more + # details). + # + # @overload claim_homepage(request, options = nil) + # Pass arguments to `claim_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload claim_homepage(name: nil) + # Pass arguments to `claim_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to claim. + # Format: `accounts/{account}/homepage` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new + # + # # Call the claim_homepage method. + # result = client.claim_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def claim_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.claim_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.claim_homepage.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.claim_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.claim_homepage request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Unclaims a store's homepage. Executing this method requires admin access. + # + # @overload unclaim_homepage(request, options = nil) + # Pass arguments to `unclaim_homepage` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload unclaim_homepage(name: nil) + # Pass arguments to `unclaim_homepage` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the homepage to unclaim. + # Format: `accounts/{account}/homepage` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new + # + # # Call the unclaim_homepage method. + # result = client.unclaim_homepage request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + # p result + # + def unclaim_homepage request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.unclaim_homepage.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.unclaim_homepage.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.unclaim_homepage.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @homepage_service_stub.unclaim_homepage request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the HomepageService REST API. + # + # This class represents the configuration for HomepageService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_homepage to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_homepage.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_homepage.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the HomepageService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :get_homepage + ## + # RPC-specific configuration for `update_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :update_homepage + ## + # RPC-specific configuration for `claim_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :claim_homepage + ## + # RPC-specific configuration for `unclaim_homepage` + # @return [::Gapic::Config::Method] + # + attr_reader :unclaim_homepage + + # @private + def initialize parent_rpcs = nil + get_homepage_config = parent_rpcs.get_homepage if parent_rpcs.respond_to? :get_homepage + @get_homepage = ::Gapic::Config::Method.new get_homepage_config + update_homepage_config = parent_rpcs.update_homepage if parent_rpcs.respond_to? :update_homepage + @update_homepage = ::Gapic::Config::Method.new update_homepage_config + claim_homepage_config = parent_rpcs.claim_homepage if parent_rpcs.respond_to? :claim_homepage + @claim_homepage = ::Gapic::Config::Method.new claim_homepage_config + unclaim_homepage_config = parent_rpcs.unclaim_homepage if parent_rpcs.respond_to? :unclaim_homepage + @unclaim_homepage = ::Gapic::Config::Method.new unclaim_homepage_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/service_stub.rb new file mode 100644 index 000000000000..57e4e04cef00 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_service/rest/service_stub.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/homepage_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + module Rest + ## + # REST service stub for the HomepageService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # A result object deserialized from the server's reply + def get_homepage request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_homepage_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # A result object deserialized from the server's reply + def update_homepage request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_homepage_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the claim_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # A result object deserialized from the server's reply + def claim_homepage request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_claim_homepage_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the unclaim_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # A result object deserialized from the server's reply + def unclaim_homepage request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_unclaim_homepage_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_homepage_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/homepage/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_homepage_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{homepage.name}", + body: "homepage", + matches: [ + ["homepage.name", %r{^accounts/[^/]+/homepage/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the claim_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_claim_homepage_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{name}:claim", + body: "*", + matches: [ + ["name", %r{^accounts/[^/]+/homepage/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the unclaim_homepage REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_unclaim_homepage_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{name}:unclaim", + body: "*", + matches: [ + ["name", %r{^accounts/[^/]+/homepage/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_services_pb.rb new file mode 100644 index 000000000000..4bc136946199 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/homepage_services_pb.rb @@ -0,0 +1,66 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/homepage.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/homepage_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module HomepageService + # Service to support an API for a store's homepage. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.HomepageService' + + # Retrieves a store's homepage. + rpc :GetHomepage, ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Homepage + # Updates a store's homepage. Executing this method requires admin access. + rpc :UpdateHomepage, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Homepage + # Claims a store's homepage. Executing this method requires admin access. + # + # If the homepage is already claimed, this will recheck the + # verification (unless the merchant is exempted from claiming, which also + # exempts from verification) and return a successful response. If ownership + # can no longer be verified, it will return an error, but it won't clear the + # claim. In case of failure, a canonical error message will be returned: + # * PERMISSION_DENIED: user doesn't have the necessary permissions on this + # MC account; + # * FAILED_PRECONDITION: + # - The account is not a Merchant Center account; + # - MC account doesn't have a homepage; + # - claiming failed (in this case the error message will contain more + # details). + rpc :ClaimHomepage, ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Homepage + # Unclaims a store's homepage. Executing this method requires admin access. + rpc :UnclaimHomepage, ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Homepage + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_pb.rb new file mode 100644 index 000000000000..35201b31847f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_pb.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/online_return_policy.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/shopping/type/types_pb' + + +descriptor_data = "\nCgoogle/shopping/merchant/accounts/v1beta/online_return_policy.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/shopping/type/types.proto\"c\n\x1cGetOnlineReturnPolicyRequest\x12\x43\n\x04name\x18\x01 \x01(\tB5\xe0\x41\x02\xfa\x41/\n-merchantapi.googleapis.com/OnlineReturnPolicy\"\x99\x01\n\x1fListOnlineReturnPoliciesRequest\x12\x45\n\x06parent\x18\x01 \x01(\tB5\xe0\x41\x02\xfa\x41/\x12-merchantapi.googleapis.com/OnlineReturnPolicy\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\"\x99\x01\n ListOnlineReturnPoliciesResponse\x12\\\n\x16online_return_policies\x18\x01 \x03(\x0b\x32<.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x80\r\n\x12OnlineReturnPolicy\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x1d\n\x10return_policy_id\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\r\n\x05label\x18\x03 \x01(\t\x12\x11\n\tcountries\x18\x04 \x03(\t\x12S\n\x06policy\x18\x05 \x01(\x0b\x32\x43.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.Policy\x12\x62\n\x0erestocking_fee\x18\x06 \x01(\x0b\x32J.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.RestockingFee\x12\x61\n\x0ereturn_methods\x18\x07 \x03(\x0e\x32I.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnMethod\x12\x63\n\x0fitem_conditions\x18\x08 \x03(\x0e\x32J.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ItemCondition\x12k\n\x13return_shipping_fee\x18\t \x01(\x0b\x32N.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnShippingFee\x12\x19\n\x11return_policy_uri\x18\n \x01(\t\x12\"\n\x15\x61\x63\x63\x65pt_defective_only\x18\x0b \x01(\x08H\x00\x88\x01\x01\x12 \n\x13process_refund_days\x18\x0c \x01(\x05H\x01\x88\x01\x01\x12\x1c\n\x0f\x61\x63\x63\x65pt_exchange\x18\r \x01(\x08H\x02\x88\x01\x01\x1a\xef\x01\n\x11ReturnShippingFee\x12\x61\n\x04type\x18\x01 \x01(\x0e\x32S.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnShippingFee.Type\x12.\n\tfixed_fee\x18\x02 \x01(\x0b\x32\x1b.google.shopping.type.Price\"G\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\t\n\x05\x46IXED\x10\x01\x12\x1e\n\x1a\x43USTOMER_PAYING_ACTUAL_FEE\x10\x02\x1a\x62\n\rRestockingFee\x12\x30\n\tfixed_fee\x18\x01 \x01(\x0b\x32\x1b.google.shopping.type.PriceH\x00\x12\x17\n\rmicro_percent\x18\x02 \x01(\x05H\x00\x42\x06\n\x04type\x1a\xd5\x01\n\x06Policy\x12V\n\x04type\x18\x01 \x01(\x0e\x32H.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.Policy.Type\x12\x0c\n\x04\x64\x61ys\x18\x02 \x01(\x03\"e\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12!\n\x1dNUMBER_OF_DAYS_AFTER_DELIVERY\x10\x01\x12\x0e\n\nNO_RETURNS\x10\x02\x12\x14\n\x10LIFETIME_RETURNS\x10\x03\"X\n\x0cReturnMethod\x12\x1d\n\x19RETURN_METHOD_UNSPECIFIED\x10\x00\x12\x0b\n\x07\x42Y_MAIL\x10\x01\x12\x0c\n\x08IN_STORE\x10\x02\x12\x0e\n\nAT_A_KIOSK\x10\x03\"B\n\rItemCondition\x12\x1e\n\x1aITEM_CONDITION_UNSPECIFIED\x10\x00\x12\x07\n\x03NEW\x10\x01\x12\x08\n\x04USED\x10\x02:\x96\x01\xea\x41\x92\x01\n-merchantapi.googleapis.com/OnlineReturnPolicy\x12\x37\x61\x63\x63ounts/{account}/onlineReturnPolicies/{return_policy}*\x14onlineReturnPolicies2\x12onlineReturnPolicyB\x18\n\x16_accept_defective_onlyB\x16\n\x14_process_refund_daysB\x12\n\x10_accept_exchange2\xce\x04\n\x19OnlineReturnPolicyService\x12\xe7\x01\n\x15GetOnlineReturnPolicy\x12\x46.google.shopping.merchant.accounts.v1beta.GetOnlineReturnPolicyRequest\x1a<.google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy\"H\xda\x41\x04name\x82\xd3\xe4\x93\x02;\x12\x39/accounts/v1beta/{name=accounts/*/onlineReturnPolicies/*}\x12\xfd\x01\n\x18ListOnlineReturnPolicies\x12I.google.shopping.merchant.accounts.v1beta.ListOnlineReturnPoliciesRequest\x1aJ.google.shopping.merchant.accounts.v1beta.ListOnlineReturnPoliciesResponse\"J\xda\x41\x06parent\x82\xd3\xe4\x93\x02;\x12\x39/accounts/v1beta/{parent=accounts/*}/onlineReturnPolicies\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x99\x01\n,com.google.shopping.merchant.accounts.v1betaB\x17OnlineReturnPolicyProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.shopping.type.Price", "google/shopping/type/types.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + GetOnlineReturnPolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetOnlineReturnPolicyRequest").msgclass + ListOnlineReturnPoliciesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListOnlineReturnPoliciesRequest").msgclass + ListOnlineReturnPoliciesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListOnlineReturnPoliciesResponse").msgclass + OnlineReturnPolicy = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy").msgclass + OnlineReturnPolicy::ReturnShippingFee = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnShippingFee").msgclass + OnlineReturnPolicy::ReturnShippingFee::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnShippingFee.Type").enummodule + OnlineReturnPolicy::RestockingFee = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.RestockingFee").msgclass + OnlineReturnPolicy::Policy = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.Policy").msgclass + OnlineReturnPolicy::Policy::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.Policy.Type").enummodule + OnlineReturnPolicy::ReturnMethod = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ReturnMethod").enummodule + OnlineReturnPolicy::ItemCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.OnlineReturnPolicy.ItemCondition").enummodule + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service.rb new file mode 100644 index 000000000000..14ee82c46978 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/client" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # The service facilitates the management of a merchant's remorse return policy + # configuration, encompassing return policies for both ads and free listings + # ## programs. This API defines the following resource model: + # + # [OnlineReturnPolicy][google.shopping.merchant.accounts.v1.OnlineReturnPolicy] + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/online_return_policy_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new + # + module OnlineReturnPolicyService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "online_return_policy_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/client.rb new file mode 100644 index 000000000000..19009a6ca572 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/client.rb @@ -0,0 +1,551 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + ## + # Client for the OnlineReturnPolicyService service. + # + # The service facilitates the management of a merchant's remorse return policy + # configuration, encompassing return policies for both ads and free listings + # ## programs. This API defines the following resource model: + # + # [OnlineReturnPolicy][google.shopping.merchant.accounts.v1.OnlineReturnPolicy] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :online_return_policy_service_stub + + ## + # Configure the OnlineReturnPolicyService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all OnlineReturnPolicyService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the OnlineReturnPolicyService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @online_return_policy_service_stub.universe_domain + end + + ## + # Create a new OnlineReturnPolicyService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the OnlineReturnPolicyService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @online_return_policy_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Gets an existing return policy. + # + # @overload get_online_return_policy(request, options = nil) + # Pass arguments to `get_online_return_policy` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_online_return_policy(name: nil) + # Pass arguments to `get_online_return_policy` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the return policy to retrieve. + # Format: `accounts/{account}/onlineReturnPolicies/{return_policy}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new + # + # # Call the get_online_return_policy method. + # result = client.get_online_return_policy request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + # p result + # + def get_online_return_policy request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_online_return_policy.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_online_return_policy.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_online_return_policy.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @online_return_policy_service_stub.call_rpc :get_online_return_policy, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists all existing return policies. + # + # @overload list_online_return_policies(request, options = nil) + # Pass arguments to `list_online_return_policies` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_online_return_policies(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_online_return_policies` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The merchant account for which to list return policies. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of `OnlineReturnPolicy` resources to return. + # The service returns fewer than this value if the number of return policies + # for the given merchant is less that than the `pageSize`. The default value + # is 10. The maximum value is 100; If a value higher than the maximum is + # specified, then the `pageSize` will default to the maximum + # @param page_token [::String] + # Optional. A page token, received from a previous `ListOnlineReturnPolicies` + # call. Provide the page token to retrieve the subsequent page. + # + # When paginating, all other parameters provided to + # `ListOnlineReturnPolicies` must match the call that provided the page + # token. The token returned as + # {::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse#next_page_token nextPageToken} + # in the response to the previous request. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new + # + # # Call the list_online_return_policies method. + # result = client.list_online_return_policies request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + # p item + # end + # + def list_online_return_policies request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_online_return_policies.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_online_return_policies.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_online_return_policies.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @online_return_policy_service_stub.call_rpc :list_online_return_policies, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @online_return_policy_service_stub, :list_online_return_policies, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the OnlineReturnPolicyService API. + # + # This class represents the configuration for OnlineReturnPolicyService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_online_return_policy to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_online_return_policy.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_online_return_policy.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the OnlineReturnPolicyService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_online_return_policy` + # @return [::Gapic::Config::Method] + # + attr_reader :get_online_return_policy + ## + # RPC-specific configuration for `list_online_return_policies` + # @return [::Gapic::Config::Method] + # + attr_reader :list_online_return_policies + + # @private + def initialize parent_rpcs = nil + get_online_return_policy_config = parent_rpcs.get_online_return_policy if parent_rpcs.respond_to? :get_online_return_policy + @get_online_return_policy = ::Gapic::Config::Method.new get_online_return_policy_config + list_online_return_policies_config = parent_rpcs.list_online_return_policies if parent_rpcs.respond_to? :list_online_return_policies + @list_online_return_policies = ::Gapic::Config::Method.new list_online_return_policies_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials.rb new file mode 100644 index 000000000000..0f21bbb51fbc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + # Credentials for the OnlineReturnPolicyService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths.rb new file mode 100644 index 000000000000..6427f273c11a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + # Path helper methods for the OnlineReturnPolicyService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified OnlineReturnPolicy resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/onlineReturnPolicies/{return_policy}` + # + # @param account [String] + # @param return_policy [String] + # + # @return [::String] + def online_return_policy_path account:, return_policy: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/onlineReturnPolicies/#{return_policy}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest.rb new file mode 100644 index 000000000000..5e68e0d5a631 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/credentials" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/paths" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # The service facilitates the management of a merchant's remorse return policy + # configuration, encompassing return policies for both ads and free listings + # ## programs. This API defines the following resource model: + # + # [OnlineReturnPolicy][google.shopping.merchant.accounts.v1.OnlineReturnPolicy] + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new + # + module OnlineReturnPolicyService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/client.rb new file mode 100644 index 000000000000..c55f3fa8e91c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/client.rb @@ -0,0 +1,511 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_pb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + module Rest + ## + # REST client for the OnlineReturnPolicyService service. + # + # The service facilitates the management of a merchant's remorse return policy + # configuration, encompassing return policies for both ads and free listings + # ## programs. This API defines the following resource model: + # + # [OnlineReturnPolicy][google.shopping.merchant.accounts.v1.OnlineReturnPolicy] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :online_return_policy_service_stub + + ## + # Configure the OnlineReturnPolicyService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all OnlineReturnPolicyService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the OnlineReturnPolicyService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @online_return_policy_service_stub.universe_domain + end + + ## + # Create a new OnlineReturnPolicyService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the OnlineReturnPolicyService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @online_return_policy_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Gets an existing return policy. + # + # @overload get_online_return_policy(request, options = nil) + # Pass arguments to `get_online_return_policy` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_online_return_policy(name: nil) + # Pass arguments to `get_online_return_policy` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the return policy to retrieve. + # Format: `accounts/{account}/onlineReturnPolicies/{return_policy}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new + # + # # Call the get_online_return_policy method. + # result = client.get_online_return_policy request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + # p result + # + def get_online_return_policy request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_online_return_policy.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_online_return_policy.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_online_return_policy.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @online_return_policy_service_stub.get_online_return_policy request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists all existing return policies. + # + # @overload list_online_return_policies(request, options = nil) + # Pass arguments to `list_online_return_policies` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_online_return_policies(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_online_return_policies` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The merchant account for which to list return policies. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of `OnlineReturnPolicy` resources to return. + # The service returns fewer than this value if the number of return policies + # for the given merchant is less that than the `pageSize`. The default value + # is 10. The maximum value is 100; If a value higher than the maximum is + # specified, then the `pageSize` will default to the maximum + # @param page_token [::String] + # Optional. A page token, received from a previous `ListOnlineReturnPolicies` + # call. Provide the page token to retrieve the subsequent page. + # + # When paginating, all other parameters provided to + # `ListOnlineReturnPolicies` must match the call that provided the page + # token. The token returned as + # {::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse#next_page_token nextPageToken} + # in the response to the previous request. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new + # + # # Call the list_online_return_policies method. + # result = client.list_online_return_policies request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + # p item + # end + # + def list_online_return_policies request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_online_return_policies.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_online_return_policies.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_online_return_policies.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @online_return_policy_service_stub.list_online_return_policies request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @online_return_policy_service_stub, :list_online_return_policies, "online_return_policies", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the OnlineReturnPolicyService REST API. + # + # This class represents the configuration for OnlineReturnPolicyService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_online_return_policy to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_online_return_policy.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_online_return_policy.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the OnlineReturnPolicyService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_online_return_policy` + # @return [::Gapic::Config::Method] + # + attr_reader :get_online_return_policy + ## + # RPC-specific configuration for `list_online_return_policies` + # @return [::Gapic::Config::Method] + # + attr_reader :list_online_return_policies + + # @private + def initialize parent_rpcs = nil + get_online_return_policy_config = parent_rpcs.get_online_return_policy if parent_rpcs.respond_to? :get_online_return_policy + @get_online_return_policy = ::Gapic::Config::Method.new get_online_return_policy_config + list_online_return_policies_config = parent_rpcs.list_online_return_policies if parent_rpcs.respond_to? :list_online_return_policies + @list_online_return_policies = ::Gapic::Config::Method.new list_online_return_policies_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/service_stub.rb new file mode 100644 index 000000000000..cd43e1245e0a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest/service_stub.rb @@ -0,0 +1,189 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/online_return_policy_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + module Rest + ## + # REST service stub for the OnlineReturnPolicyService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_online_return_policy REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy] + # A result object deserialized from the server's reply + def get_online_return_policy request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_online_return_policy_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_online_return_policies REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse] + # A result object deserialized from the server's reply + def list_online_return_policies request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_online_return_policies_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_online_return_policy REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_online_return_policy_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/onlineReturnPolicies/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_online_return_policies REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_online_return_policies_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/onlineReturnPolicies", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb.rb new file mode 100644 index 000000000000..2cc4fc87bdd3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb.rb @@ -0,0 +1,53 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/online_return_policy.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/online_return_policy_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module OnlineReturnPolicyService + # The service facilitates the management of a merchant's remorse return policy + # configuration, encompassing return policies for both ads and free listings + # ## programs. This API defines the following resource model: + # + # [OnlineReturnPolicy][google.shopping.merchant.accounts.v1.OnlineReturnPolicy] + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.OnlineReturnPolicyService' + + # Gets an existing return policy. + rpc :GetOnlineReturnPolicy, ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest, ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy + # Lists all existing return policies. + rpc :ListOnlineReturnPolicies, ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/phoneverificationstate_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/phoneverificationstate_pb.rb new file mode 100644 index 000000000000..7ba16439a7dd --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/phoneverificationstate_pb.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/phoneverificationstate.proto + +require 'google/protobuf' + + +descriptor_data = "\nEgoogle/shopping/merchant/accounts/v1beta/phoneverificationstate.proto\x12(google.shopping.merchant.accounts.v1beta*\x92\x01\n\x16PhoneVerificationState\x12(\n$PHONE_VERIFICATION_STATE_UNSPECIFIED\x10\x00\x12%\n!PHONE_VERIFICATION_STATE_VERIFIED\x10\x01\x12\'\n#PHONE_VERIFICATION_STATE_UNVERIFIED\x10\x02\x42\x9d\x01\n,com.google.shopping.merchant.accounts.v1betaB\x1bPhoneVerificationStateProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + PhoneVerificationState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.PhoneVerificationState").enummodule + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_pb.rb new file mode 100644 index 000000000000..7ba55aa51a83 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_pb.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/programs.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' + + +descriptor_data = "\n7google/shopping/merchant/accounts/v1beta/programs.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\"\xa2\x04\n\x07Program\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x1e\n\x11\x64ocumentation_uri\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12K\n\x05state\x18\x03 \x01(\x0e\x32\x37.google.shopping.merchant.accounts.v1beta.Program.StateB\x03\xe0\x41\x03\x12 \n\x13\x61\x63tive_region_codes\x18\x04 \x03(\tB\x03\xe0\x41\x03\x12^\n\x12unmet_requirements\x18\x05 \x03(\x0b\x32=.google.shopping.merchant.accounts.v1beta.Program.RequirementB\x03\xe0\x41\x03\x1a\x65\n\x0bRequirement\x12\x12\n\x05title\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\x1e\n\x11\x64ocumentation_uri\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\"\n\x15\x61\x66\x66\x65\x63ted_region_codes\x18\x03 \x03(\tB\x03\xe0\x41\x03\"K\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x10\n\x0cNOT_ELIGIBLE\x10\x01\x12\x0c\n\x08\x45LIGIBLE\x10\x02\x12\x0b\n\x07\x45NABLED\x10\x03:a\xea\x41^\n\"merchantapi.googleapis.com/Program\x12%accounts/{account}/programs/{program}*\x08programs2\x07program\"M\n\x11GetProgramRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Program\"\x82\x01\n\x13ListProgramsRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\x12\"merchantapi.googleapis.com/Program\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\"t\n\x14ListProgramsResponse\x12\x43\n\x08programs\x18\x01 \x03(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.Program\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"P\n\x14\x45nableProgramRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Program\"Q\n\x15\x44isableProgramRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Program2\x84\x07\n\x0fProgramsService\x12\xba\x01\n\nGetProgram\x12;.google.shopping.merchant.accounts.v1beta.GetProgramRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Program\"<\xda\x41\x04name\x82\xd3\xe4\x93\x02/\x12-/accounts/v1beta/{name=accounts/*/programs/*}\x12\xcd\x01\n\x0cListPrograms\x12=.google.shopping.merchant.accounts.v1beta.ListProgramsRequest\x1a>.google.shopping.merchant.accounts.v1beta.ListProgramsResponse\">\xda\x41\x06parent\x82\xd3\xe4\x93\x02/\x12-/accounts/v1beta/{parent=accounts/*}/programs\x12\xca\x01\n\rEnableProgram\x12>.google.shopping.merchant.accounts.v1beta.EnableProgramRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Program\"F\xda\x41\x04name\x82\xd3\xe4\x93\x02\x39\"4/accounts/v1beta/{name=accounts/*/programs/*}:enable:\x01*\x12\xcd\x01\n\x0e\x44isableProgram\x12?.google.shopping.merchant.accounts.v1beta.DisableProgramRequest\x1a\x31.google.shopping.merchant.accounts.v1beta.Program\"G\xda\x41\x04name\x82\xd3\xe4\x93\x02:\"5/accounts/v1beta/{name=accounts/*/programs/*}:disable:\x01*\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x8f\x01\n,com.google.shopping.merchant.accounts.v1betaB\rProgramsProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + Program = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Program").msgclass + Program::Requirement = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Program.Requirement").msgclass + Program::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Program.State").enummodule + GetProgramRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetProgramRequest").msgclass + ListProgramsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListProgramsRequest").msgclass + ListProgramsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListProgramsResponse").msgclass + EnableProgramRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.EnableProgramRequest").msgclass + DisableProgramRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.DisableProgramRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service.rb new file mode 100644 index 000000000000..aaee3267a54b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/programs_service/credentials" +require "google/shopping/merchant/accounts/v1beta/programs_service/paths" +require "google/shopping/merchant/accounts/v1beta/programs_service/client" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service for program management. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # + # This service exposes methods to retrieve a merchant's + # participation in all available programs, in addition to methods for + # explicitly enabling or disabling participation in each program. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/programs_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/programs_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + module ProgramsService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "programs_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/programs_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/client.rb new file mode 100644 index 000000000000..2948e95c9d5e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/client.rb @@ -0,0 +1,734 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/programs_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + ## + # Client for the ProgramsService service. + # + # Service for program management. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # + # This service exposes methods to retrieve a merchant's + # participation in all available programs, in addition to methods for + # explicitly enabling or disabling participation in each program. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :programs_service_stub + + ## + # Configure the ProgramsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all ProgramsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the ProgramsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @programs_service_stub.universe_domain + end + + ## + # Create a new ProgramsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the ProgramsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/programs_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @programs_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves the specified program for the account. + # + # @overload get_program(request, options = nil) + # Pass arguments to `get_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_program(name: nil) + # Pass arguments to `get_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program to retrieve. + # Format: `accounts/{account}/programs/{program}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new + # + # # Call the get_program method. + # result = client.get_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def get_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_program.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.call_rpc :get_program, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves all programs for the account. + # + # @overload list_programs(request, options = nil) + # Pass arguments to `list_programs` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_programs(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_programs` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The name of the account for which to retrieve all programs. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of programs to return in a single response. If + # unspecified (or 0), a default size of 1000 is used. The maximum value is + # 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A continuation token, received from a previous `ListPrograms` + # call. Provide this to retrieve the next page. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Program>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Program>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new + # + # # Call the list_programs method. + # result = client.list_programs request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Program. + # p item + # end + # + def list_programs request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_programs.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_programs.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_programs.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.call_rpc :list_programs, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @programs_service_stub, :list_programs, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Enable participation in the specified program for the account. Executing + # this method requires admin access. + # + # @overload enable_program(request, options = nil) + # Pass arguments to `enable_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload enable_program(name: nil) + # Pass arguments to `enable_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program for which to enable participation for the + # given account. Format: `accounts/{account}/programs/{program}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new + # + # # Call the enable_program method. + # result = client.enable_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def enable_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.enable_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.enable_program.timeout, + metadata: metadata, + retry_policy: @config.rpcs.enable_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.call_rpc :enable_program, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Disable participation in the specified program for the account. Executing + # this method requires admin access. + # + # @overload disable_program(request, options = nil) + # Pass arguments to `disable_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload disable_program(name: nil) + # Pass arguments to `disable_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program for which to disable participation for + # the given account. Format: `accounts/{account}/programs/{program}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new + # + # # Call the disable_program method. + # result = client.disable_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def disable_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.disable_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.disable_program.timeout, + metadata: metadata, + retry_policy: @config.rpcs.disable_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.call_rpc :disable_program, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the ProgramsService API. + # + # This class represents the configuration for ProgramsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_program to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_program.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_program.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the ProgramsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_program` + # @return [::Gapic::Config::Method] + # + attr_reader :get_program + ## + # RPC-specific configuration for `list_programs` + # @return [::Gapic::Config::Method] + # + attr_reader :list_programs + ## + # RPC-specific configuration for `enable_program` + # @return [::Gapic::Config::Method] + # + attr_reader :enable_program + ## + # RPC-specific configuration for `disable_program` + # @return [::Gapic::Config::Method] + # + attr_reader :disable_program + + # @private + def initialize parent_rpcs = nil + get_program_config = parent_rpcs.get_program if parent_rpcs.respond_to? :get_program + @get_program = ::Gapic::Config::Method.new get_program_config + list_programs_config = parent_rpcs.list_programs if parent_rpcs.respond_to? :list_programs + @list_programs = ::Gapic::Config::Method.new list_programs_config + enable_program_config = parent_rpcs.enable_program if parent_rpcs.respond_to? :enable_program + @enable_program = ::Gapic::Config::Method.new enable_program_config + disable_program_config = parent_rpcs.disable_program if parent_rpcs.respond_to? :disable_program + @disable_program = ::Gapic::Config::Method.new disable_program_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/credentials.rb new file mode 100644 index 000000000000..4c4206817b11 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + # Credentials for the ProgramsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/paths.rb new file mode 100644 index 000000000000..9b0d4f310390 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + # Path helper methods for the ProgramsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified Program resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/programs/{program}` + # + # @param account [String] + # @param program [String] + # + # @return [::String] + def program_path account:, program: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/programs/#{program}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest.rb new file mode 100644 index 000000000000..df679dc8a592 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/programs_service/credentials" +require "google/shopping/merchant/accounts/v1beta/programs_service/paths" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service for program management. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # + # This service exposes methods to retrieve a merchant's + # participation in all available programs, in addition to methods for + # explicitly enabling or disabling participation in each program. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/programs_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + module ProgramsService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/client.rb new file mode 100644 index 000000000000..fe051561ddca --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/client.rb @@ -0,0 +1,680 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/programs_pb" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + module Rest + ## + # REST client for the ProgramsService service. + # + # Service for program management. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # + # This service exposes methods to retrieve a merchant's + # participation in all available programs, in addition to methods for + # explicitly enabling or disabling participation in each program. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :programs_service_stub + + ## + # Configure the ProgramsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all ProgramsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the ProgramsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @programs_service_stub.universe_domain + end + + ## + # Create a new ProgramsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the ProgramsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @programs_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves the specified program for the account. + # + # @overload get_program(request, options = nil) + # Pass arguments to `get_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_program(name: nil) + # Pass arguments to `get_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program to retrieve. + # Format: `accounts/{account}/programs/{program}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new + # + # # Call the get_program method. + # result = client.get_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def get_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_program.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.get_program request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves all programs for the account. + # + # @overload list_programs(request, options = nil) + # Pass arguments to `list_programs` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_programs(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_programs` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The name of the account for which to retrieve all programs. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of programs to return in a single response. If + # unspecified (or 0), a default size of 1000 is used. The maximum value is + # 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A continuation token, received from a previous `ListPrograms` + # call. Provide this to retrieve the next page. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Program>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Program>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new + # + # # Call the list_programs method. + # result = client.list_programs request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Program. + # p item + # end + # + def list_programs request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_programs.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_programs.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_programs.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.list_programs request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @programs_service_stub, :list_programs, "programs", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Enable participation in the specified program for the account. Executing + # this method requires admin access. + # + # @overload enable_program(request, options = nil) + # Pass arguments to `enable_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload enable_program(name: nil) + # Pass arguments to `enable_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program for which to enable participation for the + # given account. Format: `accounts/{account}/programs/{program}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new + # + # # Call the enable_program method. + # result = client.enable_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def enable_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.enable_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.enable_program.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.enable_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.enable_program request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Disable participation in the specified program for the account. Executing + # this method requires admin access. + # + # @overload disable_program(request, options = nil) + # Pass arguments to `disable_program` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload disable_program(name: nil) + # Pass arguments to `disable_program` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the program for which to disable participation for + # the given account. Format: `accounts/{account}/programs/{program}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new + # + # # Call the disable_program method. + # result = client.disable_program request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + # p result + # + def disable_program request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.disable_program.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.disable_program.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.disable_program.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @programs_service_stub.disable_program request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the ProgramsService REST API. + # + # This class represents the configuration for ProgramsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_program to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_program.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_program.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the ProgramsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_program` + # @return [::Gapic::Config::Method] + # + attr_reader :get_program + ## + # RPC-specific configuration for `list_programs` + # @return [::Gapic::Config::Method] + # + attr_reader :list_programs + ## + # RPC-specific configuration for `enable_program` + # @return [::Gapic::Config::Method] + # + attr_reader :enable_program + ## + # RPC-specific configuration for `disable_program` + # @return [::Gapic::Config::Method] + # + attr_reader :disable_program + + # @private + def initialize parent_rpcs = nil + get_program_config = parent_rpcs.get_program if parent_rpcs.respond_to? :get_program + @get_program = ::Gapic::Config::Method.new get_program_config + list_programs_config = parent_rpcs.list_programs if parent_rpcs.respond_to? :list_programs + @list_programs = ::Gapic::Config::Method.new list_programs_config + enable_program_config = parent_rpcs.enable_program if parent_rpcs.respond_to? :enable_program + @enable_program = ::Gapic::Config::Method.new enable_program_config + disable_program_config = parent_rpcs.disable_program if parent_rpcs.respond_to? :disable_program + @disable_program = ::Gapic::Config::Method.new disable_program_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/service_stub.rb new file mode 100644 index 000000000000..fcf91fae48d0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_service/rest/service_stub.rb @@ -0,0 +1,309 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/programs_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + module Rest + ## + # REST service stub for the ProgramsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # A result object deserialized from the server's reply + def get_program request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_program_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_programs REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse] + # A result object deserialized from the server's reply + def list_programs request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_programs_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the enable_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # A result object deserialized from the server's reply + def enable_program request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_enable_program_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the disable_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program] + # A result object deserialized from the server's reply + def disable_program request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_disable_program_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_program_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/programs/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_programs REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_programs_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/programs", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the enable_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_enable_program_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{name}:enable", + body: "*", + matches: [ + ["name", %r{^accounts/[^/]+/programs/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the disable_program REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_disable_program_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{name}:disable", + body: "*", + matches: [ + ["name", %r{^accounts/[^/]+/programs/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_services_pb.rb new file mode 100644 index 000000000000..0e8e8c092895 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/programs_services_pb.rb @@ -0,0 +1,65 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/programs.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/programs_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ProgramsService + # Service for program management. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # + # This service exposes methods to retrieve a merchant's + # participation in all available programs, in addition to methods for + # explicitly enabling or disabling participation in each program. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.ProgramsService' + + # Retrieves the specified program for the account. + rpc :GetProgram, ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Program + # Retrieves all programs for the account. + rpc :ListPrograms, ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse + # Enable participation in the specified program for the account. Executing + # this method requires admin access. + rpc :EnableProgram, ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Program + # Disable participation in the specified program for the account. Executing + # this method requires admin access. + rpc :DisableProgram, ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Program + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_pb.rb new file mode 100644 index 000000000000..5eaa7c25a73d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_pb.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/regions.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' +require 'google/protobuf/field_mask_pb' +require 'google/protobuf/wrappers_pb' + + +descriptor_data = "\n6google/shopping/merchant/accounts/v1beta/regions.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\"K\n\x10GetRegionRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!merchantapi.googleapis.com/Region\"\xb0\x01\n\x13\x43reateRegionRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x16\n\tregion_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x45\n\x06region\x18\x03 \x01(\x0b\x32\x30.google.shopping.merchant.accounts.v1beta.RegionB\x03\xe0\x41\x02\"\x92\x01\n\x13UpdateRegionRequest\x12\x45\n\x06region\x18\x01 \x01(\x0b\x32\x30.google.shopping.merchant.accounts.v1beta.RegionB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x01\"N\n\x13\x44\x65leteRegionRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!merchantapi.googleapis.com/Region\"\x81\x01\n\x12ListRegionsRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\"q\n\x13ListRegionsResponse\x12\x41\n\x07regions\x18\x01 \x03(\x0b\x32\x30.google.shopping.merchant.accounts.v1beta.Region\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\xf1\x05\n\x06Region\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x1e\n\x0c\x64isplay_name\x18\x02 \x01(\tB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12^\n\x10postal_code_area\x18\x03 \x01(\x0b\x32?.google.shopping.merchant.accounts.v1beta.Region.PostalCodeAreaB\x03\xe0\x41\x01\x12[\n\x0egeotarget_area\x18\x04 \x01(\x0b\x32>.google.shopping.merchant.accounts.v1beta.Region.GeoTargetAreaB\x03\xe0\x41\x01\x12\x44\n\x1bregional_inventory_eligible\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.BoolValueB\x03\xe0\x41\x03\x12:\n\x11shipping_eligible\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.BoolValueB\x03\xe0\x41\x03\x1a\xcf\x01\n\x0ePostalCodeArea\x12\x18\n\x0bregion_code\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12j\n\x0cpostal_codes\x18\x02 \x03(\x0b\x32O.google.shopping.merchant.accounts.v1beta.Region.PostalCodeArea.PostalCodeRangeB\x03\xe0\x41\x02\x1a\x37\n\x0fPostalCodeRange\x12\x12\n\x05\x62\x65gin\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x10\n\x03\x65nd\x18\x02 \x01(\tB\x03\xe0\x41\x01\x1a\x34\n\rGeoTargetArea\x12#\n\x16geotarget_criteria_ids\x18\x01 \x03(\x03\x42\x03\xe0\x41\x02:\\\xea\x41Y\n!merchantapi.googleapis.com/Region\x12#accounts/{account}/regions/{region}*\x07regions2\x06regionB\x0f\n\r_display_name2\xb9\x08\n\x0eRegionsService\x12\xb6\x01\n\tGetRegion\x12:.google.shopping.merchant.accounts.v1beta.GetRegionRequest\x1a\x30.google.shopping.merchant.accounts.v1beta.Region\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.\x12,/accounts/v1beta/{name=accounts/*/regions/*}\x12\xd7\x01\n\x0c\x43reateRegion\x12=.google.shopping.merchant.accounts.v1beta.CreateRegionRequest\x1a\x30.google.shopping.merchant.accounts.v1beta.Region\"V\xda\x41\x17parent,region,region_id\x82\xd3\xe4\x93\x02\x36\",/accounts/v1beta/{parent=accounts/*}/regions:\x06region\x12\xd9\x01\n\x0cUpdateRegion\x12=.google.shopping.merchant.accounts.v1beta.UpdateRegionRequest\x1a\x30.google.shopping.merchant.accounts.v1beta.Region\"X\xda\x41\x12region,update_mask\x82\xd3\xe4\x93\x02=23/accounts/v1beta/{region.name=accounts/*/regions/*}:\x06region\x12\xa2\x01\n\x0c\x44\x65leteRegion\x12=.google.shopping.merchant.accounts.v1beta.DeleteRegionRequest\x1a\x16.google.protobuf.Empty\";\xda\x41\x04name\x82\xd3\xe4\x93\x02.*,/accounts/v1beta/{name=accounts/*/regions/*}\x12\xc9\x01\n\x0bListRegions\x12<.google.shopping.merchant.accounts.v1beta.ListRegionsRequest\x1a=.google.shopping.merchant.accounts.v1beta.ListRegionsResponse\"=\xda\x41\x06parent\x82\xd3\xe4\x93\x02.\x12,/accounts/v1beta/{parent=accounts/*}/regions\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x8e\x01\n,com.google.shopping.merchant.accounts.v1betaB\x0cRegionsProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ["google.protobuf.BoolValue", "google/protobuf/wrappers.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + GetRegionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetRegionRequest").msgclass + CreateRegionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CreateRegionRequest").msgclass + UpdateRegionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateRegionRequest").msgclass + DeleteRegionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.DeleteRegionRequest").msgclass + ListRegionsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListRegionsRequest").msgclass + ListRegionsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListRegionsResponse").msgclass + Region = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Region").msgclass + Region::PostalCodeArea = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Region.PostalCodeArea").msgclass + Region::PostalCodeArea::PostalCodeRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Region.PostalCodeArea.PostalCodeRange").msgclass + Region::GeoTargetArea = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Region.GeoTargetArea").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service.rb new file mode 100644 index 000000000000..e58e24faaaa2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/regions_service/credentials" +require "google/shopping/merchant/accounts/v1beta/regions_service/paths" +require "google/shopping/merchant/accounts/v1beta/regions_service/client" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Manages regions configuration. + # + # This API defines the following resource model: + # + # - [Region][google.shopping.merchant.accounts.v1main.Region] + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/regions_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/regions_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + module RegionsService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "regions_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/regions_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/client.rb new file mode 100644 index 000000000000..8b4cf82a7a17 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/client.rb @@ -0,0 +1,835 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/regions_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + ## + # Client for the RegionsService service. + # + # Manages regions configuration. + # + # This API defines the following resource model: + # + # - [Region][google.shopping.merchant.accounts.v1main.Region] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :regions_service_stub + + ## + # Configure the RegionsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all RegionsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the RegionsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @regions_service_stub.universe_domain + end + + ## + # Create a new RegionsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the RegionsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/regions_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @regions_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves a region defined in your Merchant Center account. + # + # @overload get_region(request, options = nil) + # Pass arguments to `get_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_region(name: nil) + # Pass arguments to `get_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the region to retrieve. + # Format: `accounts/{account}/regions/{region}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new + # + # # Call the get_region method. + # result = client.get_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def get_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_region.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.call_rpc :get_region, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a region definition in your Merchant Center account. Executing this + # method requires admin access. + # + # @overload create_region(request, options = nil) + # Pass arguments to `create_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload create_region(parent: nil, region_id: nil, region: nil) + # Pass arguments to `create_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account to create a region for. + # Format: `accounts/{account}` + # @param region_id [::String] + # Required. The identifier for the region, unique over all regions of the + # same account. + # @param region [::Google::Shopping::Merchant::Accounts::V1beta::Region, ::Hash] + # Required. The region to create. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new + # + # # Call the create_region method. + # result = client.create_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def create_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.create_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.create_region.timeout, + metadata: metadata, + retry_policy: @config.rpcs.create_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.call_rpc :create_region, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a region definition in your Merchant Center account. Executing this + # method requires admin access. + # + # @overload update_region(request, options = nil) + # Pass arguments to `update_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_region(region: nil, update_mask: nil) + # Pass arguments to `update_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param region [::Google::Shopping::Merchant::Accounts::V1beta::Region, ::Hash] + # Required. The updated region. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Optional. The comma-separated field mask indicating the fields to update. + # Example: + # `"displayName,postalCodeArea.regionCode"`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new + # + # # Call the update_region method. + # result = client.update_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def update_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.region&.name + header_params["region.name"] = request.region.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_region.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.call_rpc :update_region, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a region definition from your Merchant Center account. Executing + # this method requires admin access. + # + # @overload delete_region(request, options = nil) + # Pass arguments to `delete_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload delete_region(name: nil) + # Pass arguments to `delete_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the region to delete. + # Format: `accounts/{account}/regions/{region}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new + # + # # Call the delete_region method. + # result = client.delete_region request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.delete_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.delete_region.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.call_rpc :delete_region, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the regions in your Merchant Center account. + # + # @overload list_regions(request, options = nil) + # Pass arguments to `list_regions` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_regions(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_regions` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account to list regions for. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of regions to return. The service may return + # fewer than this value. + # If unspecified, at most 50 regions will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListRegions` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListRegions` must + # match the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Region>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Region>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new + # + # # Call the list_regions method. + # result = client.list_regions request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Region. + # p item + # end + # + def list_regions request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_regions.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_regions.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_regions.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.call_rpc :list_regions, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @regions_service_stub, :list_regions, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the RegionsService API. + # + # This class represents the configuration for RegionsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_region to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_region.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_region.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the RegionsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_region` + # @return [::Gapic::Config::Method] + # + attr_reader :get_region + ## + # RPC-specific configuration for `create_region` + # @return [::Gapic::Config::Method] + # + attr_reader :create_region + ## + # RPC-specific configuration for `update_region` + # @return [::Gapic::Config::Method] + # + attr_reader :update_region + ## + # RPC-specific configuration for `delete_region` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_region + ## + # RPC-specific configuration for `list_regions` + # @return [::Gapic::Config::Method] + # + attr_reader :list_regions + + # @private + def initialize parent_rpcs = nil + get_region_config = parent_rpcs.get_region if parent_rpcs.respond_to? :get_region + @get_region = ::Gapic::Config::Method.new get_region_config + create_region_config = parent_rpcs.create_region if parent_rpcs.respond_to? :create_region + @create_region = ::Gapic::Config::Method.new create_region_config + update_region_config = parent_rpcs.update_region if parent_rpcs.respond_to? :update_region + @update_region = ::Gapic::Config::Method.new update_region_config + delete_region_config = parent_rpcs.delete_region if parent_rpcs.respond_to? :delete_region + @delete_region = ::Gapic::Config::Method.new delete_region_config + list_regions_config = parent_rpcs.list_regions if parent_rpcs.respond_to? :list_regions + @list_regions = ::Gapic::Config::Method.new list_regions_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/credentials.rb new file mode 100644 index 000000000000..690d5a69e022 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + # Credentials for the RegionsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/paths.rb new file mode 100644 index 000000000000..f279f6252ae8 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + # Path helper methods for the RegionsService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified Region resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/regions/{region}` + # + # @param account [String] + # @param region [String] + # + # @return [::String] + def region_path account:, region: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/regions/#{region}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest.rb new file mode 100644 index 000000000000..b35660815568 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/regions_service/credentials" +require "google/shopping/merchant/accounts/v1beta/regions_service/paths" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Manages regions configuration. + # + # This API defines the following resource model: + # + # - [Region][google.shopping.merchant.accounts.v1main.Region] + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/regions_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + module RegionsService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/client.rb new file mode 100644 index 000000000000..69334c7c5c57 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/client.rb @@ -0,0 +1,774 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/regions_pb" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + module Rest + ## + # REST client for the RegionsService service. + # + # Manages regions configuration. + # + # This API defines the following resource model: + # + # - [Region][google.shopping.merchant.accounts.v1main.Region] + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :regions_service_stub + + ## + # Configure the RegionsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all RegionsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the RegionsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @regions_service_stub.universe_domain + end + + ## + # Create a new RegionsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the RegionsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @regions_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves a region defined in your Merchant Center account. + # + # @overload get_region(request, options = nil) + # Pass arguments to `get_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_region(name: nil) + # Pass arguments to `get_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the region to retrieve. + # Format: `accounts/{account}/regions/{region}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new + # + # # Call the get_region method. + # result = client.get_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def get_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_region.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.get_region request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a region definition in your Merchant Center account. Executing this + # method requires admin access. + # + # @overload create_region(request, options = nil) + # Pass arguments to `create_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload create_region(parent: nil, region_id: nil, region: nil) + # Pass arguments to `create_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account to create a region for. + # Format: `accounts/{account}` + # @param region_id [::String] + # Required. The identifier for the region, unique over all regions of the + # same account. + # @param region [::Google::Shopping::Merchant::Accounts::V1beta::Region, ::Hash] + # Required. The region to create. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new + # + # # Call the create_region method. + # result = client.create_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def create_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.create_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.create_region.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.create_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.create_region request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a region definition in your Merchant Center account. Executing this + # method requires admin access. + # + # @overload update_region(request, options = nil) + # Pass arguments to `update_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_region(region: nil, update_mask: nil) + # Pass arguments to `update_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param region [::Google::Shopping::Merchant::Accounts::V1beta::Region, ::Hash] + # Required. The updated region. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Optional. The comma-separated field mask indicating the fields to update. + # Example: + # `"displayName,postalCodeArea.regionCode"`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new + # + # # Call the update_region method. + # result = client.update_region request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + # p result + # + def update_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_region.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.update_region request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a region definition from your Merchant Center account. Executing + # this method requires admin access. + # + # @overload delete_region(request, options = nil) + # Pass arguments to `delete_region` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload delete_region(name: nil) + # Pass arguments to `delete_region` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the region to delete. + # Format: `accounts/{account}/regions/{region}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new + # + # # Call the delete_region method. + # result = client.delete_region request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_region request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.delete_region.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.delete_region.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_region.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.delete_region request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists the regions in your Merchant Center account. + # + # @overload list_regions(request, options = nil) + # Pass arguments to `list_regions` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_regions(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_regions` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account to list regions for. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of regions to return. The service may return + # fewer than this value. + # If unspecified, at most 50 regions will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListRegions` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListRegions` must + # match the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Region>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::Region>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new + # + # # Call the list_regions method. + # result = client.list_regions request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Region. + # p item + # end + # + def list_regions request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_regions.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_regions.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_regions.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @regions_service_stub.list_regions request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @regions_service_stub, :list_regions, "regions", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the RegionsService REST API. + # + # This class represents the configuration for RegionsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_region to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_region.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_region.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the RegionsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_region` + # @return [::Gapic::Config::Method] + # + attr_reader :get_region + ## + # RPC-specific configuration for `create_region` + # @return [::Gapic::Config::Method] + # + attr_reader :create_region + ## + # RPC-specific configuration for `update_region` + # @return [::Gapic::Config::Method] + # + attr_reader :update_region + ## + # RPC-specific configuration for `delete_region` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_region + ## + # RPC-specific configuration for `list_regions` + # @return [::Gapic::Config::Method] + # + attr_reader :list_regions + + # @private + def initialize parent_rpcs = nil + get_region_config = parent_rpcs.get_region if parent_rpcs.respond_to? :get_region + @get_region = ::Gapic::Config::Method.new get_region_config + create_region_config = parent_rpcs.create_region if parent_rpcs.respond_to? :create_region + @create_region = ::Gapic::Config::Method.new create_region_config + update_region_config = parent_rpcs.update_region if parent_rpcs.respond_to? :update_region + @update_region = ::Gapic::Config::Method.new update_region_config + delete_region_config = parent_rpcs.delete_region if parent_rpcs.respond_to? :delete_region + @delete_region = ::Gapic::Config::Method.new delete_region_config + list_regions_config = parent_rpcs.list_regions if parent_rpcs.respond_to? :list_regions + @list_regions = ::Gapic::Config::Method.new list_regions_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/service_stub.rb new file mode 100644 index 000000000000..f96f1a9dd4d7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_service/rest/service_stub.rb @@ -0,0 +1,368 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/regions_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + module Rest + ## + # REST service stub for the RegionsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # A result object deserialized from the server's reply + def get_region request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_region_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the create_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # A result object deserialized from the server's reply + def create_region request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_create_region_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # A result object deserialized from the server's reply + def update_region request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_region_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the delete_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_region request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_region_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_regions REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse] + # A result object deserialized from the server's reply + def list_regions request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_regions_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_region_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/regions/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the create_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_create_region_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{parent}/regions", + body: "region", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_region_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{region.name}", + body: "region", + matches: [ + ["region.name", %r{^accounts/[^/]+/regions/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_region REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_region_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/regions/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_regions REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_regions_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/regions", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_services_pb.rb new file mode 100644 index 000000000000..75c51b7653d6 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/regions_services_pb.rb @@ -0,0 +1,62 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/regions.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/regions_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module RegionsService + # Manages regions configuration. + # + # This API defines the following resource model: + # + # - [Region][google.shopping.merchant.accounts.v1main.Region] + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.RegionsService' + + # Retrieves a region defined in your Merchant Center account. + rpc :GetRegion, ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Region + # Creates a region definition in your Merchant Center account. Executing this + # method requires admin access. + rpc :CreateRegion, ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Region + # Updates a region definition in your Merchant Center account. Executing this + # method requires admin access. + rpc :UpdateRegion, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest, ::Google::Shopping::Merchant::Accounts::V1beta::Region + # Deletes a region definition from your Merchant Center account. Executing + # this method requires admin access. + rpc :DeleteRegion, ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest, ::Google::Protobuf::Empty + # Lists the regions in your Merchant Center account. + rpc :ListRegions, ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/rest.rb new file mode 100644 index 000000000000..97a5b3e4a1d8 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/rest.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest" +require "google/shopping/merchant/accounts/v1beta/user_service/rest" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest" +require "google/shopping/merchant/accounts/v1beta/version" + +module Google + module Shopping + module Merchant + module Accounts + ## + # To load just the REST part of this package, including all its services, and instantiate a REST client: + # + # @example + # + # require "google/shopping/merchant/accounts/v1beta/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new + # + module V1beta + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service.rb new file mode 100644 index 000000000000..c48a6b337e59 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/client" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to get method call shipping setting information per Merchant API + # method. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/shipping_settings_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new + # + module ShippingSettingsService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "shipping_settings_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/client.rb new file mode 100644 index 000000000000..629008493831 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/client.rb @@ -0,0 +1,526 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/shippingsettings_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ShippingSettingsService + ## + # Client for the ShippingSettingsService service. + # + # Service to get method call shipping setting information per Merchant API + # method. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :shipping_settings_service_stub + + ## + # Configure the ShippingSettingsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all ShippingSettingsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the ShippingSettingsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @shipping_settings_service_stub.universe_domain + end + + ## + # Create a new ShippingSettingsService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the ShippingSettingsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/shippingsettings_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @shipping_settings_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieve shipping setting information. + # + # @overload get_shipping_settings(request, options = nil) + # Pass arguments to `get_shipping_settings` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_shipping_settings(name: nil) + # Pass arguments to `get_shipping_settings` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the shipping setting to retrieve. + # Format: `accounts/{account}/shippingsetting` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new + # + # # Call the get_shipping_settings method. + # result = client.get_shipping_settings request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + # p result + # + def get_shipping_settings request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_shipping_settings.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_shipping_settings.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_shipping_settings.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @shipping_settings_service_stub.call_rpc :get_shipping_settings, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Replace the shipping setting of a merchant with the request shipping + # setting. Executing this method requires admin access. + # + # @overload insert_shipping_settings(request, options = nil) + # Pass arguments to `insert_shipping_settings` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload insert_shipping_settings(parent: nil, shipping_setting: nil) + # Pass arguments to `insert_shipping_settings` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account where this product will be inserted. + # Format: accounts/\\{account} + # @param shipping_setting [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings, ::Hash] + # Required. The new version of the account. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new + # + # # Call the insert_shipping_settings method. + # result = client.insert_shipping_settings request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + # p result + # + def insert_shipping_settings request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.insert_shipping_settings.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.insert_shipping_settings.timeout, + metadata: metadata, + retry_policy: @config.rpcs.insert_shipping_settings.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @shipping_settings_service_stub.call_rpc :insert_shipping_settings, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the ShippingSettingsService API. + # + # This class represents the configuration for ShippingSettingsService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_shipping_settings to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_shipping_settings.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_shipping_settings.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the ShippingSettingsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_shipping_settings` + # @return [::Gapic::Config::Method] + # + attr_reader :get_shipping_settings + ## + # RPC-specific configuration for `insert_shipping_settings` + # @return [::Gapic::Config::Method] + # + attr_reader :insert_shipping_settings + + # @private + def initialize parent_rpcs = nil + get_shipping_settings_config = parent_rpcs.get_shipping_settings if parent_rpcs.respond_to? :get_shipping_settings + @get_shipping_settings = ::Gapic::Config::Method.new get_shipping_settings_config + insert_shipping_settings_config = parent_rpcs.insert_shipping_settings if parent_rpcs.respond_to? :insert_shipping_settings + @insert_shipping_settings = ::Gapic::Config::Method.new insert_shipping_settings_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials.rb new file mode 100644 index 000000000000..4383546f8dd2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ShippingSettingsService + # Credentials for the ShippingSettingsService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths.rb new file mode 100644 index 000000000000..7189a5fb9764 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ShippingSettingsService + # Path helper methods for the ShippingSettingsService API. + module Paths + ## + # Create a fully-qualified ShippingSettings resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/shippingSettings` + # + # @param account [String] + # + # @return [::String] + def shipping_settings_path account: + "accounts/#{account}/shippingSettings" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest.rb new file mode 100644 index 000000000000..d7e6a65e5f8d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/credentials" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/paths" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to get method call shipping setting information per Merchant API + # method. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new + # + module ShippingSettingsService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/client.rb new file mode 100644 index 000000000000..90aa70fc12f4 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/client.rb @@ -0,0 +1,486 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/shippingsettings_pb" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ShippingSettingsService + module Rest + ## + # REST client for the ShippingSettingsService service. + # + # Service to get method call shipping setting information per Merchant API + # method. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :shipping_settings_service_stub + + ## + # Configure the ShippingSettingsService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all ShippingSettingsService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the ShippingSettingsService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @shipping_settings_service_stub.universe_domain + end + + ## + # Create a new ShippingSettingsService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the ShippingSettingsService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @shipping_settings_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieve shipping setting information. + # + # @overload get_shipping_settings(request, options = nil) + # Pass arguments to `get_shipping_settings` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_shipping_settings(name: nil) + # Pass arguments to `get_shipping_settings` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the shipping setting to retrieve. + # Format: `accounts/{account}/shippingsetting` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new + # + # # Call the get_shipping_settings method. + # result = client.get_shipping_settings request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + # p result + # + def get_shipping_settings request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_shipping_settings.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_shipping_settings.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_shipping_settings.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @shipping_settings_service_stub.get_shipping_settings request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Replace the shipping setting of a merchant with the request shipping + # setting. Executing this method requires admin access. + # + # @overload insert_shipping_settings(request, options = nil) + # Pass arguments to `insert_shipping_settings` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload insert_shipping_settings(parent: nil, shipping_setting: nil) + # Pass arguments to `insert_shipping_settings` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account where this product will be inserted. + # Format: accounts/\\{account} + # @param shipping_setting [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings, ::Hash] + # Required. The new version of the account. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new + # + # # Call the insert_shipping_settings method. + # result = client.insert_shipping_settings request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + # p result + # + def insert_shipping_settings request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.insert_shipping_settings.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.insert_shipping_settings.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.insert_shipping_settings.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @shipping_settings_service_stub.insert_shipping_settings request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the ShippingSettingsService REST API. + # + # This class represents the configuration for ShippingSettingsService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_shipping_settings to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_shipping_settings.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_shipping_settings.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the ShippingSettingsService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_shipping_settings` + # @return [::Gapic::Config::Method] + # + attr_reader :get_shipping_settings + ## + # RPC-specific configuration for `insert_shipping_settings` + # @return [::Gapic::Config::Method] + # + attr_reader :insert_shipping_settings + + # @private + def initialize parent_rpcs = nil + get_shipping_settings_config = parent_rpcs.get_shipping_settings if parent_rpcs.respond_to? :get_shipping_settings + @get_shipping_settings = ::Gapic::Config::Method.new get_shipping_settings_config + insert_shipping_settings_config = parent_rpcs.insert_shipping_settings if parent_rpcs.respond_to? :insert_shipping_settings + @insert_shipping_settings = ::Gapic::Config::Method.new insert_shipping_settings_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/service_stub.rb new file mode 100644 index 000000000000..6cd12f73589d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest/service_stub.rb @@ -0,0 +1,190 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/shippingsettings_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module ShippingSettingsService + module Rest + ## + # REST service stub for the ShippingSettingsService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_shipping_settings REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # A result object deserialized from the server's reply + def get_shipping_settings request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_shipping_settings_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the insert_shipping_settings REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # A result object deserialized from the server's reply + def insert_shipping_settings request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_insert_shipping_settings_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_shipping_settings REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_shipping_settings_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/shippingSettings/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the insert_shipping_settings REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_insert_shipping_settings_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{parent}/shippingSettings:insert", + body: "shipping_setting", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shippingsettings_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shippingsettings_pb.rb new file mode 100644 index 000000000000..b7b8d3769f26 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/shippingsettings_pb.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/shippingsettings.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/shopping/type/types_pb' + + +descriptor_data = "\n?google/shopping/merchant/accounts/v1beta/shippingsettings.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a google/shopping/type/types.proto\"\xcb\x02\n\x10ShippingSettings\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12H\n\x08services\x18\x02 \x03(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.ServiceB\x03\xe0\x41\x01\x12L\n\nwarehouses\x18\x03 \x03(\x0b\x32\x33.google.shopping.merchant.accounts.v1beta.WarehouseB\x03\xe0\x41\x01\x12\x11\n\x04\x65tag\x18\x04 \x01(\tB\x03\xe0\x41\x02:y\xea\x41v\n+merchantapi.googleapis.com/ShippingSettings\x12#accounts/{account}/shippingSettings*\x10shippingSettings2\x10shippingSettings\"\xc7\x10\n\x07Service\x12\x1e\n\x0cservice_name\x18\x01 \x01(\tB\x03\xe0\x41\x02H\x00\x88\x01\x01\x12\x18\n\x06\x61\x63tive\x18\x02 \x01(\x08\x42\x03\xe0\x41\x02H\x01\x88\x01\x01\x12\x1f\n\x12\x64\x65livery_countries\x18\x03 \x03(\tB\x03\xe0\x41\x02\x12\x1a\n\rcurrency_code\x18\x04 \x01(\tH\x02\x88\x01\x01\x12W\n\rdelivery_time\x18\x05 \x01(\x0b\x32\x36.google.shopping.merchant.accounts.v1beta.DeliveryTimeB\x03\xe0\x41\x02H\x03\x88\x01\x01\x12M\n\x0brate_groups\x18\x06 \x03(\x0b\x32\x33.google.shopping.merchant.accounts.v1beta.RateGroupB\x03\xe0\x41\x01\x12Z\n\rshipment_type\x18\x07 \x01(\x0e\x32>.google.shopping.merchant.accounts.v1beta.Service.ShipmentTypeH\x04\x88\x01\x01\x12=\n\x13minimum_order_value\x18\x08 \x01(\x0b\x32\x1b.google.shopping.type.PriceH\x05\x88\x01\x01\x12h\n\x19minimum_order_value_table\x18\t \x01(\x0b\x32@.google.shopping.merchant.accounts.v1beta.MinimumOrderValueTableH\x06\x88\x01\x01\x12X\n\x0cstore_config\x18\n \x01(\x0b\x32=.google.shopping.merchant.accounts.v1beta.Service.StoreConfigH\x07\x88\x01\x01\x12_\n\x10loyalty_programs\x18\x0b \x03(\x0b\x32@.google.shopping.merchant.accounts.v1beta.Service.LoyaltyProgramB\x03\xe0\x41\x01\x1a\xe2\x06\n\x0bStoreConfig\x12o\n\x12store_service_type\x18\x01 \x01(\x0e\x32N.google.shopping.merchant.accounts.v1beta.Service.StoreConfig.StoreServiceTypeH\x00\x88\x01\x01\x12\x18\n\x0bstore_codes\x18\x02 \x03(\tB\x03\xe0\x41\x01\x12\x66\n\rcutoff_config\x18\x03 \x01(\x0b\x32J.google.shopping.merchant.accounts.v1beta.Service.StoreConfig.CutoffConfigH\x01\x88\x01\x01\x12O\n\x0eservice_radius\x18\x04 \x01(\x0b\x32\x32.google.shopping.merchant.accounts.v1beta.DistanceH\x02\x88\x01\x01\x1a\xf5\x02\n\x0c\x43utoffConfig\x12z\n\x11local_cutoff_time\x18\x01 \x01(\x0b\x32Z.google.shopping.merchant.accounts.v1beta.Service.StoreConfig.CutoffConfig.LocalCutoffTimeH\x00\x88\x01\x01\x12%\n\x18store_close_offset_hours\x18\x02 \x01(\x03H\x01\x88\x01\x01\x12$\n\x17no_delivery_post_cutoff\x18\x03 \x01(\x08H\x02\x88\x01\x01\x1aM\n\x0fLocalCutoffTime\x12\x11\n\x04hour\x18\x01 \x01(\x03H\x00\x88\x01\x01\x12\x13\n\x06minute\x18\x02 \x01(\x03H\x01\x88\x01\x01\x42\x07\n\x05_hourB\t\n\x07_minuteB\x14\n\x12_local_cutoff_timeB\x1b\n\x19_store_close_offset_hoursB\x1a\n\x18_no_delivery_post_cutoff\"[\n\x10StoreServiceType\x12\"\n\x1eSTORE_SERVICE_TYPE_UNSPECIFIED\x10\x00\x12\x0e\n\nALL_STORES\x10\x01\x12\x13\n\x0fSELECTED_STORES\x10\x02\x42\x15\n\x13_store_service_typeB\x10\n\x0e_cutoff_configB\x11\n\x0f_service_radius\x1a\xf7\x01\n\x0eLoyaltyProgram\x12\x1a\n\rprogram_label\x18\x01 \x01(\tH\x00\x88\x01\x01\x12x\n\x15loyalty_program_tiers\x18\x02 \x03(\x0b\x32T.google.shopping.merchant.accounts.v1beta.Service.LoyaltyProgram.LoyaltyProgramTiersB\x03\xe0\x41\x01\x1a=\n\x13LoyaltyProgramTiers\x12\x17\n\ntier_label\x18\x01 \x01(\tH\x00\x88\x01\x01\x42\r\n\x0b_tier_labelB\x10\n\x0e_program_label\"e\n\x0cShipmentType\x12\x1d\n\x19SHIPMENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x44\x45LIVERY\x10\x01\x12\x12\n\x0eLOCAL_DELIVERY\x10\x02\x12\x14\n\x10\x43OLLECTION_POINT\x10\x03\x42\x0f\n\r_service_nameB\t\n\x07_activeB\x10\n\x0e_currency_codeB\x10\n\x0e_delivery_timeB\x10\n\x0e_shipment_typeB\x16\n\x14_minimum_order_valueB\x1c\n\x1a_minimum_order_value_tableB\x0f\n\r_store_config\"\xb6\x01\n\x08\x44istance\x12\x12\n\x05value\x18\x01 \x01(\x03H\x00\x88\x01\x01\x12J\n\x04unit\x18\x02 \x01(\x0e\x32\x37.google.shopping.merchant.accounts.v1beta.Distance.UnitH\x01\x88\x01\x01\"7\n\x04Unit\x12\x14\n\x10UNIT_UNSPECIFIED\x10\x00\x12\t\n\x05MILES\x10\x01\x12\x0e\n\nKILOMETERS\x10\x02\x42\x08\n\x06_valueB\x07\n\x05_unit\"\xb0\x03\n\tWarehouse\x12\x16\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02H\x00\x88\x01\x01\x12U\n\x10shipping_address\x18\x02 \x01(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.AddressB\x03\xe0\x41\x02H\x01\x88\x01\x01\x12\\\n\x0b\x63utoff_time\x18\x03 \x01(\x0b\x32=.google.shopping.merchant.accounts.v1beta.WarehouseCutoffTimeB\x03\xe0\x41\x02H\x02\x88\x01\x01\x12\x1f\n\rhandling_days\x18\x04 \x01(\x03\x42\x03\xe0\x41\x02H\x03\x88\x01\x01\x12]\n\x13\x62usiness_day_config\x18\x05 \x01(\x0b\x32;.google.shopping.merchant.accounts.v1beta.BusinessDayConfigH\x04\x88\x01\x01\x42\x07\n\x05_nameB\x13\n\x11_shipping_addressB\x0e\n\x0c_cutoff_timeB\x10\n\x0e_handling_daysB\x16\n\x14_business_day_config\"[\n\x13WarehouseCutoffTime\x12\x16\n\x04hour\x18\x01 \x01(\x05\x42\x03\xe0\x41\x02H\x00\x88\x01\x01\x12\x18\n\x06minute\x18\x02 \x01(\x05\x42\x03\xe0\x41\x02H\x01\x88\x01\x01\x42\x07\n\x05_hourB\t\n\x07_minute\"\xf7\x01\n\x07\x41\x64\x64ress\x12\x1b\n\x0estreet_address\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x16\n\x04\x63ity\x18\x02 \x01(\tB\x03\xe0\x41\x02H\x01\x88\x01\x01\x12%\n\x13\x61\x64ministrative_area\x18\x03 \x01(\tB\x03\xe0\x41\x02H\x02\x88\x01\x01\x12\x1d\n\x0bpostal_code\x18\x04 \x01(\tB\x03\xe0\x41\x02H\x03\x88\x01\x01\x12\x1d\n\x0bregion_code\x18\x05 \x01(\tB\x03\xe0\x41\x02H\x04\x88\x01\x01\x42\x11\n\x0f_street_addressB\x07\n\x05_cityB\x16\n\x14_administrative_areaB\x0e\n\x0c_postal_codeB\x0e\n\x0c_region_code\"\xb5\x06\n\x0c\x44\x65liveryTime\x12\x1d\n\x10min_transit_days\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x1d\n\x10max_transit_days\x18\x02 \x01(\x05H\x01\x88\x01\x01\x12N\n\x0b\x63utoff_time\x18\x03 \x01(\x0b\x32\x34.google.shopping.merchant.accounts.v1beta.CutoffTimeH\x02\x88\x01\x01\x12\x1e\n\x11min_handling_days\x18\x04 \x01(\x05H\x03\x88\x01\x01\x12\x1e\n\x11max_handling_days\x18\x05 \x01(\x05H\x04\x88\x01\x01\x12W\n\x12transit_time_table\x18\x06 \x01(\x0b\x32\x36.google.shopping.merchant.accounts.v1beta.TransitTableH\x05\x88\x01\x01\x12\x66\n\x1chandling_business_day_config\x18\x07 \x01(\x0b\x32;.google.shopping.merchant.accounts.v1beta.BusinessDayConfigH\x06\x88\x01\x01\x12\x65\n\x1btransit_business_day_config\x18\x08 \x01(\x0b\x32;.google.shopping.merchant.accounts.v1beta.BusinessDayConfigH\x07\x88\x01\x01\x12q\n\x1ewarehouse_based_delivery_times\x18\t \x03(\x0b\x32\x44.google.shopping.merchant.accounts.v1beta.WarehouseBasedDeliveryTimeB\x03\xe0\x41\x01\x42\x13\n\x11_min_transit_daysB\x13\n\x11_max_transit_daysB\x0e\n\x0c_cutoff_timeB\x14\n\x12_min_handling_daysB\x14\n\x12_max_handling_daysB\x15\n\x13_transit_time_tableB\x1f\n\x1d_handling_business_day_configB\x1e\n\x1c_transit_business_day_config\"}\n\nCutoffTime\x12\x16\n\x04hour\x18\x01 \x01(\x05\x42\x03\xe0\x41\x02H\x00\x88\x01\x01\x12\x18\n\x06minute\x18\x02 \x01(\x05\x42\x03\xe0\x41\x02H\x01\x88\x01\x01\x12\x1b\n\ttime_zone\x18\x03 \x01(\tB\x03\xe0\x41\x02H\x02\x88\x01\x01\x42\x07\n\x05_hourB\t\n\x07_minuteB\x0c\n\n_time_zone\"\xf4\x01\n\x11\x42usinessDayConfig\x12_\n\rbusiness_days\x18\x01 \x03(\x0e\x32\x43.google.shopping.merchant.accounts.v1beta.BusinessDayConfig.WeekdayB\x03\xe0\x41\x02\"~\n\x07Weekday\x12\x17\n\x13WEEKDAY_UNSPECIFIED\x10\x00\x12\n\n\x06MONDAY\x10\x01\x12\x0b\n\x07TUESDAY\x10\x02\x12\r\n\tWEDNESDAY\x10\x03\x12\x0c\n\x08THURSDAY\x10\x04\x12\n\n\x06\x46RIDAY\x10\x05\x12\x0c\n\x08SATURDAY\x10\x06\x12\n\n\x06SUNDAY\x10\x07\"\xa5\x01\n\x1aWarehouseBasedDeliveryTime\x12\x19\n\x07\x63\x61rrier\x18\x01 \x01(\tB\x03\xe0\x41\x02H\x00\x88\x01\x01\x12!\n\x0f\x63\x61rrier_service\x18\x02 \x01(\tB\x03\xe0\x41\x02H\x01\x88\x01\x01\x12\x1b\n\twarehouse\x18\x03 \x01(\tB\x03\xe0\x41\x02H\x02\x88\x01\x01\x42\n\n\x08_carrierB\x12\n\x10_carrier_serviceB\x0c\n\n_warehouse\"\xa7\x03\n\tRateGroup\x12\'\n\x1a\x61pplicable_shipping_labels\x18\x01 \x03(\tB\x03\xe0\x41\x02\x12J\n\x0csingle_value\x18\x02 \x01(\x0b\x32/.google.shopping.merchant.accounts.v1beta.ValueH\x00\x88\x01\x01\x12H\n\nmain_table\x18\x03 \x01(\x0b\x32/.google.shopping.merchant.accounts.v1beta.TableH\x01\x88\x01\x01\x12G\n\tsubtables\x18\x04 \x03(\x0b\x32/.google.shopping.merchant.accounts.v1beta.TableB\x03\xe0\x41\x01\x12Q\n\rcarrier_rates\x18\x05 \x03(\x0b\x32\x35.google.shopping.merchant.accounts.v1beta.CarrierRateB\x03\xe0\x41\x01\x12\x16\n\x04name\x18\x06 \x01(\tB\x03\xe0\x41\x01H\x02\x88\x01\x01\x42\x0f\n\r_single_valueB\r\n\x0b_main_tableB\x07\n\x05_name\"\xaa\x02\n\x05Table\x12\x11\n\x04name\x18\x01 \x01(\tH\x00\x88\x01\x01\x12P\n\x0brow_headers\x18\x02 \x01(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.HeadersB\x03\xe0\x41\x02H\x01\x88\x01\x01\x12N\n\x0e\x63olumn_headers\x18\x03 \x01(\x0b\x32\x31.google.shopping.merchant.accounts.v1beta.HeadersH\x02\x88\x01\x01\x12@\n\x04rows\x18\x04 \x03(\x0b\x32-.google.shopping.merchant.accounts.v1beta.RowB\x03\xe0\x41\x02\x42\x07\n\x05_nameB\x0e\n\x0c_row_headersB\x11\n\x0f_column_headers\"\xac\x03\n\x0cTransitTable\x12$\n\x17postal_code_group_names\x18\x01 \x03(\tB\x03\xe0\x41\x02\x12 \n\x13transit_time_labels\x18\x02 \x03(\tB\x03\xe0\x41\x02\x12X\n\x04rows\x18\x03 \x03(\x0b\x32\x45.google.shopping.merchant.accounts.v1beta.TransitTable.TransitTimeRowB\x03\xe0\x41\x02\x1a\xf9\x01\n\x0eTransitTimeRow\x12k\n\x06values\x18\x01 \x03(\x0b\x32V.google.shopping.merchant.accounts.v1beta.TransitTable.TransitTimeRow.TransitTimeValueB\x03\xe0\x41\x02\x1az\n\x10TransitTimeValue\x12\x1d\n\x10min_transit_days\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x1d\n\x10max_transit_days\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x13\n\x11_min_transit_daysB\x13\n\x11_max_transit_days\"\x81\x02\n\x16MinimumOrderValueTable\x12{\n\x18store_code_set_with_movs\x18\x01 \x03(\x0b\x32T.google.shopping.merchant.accounts.v1beta.MinimumOrderValueTable.StoreCodeSetWithMovB\x03\xe0\x41\x02\x1aj\n\x13StoreCodeSetWithMov\x12\x18\n\x0bstore_codes\x18\x01 \x03(\tB\x03\xe0\x41\x01\x12/\n\x05value\x18\x02 \x01(\x0b\x32\x1b.google.shopping.type.PriceH\x00\x88\x01\x01\x42\x08\n\x06_value\"\x84\x02\n\x07Headers\x12\x30\n\x06prices\x18\x01 \x03(\x0b\x32\x1b.google.shopping.type.PriceB\x03\xe0\x41\x02\x12\x32\n\x07weights\x18\x02 \x03(\x0b\x32\x1c.google.shopping.type.WeightB\x03\xe0\x41\x02\x12\x1c\n\x0fnumber_of_items\x18\x03 \x03(\tB\x03\xe0\x41\x02\x12$\n\x17postal_code_group_names\x18\x04 \x03(\tB\x03\xe0\x41\x02\x12O\n\tlocations\x18\x05 \x03(\x0b\x32\x37.google.shopping.merchant.accounts.v1beta.LocationIdSetB\x03\xe0\x41\x02\"*\n\rLocationIdSet\x12\x19\n\x0clocation_ids\x18\x01 \x03(\tB\x03\xe0\x41\x02\"J\n\x03Row\x12\x43\n\x05\x63\x65lls\x18\x01 \x03(\x0b\x32/.google.shopping.merchant.accounts.v1beta.ValueB\x03\xe0\x41\x02\"\xf8\x01\n\x05Value\x12\x18\n\x0bno_shipping\x18\x01 \x01(\x08H\x00\x88\x01\x01\x12\x33\n\tflat_rate\x18\x02 \x01(\x0b\x32\x1b.google.shopping.type.PriceH\x01\x88\x01\x01\x12\x1d\n\x10price_percentage\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x19\n\x0c\x63\x61rrier_rate\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x15\n\x08subtable\x18\x05 \x01(\tH\x04\x88\x01\x01\x42\x0e\n\x0c_no_shippingB\x0c\n\n_flat_rateB\x13\n\x11_price_percentageB\x0f\n\r_carrier_rateB\x0b\n\t_subtable\"\xe0\x02\n\x0b\x43\x61rrierRate\x12\x16\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02H\x00\x88\x01\x01\x12\x19\n\x07\x63\x61rrier\x18\x02 \x01(\tB\x03\xe0\x41\x02H\x01\x88\x01\x01\x12!\n\x0f\x63\x61rrier_service\x18\x03 \x01(\tB\x03\xe0\x41\x02H\x02\x88\x01\x01\x12$\n\x12origin_postal_code\x18\x04 \x01(\tB\x03\xe0\x41\x02H\x03\x88\x01\x01\x12\'\n\x15percentage_adjustment\x18\x05 \x01(\tB\x03\xe0\x41\x01H\x04\x88\x01\x01\x12>\n\x0f\x66lat_adjustment\x18\x06 \x01(\x0b\x32\x1b.google.shopping.type.PriceB\x03\xe0\x41\x01H\x05\x88\x01\x01\x42\x07\n\x05_nameB\n\n\x08_carrierB\x12\n\x10_carrier_serviceB\x15\n\x13_origin_postal_codeB\x18\n\x16_percentage_adjustmentB\x12\n\x10_flat_adjustment\"_\n\x1aGetShippingSettingsRequest\x12\x41\n\x04name\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+merchantapi.googleapis.com/ShippingSettings\"\x8f\x01\n\x1dInsertShippingSettingsRequest\x12\x13\n\x06parent\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12Y\n\x10shipping_setting\x18\x02 \x01(\x0b\x32:.google.shopping.merchant.accounts.v1beta.ShippingSettingsB\x03\xe0\x41\x02\x32\xb8\x04\n\x17ShippingSettingsService\x12\xdb\x01\n\x13GetShippingSettings\x12\x44.google.shopping.merchant.accounts.v1beta.GetShippingSettingsRequest\x1a:.google.shopping.merchant.accounts.v1beta.ShippingSettings\"B\xda\x41\x04name\x82\xd3\xe4\x93\x02\x35\x12\x33/accounts/v1beta/{name=accounts/*/shippingSettings}\x12\xf5\x01\n\x16InsertShippingSettings\x12G.google.shopping.merchant.accounts.v1beta.InsertShippingSettingsRequest\x1a:.google.shopping.merchant.accounts.v1beta.ShippingSettings\"V\x82\xd3\xe4\x93\x02P\" e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves the state of the agreement for the application terms of service. + # + # @overload retrieve_for_application_terms_of_service_agreement_state(request, options = nil) + # Pass arguments to `retrieve_for_application_terms_of_service_agreement_state` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload retrieve_for_application_terms_of_service_agreement_state(parent: nil) + # Pass arguments to `retrieve_for_application_terms_of_service_agreement_state` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account for which to get a TermsOfServiceAgreementState + # Format: `accounts/{account}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new + # + # # Call the retrieve_for_application_terms_of_service_agreement_state method. + # result = client.retrieve_for_application_terms_of_service_agreement_state request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState. + # p result + # + def retrieve_for_application_terms_of_service_agreement_state request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.timeout, + metadata: metadata, + retry_policy: @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_agreement_state_service_stub.call_rpc :retrieve_for_application_terms_of_service_agreement_state, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the TermsOfServiceAgreementStateService API. + # + # This class represents the configuration for TermsOfServiceAgreementStateService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_terms_of_service_agreement_state to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service_agreement_state.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service_agreement_state.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the TermsOfServiceAgreementStateService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_terms_of_service_agreement_state` + # @return [::Gapic::Config::Method] + # + attr_reader :get_terms_of_service_agreement_state + ## + # RPC-specific configuration for `retrieve_for_application_terms_of_service_agreement_state` + # @return [::Gapic::Config::Method] + # + attr_reader :retrieve_for_application_terms_of_service_agreement_state + + # @private + def initialize parent_rpcs = nil + get_terms_of_service_agreement_state_config = parent_rpcs.get_terms_of_service_agreement_state if parent_rpcs.respond_to? :get_terms_of_service_agreement_state + @get_terms_of_service_agreement_state = ::Gapic::Config::Method.new get_terms_of_service_agreement_state_config + retrieve_for_application_terms_of_service_agreement_state_config = parent_rpcs.retrieve_for_application_terms_of_service_agreement_state if parent_rpcs.respond_to? :retrieve_for_application_terms_of_service_agreement_state + @retrieve_for_application_terms_of_service_agreement_state = ::Gapic::Config::Method.new retrieve_for_application_terms_of_service_agreement_state_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/credentials.rb new file mode 100644 index 000000000000..18d34d40a98e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceAgreementStateService + # Credentials for the TermsOfServiceAgreementStateService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/paths.rb new file mode 100644 index 000000000000..c00da5bd22a5 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceAgreementStateService + # Path helper methods for the TermsOfServiceAgreementStateService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified TermsOfServiceAgreementState resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/termsOfServiceAgreementStates/{identifier}` + # + # @param account [String] + # @param identifier [String] + # + # @return [::String] + def terms_of_service_agreement_state_path account:, identifier: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/termsOfServiceAgreementStates/#{identifier}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest.rb new file mode 100644 index 000000000000..2ad8d30c4059 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/credentials" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/paths" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support `TermsOfServiceAgreementState` API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new + # + module TermsOfServiceAgreementStateService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/client.rb new file mode 100644 index 000000000000..1b9ec90ede47 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/client.rb @@ -0,0 +1,482 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceAgreementStateService + module Rest + ## + # REST client for the TermsOfServiceAgreementStateService service. + # + # Service to support `TermsOfServiceAgreementState` API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :terms_of_service_agreement_state_service_stub + + ## + # Configure the TermsOfServiceAgreementStateService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all TermsOfServiceAgreementStateService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the TermsOfServiceAgreementStateService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @terms_of_service_agreement_state_service_stub.universe_domain + end + + ## + # Create a new TermsOfServiceAgreementStateService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the TermsOfServiceAgreementStateService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @terms_of_service_agreement_state_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Returns the state of a terms of service agreement. + # + # @overload get_terms_of_service_agreement_state(request, options = nil) + # Pass arguments to `get_terms_of_service_agreement_state` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_terms_of_service_agreement_state(name: nil) + # Pass arguments to `get_terms_of_service_agreement_state` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the terms of service version. + # Format: `accounts/{account}/termsOfServiceAgreementState/{identifier}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new + # + # # Call the get_terms_of_service_agreement_state method. + # result = client.get_terms_of_service_agreement_state request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState. + # p result + # + def get_terms_of_service_agreement_state request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_terms_of_service_agreement_state.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_terms_of_service_agreement_state.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_terms_of_service_agreement_state.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_agreement_state_service_stub.get_terms_of_service_agreement_state request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves the state of the agreement for the application terms of service. + # + # @overload retrieve_for_application_terms_of_service_agreement_state(request, options = nil) + # Pass arguments to `retrieve_for_application_terms_of_service_agreement_state` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload retrieve_for_application_terms_of_service_agreement_state(parent: nil) + # Pass arguments to `retrieve_for_application_terms_of_service_agreement_state` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The account for which to get a TermsOfServiceAgreementState + # Format: `accounts/{account}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new + # + # # Call the retrieve_for_application_terms_of_service_agreement_state method. + # result = client.retrieve_for_application_terms_of_service_agreement_state request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState. + # p result + # + def retrieve_for_application_terms_of_service_agreement_state request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.retrieve_for_application_terms_of_service_agreement_state.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_agreement_state_service_stub.retrieve_for_application_terms_of_service_agreement_state request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the TermsOfServiceAgreementStateService REST API. + # + # This class represents the configuration for TermsOfServiceAgreementStateService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_terms_of_service_agreement_state to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service_agreement_state.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service_agreement_state.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the TermsOfServiceAgreementStateService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_terms_of_service_agreement_state` + # @return [::Gapic::Config::Method] + # + attr_reader :get_terms_of_service_agreement_state + ## + # RPC-specific configuration for `retrieve_for_application_terms_of_service_agreement_state` + # @return [::Gapic::Config::Method] + # + attr_reader :retrieve_for_application_terms_of_service_agreement_state + + # @private + def initialize parent_rpcs = nil + get_terms_of_service_agreement_state_config = parent_rpcs.get_terms_of_service_agreement_state if parent_rpcs.respond_to? :get_terms_of_service_agreement_state + @get_terms_of_service_agreement_state = ::Gapic::Config::Method.new get_terms_of_service_agreement_state_config + retrieve_for_application_terms_of_service_agreement_state_config = parent_rpcs.retrieve_for_application_terms_of_service_agreement_state if parent_rpcs.respond_to? :retrieve_for_application_terms_of_service_agreement_state + @retrieve_for_application_terms_of_service_agreement_state = ::Gapic::Config::Method.new retrieve_for_application_terms_of_service_agreement_state_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/service_stub.rb new file mode 100644 index 000000000000..cabfca9382ce --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest/service_stub.rb @@ -0,0 +1,189 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceAgreementStateService + module Rest + ## + # REST service stub for the TermsOfServiceAgreementStateService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_terms_of_service_agreement_state REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # A result object deserialized from the server's reply + def get_terms_of_service_agreement_state request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_terms_of_service_agreement_state_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the retrieve_for_application_terms_of_service_agreement_state REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState] + # A result object deserialized from the server's reply + def retrieve_for_application_terms_of_service_agreement_state request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_retrieve_for_application_terms_of_service_agreement_state_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_terms_of_service_agreement_state REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_terms_of_service_agreement_state_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/termsOfServiceAgreementStates/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the retrieve_for_application_terms_of_service_agreement_state REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_retrieve_for_application_terms_of_service_agreement_state_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/termsOfServiceAgreementStates:retrieveForApplication", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service.rb new file mode 100644 index 000000000000..52a35d3fbf35 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/client" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support `TermsOfService` API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/terms_of_service_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + module TermsOfServiceService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "terms_of_service_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/client.rb new file mode 100644 index 000000000000..96a3c4a9a721 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/client.rb @@ -0,0 +1,623 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/termsofservice_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + ## + # Client for the TermsOfServiceService service. + # + # Service to support `TermsOfService` API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :terms_of_service_service_stub + + ## + # Configure the TermsOfServiceService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all TermsOfServiceService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the TermsOfServiceService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @terms_of_service_service_stub.universe_domain + end + + ## + # Create a new TermsOfServiceService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the TermsOfServiceService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/termsofservice_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @terms_of_service_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves the `TermsOfService` associated with the provided version. + # + # @overload get_terms_of_service(request, options = nil) + # Pass arguments to `get_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_terms_of_service(name: nil) + # Pass arguments to `get_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new + # + # # Call the get_terms_of_service method. + # result = client.get_terms_of_service request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + # p result + # + def get_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_terms_of_service.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.call_rpc :get_terms_of_service, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves the latest version of the `TermsOfService` for a given `kind` and + # `region_code`. + # + # @overload retrieve_latest_terms_of_service(request, options = nil) + # Pass arguments to `retrieve_latest_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload retrieve_latest_terms_of_service(region_code: nil, kind: nil) + # Pass arguments to `retrieve_latest_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param region_code [::String] + # Region code as defined by [CLDR](https://cldr.unicode.org/). This is either + # a country when the ToS applies specifically to that country or 001 when it + # applies globally. + # @param kind [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceKind] + # The Kind this terms of service version applies to. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new + # + # # Call the retrieve_latest_terms_of_service method. + # result = client.retrieve_latest_terms_of_service request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + # p result + # + def retrieve_latest_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.retrieve_latest_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.retrieve_latest_terms_of_service.timeout, + metadata: metadata, + retry_policy: @config.rpcs.retrieve_latest_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.call_rpc :retrieve_latest_terms_of_service, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Accepts a `TermsOfService`. Executing this method requires admin access. + # + # @overload accept_terms_of_service(request, options = nil) + # Pass arguments to `accept_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload accept_terms_of_service(name: nil, account: nil, region_code: nil) + # Pass arguments to `accept_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # @param account [::String] + # Required. The account for which to accept the ToS. + # @param region_code [::String] + # Required. Region code as defined by [CLDR](https://cldr.unicode.org/). This + # is either a country when the ToS applies specifically to that country or + # 001 when it applies globally. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new + # + # # Call the accept_terms_of_service method. + # result = client.accept_terms_of_service request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def accept_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.accept_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.accept_terms_of_service.timeout, + metadata: metadata, + retry_policy: @config.rpcs.accept_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.call_rpc :accept_terms_of_service, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the TermsOfServiceService API. + # + # This class represents the configuration for TermsOfServiceService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_terms_of_service to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the TermsOfServiceService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :get_terms_of_service + ## + # RPC-specific configuration for `retrieve_latest_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :retrieve_latest_terms_of_service + ## + # RPC-specific configuration for `accept_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :accept_terms_of_service + + # @private + def initialize parent_rpcs = nil + get_terms_of_service_config = parent_rpcs.get_terms_of_service if parent_rpcs.respond_to? :get_terms_of_service + @get_terms_of_service = ::Gapic::Config::Method.new get_terms_of_service_config + retrieve_latest_terms_of_service_config = parent_rpcs.retrieve_latest_terms_of_service if parent_rpcs.respond_to? :retrieve_latest_terms_of_service + @retrieve_latest_terms_of_service = ::Gapic::Config::Method.new retrieve_latest_terms_of_service_config + accept_terms_of_service_config = parent_rpcs.accept_terms_of_service if parent_rpcs.respond_to? :accept_terms_of_service + @accept_terms_of_service = ::Gapic::Config::Method.new accept_terms_of_service_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials.rb new file mode 100644 index 000000000000..edd918629f9b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + # Credentials for the TermsOfServiceService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths.rb new file mode 100644 index 000000000000..6f84bd71bdca --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + # Path helper methods for the TermsOfServiceService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified TermsOfService resource string. + # + # The resource will be in the following format: + # + # `termsOfService/{version}` + # + # @param version [String] + # + # @return [::String] + def terms_of_service_path version: + "termsOfService/#{version}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest.rb new file mode 100644 index 000000000000..70c6bc912605 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/credentials" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/paths" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support `TermsOfService` API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + module TermsOfServiceService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/client.rb new file mode 100644 index 000000000000..d20203a12f67 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/client.rb @@ -0,0 +1,584 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/termsofservice_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + module Rest + ## + # REST client for the TermsOfServiceService service. + # + # Service to support `TermsOfService` API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :terms_of_service_service_stub + + ## + # Configure the TermsOfServiceService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all TermsOfServiceService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.timeout = 60.0 + default_config.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the TermsOfServiceService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @terms_of_service_service_stub.universe_domain + end + + ## + # Create a new TermsOfServiceService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the TermsOfServiceService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @terms_of_service_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves the `TermsOfService` associated with the provided version. + # + # @overload get_terms_of_service(request, options = nil) + # Pass arguments to `get_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_terms_of_service(name: nil) + # Pass arguments to `get_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new + # + # # Call the get_terms_of_service method. + # result = client.get_terms_of_service request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + # p result + # + def get_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_terms_of_service.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.get_terms_of_service request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Retrieves the latest version of the `TermsOfService` for a given `kind` and + # `region_code`. + # + # @overload retrieve_latest_terms_of_service(request, options = nil) + # Pass arguments to `retrieve_latest_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload retrieve_latest_terms_of_service(region_code: nil, kind: nil) + # Pass arguments to `retrieve_latest_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param region_code [::String] + # Region code as defined by [CLDR](https://cldr.unicode.org/). This is either + # a country when the ToS applies specifically to that country or 001 when it + # applies globally. + # @param kind [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceKind] + # The Kind this terms of service version applies to. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new + # + # # Call the retrieve_latest_terms_of_service method. + # result = client.retrieve_latest_terms_of_service request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + # p result + # + def retrieve_latest_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.retrieve_latest_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.retrieve_latest_terms_of_service.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.retrieve_latest_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.retrieve_latest_terms_of_service request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Accepts a `TermsOfService`. Executing this method requires admin access. + # + # @overload accept_terms_of_service(request, options = nil) + # Pass arguments to `accept_terms_of_service` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload accept_terms_of_service(name: nil, account: nil, region_code: nil) + # Pass arguments to `accept_terms_of_service` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # @param account [::String] + # Required. The account for which to accept the ToS. + # @param region_code [::String] + # Required. Region code as defined by [CLDR](https://cldr.unicode.org/). This + # is either a country when the ToS applies specifically to that country or + # 001 when it applies globally. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new + # + # # Call the accept_terms_of_service method. + # result = client.accept_terms_of_service request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def accept_terms_of_service request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.accept_terms_of_service.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.accept_terms_of_service.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.accept_terms_of_service.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @terms_of_service_service_stub.accept_terms_of_service request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the TermsOfServiceService REST API. + # + # This class represents the configuration for TermsOfServiceService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_terms_of_service to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_terms_of_service.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the TermsOfServiceService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :get_terms_of_service + ## + # RPC-specific configuration for `retrieve_latest_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :retrieve_latest_terms_of_service + ## + # RPC-specific configuration for `accept_terms_of_service` + # @return [::Gapic::Config::Method] + # + attr_reader :accept_terms_of_service + + # @private + def initialize parent_rpcs = nil + get_terms_of_service_config = parent_rpcs.get_terms_of_service if parent_rpcs.respond_to? :get_terms_of_service + @get_terms_of_service = ::Gapic::Config::Method.new get_terms_of_service_config + retrieve_latest_terms_of_service_config = parent_rpcs.retrieve_latest_terms_of_service if parent_rpcs.respond_to? :retrieve_latest_terms_of_service + @retrieve_latest_terms_of_service = ::Gapic::Config::Method.new retrieve_latest_terms_of_service_config + accept_terms_of_service_config = parent_rpcs.accept_terms_of_service if parent_rpcs.respond_to? :accept_terms_of_service + @accept_terms_of_service = ::Gapic::Config::Method.new accept_terms_of_service_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/service_stub.rb new file mode 100644 index 000000000000..8250c19b50b5 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest/service_stub.rb @@ -0,0 +1,246 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/termsofservice_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + module Rest + ## + # REST service stub for the TermsOfServiceService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # A result object deserialized from the server's reply + def get_terms_of_service request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_terms_of_service_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the retrieve_latest_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService] + # A result object deserialized from the server's reply + def retrieve_latest_terms_of_service request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_retrieve_latest_terms_of_service_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the accept_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def accept_terms_of_service request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_accept_terms_of_service_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_terms_of_service_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^termsOfService/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the retrieve_latest_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_retrieve_latest_terms_of_service_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/termsOfService:retrieveLatest", + matches: [] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the accept_terms_of_service REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_accept_terms_of_service_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}:accept", + matches: [ + ["name", %r{^termsOfService/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_pb.rb new file mode 100644 index 000000000000..bebec99d25f7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_pb.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/termsofservice.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' +require 'google/shopping/merchant/accounts/v1beta/termsofservicekind_pb' + + +descriptor_data = "\n=google/shopping/merchant/accounts/v1beta/termsofservice.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x41google/shopping/merchant/accounts/v1beta/termsofservicekind.proto\"\xb2\x02\n\x0eTermsOfService\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x08\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\x12\x13\n\x0bregion_code\x18\x02 \x01(\t\x12J\n\x04kind\x18\x03 \x01(\x0e\x32<.google.shopping.merchant.accounts.v1beta.TermsOfServiceKind\x12\x15\n\x08\x66ile_uri\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x10\n\x08\x65xternal\x18\x05 \x01(\x08:H\xea\x41\x45\n)merchantapi.googleapis.com/TermsOfService\x12\x18termsOfService/{version}B\x0b\n\t_file_uri\"[\n\x18GetTermsOfServiceRequest\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\"\x86\x01\n#RetrieveLatestTermsOfServiceRequest\x12\x13\n\x0bregion_code\x18\x01 \x01(\t\x12J\n\x04kind\x18\x02 \x01(\x0e\x32<.google.shopping.merchant.accounts.v1beta.TermsOfServiceKind\"\xb5\x01\n\x1b\x41\x63\x63\x65ptTermsOfServiceRequest\x12?\n\x04name\x18\x01 \x01(\tB1\xe0\x41\x02\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\x12;\n\x07\x61\x63\x63ount\x18\x02 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x18\n\x0bregion_code\x18\x03 \x01(\tB\x03\xe0\x41\x02\x32\xc7\x05\n\x15TermsOfServiceService\x12\xca\x01\n\x11GetTermsOfService\x12\x42.google.shopping.merchant.accounts.v1beta.GetTermsOfServiceRequest\x1a\x38.google.shopping.merchant.accounts.v1beta.TermsOfService\"7\xda\x41\x04name\x82\xd3\xe4\x93\x02*\x12(/accounts/v1beta/{name=termsOfService/*}\x12\xdf\x01\n\x1cRetrieveLatestTermsOfService\x12M.google.shopping.merchant.accounts.v1beta.RetrieveLatestTermsOfServiceRequest\x1a\x38.google.shopping.merchant.accounts.v1beta.TermsOfService\"6\x82\xd3\xe4\x93\x02\x30\x12./accounts/v1beta/termsOfService:retrieveLatest\x12\xb5\x01\n\x14\x41\x63\x63\x65ptTermsOfService\x12\x45.google.shopping.merchant.accounts.v1beta.AcceptTermsOfServiceRequest\x1a\x16.google.protobuf.Empty\">\xda\x41\x04name\x82\xd3\xe4\x93\x02\x31\x12//accounts/v1beta/{name=termsOfService/*}:accept\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x95\x01\n,com.google.shopping.merchant.accounts.v1betaB\x13TermsOfServiceProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + TermsOfService = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.TermsOfService").msgclass + GetTermsOfServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetTermsOfServiceRequest").msgclass + RetrieveLatestTermsOfServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.RetrieveLatestTermsOfServiceRequest").msgclass + AcceptTermsOfServiceRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.AcceptTermsOfServiceRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_services_pb.rb new file mode 100644 index 000000000000..39854de674c1 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservice_services_pb.rb @@ -0,0 +1,52 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/termsofservice.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/termsofservice_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceService + # Service to support `TermsOfService` API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.TermsOfServiceService' + + # Retrieves the `TermsOfService` associated with the provided version. + rpc :GetTermsOfService, ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest, ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService + # Retrieves the latest version of the `TermsOfService` for a given `kind` and + # `region_code`. + rpc :RetrieveLatestTermsOfService, ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest, ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService + # Accepts a `TermsOfService`. Executing this method requires admin access. + rpc :AcceptTermsOfService, ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest, ::Google::Protobuf::Empty + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb.rb new file mode 100644 index 000000000000..41897eab736e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/shopping/merchant/accounts/v1beta/termsofservicekind_pb' +require 'google/type/date_pb' + + +descriptor_data = "\nKgoogle/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x41google/shopping/merchant/accounts/v1beta/termsofservicekind.proto\x1a\x16google/type/date.proto\"\x8f\x04\n\x1cTermsOfServiceAgreementState\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x13\n\x0bregion_code\x18\x02 \x01(\t\x12[\n\x15terms_of_service_kind\x18\x03 \x01(\x0e\x32<.google.shopping.merchant.accounts.v1beta.TermsOfServiceKind\x12I\n\x08\x61\x63\x63\x65pted\x18\x04 \x01(\x0b\x32\x32.google.shopping.merchant.accounts.v1beta.AcceptedH\x00\x88\x01\x01\x12I\n\x08required\x18\x05 \x01(\x0b\x32\x32.google.shopping.merchant.accounts.v1beta.RequiredH\x01\x88\x01\x01:\xb9\x01\xea\x41\xb5\x01\n7merchantapi.googleapis.com/TermsOfServiceAgreementState\x12=accounts/{account}/termsOfServiceAgreementStates/{identifier}*\x1dtermsOfServiceAgreementStates2\x1ctermsOfServiceAgreementStateB\x0b\n\t_acceptedB\x0b\n\t_required\"\xcf\x01\n\x08\x41\x63\x63\x65pted\x12H\n\x10terms_of_service\x18\x01 \x01(\tB.\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\x12<\n\x0b\x61\x63\x63\x65pted_by\x18\x02 \x01(\tB\'\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12+\n\x0bvalid_until\x18\x03 \x01(\x0b\x32\x11.google.type.DateH\x00\x88\x01\x01\x42\x0e\n\x0c_valid_until\"j\n\x08Required\x12H\n\x10terms_of_service\x18\x01 \x01(\tB.\xfa\x41+\n)merchantapi.googleapis.com/TermsOfService\x12\x14\n\x0ctos_file_uri\x18\x02 \x01(\t\"w\n&GetTermsOfServiceAgreementStateRequest\x12M\n\x04name\x18\x01 \x01(\tB?\xe0\x41\x02\xfa\x41\x39\n7merchantapi.googleapis.com/TermsOfServiceAgreementState\"\x8c\x01\n9RetrieveForApplicationTermsOfServiceAgreementStateRequest\x12O\n\x06parent\x18\x01 \x01(\tB?\xe0\x41\x02\xfa\x41\x39\x12\x37merchantapi.googleapis.com/TermsOfServiceAgreementState2\xcf\x05\n#TermsOfServiceAgreementStateService\x12\x8e\x02\n\x1fGetTermsOfServiceAgreementState\x12P.google.shopping.merchant.accounts.v1beta.GetTermsOfServiceAgreementStateRequest\x1a\x46.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementState\"Q\xda\x41\x04name\x82\xd3\xe4\x93\x02\x44\x12\x42/accounts/v1beta/{name=accounts/*/termsOfServiceAgreementStates/*}\x12\xcd\x02\n2RetrieveForApplicationTermsOfServiceAgreementState\x12\x63.google.shopping.merchant.accounts.v1beta.RetrieveForApplicationTermsOfServiceAgreementStateRequest\x1a\x46.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementState\"j\xda\x41\x06parent\x82\xd3\xe4\x93\x02[\x12Y/accounts/v1beta/{parent=accounts/*}/termsOfServiceAgreementStates:retrieveForApplication\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xa3\x01\n,com.google.shopping.merchant.accounts.v1betaB!TermsOfServiceAgreementStateProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.type.Date", "google/type/date.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + TermsOfServiceAgreementState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementState").msgclass + Accepted = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Accepted").msgclass + Required = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.Required").msgclass + GetTermsOfServiceAgreementStateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetTermsOfServiceAgreementStateRequest").msgclass + RetrieveForApplicationTermsOfServiceAgreementStateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.RetrieveForApplicationTermsOfServiceAgreementStateRequest").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_services_pb.rb new file mode 100644 index 000000000000..f083fda56793 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_services_pb.rb @@ -0,0 +1,49 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module TermsOfServiceAgreementStateService + # Service to support `TermsOfServiceAgreementState` API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateService' + + # Returns the state of a terms of service agreement. + rpc :GetTermsOfServiceAgreementState, ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest, ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState + # Retrieves the state of the agreement for the application terms of service. + rpc :RetrieveForApplicationTermsOfServiceAgreementState, ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest, ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservicekind_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservicekind_pb.rb new file mode 100644 index 000000000000..080dd9c4f994 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/termsofservicekind_pb.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/termsofservicekind.proto + +require 'google/protobuf' + + +descriptor_data = "\nAgoogle/shopping/merchant/accounts/v1beta/termsofservicekind.proto\x12(google.shopping.merchant.accounts.v1beta*P\n\x12TermsOfServiceKind\x12%\n!TERMS_OF_SERVICE_KIND_UNSPECIFIED\x10\x00\x12\x13\n\x0fMERCHANT_CENTER\x10\x01\x42\x99\x01\n,com.google.shopping.merchant.accounts.v1betaB\x17TermsOfServiceKindProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + TermsOfServiceKind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.TermsOfServiceKind").enummodule + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_pb.rb new file mode 100644 index 000000000000..2152b592038f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_pb.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/shopping/merchant/accounts/v1beta/user.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/protobuf/empty_pb' +require 'google/protobuf/field_mask_pb' +require 'google/shopping/merchant/accounts/v1beta/accessright_pb' + + +descriptor_data = "\n3google/shopping/merchant/accounts/v1beta/user.proto\x12(google.shopping.merchant.accounts.v1beta\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a:google/shopping/merchant/accounts/v1beta/accessright.proto\"\xc6\x02\n\x04User\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12H\n\x05state\x18\x02 \x01(\x0e\x32\x34.google.shopping.merchant.accounts.v1beta.User.StateB\x03\xe0\x41\x03\x12Q\n\raccess_rights\x18\x04 \x03(\x0e\x32\x35.google.shopping.merchant.accounts.v1beta.AccessRightB\x03\xe0\x41\x01\"9\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0b\n\x07PENDING\x10\x01\x12\x0c\n\x08VERIFIED\x10\x02:S\xea\x41P\n\x1fmerchantapi.googleapis.com/User\x12 accounts/{account}/users/{email}*\x05users2\x04user\"G\n\x0eGetUserRequest\x12\x35\n\x04name\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fmerchantapi.googleapis.com/User\"\xa8\x01\n\x11\x43reateUserRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x14\n\x07user_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x41\n\x04user\x18\x03 \x01(\x0b\x32..google.shopping.merchant.accounts.v1beta.UserB\x03\xe0\x41\x02\"J\n\x11\x44\x65leteUserRequest\x12\x35\n\x04name\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fmerchantapi.googleapis.com/User\"\x8c\x01\n\x11UpdateUserRequest\x12\x41\n\x04user\x18\x01 \x01(\x0b\x32..google.shopping.merchant.accounts.v1beta.UserB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\"\x7f\n\x10ListUsersRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Account\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\"k\n\x11ListUsersResponse\x12=\n\x05users\x18\x01 \x03(\x0b\x32..google.shopping.merchant.accounts.v1beta.User\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xfc\x07\n\x0bUserService\x12\xae\x01\n\x07GetUser\x12\x38.google.shopping.merchant.accounts.v1beta.GetUserRequest\x1a..google.shopping.merchant.accounts.v1beta.User\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,\x12*/accounts/v1beta/{name=accounts/*/users/*}\x12\xc1\x01\n\nCreateUser\x12;.google.shopping.merchant.accounts.v1beta.CreateUserRequest\x1a..google.shopping.merchant.accounts.v1beta.User\"F\xda\x41\x0bparent,user\x82\xd3\xe4\x93\x02\x32\"*/accounts/v1beta/{parent=accounts/*}/users:\x04user\x12\x9c\x01\n\nDeleteUser\x12;.google.shopping.merchant.accounts.v1beta.DeleteUserRequest\x1a\x16.google.protobuf.Empty\"9\xda\x41\x04name\x82\xd3\xe4\x93\x02,**/accounts/v1beta/{name=accounts/*/users/*}\x12\xcb\x01\n\nUpdateUser\x12;.google.shopping.merchant.accounts.v1beta.UpdateUserRequest\x1a..google.shopping.merchant.accounts.v1beta.User\"P\xda\x41\x10user,update_mask\x82\xd3\xe4\x93\x02\x37\x32//accounts/v1beta/{user.name=accounts/*/users/*}:\x04user\x12\xc1\x01\n\tListUsers\x12:.google.shopping.merchant.accounts.v1beta.ListUsersRequest\x1a;.google.shopping.merchant.accounts.v1beta.ListUsersResponse\";\xda\x41\x06parent\x82\xd3\xe4\x93\x02,\x12*/accounts/v1beta/{parent=accounts/*}/users\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\x8b\x01\n,com.google.shopping.merchant.accounts.v1betaB\tUserProtoP\x01ZNcloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspbb\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.FieldMask", "google/protobuf/field_mask.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + User = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.User").msgclass + User::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.User.State").enummodule + GetUserRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.GetUserRequest").msgclass + CreateUserRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.CreateUserRequest").msgclass + DeleteUserRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.DeleteUserRequest").msgclass + UpdateUserRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.UpdateUserRequest").msgclass + ListUsersRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListUsersRequest").msgclass + ListUsersResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.accounts.v1beta.ListUsersResponse").msgclass + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service.rb new file mode 100644 index 000000000000..51ac9a6431b9 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/user_service/credentials" +require "google/shopping/merchant/accounts/v1beta/user_service/paths" +require "google/shopping/merchant/accounts/v1beta/user_service/client" +require "google/shopping/merchant/accounts/v1beta/user_service/rest" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support user API. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/shopping/merchant/accounts/v1beta/user_service" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/shopping/merchant/accounts/v1beta/user_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + module UserService + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "user_service", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/user_service/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/client.rb new file mode 100644 index 000000000000..109e5b7de22a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/client.rb @@ -0,0 +1,838 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/user_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + ## + # Client for the UserService service. + # + # Service to support user API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :user_service_stub + + ## + # Configure the UserService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all UserService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the UserService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @user_service_stub.universe_domain + end + + ## + # Create a new UserService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the UserService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # These require statements are intentionally placed here to initialize + # the gRPC module only when it's required. + # See https://github.com/googleapis/toolkit/issues/446 + require "gapic/grpc" + require "google/shopping/merchant/accounts/v1beta/user_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @user_service_stub = ::Gapic::ServiceStub.new( + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool + ) + end + + # Service calls + + ## + # Retrieves a Merchant Center account user. + # + # @overload get_user(request, options = nil) + # Pass arguments to `get_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload get_user(name: nil) + # Pass arguments to `get_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the user to retrieve. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to retrieve the user corresponding to the caller by + # using `me` rather than an email address as in + # `accounts/{account}/users/me`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new + # + # # Call the get_user method. + # result = client.get_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def get_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.get_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.get_user.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.call_rpc :get_user, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload create_user(request, options = nil) + # Pass arguments to `create_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload create_user(parent: nil, user_id: nil, user: nil) + # Pass arguments to `create_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The resource name of the account for which a user will be + # created. Format: `accounts/{account}` + # @param user_id [::String] + # Required. The email address of the user (for example, + # `john.doe@gmail.com`). + # @param user [::Google::Shopping::Merchant::Accounts::V1beta::User, ::Hash] + # Required. The user to create. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new + # + # # Call the create_user method. + # result = client.create_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def create_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.create_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.create_user.timeout, + metadata: metadata, + retry_policy: @config.rpcs.create_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.call_rpc :create_user, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload delete_user(request, options = nil) + # Pass arguments to `delete_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload delete_user(name: nil) + # Pass arguments to `delete_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the user to delete. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to delete the user corresponding to the caller by using + # `me` rather than an email address as in `accounts/{account}/users/me`. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new + # + # # Call the delete_user method. + # result = client.delete_user request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.delete_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.name + header_params["name"] = request.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.delete_user.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.call_rpc :delete_user, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload update_user(request, options = nil) + # Pass arguments to `update_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload update_user(user: nil, update_mask: nil) + # Pass arguments to `update_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param user [::Google::Shopping::Merchant::Accounts::V1beta::User, ::Hash] + # Required. The new version of the user. + # + # Use `me` to refer to your own email address, for example + # `accounts/{account}/users/me`. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new + # + # # Call the update_user method. + # result = client.update_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def update_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.update_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.user&.name + header_params["user.name"] = request.user.name + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.update_user.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.call_rpc :update_user, request, options: options do |response, operation| + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists all users of a Merchant Center account. + # + # @overload list_users(request, options = nil) + # Pass arguments to `list_users` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. + # + # @overload list_users(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_users` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of users. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of users to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @param page_token [::String] + # Optional. A page token, received from a previous `ListUsers` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListUsers` must match + # the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::User>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::User>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new + # + # # Call the list_users method. + # result = client.list_users request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::User. + # p item + # end + # + def list_users request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + metadata = @config.rpcs.list_users.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_users.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_users.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.call_rpc :list_users, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @user_service_stub, :list_users, request, response, operation, options + yield response, operation if block_given? + return response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the UserService API. + # + # This class represents the configuration for UserService, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_user to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_user.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_user.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the UserService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_user` + # @return [::Gapic::Config::Method] + # + attr_reader :get_user + ## + # RPC-specific configuration for `create_user` + # @return [::Gapic::Config::Method] + # + attr_reader :create_user + ## + # RPC-specific configuration for `delete_user` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_user + ## + # RPC-specific configuration for `update_user` + # @return [::Gapic::Config::Method] + # + attr_reader :update_user + ## + # RPC-specific configuration for `list_users` + # @return [::Gapic::Config::Method] + # + attr_reader :list_users + + # @private + def initialize parent_rpcs = nil + get_user_config = parent_rpcs.get_user if parent_rpcs.respond_to? :get_user + @get_user = ::Gapic::Config::Method.new get_user_config + create_user_config = parent_rpcs.create_user if parent_rpcs.respond_to? :create_user + @create_user = ::Gapic::Config::Method.new create_user_config + delete_user_config = parent_rpcs.delete_user if parent_rpcs.respond_to? :delete_user + @delete_user = ::Gapic::Config::Method.new delete_user_config + update_user_config = parent_rpcs.update_user if parent_rpcs.respond_to? :update_user + @update_user = ::Gapic::Config::Method.new update_user_config + list_users_config = parent_rpcs.list_users if parent_rpcs.respond_to? :list_users + @list_users = ::Gapic::Config::Method.new list_users_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/credentials.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/credentials.rb new file mode 100644 index 000000000000..c8a665edc908 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/credentials.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + # Credentials for the UserService API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/content" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/paths.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/paths.rb new file mode 100644 index 000000000000..35ba76bcac5d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/paths.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + # Path helper methods for the UserService API. + module Paths + ## + # Create a fully-qualified Account resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}` + # + # @param account [String] + # + # @return [::String] + def account_path account: + "accounts/#{account}" + end + + ## + # Create a fully-qualified User resource string. + # + # The resource will be in the following format: + # + # `accounts/{account}/users/{email}` + # + # @param account [String] + # @param email [String] + # + # @return [::String] + def user_path account:, email: + raise ::ArgumentError, "account cannot contain /" if account.to_s.include? "/" + + "accounts/#{account}/users/#{email}" + end + + extend self + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest.rb new file mode 100644 index 000000000000..eb03ba11cbb3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/shopping/merchant/accounts/v1beta/version" + +require "google/shopping/merchant/accounts/v1beta/user_service/credentials" +require "google/shopping/merchant/accounts/v1beta/user_service/paths" +require "google/shopping/merchant/accounts/v1beta/user_service/rest/client" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + ## + # Service to support user API. + # + # To load this service and instantiate a REST client: + # + # require "google/shopping/merchant/accounts/v1beta/user_service/rest" + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + module UserService + # Client for the REST transport + module Rest + end + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/shopping/merchant/accounts/v1beta/user_service/rest/helpers" if ::File.file? helper_path diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/client.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/client.rb new file mode 100644 index 000000000000..abf856e6e345 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/client.rb @@ -0,0 +1,777 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/shopping/merchant/accounts/v1beta/user_pb" +require "google/shopping/merchant/accounts/v1beta/user_service/rest/service_stub" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + module Rest + ## + # REST client for the UserService service. + # + # Service to support user API. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :user_service_stub + + ## + # Configure the UserService Client class. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all UserService clients + # ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Shopping", "Merchant", "Accounts", "V1beta"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the UserService Client instance. + # + # The configuration is set to the derived mode, meaning that values can be changed, + # but structural changes (adding new fields, etc.) are not allowed. Structural changes + # should be made on {Client.configure}. + # + # See {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @user_service_stub.universe_domain + end + + ## + # Create a new UserService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the UserService client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint.nil? || + (@config.endpoint == Configuration::DEFAULT_ENDPOINT && + !@config.endpoint.split(".").first.include?("-")) + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt + if credentials.is_a?(::String) || credentials.is_a?(::Hash) + credentials = Credentials.new credentials, scope: @config.scope + end + + @quota_project_id = @config.quota_project + @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id + + @user_service_stub = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials + ) + end + + # Service calls + + ## + # Retrieves a Merchant Center account user. + # + # @overload get_user(request, options = nil) + # Pass arguments to `get_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload get_user(name: nil) + # Pass arguments to `get_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the user to retrieve. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to retrieve the user corresponding to the caller by + # using `me` rather than an email address as in + # `accounts/{account}/users/me`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new + # + # # Call the get_user method. + # result = client.get_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def get_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.get_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.get_user.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.get_user request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Creates a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload create_user(request, options = nil) + # Pass arguments to `create_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload create_user(parent: nil, user_id: nil, user: nil) + # Pass arguments to `create_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The resource name of the account for which a user will be + # created. Format: `accounts/{account}` + # @param user_id [::String] + # Required. The email address of the user (for example, + # `john.doe@gmail.com`). + # @param user [::Google::Shopping::Merchant::Accounts::V1beta::User, ::Hash] + # Required. The user to create. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new + # + # # Call the create_user method. + # result = client.create_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def create_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.create_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.create_user.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.create_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.create_user request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload delete_user(request, options = nil) + # Pass arguments to `delete_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload delete_user(name: nil) + # Pass arguments to `delete_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param name [::String] + # Required. The name of the user to delete. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to delete the user corresponding to the caller by using + # `me` rather than an email address as in `accounts/{account}/users/me`. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new + # + # # Call the delete_user method. + # result = client.delete_user request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.delete_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.delete_user.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.delete_user request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates a Merchant Center account user. Executing this method requires + # admin access. + # + # @overload update_user(request, options = nil) + # Pass arguments to `update_user` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update_user(user: nil, update_mask: nil) + # Pass arguments to `update_user` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param user [::Google::Shopping::Merchant::Accounts::V1beta::User, ::Hash] + # Required. The new version of the user. + # + # Use `me` to refer to your own email address, for example + # `accounts/{account}/users/me`. + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. List of fields being updated. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new + # + # # Call the update_user method. + # result = client.update_user request + # + # # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + # p result + # + def update_user request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update_user.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update_user.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_user.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.update_user request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists all users of a Merchant Center account. + # + # @overload list_users(request, options = nil) + # Pass arguments to `list_users` via a request object, either of type + # {::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest} or an equivalent Hash. + # + # @param request [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload list_users(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_users` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The parent, which owns this collection of users. + # Format: `accounts/{account}` + # @param page_size [::Integer] + # Optional. The maximum number of users to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @param page_token [::String] + # Optional. A page token, received from a previous `ListUsers` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListUsers` must match + # the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::User>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::Accounts::V1beta::User>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/shopping/merchant/accounts/v1beta" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new + # + # # Call the list_users method. + # result = client.list_users request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::User. + # p item + # end + # + def list_users request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.list_users.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Shopping::Merchant::Accounts::V1beta::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_users.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_users.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @user_service_stub.list_users request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @user_service_stub, :list_users, "users", request, result, options + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the UserService REST API. + # + # This class represents the configuration for UserService REST, + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. + # + # Configuration can be applied globally to all clients, or to a single client + # on construction. + # + # @example + # + # # Modify the global config, setting the timeout for + # # get_user to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.get_user.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.get_user.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional headers to be sent with the call. + # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "merchantapi.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr :timeout, nil, ::Numeric, nil + config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil + config_attr :universe_domain, nil, ::String, nil + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the UserService API. + # + # Includes fields providing the configuration for each RPC in this service. + # Each configuration object is of type `Gapic::Config::Method` and includes + # the following configuration fields: + # + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `get_user` + # @return [::Gapic::Config::Method] + # + attr_reader :get_user + ## + # RPC-specific configuration for `create_user` + # @return [::Gapic::Config::Method] + # + attr_reader :create_user + ## + # RPC-specific configuration for `delete_user` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_user + ## + # RPC-specific configuration for `update_user` + # @return [::Gapic::Config::Method] + # + attr_reader :update_user + ## + # RPC-specific configuration for `list_users` + # @return [::Gapic::Config::Method] + # + attr_reader :list_users + + # @private + def initialize parent_rpcs = nil + get_user_config = parent_rpcs.get_user if parent_rpcs.respond_to? :get_user + @get_user = ::Gapic::Config::Method.new get_user_config + create_user_config = parent_rpcs.create_user if parent_rpcs.respond_to? :create_user + @create_user = ::Gapic::Config::Method.new create_user_config + delete_user_config = parent_rpcs.delete_user if parent_rpcs.respond_to? :delete_user + @delete_user = ::Gapic::Config::Method.new delete_user_config + update_user_config = parent_rpcs.update_user if parent_rpcs.respond_to? :update_user + @update_user = ::Gapic::Config::Method.new update_user_config + list_users_config = parent_rpcs.list_users if parent_rpcs.respond_to? :list_users + @list_users = ::Gapic::Config::Method.new list_users_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/service_stub.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/service_stub.rb new file mode 100644 index 000000000000..446027f6ccc6 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_service/rest/service_stub.rb @@ -0,0 +1,368 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/shopping/merchant/accounts/v1beta/user_pb" + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + module Rest + ## + # REST service stub for the UserService service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + def initialize endpoint:, endpoint_template:, universe_domain:, credentials: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + raise_faraday_errors: false + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # Baseline implementation for the get_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # A result object deserialized from the server's reply + def get_user request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_user_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::User.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the create_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # A result object deserialized from the server's reply + def create_user request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_create_user_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::User.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the delete_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_user request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_user_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the update_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::User] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # A result object deserialized from the server's reply + def update_user request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_user_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::User.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # Baseline implementation for the list_users REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse] + # A result object deserialized from the server's reply + def list_users request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_users_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse.decode_json response.body, ignore_unknown_fields: true + + yield result, operation if block_given? + result + end + + ## + # @private + # + # GRPC transcoding helper method for the get_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_user_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/users/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the create_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_create_user_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/accounts/v1beta/{parent}/users", + body: "user", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_user_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/accounts/v1beta/{name}", + matches: [ + ["name", %r{^accounts/[^/]+/users/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_user REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_user_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/accounts/v1beta/{user.name}", + body: "user", + matches: [ + ["user.name", %r{^accounts/[^/]+/users/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_users REST call + # + # @param request_pb [::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_users_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/accounts/v1beta/{parent}/users", + matches: [ + ["parent", %r{^accounts/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_services_pb.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_services_pb.rb new file mode 100644 index 000000000000..3513243cf7e0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/user_services_pb.rb @@ -0,0 +1,58 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/shopping/merchant/accounts/v1beta/user.proto for package 'google.shopping.merchant.accounts.v1beta' +# Original file comments: +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/shopping/merchant/accounts/v1beta/user_pb' + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + module UserService + # Service to support user API. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.shopping.merchant.accounts.v1beta.UserService' + + # Retrieves a Merchant Center account user. + rpc :GetUser, ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest, ::Google::Shopping::Merchant::Accounts::V1beta::User + # Creates a Merchant Center account user. Executing this method requires + # admin access. + rpc :CreateUser, ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, ::Google::Shopping::Merchant::Accounts::V1beta::User + # Deletes a Merchant Center account user. Executing this method requires + # admin access. + rpc :DeleteUser, ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest, ::Google::Protobuf::Empty + # Updates a Merchant Center account user. Executing this method requires + # admin access. + rpc :UpdateUser, ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest, ::Google::Shopping::Merchant::Accounts::V1beta::User + # Lists all users of a Merchant Center account. + rpc :ListUsers, ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest, ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/version.rb b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/version.rb new file mode 100644 index 000000000000..9e7a2ef1fa82 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/lib/google/shopping/merchant/accounts/v1beta/version.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + VERSION = "0.0.1" + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/README.md b/google-shopping-merchant-accounts-v1beta/proto_docs/README.md new file mode 100644 index 000000000000..03467a3756be --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/README.md @@ -0,0 +1,4 @@ +# Merchant V1BETA Protocol Buffer Documentation + +These files are for the YARD documentation of the generated protobuf files. +They are not intended to be required or loaded at runtime. diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/client.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/client.rb new file mode 100644 index 000000000000..934c39849a6a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/client.rb @@ -0,0 +1,399 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # Required information for every language. + # @!attribute [rw] reference_docs_uri + # @deprecated This field is deprecated and may be removed in the next major version update. + # @return [::String] + # Link to automatically generated reference documentation. Example: + # https://cloud.google.com/nodejs/docs/reference/asset/latest + # @!attribute [rw] destinations + # @return [::Array<::Google::Api::ClientLibraryDestination>] + # The destination where API teams want this client library to be published. + class CommonLanguageSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Details about how and where to publish client libraries. + # @!attribute [rw] version + # @return [::String] + # Version of the API to apply these settings to. This is the full protobuf + # package for the API, ending in the version element. + # Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + # @!attribute [rw] launch_stage + # @return [::Google::Api::LaunchStage] + # Launch stage of this version of the API. + # @!attribute [rw] rest_numeric_enums + # @return [::Boolean] + # When using transport=rest, the client request will encode enums as + # numbers rather than strings. + # @!attribute [rw] java_settings + # @return [::Google::Api::JavaSettings] + # Settings for legacy Java features, supported in the Service YAML. + # @!attribute [rw] cpp_settings + # @return [::Google::Api::CppSettings] + # Settings for C++ client libraries. + # @!attribute [rw] php_settings + # @return [::Google::Api::PhpSettings] + # Settings for PHP client libraries. + # @!attribute [rw] python_settings + # @return [::Google::Api::PythonSettings] + # Settings for Python client libraries. + # @!attribute [rw] node_settings + # @return [::Google::Api::NodeSettings] + # Settings for Node client libraries. + # @!attribute [rw] dotnet_settings + # @return [::Google::Api::DotnetSettings] + # Settings for .NET client libraries. + # @!attribute [rw] ruby_settings + # @return [::Google::Api::RubySettings] + # Settings for Ruby client libraries. + # @!attribute [rw] go_settings + # @return [::Google::Api::GoSettings] + # Settings for Go client libraries. + class ClientLibrarySettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # This message configures the settings for publishing [Google Cloud Client + # libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) + # generated from the service config. + # @!attribute [rw] method_settings + # @return [::Array<::Google::Api::MethodSettings>] + # A list of API method settings, e.g. the behavior for methods that use the + # long-running operation pattern. + # @!attribute [rw] new_issue_uri + # @return [::String] + # Link to a *public* URI where users can report issues. Example: + # https://issuetracker.google.com/issues/new?component=190865&template=1161103 + # @!attribute [rw] documentation_uri + # @return [::String] + # Link to product home page. Example: + # https://cloud.google.com/asset-inventory/docs/overview + # @!attribute [rw] api_short_name + # @return [::String] + # Used as a tracking tag when collecting data about the APIs developer + # relations artifacts like docs, packages delivered to package managers, + # etc. Example: "speech". + # @!attribute [rw] github_label + # @return [::String] + # GitHub label to apply to issues and pull requests opened for this API. + # @!attribute [rw] codeowner_github_teams + # @return [::Array<::String>] + # GitHub teams to be added to CODEOWNERS in the directory in GitHub + # containing source code for the client libraries for this API. + # @!attribute [rw] doc_tag_prefix + # @return [::String] + # A prefix used in sample code when demarking regions to be included in + # documentation. + # @!attribute [rw] organization + # @return [::Google::Api::ClientLibraryOrganization] + # For whom the client library is being published. + # @!attribute [rw] library_settings + # @return [::Array<::Google::Api::ClientLibrarySettings>] + # Client library settings. If the same version string appears multiple + # times in this list, then the last one wins. Settings from earlier + # settings with the same version string are discarded. + # @!attribute [rw] proto_reference_documentation_uri + # @return [::String] + # Optional link to proto reference documentation. Example: + # https://cloud.google.com/pubsub/lite/docs/reference/rpc + # @!attribute [rw] rest_reference_documentation_uri + # @return [::String] + # Optional link to REST reference documentation. Example: + # https://cloud.google.com/pubsub/lite/docs/reference/rest + class Publishing + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Java client libraries. + # @!attribute [rw] library_package + # @return [::String] + # The package name to use in Java. Clobbers the java_package option + # set in the protobuf. This should be used **only** by APIs + # who have already set the language_settings.java.package_name" field + # in gapic.yaml. API teams should use the protobuf java_package option + # where possible. + # + # Example of a YAML configuration:: + # + # publishing: + # java_settings: + # library_package: com.google.cloud.pubsub.v1 + # @!attribute [rw] service_class_names + # @return [::Google::Protobuf::Map{::String => ::String}] + # Configure the Java class name to use instead of the service's for its + # corresponding generated GAPIC client. Keys are fully-qualified + # service names as they appear in the protobuf (including the full + # the language_settings.java.interface_names" field in gapic.yaml. API + # teams should otherwise use the service name as it appears in the + # protobuf. + # + # Example of a YAML configuration:: + # + # publishing: + # java_settings: + # service_class_names: + # - google.pubsub.v1.Publisher: TopicAdmin + # - google.pubsub.v1.Subscriber: SubscriptionAdmin + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class JavaSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class ServiceClassNamesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Settings for C++ client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class CppSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Php client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class PhpSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Python client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class PythonSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Node client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class NodeSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Dotnet client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + # @!attribute [rw] renamed_services + # @return [::Google::Protobuf::Map{::String => ::String}] + # Map from original service names to renamed versions. + # This is used when the default generated types + # would cause a naming conflict. (Neither name is + # fully-qualified.) + # Example: Subscriber to SubscriberServiceApi. + # @!attribute [rw] renamed_resources + # @return [::Google::Protobuf::Map{::String => ::String}] + # Map from full resource types to the effective short name + # for the resource. This is used when otherwise resource + # named from different services would cause naming collisions. + # Example entry: + # "datalabeling.googleapis.com/Dataset": "DataLabelingDataset" + # @!attribute [rw] ignored_resources + # @return [::Array<::String>] + # List of full resource types to ignore during generation. + # This is typically used for API-specific Location resources, + # which should be handled by the generator as if they were actually + # the common Location resources. + # Example entry: "documentai.googleapis.com/Location" + # @!attribute [rw] forced_namespace_aliases + # @return [::Array<::String>] + # Namespaces which must be aliased in snippets due to + # a known (but non-generator-predictable) naming collision + # @!attribute [rw] handwritten_signatures + # @return [::Array<::String>] + # Method signatures (in the form "service.method(signature)") + # which are provided separately, so shouldn't be generated. + # Snippets *calling* these methods are still generated, however. + class DotnetSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class RenamedServicesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class RenamedResourcesEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Settings for Ruby client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class RubySettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Settings for Go client libraries. + # @!attribute [rw] common + # @return [::Google::Api::CommonLanguageSettings] + # Some settings. + class GoSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Describes the generator configuration for a method. + # @!attribute [rw] selector + # @return [::String] + # The fully qualified name of the method, for which the options below apply. + # This is used to find the method to apply the options. + # @!attribute [rw] long_running + # @return [::Google::Api::MethodSettings::LongRunning] + # Describes settings to use for long-running operations when generating + # API methods for RPCs. Complements RPCs that use the annotations in + # google/longrunning/operations.proto. + # + # Example of a YAML configuration:: + # + # publishing: + # method_settings: + # - selector: google.cloud.speech.v2.Speech.BatchRecognize + # long_running: + # initial_poll_delay: + # seconds: 60 # 1 minute + # poll_delay_multiplier: 1.5 + # max_poll_delay: + # seconds: 360 # 6 minutes + # total_poll_timeout: + # seconds: 54000 # 90 minutes + # @!attribute [rw] auto_populated_fields + # @return [::Array<::String>] + # List of top-level fields of the request message, that should be + # automatically populated by the client libraries based on their + # (google.api.field_info).format. Currently supported format: UUID4. + # + # Example of a YAML configuration: + # + # publishing: + # method_settings: + # - selector: google.example.v1.ExampleService.CreateExample + # auto_populated_fields: + # - request_id + class MethodSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Describes settings to use when generating API methods that use the + # long-running operation pattern. + # All default values below are from those used in the client library + # generators (e.g. + # [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). + # @!attribute [rw] initial_poll_delay + # @return [::Google::Protobuf::Duration] + # Initial delay after which the first poll request will be made. + # Default value: 5 seconds. + # @!attribute [rw] poll_delay_multiplier + # @return [::Float] + # Multiplier to gradually increase delay between subsequent polls until it + # reaches max_poll_delay. + # Default value: 1.5. + # @!attribute [rw] max_poll_delay + # @return [::Google::Protobuf::Duration] + # Maximum time between two subsequent poll requests. + # Default value: 45 seconds. + # @!attribute [rw] total_poll_timeout + # @return [::Google::Protobuf::Duration] + # Total polling timeout. + # Default value: 5 minutes. + class LongRunning + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # The organization for which the client libraries are being published. + # Affects the url where generated docs are published, etc. + module ClientLibraryOrganization + # Not useful. + CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0 + + # Google Cloud Platform Org. + CLOUD = 1 + + # Ads (Advertising) Org. + ADS = 2 + + # Photos Org. + PHOTOS = 3 + + # Street View Org. + STREET_VIEW = 4 + + # Shopping Org. + SHOPPING = 5 + + # Geo Org. + GEO = 6 + + # Generative AI - https://developers.generativeai.google + GENERATIVE_AI = 7 + end + + # To where should client libraries be published? + module ClientLibraryDestination + # Client libraries will neither be generated nor published to package + # managers. + CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0 + + # Generate the client library in a repo under github.com/googleapis, + # but don't publish it to package managers. + GITHUB = 10 + + # Publish the library to package managers like nuget.org and npmjs.com. + PACKAGE_MANAGER = 20 + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/field_behavior.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/field_behavior.rb new file mode 100644 index 000000000000..b03587481349 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/field_behavior.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # An indicator of the behavior of a given field (for example, that a field + # is required in requests, or given as output but ignored as input). + # This **does not** change the behavior in protocol buffers itself; it only + # denotes the behavior and may affect how API tooling handles the field. + # + # Note: This enum **may** receive new values in the future. + module FieldBehavior + # Conventional default for enums. Do not use this. + FIELD_BEHAVIOR_UNSPECIFIED = 0 + + # Specifically denotes a field as optional. + # While all fields in protocol buffers are optional, this may be specified + # for emphasis if appropriate. + OPTIONAL = 1 + + # Denotes a field as required. + # This indicates that the field **must** be provided as part of the request, + # and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + REQUIRED = 2 + + # Denotes a field as output only. + # This indicates that the field is provided in responses, but including the + # field in a request does nothing (the server *must* ignore it and + # *must not* throw an error as a result of the field's presence). + OUTPUT_ONLY = 3 + + # Denotes a field as input only. + # This indicates that the field is provided in requests, and the + # corresponding field is not included in output. + INPUT_ONLY = 4 + + # Denotes a field as immutable. + # This indicates that the field may be set once in a request to create a + # resource, but may not be changed thereafter. + IMMUTABLE = 5 + + # Denotes that a (repeated) field is an unordered list. + # This indicates that the service may provide the elements of the list + # in any arbitrary order, rather than the order the user originally + # provided. Additionally, the list's order may or may not be stable. + UNORDERED_LIST = 6 + + # Denotes that this field returns a non-empty default value if not set. + # This indicates that if the user provides the empty value in a request, + # a non-empty value will be returned. The user will not be aware of what + # non-empty value to expect. + NON_EMPTY_DEFAULT = 7 + + # Denotes that the field in a resource (a message annotated with + # google.api.resource) is used in the resource name to uniquely identify the + # resource. For AIP-compliant APIs, this should only be applied to the + # `name` field on the resource. + # + # This behavior should not be applied to references to other resources within + # the message. + # + # The identifier field of resources often have different field behavior + # depending on the request it is embedded in (e.g. for Create methods name + # is optional and unused, while for Update methods it is required). Instead + # of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8 + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/launch_stage.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/launch_stage.rb new file mode 100644 index 000000000000..38b4b61e6061 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/launch_stage.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # The launch stage as defined by [Google Cloud Platform + # Launch Stages](https://cloud.google.com/terms/launch-stages). + module LaunchStage + # Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0 + + # The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6 + + # Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7 + + # Early Access features are limited to a closed group of testers. To use + # these features, you must sign up in advance and sign a Trusted Tester + # agreement (which includes confidentiality provisions). These features may + # be unstable, changed in backward-incompatible ways, and are not + # guaranteed to be released. + EARLY_ACCESS = 1 + + # Alpha is a limited availability test for releases before they are cleared + # for widespread use. By Alpha, all significant design issues are resolved + # and we are in the process of verifying functionality. Alpha customers + # need to apply for access, agree to applicable terms, and have their + # projects allowlisted. Alpha releases don't have to be feature complete, + # no SLAs are provided, and there are no technical support obligations, but + # they will be far enough along that customers can actually use them in + # test environments or for limited-use tests -- just like they would in + # normal production cases. + ALPHA = 2 + + # Beta is the point at which we are ready to open a release for any + # customer to use. There are no SLA or technical support obligations in a + # Beta release. Products will be complete from a feature perspective, but + # may have some open outstanding issues. Beta releases are suitable for + # limited production use cases. + BETA = 3 + + # GA features are open to all developers and are considered stable and + # fully qualified for production use. + GA = 4 + + # Deprecated features are scheduled to be shut down and removed. For more + # information, see the "Deprecation Policy" section of our [Terms of + # Service](https://cloud.google.com/terms/) + # and the [Google Cloud Platform Subject to the Deprecation + # Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5 + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/resource.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/resource.rb new file mode 100644 index 000000000000..6497ebc78dc1 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/api/resource.rb @@ -0,0 +1,222 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Api + # A simple descriptor of a resource type. + # + # ResourceDescriptor annotates a resource message (either by means of a + # protobuf annotation or use in the service config), and associates the + # resource's schema, the resource type, and the pattern of the resource name. + # + # Example: + # + # message Topic { + # // Indicates this message defines a resource schema. + # // Declares the resource type in the format of {service}/{kind}. + # // For Kubernetes resources, the format is {api group}/{kind}. + # option (google.api.resource) = { + # type: "pubsub.googleapis.com/Topic" + # pattern: "projects/{project}/topics/{topic}" + # }; + # } + # + # The ResourceDescriptor Yaml config will look like: + # + # resources: + # - type: "pubsub.googleapis.com/Topic" + # pattern: "projects/{project}/topics/{topic}" + # + # Sometimes, resources have multiple patterns, typically because they can + # live under multiple parents. + # + # Example: + # + # message LogEntry { + # option (google.api.resource) = { + # type: "logging.googleapis.com/LogEntry" + # pattern: "projects/{project}/logs/{log}" + # pattern: "folders/{folder}/logs/{log}" + # pattern: "organizations/{organization}/logs/{log}" + # pattern: "billingAccounts/{billing_account}/logs/{log}" + # }; + # } + # + # The ResourceDescriptor Yaml config will look like: + # + # resources: + # - type: 'logging.googleapis.com/LogEntry' + # pattern: "projects/{project}/logs/{log}" + # pattern: "folders/{folder}/logs/{log}" + # pattern: "organizations/{organization}/logs/{log}" + # pattern: "billingAccounts/{billing_account}/logs/{log}" + # @!attribute [rw] type + # @return [::String] + # The resource type. It must be in the format of + # \\{service_name}/\\{resource_type_kind}. The `resource_type_kind` must be + # singular and must not include version numbers. + # + # Example: `storage.googleapis.com/Bucket` + # + # The value of the resource_type_kind must follow the regular expression + # /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and + # should use PascalCase (UpperCamelCase). The maximum number of + # characters allowed for the `resource_type_kind` is 100. + # @!attribute [rw] pattern + # @return [::Array<::String>] + # Optional. The relative resource name pattern associated with this resource + # type. The DNS prefix of the full resource name shouldn't be specified here. + # + # The path pattern must follow the syntax, which aligns with HTTP binding + # syntax: + # + # Template = Segment { "/" Segment } ; + # Segment = LITERAL | Variable ; + # Variable = "{" LITERAL "}" ; + # + # Examples: + # + # - "projects/\\{project}/topics/\\{topic}" + # - "projects/\\{project}/knowledgeBases/\\{knowledge_base}" + # + # The components in braces correspond to the IDs for each resource in the + # hierarchy. It is expected that, if multiple patterns are provided, + # the same component name (e.g. "project") refers to IDs of the same + # type of resource. + # @!attribute [rw] name_field + # @return [::String] + # Optional. The field on the resource that designates the resource name + # field. If omitted, this is assumed to be "name". + # @!attribute [rw] history + # @return [::Google::Api::ResourceDescriptor::History] + # Optional. The historical or future-looking state of the resource pattern. + # + # Example: + # + # // The InspectTemplate message originally only supported resource + # // names with organization, and project was added later. + # message InspectTemplate { + # option (google.api.resource) = { + # type: "dlp.googleapis.com/InspectTemplate" + # pattern: + # "organizations/{organization}/inspectTemplates/{inspect_template}" + # pattern: "projects/{project}/inspectTemplates/{inspect_template}" + # history: ORIGINALLY_SINGLE_PATTERN + # }; + # } + # @!attribute [rw] plural + # @return [::String] + # The plural name used in the resource name and permission names, such as + # 'projects' for the resource name of 'projects/\\{project}' and the permission + # name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same + # concept of the `plural` field in k8s CRD spec + # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + # + # Note: The plural form is required even for singleton resources. See + # https://aip.dev/156 + # @!attribute [rw] singular + # @return [::String] + # The same concept of the `singular` field in k8s CRD spec + # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + # Such as "project" for the `resourcemanager.googleapis.com/Project` type. + # @!attribute [rw] style + # @return [::Array<::Google::Api::ResourceDescriptor::Style>] + # Style flag(s) for this resource. + # These indicate that a resource is expected to conform to a given + # style. See the specific style flags for additional information. + class ResourceDescriptor + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A description of the historical or future-looking state of the + # resource pattern. + module History + # The "unset" value. + HISTORY_UNSPECIFIED = 0 + + # The resource originally had one pattern and launched as such, and + # additional patterns were added later. + ORIGINALLY_SINGLE_PATTERN = 1 + + # The resource has one pattern, but the API owner expects to add more + # later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents + # that from being necessary once there are multiple patterns.) + FUTURE_MULTI_PATTERN = 2 + end + + # A flag representing a specific style that a resource claims to conform to. + module Style + # The unspecified value. Do not use. + STYLE_UNSPECIFIED = 0 + + # This resource is intended to be "declarative-friendly". + # + # Declarative-friendly resources must be more strictly consistent, and + # setting this to true communicates to tools that this resource should + # adhere to declarative-friendly expectations. + # + # Note: This is used by the API linter (linter.aip.dev) to enable + # additional checks. + DECLARATIVE_FRIENDLY = 1 + end + end + + # Defines a proto annotation that describes a string field that refers to + # an API resource. + # @!attribute [rw] type + # @return [::String] + # The resource type that the annotated field references. + # + # Example: + # + # message Subscription { + # string topic = 2 [(google.api.resource_reference) = { + # type: "pubsub.googleapis.com/Topic" + # }]; + # } + # + # Occasionally, a field may reference an arbitrary resource. In this case, + # APIs use the special value * in their resource reference. + # + # Example: + # + # message GetIamPolicyRequest { + # string resource = 2 [(google.api.resource_reference) = { + # type: "*" + # }]; + # } + # @!attribute [rw] child_type + # @return [::String] + # The resource type of a child collection that the annotated field + # references. This is useful for annotating the `parent` field that + # doesn't have a fixed resource type. + # + # Example: + # + # message ListLogEntriesRequest { + # string parent = 1 [(google.api.resource_reference) = { + # child_type: "logging.googleapis.com/LogEntry" + # }; + # } + class ResourceReference + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/duration.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/duration.rb new file mode 100644 index 000000000000..b5731a824060 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/duration.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A Duration represents a signed, fixed-length span of time represented + # as a count of seconds and fractions of seconds at nanosecond + # resolution. It is independent of any calendar and concepts like "day" + # or "month". It is related to Timestamp in that the difference between + # two Timestamp values is a Duration and it can be added or subtracted + # from a Timestamp. Range is approximately +-10,000 years. + # + # # Examples + # + # Example 1: Compute Duration from two Timestamps in pseudo code. + # + # Timestamp start = ...; + # Timestamp end = ...; + # Duration duration = ...; + # + # duration.seconds = end.seconds - start.seconds; + # duration.nanos = end.nanos - start.nanos; + # + # if (duration.seconds < 0 && duration.nanos > 0) { + # duration.seconds += 1; + # duration.nanos -= 1000000000; + # } else if (duration.seconds > 0 && duration.nanos < 0) { + # duration.seconds -= 1; + # duration.nanos += 1000000000; + # } + # + # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + # + # Timestamp start = ...; + # Duration duration = ...; + # Timestamp end = ...; + # + # end.seconds = start.seconds + duration.seconds; + # end.nanos = start.nanos + duration.nanos; + # + # if (end.nanos < 0) { + # end.seconds -= 1; + # end.nanos += 1000000000; + # } else if (end.nanos >= 1000000000) { + # end.seconds += 1; + # end.nanos -= 1000000000; + # } + # + # Example 3: Compute Duration from datetime.timedelta in Python. + # + # td = datetime.timedelta(days=3, minutes=10) + # duration = Duration() + # duration.FromTimedelta(td) + # + # # JSON Mapping + # + # In JSON format, the Duration type is encoded as a string rather than an + # object, where the string ends in the suffix "s" (indicating seconds) and + # is preceded by the number of seconds, with nanoseconds expressed as + # fractional seconds. For example, 3 seconds with 0 nanoseconds should be + # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + # be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + # microsecond should be expressed in JSON format as "3.000001s". + # @!attribute [rw] seconds + # @return [::Integer] + # Signed seconds of the span of time. Must be from -315,576,000,000 + # to +315,576,000,000 inclusive. Note: these bounds are computed from: + # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + # @!attribute [rw] nanos + # @return [::Integer] + # Signed fractions of a second at nanosecond resolution of the span + # of time. Durations less than one second are represented with a 0 + # `seconds` field and a positive or negative `nanos` field. For durations + # of one second or more, a non-zero value for the `nanos` field must be + # of the same sign as the `seconds` field. Must be from -999,999,999 + # to +999,999,999 inclusive. + class Duration + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/empty.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/empty.rb new file mode 100644 index 000000000000..8c6b19d52e3d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/empty.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A generic empty message that you can re-use to avoid defining duplicated + # empty messages in your APIs. A typical example is to use it as the request + # or the response type of an API method. For instance: + # + # service Foo { + # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + # } + class Empty + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/field_mask.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/field_mask.rb new file mode 100644 index 000000000000..8e7abcf8f052 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/field_mask.rb @@ -0,0 +1,229 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # `FieldMask` represents a set of symbolic field paths, for example: + # + # paths: "f.a" + # paths: "f.b.d" + # + # Here `f` represents a field in some root message, `a` and `b` + # fields in the message found in `f`, and `d` a field found in the + # message in `f.b`. + # + # Field masks are used to specify a subset of fields that should be + # returned by a get operation or modified by an update operation. + # Field masks also have a custom JSON encoding (see below). + # + # # Field Masks in Projections + # + # When used in the context of a projection, a response message or + # sub-message is filtered by the API to only contain those fields as + # specified in the mask. For example, if the mask in the previous + # example is applied to a response message as follows: + # + # f { + # a : 22 + # b { + # d : 1 + # x : 2 + # } + # y : 13 + # } + # z: 8 + # + # The result will not contain specific values for fields x,y and z + # (their value will be set to the default, and omitted in proto text + # output): + # + # + # f { + # a : 22 + # b { + # d : 1 + # } + # } + # + # A repeated field is not allowed except at the last position of a + # paths string. + # + # If a FieldMask object is not present in a get operation, the + # operation applies to all fields (as if a FieldMask of all fields + # had been specified). + # + # Note that a field mask does not necessarily apply to the + # top-level response message. In case of a REST get operation, the + # field mask applies directly to the response, but in case of a REST + # list operation, the mask instead applies to each individual message + # in the returned resource list. In case of a REST custom method, + # other definitions may be used. Where the mask applies will be + # clearly documented together with its declaration in the API. In + # any case, the effect on the returned resource/resources is required + # behavior for APIs. + # + # # Field Masks in Update Operations + # + # A field mask in update operations specifies which fields of the + # targeted resource are going to be updated. The API is required + # to only change the values of the fields as specified in the mask + # and leave the others untouched. If a resource is passed in to + # describe the updated values, the API ignores the values of all + # fields not covered by the mask. + # + # If a repeated field is specified for an update operation, new values will + # be appended to the existing repeated field in the target resource. Note that + # a repeated field is only allowed in the last position of a `paths` string. + # + # If a sub-message is specified in the last position of the field mask for an + # update operation, then new value will be merged into the existing sub-message + # in the target resource. + # + # For example, given the target message: + # + # f { + # b { + # d: 1 + # x: 2 + # } + # c: [1] + # } + # + # And an update message: + # + # f { + # b { + # d: 10 + # } + # c: [2] + # } + # + # then if the field mask is: + # + # paths: ["f.b", "f.c"] + # + # then the result will be: + # + # f { + # b { + # d: 10 + # x: 2 + # } + # c: [1, 2] + # } + # + # An implementation may provide options to override this default behavior for + # repeated and message fields. + # + # In order to reset a field's value to the default, the field must + # be in the mask and set to the default value in the provided resource. + # Hence, in order to reset all fields of a resource, provide a default + # instance of the resource and set all fields in the mask, or do + # not provide a mask as described below. + # + # If a field mask is not present on update, the operation applies to + # all fields (as if a field mask of all fields has been specified). + # Note that in the presence of schema evolution, this may mean that + # fields the client does not know and has therefore not filled into + # the request will be reset to their default. If this is unwanted + # behavior, a specific service may require a client to always specify + # a field mask, producing an error if not. + # + # As with get operations, the location of the resource which + # describes the updated values in the request message depends on the + # operation kind. In any case, the effect of the field mask is + # required to be honored by the API. + # + # ## Considerations for HTTP REST + # + # The HTTP kind of an update operation which uses a field mask must + # be set to PATCH instead of PUT in order to satisfy HTTP semantics + # (PUT must only be used for full updates). + # + # # JSON Encoding of Field Masks + # + # In JSON, a field mask is encoded as a single string where paths are + # separated by a comma. Fields name in each path are converted + # to/from lower-camel naming conventions. + # + # As an example, consider the following message declarations: + # + # message Profile { + # User user = 1; + # Photo photo = 2; + # } + # message User { + # string display_name = 1; + # string address = 2; + # } + # + # In proto a field mask for `Profile` may look as such: + # + # mask { + # paths: "user.display_name" + # paths: "photo" + # } + # + # In JSON, the same mask is represented as below: + # + # { + # mask: "user.displayName,photo" + # } + # + # # Field Masks and Oneof Fields + # + # Field masks treat fields in oneofs just as regular fields. Consider the + # following message: + # + # message SampleMessage { + # oneof test_oneof { + # string name = 4; + # SubMessage sub_message = 9; + # } + # } + # + # The field mask can be: + # + # mask { + # paths: "name" + # } + # + # Or: + # + # mask { + # paths: "sub_message" + # } + # + # Note that oneof type names ("test_oneof" in this case) cannot be used in + # paths. + # + # ## Field Mask Verification + # + # The implementation of any API method which has a FieldMask type field in the + # request should verify the included field paths, and return an + # `INVALID_ARGUMENT` error if any path is unmappable. + # @!attribute [rw] paths + # @return [::Array<::String>] + # The set of field mask paths. + class FieldMask + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/timestamp.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/timestamp.rb new file mode 100644 index 000000000000..4ac9c4801a3f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/timestamp.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # A Timestamp represents a point in time independent of any time zone or local + # calendar, encoded as a count of seconds and fractions of seconds at + # nanosecond resolution. The count is relative to an epoch at UTC midnight on + # January 1, 1970, in the proleptic Gregorian calendar which extends the + # Gregorian calendar backwards to year one. + # + # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + # second table is needed for interpretation, using a [24-hour linear + # smear](https://developers.google.com/time/smear). + # + # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + # restricting to that range, we ensure that we can convert to and from [RFC + # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + # + # # Examples + # + # Example 1: Compute Timestamp from POSIX `time()`. + # + # Timestamp timestamp; + # timestamp.set_seconds(time(NULL)); + # timestamp.set_nanos(0); + # + # Example 2: Compute Timestamp from POSIX `gettimeofday()`. + # + # struct timeval tv; + # gettimeofday(&tv, NULL); + # + # Timestamp timestamp; + # timestamp.set_seconds(tv.tv_sec); + # timestamp.set_nanos(tv.tv_usec * 1000); + # + # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + # + # FILETIME ft; + # GetSystemTimeAsFileTime(&ft); + # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + # + # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + # Timestamp timestamp; + # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + # + # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + # + # long millis = System.currentTimeMillis(); + # + # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + # .setNanos((int) ((millis % 1000) * 1000000)).build(); + # + # Example 5: Compute Timestamp from Java `Instant.now()`. + # + # Instant now = Instant.now(); + # + # Timestamp timestamp = + # Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + # .setNanos(now.getNano()).build(); + # + # Example 6: Compute Timestamp from current time in Python. + # + # timestamp = Timestamp() + # timestamp.GetCurrentTime() + # + # # JSON Mapping + # + # In JSON format, the Timestamp type is encoded as a string in the + # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z" + # where \\{year} is always expressed using four digits while \\{month}, \\{day}, + # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional + # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + # is required. A proto3 JSON serializer should always use UTC (as indicated by + # "Z") when printing the Timestamp type and a proto3 JSON parser should be + # able to accept both UTC and other timezones (as indicated by an offset). + # + # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + # 01:30 UTC on January 15, 2017. + # + # In JavaScript, one can convert a Date object to this format using the + # standard + # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + # method. In Python, a standard `datetime.datetime` object can be converted + # to this format using + # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + # the Joda Time's [`ISODateTimeFormat.dateTime()`]( + # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() + # ) to obtain a formatter capable of generating timestamps in this format. + # @!attribute [rw] seconds + # @return [::Integer] + # Represents seconds of UTC time since Unix epoch + # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + # 9999-12-31T23:59:59Z inclusive. + # @!attribute [rw] nanos + # @return [::Integer] + # Non-negative fractions of a second at nanosecond resolution. Negative + # second values with fractions must still have non-negative nanos values + # that count forward in time. Must be from 0 to 999,999,999 + # inclusive. + class Timestamp + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/wrappers.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/wrappers.rb new file mode 100644 index 000000000000..5160138862c2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/protobuf/wrappers.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Protobuf + # Wrapper message for `double`. + # + # The JSON representation for `DoubleValue` is JSON number. + # @!attribute [rw] value + # @return [::Float] + # The double value. + class DoubleValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `float`. + # + # The JSON representation for `FloatValue` is JSON number. + # @!attribute [rw] value + # @return [::Float] + # The float value. + class FloatValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `int64`. + # + # The JSON representation for `Int64Value` is JSON string. + # @!attribute [rw] value + # @return [::Integer] + # The int64 value. + class Int64Value + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `uint64`. + # + # The JSON representation for `UInt64Value` is JSON string. + # @!attribute [rw] value + # @return [::Integer] + # The uint64 value. + class UInt64Value + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `int32`. + # + # The JSON representation for `Int32Value` is JSON number. + # @!attribute [rw] value + # @return [::Integer] + # The int32 value. + class Int32Value + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `uint32`. + # + # The JSON representation for `UInt32Value` is JSON number. + # @!attribute [rw] value + # @return [::Integer] + # The uint32 value. + class UInt32Value + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `bool`. + # + # The JSON representation for `BoolValue` is JSON `true` and `false`. + # @!attribute [rw] value + # @return [::Boolean] + # The bool value. + class BoolValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `string`. + # + # The JSON representation for `StringValue` is JSON string. + # @!attribute [rw] value + # @return [::String] + # The string value. + class StringValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Wrapper message for `bytes`. + # + # The JSON representation for `BytesValue` is JSON string. + # @!attribute [rw] value + # @return [::String] + # The bytes value. + class BytesValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accessright.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accessright.rb new file mode 100644 index 000000000000..72ae8df16f22 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accessright.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The access right. + module AccessRight + # Default value. This value is unused. + ACCESS_RIGHT_UNSPECIFIED = 0 + + # Standard access rights. + STANDARD = 1 + + # Admin access rights. + ADMIN = 2 + + # Users with this right have access to performance and insights. + PERFORMANCE_REPORTING = 3 + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/account_tax.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/account_tax.rb new file mode 100644 index 000000000000..52456ab00414 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/account_tax.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The tax settings of a merchant account. All methods require the admin role. + # @!attribute [rw] name + # @return [::String] + # Identifier. The name of the tax setting. + # Format: + # "\\{account_tax.name=accounts/\\{account}}" + # @!attribute [r] account + # @return [::Integer] + # Output only. The ID of the account to which these account tax settings + # belong. + # @!attribute [rw] tax_rules + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::TaxRule>] + # Tax rules. "Define the tax rules in each region. + # No tax will be presented if a region has no rule." + class AccountTax + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request to get tax settings + # @!attribute [rw] name + # @return [::String] + # Required. The name from which tax settings will be retrieved + class GetAccountTaxRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request to update the tax settings + # @!attribute [rw] account_tax + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountTax] + # Required. The tax setting that will be updated + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # The list of fields to be updated + class UpdateAccountTaxRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request to list all sub-account tax settings only for the requesting merchant + # This method can only be called on a multi-client account, otherwise it'll + # return an error. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent, which owns this collection of account tax. + # Format: accounts/\\{account} + # @!attribute [rw] page_size + # @return [::Integer] + # The maximum number of tax settings to return in the response, used for + # paging. + # @!attribute [rw] page_token + # @return [::String] + # The token returned by the previous request. + class ListAccountTaxRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response to account tax list request + # This method can only be called on a multi-client account, otherwise it'll + # return an error. + # @!attribute [rw] account_taxes + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::AccountTax>] + # Page of accounttax settings + # @!attribute [rw] next_page_token + # @return [::String] + # The token for the retrieval of the next page of account tax settings. + class ListAccountTaxResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accountissue.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accountissue.rb new file mode 100644 index 000000000000..00d6cc78a83e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accountissue.rb @@ -0,0 +1,142 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # An + # [`AccountIssue`](https://support.google.com/merchants/answer/12153802?sjid=17798438912526418908-EU#account). + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the account issue. + # Format: `accounts/{account}/issues/{id}` + # @!attribute [rw] title + # @return [::String] + # The localized title of the issue. + # @!attribute [rw] severity + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue::Severity] + # The overall severity of the issue. + # @!attribute [rw] impacted_destinations + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue::ImpactedDestination>] + # The impact this issue has on various destinations. + # @!attribute [rw] detail + # @return [::String] + # Further localized details about the issue. + # @!attribute [rw] documentation_uri + # @return [::String] + # Link to Merchant Center Help Center providing further information about the + # issue and how to fix it. + class AccountIssue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The impact of the issue on a destination. + # @!attribute [rw] reporting_context + # @return [::Google::Shopping::Type::ReportingContext::ReportingContextEnum] + # The impacted reporting context. + # @!attribute [rw] impacts + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue::ImpactedDestination::Impact>] + # The (negative) impact for various regions on the given destination. + class ImpactedDestination + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The impact of the issue on a region. + # @!attribute [rw] region_code + # @return [::String] + # The [CLDR region code](https://cldr.unicode.org/) where this issue + # applies. + # @!attribute [rw] severity + # @return [::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue::Severity] + # The severity of the issue on the destination and region. + class Impact + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # All possible issue severities. + module Severity + # The severity is unknown. + SEVERITY_UNSPECIFIED = 0 + + # The issue causes offers to not serve. + CRITICAL = 1 + + # The issue might affect offers (in the future) or might be an + # indicator of issues with offers. + ERROR = 2 + + # The issue is a suggestion for improvement. + SUGGESTION = 3 + end + end + + # Request message for the `ListAccountIssues` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent, which owns this collection of issues. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of issues to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListAccountIssues` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccountIssues` must + # match the call that provided the page token. + # @!attribute [rw] language_code + # @return [::String] + # Optional. The issues in the response will have human-readable fields in the + # given language. The format is [BCP-47](https://tools.ietf.org/html/bcp47), + # such as `en-US` or `sr-Latn`. If not value is provided, `en-US` will be + # used. + # @!attribute [rw] time_zone + # @return [::Google::Type::TimeZone] + # Optional. The [IANA](https://www.iana.org/time-zones) timezone used to + # localize times in human-readable fields. For example 'America/Los_Angeles'. + # If not set, 'America/Los_Angeles' will be used. + class ListAccountIssuesRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListAccountIssues` method. + # @!attribute [rw] account_issues + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue>] + # The issues from the specified account. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListAccountIssuesResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accounts.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accounts.rb new file mode 100644 index 000000000000..79ecc6cce72e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/accounts.rb @@ -0,0 +1,219 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # An account. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the account. + # Format: `accounts/{account}` + # @!attribute [r] account_id + # @return [::Integer] + # Output only. The ID of the account. + # @!attribute [rw] account_name + # @return [::String] + # Required. A human-readable name of the account. See + # [store name](https://support.google.com/merchants/answer/160556) and + # [business name](https://support.google.com/merchants/answer/12159159) for + # more information. + # @!attribute [rw] adult_content + # @return [::Boolean] + # Whether this account contains adult content. + # @!attribute [r] test_account + # @return [::Boolean] + # Output only. Whether this is a test account. + # @!attribute [rw] time_zone + # @return [::Google::Type::TimeZone] + # Required. The time zone of the account. + # + # On writes, `time_zone` sets both the `reporting_time_zone` and the + # `display_time_zone`. + # + # For reads, `time_zone` always returns the `display_time_zone`. If + # `display_time_zone` doesn't exist for your account, `time_zone` is empty. + # @!attribute [rw] language_code + # @return [::String] + # Required. The account's [BCP-47 language + # code](https://tools.ietf.org/html/bcp47), such as `en-US` or `sr-Latn`. + class Account + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetAccount` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the account to retrieve. + # Format: `accounts/{account}` + class GetAccountRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `CreateAndConfigureAccount` method. + # @!attribute [rw] account + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # Required. The account to be created. + # @!attribute [rw] users + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest>] + # Optional. Users to be added to the account. + # @!attribute [rw] accept_terms_of_service + # @return [::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AcceptTermsOfService] + # Optional. The Terms of Service (ToS) to be accepted immediately upon + # account creation. + # @!attribute [rw] service + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AddAccountService>] + # Optional. If specified, an account service between the account to be + # created and the provider account is initialized as part of the + # creation. + class CreateAndConfigureAccountRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Reference to a Terms of Service resource. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the terms of service version. + # @!attribute [rw] region_code + # @return [::String] + # Required. Region code as defined by [CLDR](https://cldr.unicode.org/). + # This is either a country when the ToS applies specifically to that + # country or `001` when it applies globally. + class AcceptTermsOfService + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Additional instructions to add account services during creation of the + # account. + # @!attribute [rw] account_aggregation + # @return [::Google::Protobuf::Empty] + # The provider is an aggregator for the account. + # @!attribute [rw] provider + # @return [::String] + # Optional. The provider of the service. + # Format: `accounts/{account}` + class AddAccountService + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Request message for the `DeleteAccount` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the account to delete. + # Format: `accounts/{account}` + class DeleteAccountRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateAccount` method. + # @!attribute [rw] account + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Account] + # Required. The new version of the account. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateAccountRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ListAccounts` method. + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + # @!attribute [rw] filter + # @return [::String] + # Optional. Returns only accounts that match the + # [filter](/merchant/api/guides/accounts/filter). + # For more details, see the + # [filter syntax reference](/merchant/api/guides/accounts/filter-syntax). + class ListAccountsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListAccounts` method. + # @!attribute [rw] accounts + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # The accounts matching the `ListAccountsRequest`. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListAccountsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ListSubAccounts` method. + # @!attribute [rw] provider + # @return [::String] + # Required. The parent account. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of accounts to return. The service may return + # fewer than this value. If unspecified, at most 250 accounts are returned. + # The maximum value is 500; values above 500 are coerced to 500. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListAccounts` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListAccounts` must match + # the call that provided the page token. + class ListSubAccountsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListSubAccounts` method. + # @!attribute [rw] accounts + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Account>] + # The accounts for which the given parent account is an aggregator. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListSubAccountsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessidentity.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessidentity.rb new file mode 100644 index 000000000000..e75d5d98c31c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessidentity.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Collection of information related to the [identity of a + # business](https://support.google.com/merchants/answer/12564247). + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the business identity. + # Format: `accounts/{account}/businessIdentity` + # @!attribute [rw] promotions_consent + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::PromotionsConsent] + # Optional. Whether the identity attributes may be used for promotions. + # @!attribute [rw] black_owned + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute] + # Optional. Specifies whether the business identifies itself as being + # black-owned. This optional field will only be available for merchants with + # a business country set to `US`. It is also not applicable for marketplaces + # or marketplace sellers. + # @!attribute [rw] women_owned + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute] + # Optional. Specifies whether the business identifies itself as being + # women-owned. This optional field will only be available for merchants with + # a business country set to `US`. It is also not applicable for marketplaces + # or marketplace sellers. + # @!attribute [rw] veteran_owned + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute] + # Optional. Specifies whether the business identifies itself as being + # veteran-owned. This optional field will only be available for merchants + # with a business country set to `US`. It is also not applicable for + # marketplaces or marketplace sellers. + # @!attribute [rw] latino_owned + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute] + # Optional. Specifies whether the business identifies itself as being + # latino-owned. This optional field will only be available for merchants with + # a business country set to `US`. It is also not applicable for marketplaces + # or marketplace sellers. + # @!attribute [rw] small_business + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute] + # Optional. Specifies whether the business identifies itself as a small + # business. This optional field will only be available for merchants with a + # business country set to `US`. It is also not applicable for marketplaces. + class BusinessIdentity + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # All information related to an identity attribute. + # @!attribute [rw] identity_declaration + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity::IdentityAttribute::IdentityDeclaration] + # Required. The declaration of identity for this attribute. + class IdentityAttribute + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # All possible settings regarding the declaration of an identity. + module IdentityDeclaration + # Default value indicating that no selection was made. + IDENTITY_DECLARATION_UNSPECIFIED = 0 + + # Indicates that the account identifies with the attribute. + SELF_IDENTIFIES_AS = 1 + + # Indicates that the account does not identify with the attribute. + DOES_NOT_SELF_IDENTIFY_AS = 2 + end + end + + # All possible settings regarding promotions related to the business + # identity. + module PromotionsConsent + # Default value indicating that no selection was made. + PROMOTIONS_CONSENT_UNSPECIFIED = 0 + + # Indicates that the account consented to having their business identity + # used for promotions. + PROMOTIONS_CONSENT_GIVEN = 1 + + # Indicates that the account did not consent to having their business + # identity used for promotions. + PROMOTIONS_CONSENT_DENIED = 2 + end + end + + # Request message for the `GetBusinessIdentity` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the business identity. + # Format: `accounts/{account}/businessIdentity` + class GetBusinessIdentityRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateBusinessIdentity` method. + # @!attribute [rw] business_identity + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity] + # Required. The new version of the business identity. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateBusinessIdentityRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessinfo.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessinfo.rb new file mode 100644 index 000000000000..efbe6674e908 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/businessinfo.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Collection of information related to a business. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the business info. + # Format: `accounts/{account}/businessInfo` + # @!attribute [rw] address + # @return [::Google::Type::PostalAddress] + # Optional. The address of the business. + # @!attribute [r] phone + # @return [::Google::Type::PhoneNumber] + # Output only. The phone number of the business. + # @!attribute [r] phone_verification_state + # @return [::Google::Shopping::Merchant::Accounts::V1beta::PhoneVerificationState] + # Output only. The phone verification state of the business. + # @!attribute [rw] customer_service + # @return [::Google::Shopping::Merchant::Accounts::V1beta::CustomerService] + # Optional. The customer service of the business. + class BusinessInfo + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetBusinessInfo` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the business info. + # Format: `accounts/{account}/businessInfo` + class GetBusinessInfoRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateBusinessInfo` method. + # @!attribute [rw] business_info + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo] + # Required. The new version of the business info. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateBusinessInfoRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/customerservice.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/customerservice.rb new file mode 100644 index 000000000000..e15f26099a53 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/customerservice.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Customer service information. + # @!attribute [rw] uri + # @return [::String] + # Optional. The URI where customer service may be found. + # @!attribute [rw] email + # @return [::String] + # Optional. The email address where customer service may be reached. + # @!attribute [rw] phone + # @return [::Google::Type::PhoneNumber] + # Optional. The phone number where customer service may be called. + class CustomerService + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/emailpreferences.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/emailpreferences.rb new file mode 100644 index 000000000000..466fe41e6de1 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/emailpreferences.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The categories of notifications the user opted into / opted out of. The email + # preferences do not include mandatory announcements as users can't opt out of + # them. + # @!attribute [rw] name + # @return [::String] + # Identifier. The name of the EmailPreferences. The endpoint is only + # supported for the authenticated user. + # @!attribute [rw] news_and_tips + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences::OptInState] + # Optional. Updates on new features, tips and best practices. + class EmailPreferences + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Opt in state of the email preference. + module OptInState + # Opt-in status is not specified. + OPT_IN_STATE_UNSPECIFIED = 0 + + # User has opted out of receiving this type of email. + OPTED_OUT = 1 + + # User has opted in to receiving this type of email. + OPTED_IN = 2 + + # User has opted in to receiving this type of email and the confirmation + # email has been sent, but user has not yet confirmed the opt in (applies + # only to certain countries). + UNCONFIRMED = 3 + end + end + + # Request message for GetEmailPreferences method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the `EmailPreferences` resource. + # Format: `accounts/{account}/users/{email}/emailPreferences` + class GetEmailPreferencesRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for UpdateEmailPreferences method. + # @!attribute [rw] email_preferences + # @return [::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences] + # Required. Email Preferences to be updated. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateEmailPreferencesRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/homepage.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/homepage.rb new file mode 100644 index 000000000000..9591d48c85ef --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/homepage.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # A store's homepage. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the store's homepage. + # Format: `accounts/{account}/homepage` + # @!attribute [rw] uri + # @return [::String] + # Required. The URI (typically a URL) of the store's homepage. + # @!attribute [r] claimed + # @return [::Boolean] + # Output only. Whether the homepage is claimed. See + # https://support.google.com/merchants/answer/176793. + class Homepage + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetHomepage` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the homepage to retrieve. + # Format: `accounts/{account}/homepage` + class GetHomepageRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateHomepage` method. + # @!attribute [rw] homepage + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Homepage] + # Required. The new version of the homepage. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateHomepageRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ClaimHomepage` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the homepage to claim. + # Format: `accounts/{account}/homepage` + class ClaimHomepageRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UnclaimHomepage` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the homepage to unclaim. + # Format: `accounts/{account}/homepage` + class UnclaimHomepageRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/online_return_policy.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/online_return_policy.rb new file mode 100644 index 000000000000..68fc900f1cf0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/online_return_policy.rb @@ -0,0 +1,238 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Request message for the `GetOnlineReturnPolicy` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the return policy to retrieve. + # Format: `accounts/{account}/onlineReturnPolicies/{return_policy}` + class GetOnlineReturnPolicyRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ListOnlineReturnPolicies` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The merchant account for which to list return policies. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of `OnlineReturnPolicy` resources to return. + # The service returns fewer than this value if the number of return policies + # for the given merchant is less that than the `pageSize`. The default value + # is 10. The maximum value is 100; If a value higher than the maximum is + # specified, then the `pageSize` will default to the maximum + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListOnlineReturnPolicies` + # call. Provide the page token to retrieve the subsequent page. + # + # When paginating, all other parameters provided to + # `ListOnlineReturnPolicies` must match the call that provided the page + # token. The token returned as + # {::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse#next_page_token nextPageToken} + # in the response to the previous request. + class ListOnlineReturnPoliciesRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListOnlineReturnPolicies` method. + # @!attribute [rw] online_return_policies + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy>] + # The retrieved return policies. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `pageToken` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListOnlineReturnPoliciesResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # [Online return policy](https://support.google.com/merchants/answer/10220642) + # object. This is currently used to represent return policies for ads and free + # listings programs. + # @!attribute [rw] name + # @return [::String] + # Identifier. The name of the `OnlineReturnPolicy` resource. + # Format: `accounts/{account}/onlineReturnPolicies/{return_policy}` + # @!attribute [r] return_policy_id + # @return [::String] + # Output only. Return policy ID generated by Google. + # @!attribute [rw] label + # @return [::String] + # This field represents the unique user-defined label of the return policy. + # It is important to note that the same label cannot be used in different + # return policies for the same country. Unless a product specifies a specific + # label attribute, policies will be automatically labeled as 'default'. + # To assign a custom return policy to certain product groups, follow the + # instructions provided in the [Return policy label] + # (https://support.google.com/merchants/answer/9445425). + # The label can contain up to 50 characters. + # @!attribute [rw] countries + # @return [::Array<::String>] + # The countries of sale where the return policy applies. The values + # must be a valid 2 letter ISO 3166 code. + # @!attribute [rw] policy + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::Policy] + # The return policy. + # @!attribute [rw] restocking_fee + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::RestockingFee] + # The restocking fee that applies to all return reason categories. This would + # be treated as a free restocking fee if the value is not set. + # @!attribute [rw] return_methods + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::ReturnMethod>] + # The return methods of how customers can return an item. This value is + # required to not be empty unless the type of return policy is noReturns. + # @!attribute [rw] item_conditions + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::ItemCondition>] + # The item conditions accepted for returns must not be empty unless the type + # of return policy is 'noReturns'. + # @!attribute [rw] return_shipping_fee + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::ReturnShippingFee] + # The return shipping fee. Should be set only when customer need to download + # and print the return label. + # @!attribute [rw] return_policy_uri + # @return [::String] + # The return policy uri. This can used by Google to do a sanity check for the + # policy. It must be a valid URL. + # @!attribute [rw] accept_defective_only + # @return [::Boolean] + # This field specifies if merchant only accepts defective products for + # returns, and this field is required. + # @!attribute [rw] process_refund_days + # @return [::Integer] + # The field specifies the number of days it takes for merchants to process + # refunds, field is optional. + # @!attribute [rw] accept_exchange + # @return [::Boolean] + # This field specifies if merchant allows customers to exchange products, + # this field is required. + class OnlineReturnPolicy + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The return shipping fee. This can either be a fixed fee or a boolean to + # indicate that the customer pays the actual shipping cost. + # @!attribute [rw] type + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::ReturnShippingFee::Type] + # Type of return shipping fee. + # @!attribute [rw] fixed_fee + # @return [::Google::Shopping::Type::Price] + # Fixed return shipping fee amount. This value is only applicable when type + # is `FIXED`. We will treat the return shipping fee as free if type is + # `FIXED` and this value is not set. + class ReturnShippingFee + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Return shipping fee types. + module Type + # Default value. This value is unused. + TYPE_UNSPECIFIED = 0 + + # The return shipping fee is a fixed value. + FIXED = 1 + + # Customers will pay the actual return shipping fee. + CUSTOMER_PAYING_ACTUAL_FEE = 2 + end + end + + # The restocking fee. This can be a flat fee or a micro percent. + # @!attribute [rw] fixed_fee + # @return [::Google::Shopping::Type::Price] + # Fixed restocking fee. + # @!attribute [rw] micro_percent + # @return [::Integer] + # Percent of total price in micros. 15,000,000 means 15% of the total + # price would be charged. + class RestockingFee + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The available policies. + # @!attribute [rw] type + # @return [::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy::Policy::Type] + # Policy type. + # @!attribute [rw] days + # @return [::Integer] + # The number of days items can be returned after delivery, where one day + # is defined as 24 hours after the delivery timestamp. Required for + # `NUMBER_OF_DAYS_AFTER_DELIVERY` returns. + class Policy + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Return policy types. + module Type + # Default value. This value is unused. + TYPE_UNSPECIFIED = 0 + + # The number of days within which a return is valid after delivery. + NUMBER_OF_DAYS_AFTER_DELIVERY = 1 + + # No returns. + NO_RETURNS = 2 + + # Life time returns. + LIFETIME_RETURNS = 3 + end + end + + # The available return methods. + module ReturnMethod + # Default value. This value is unused. + RETURN_METHOD_UNSPECIFIED = 0 + + # Return by mail. + BY_MAIL = 1 + + # Return in store. + IN_STORE = 2 + + # Return at a kiosk. + AT_A_KIOSK = 3 + end + + # The available item conditions. + module ItemCondition + # Default value. This value is unused. + ITEM_CONDITION_UNSPECIFIED = 0 + + # New. + NEW = 1 + + # Used. + USED = 2 + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/phoneverificationstate.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/phoneverificationstate.rb new file mode 100644 index 000000000000..97bf0c4255df --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/phoneverificationstate.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The phone verification state. + module PhoneVerificationState + # Default value. This value is unused. + PHONE_VERIFICATION_STATE_UNSPECIFIED = 0 + + # The phone is verified. + PHONE_VERIFICATION_STATE_VERIFIED = 1 + + # The phone is unverified + PHONE_VERIFICATION_STATE_UNVERIFIED = 2 + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/programs.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/programs.rb new file mode 100644 index 000000000000..c6fc6e8b6e4c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/programs.rb @@ -0,0 +1,160 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Defines participation in a given program for the specified account. + # + # Programs provide a mechanism for adding functionality to merchant accounts. A + # typical example of this is the [Free product + # listings](https://support.google.com/merchants/topic/9240261?ref_topic=7257954,7259405,&sjid=796648681813264022-EU) + # program, which enables products from a merchant's store to be shown across + # Google for free. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the program. + # Format: `accounts/{account}/programs/{program}` + # @!attribute [r] documentation_uri + # @return [::String] + # Output only. The URL of a Merchant Center help page describing the program. + # @!attribute [r] state + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Program::State] + # Output only. The participation state of the account in the program. + # @!attribute [r] active_region_codes + # @return [::Array<::String>] + # Output only. The regions in which the account is actively participating in + # the program. Active regions are defined as those where all program + # requirements affecting the regions have been met. + # + # Region codes are defined by [CLDR](https://cldr.unicode.org/). This is + # either a country where the program applies specifically to that country or + # `001` when the program applies globally. + # @!attribute [r] unmet_requirements + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Program::Requirement>] + # Output only. The requirements that the account has not yet satisfied that + # are affecting participation in the program. + class Program + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Defines a requirement specified for participation in the program. + # @!attribute [r] title + # @return [::String] + # Output only. Name of the requirement. + # @!attribute [r] documentation_uri + # @return [::String] + # Output only. The URL of a help page describing the requirement. + # @!attribute [r] affected_region_codes + # @return [::Array<::String>] + # Output only. The regions that are currently affected by this requirement + # not being met. + # + # Region codes are defined by [CLDR](https://cldr.unicode.org/). This is + # either a country where the program applies specifically to that country + # or `001` when the program applies globally. + class Requirement + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Possible program participation states for the account. + module State + # Default value. This value is unused. + STATE_UNSPECIFIED = 0 + + # The account is not eligible to participate in the program. + NOT_ELIGIBLE = 1 + + # The account is eligible to participate in the program. + ELIGIBLE = 2 + + # The program is enabled for the account. + ENABLED = 3 + end + end + + # Request message for the GetProgram method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the program to retrieve. + # Format: `accounts/{account}/programs/{program}` + class GetProgramRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the ListPrograms method. + # @!attribute [rw] parent + # @return [::String] + # Required. The name of the account for which to retrieve all programs. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of programs to return in a single response. If + # unspecified (or 0), a default size of 1000 is used. The maximum value is + # 1000; values above 1000 will be coerced to 1000. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A continuation token, received from a previous `ListPrograms` + # call. Provide this to retrieve the next page. + class ListProgramsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the ListPrograms method. + # @!attribute [rw] programs + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Program>] + # The programs for the given account. + # @!attribute [rw] next_page_token + # @return [::String] + # A token that can be sent as `page_token` to retrieve the next page. If this + # field is omitted, there are no subsequent pages. + class ListProgramsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the EnableProgram method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the program for which to enable participation for the + # given account. Format: `accounts/{account}/programs/{program}` + class EnableProgramRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the DisableProgram method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the program for which to disable participation for + # the given account. Format: `accounts/{account}/programs/{program}` + class DisableProgramRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/regions.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/regions.rb new file mode 100644 index 000000000000..368b58789bac --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/regions.rb @@ -0,0 +1,195 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Request message for the `GetRegion` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the region to retrieve. + # Format: `accounts/{account}/regions/{region}` + class GetRegionRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `CreateRegion` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account to create a region for. + # Format: `accounts/{account}` + # @!attribute [rw] region_id + # @return [::String] + # Required. The identifier for the region, unique over all regions of the + # same account. + # @!attribute [rw] region + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # Required. The region to create. + class CreateRegionRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateRegion` method. + # @!attribute [rw] region + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region] + # Required. The updated region. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Optional. The comma-separated field mask indicating the fields to update. + # Example: + # `"displayName,postalCodeArea.regionCode"`. + class UpdateRegionRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `DeleteRegion` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the region to delete. + # Format: `accounts/{account}/regions/{region}` + class DeleteRegionRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ListRegions` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account to list regions for. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of regions to return. The service may return + # fewer than this value. + # If unspecified, at most 50 regions will be returned. + # The maximum value is 1000; values above 1000 will be coerced to 1000. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListRegions` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListRegions` must + # match the call that provided the page token. + class ListRegionsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListRegions` method. + # @!attribute [rw] regions + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Region>] + # The regions from the specified merchant. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListRegionsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Represents a geographic region that you can use as a target with both the + # `RegionalInventory` and `ShippingSettings` services. You can define regions + # as collections of either postal codes or, in some countries, using predefined + # geotargets. For more information, see [Set up regions + # ](https://support.google.com/merchants/answer/7410946#zippy=%2Ccreate-a-new-region) + # for more information. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the region. + # Format: `accounts/{account}/regions/{region}` + # @!attribute [rw] display_name + # @return [::String] + # Optional. The display name of the region. + # @!attribute [rw] postal_code_area + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region::PostalCodeArea] + # Optional. A list of postal codes that defines the region area. + # @!attribute [rw] geotarget_area + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Region::GeoTargetArea] + # Optional. A list of geotargets that defines the region area. + # @!attribute [r] regional_inventory_eligible + # @return [::Google::Protobuf::BoolValue] + # Output only. Indicates if the region is eligible for use in the Regional + # Inventory configuration. + # @!attribute [r] shipping_eligible + # @return [::Google::Protobuf::BoolValue] + # Output only. Indicates if the region is eligible for use in the Shipping + # Services configuration. + class Region + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A list of postal codes that defines the region area. + # Note: All regions defined using postal codes are accessible through the + # account's `ShippingSettings.postalCodeGroups` resource. + # @!attribute [rw] region_code + # @return [::String] + # Required. [CLDR territory + # code](http://www.unicode.org/repos/cldr/tags/latest/common/main/en.xml) + # or the country the postal code group applies to. + # @!attribute [rw] postal_codes + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Region::PostalCodeArea::PostalCodeRange>] + # Required. A range of postal codes. + class PostalCodeArea + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A range of postal codes that defines the region area. + # @!attribute [rw] begin + # @return [::String] + # Required. A postal code or a pattern of the form prefix* denoting the + # inclusive lower bound of the range defining the area. Examples values: + # `94108`, `9410*`, `9*`. + # @!attribute [rw] end + # @return [::String] + # Optional. A postal code or a pattern of the form `prefix*` denoting the + # inclusive upper bound of the range defining the area. It must have the + # same length as postalCodeRangeBegin: if postalCodeRangeBegin is a + # postal code then postalCodeRangeEnd must be a postal code too; if + # postalCodeRangeBegin is a pattern then postalCodeRangeEnd must be a + # pattern with the same prefix length. Optional: if not set, then the + # area is defined as being all the postal codes matching + # postalCodeRangeBegin. + class PostalCodeRange + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # A list of geotargets that defines the region area. + # @!attribute [rw] geotarget_criteria_ids + # @return [::Array<::Integer>] + # Required. A non-empty list of [location + # IDs](https://developers.google.com/adwords/api/docs/appendix/geotargeting). + # They must all be of the same location type (for example, state). + class GeoTargetArea + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/shippingsettings.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/shippingsettings.rb new file mode 100644 index 000000000000..b36dcbeb7476 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/shippingsettings.rb @@ -0,0 +1,743 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The merchant account's [shipping + # setting]((https://support.google.com/merchants/answer/6069284). + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the shipping setting. + # Format: `accounts/{account}/shippingSetting` + # @!attribute [rw] services + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Service>] + # Optional. The target account's list of services. + # @!attribute [rw] warehouses + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Warehouse>] + # Optional. A list of warehouses which can be referred to in `services`. + # @!attribute [rw] etag + # @return [::String] + # Required. This field is used for avoid async issue. Make sure shipping + # setting data + # didn't change between get call and insert call. The user should do + # following steps: + # + # 1. Set etag field as empty string for initial shipping setting creation. + # + # 2. After initial creation, call get method to obtain an etag and current + # shipping setting data before call insert. + # + # 3. Modify to wanted shipping setting information. + # + # 4. Call insert method with the wanted shipping setting information with + # the etag obtained from step 2. + # + # 5. If shipping setting data changed between step 2 and step 4. Insert + # request will fail because the etag changes every time the shipping setting + # data changes. User should repeate step 2-4 with the new etag. + class ShippingSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Shipping service. + # @!attribute [rw] service_name + # @return [::String] + # Required. Free-form name of the service. Must be unique within target + # account. + # @!attribute [rw] active + # @return [::Boolean] + # Required. A boolean exposing the active status of the shipping service. + # @!attribute [rw] delivery_countries + # @return [::Array<::String>] + # Required. The CLDR territory code of the countries to which the service + # applies. + # @!attribute [rw] currency_code + # @return [::String] + # The CLDR code of the currency to which this service applies. Must match + # that of the prices in rate groups. + # @!attribute [rw] delivery_time + # @return [::Google::Shopping::Merchant::Accounts::V1beta::DeliveryTime] + # Required. Time spent in various aspects from order to the delivery of the + # product. + # @!attribute [rw] rate_groups + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::RateGroup>] + # Optional. Shipping rate group definitions. Only the last one is allowed to + # have an empty `applicable_shipping_labels`, which means "everything else". + # The other `applicable_shipping_labels` must not overlap. + # @!attribute [rw] shipment_type + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Service::ShipmentType] + # Type of locations this service ships orders to. + # @!attribute [rw] minimum_order_value + # @return [::Google::Shopping::Type::Price] + # Minimum order value for this service. If set, indicates that customers + # will have to spend at least this amount. + # All prices within a service must have the same currency. + # Cannot be set together with minimum_order_value_table. + # @!attribute [rw] minimum_order_value_table + # @return [::Google::Shopping::Merchant::Accounts::V1beta::MinimumOrderValueTable] + # Table of per store minimum order values for the pickup fulfillment type. + # Cannot be set together with minimum_order_value. + # @!attribute [rw] store_config + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Service::StoreConfig] + # A list of stores your products are delivered from. + # This is only valid for the local delivery shipment type. + # @!attribute [rw] loyalty_programs + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Service::LoyaltyProgram>] + # Optional. Loyalty programs that this shipping service is limited to. + class Service + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A list of stores your products are delivered from. + # This is only valid for the local delivery shipment type. + # @!attribute [rw] store_service_type + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Service::StoreConfig::StoreServiceType] + # Indicates whether all stores, or selected stores, listed by this + # merchant provide local delivery. + # @!attribute [rw] store_codes + # @return [::Array<::String>] + # Optional. A list of store codes that provide local delivery. + # If empty, then `all_stores` must be true. + # @!attribute [rw] cutoff_config + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Service::StoreConfig::CutoffConfig] + # Configs related to local delivery ends for the day. + # @!attribute [rw] service_radius + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Distance] + # Maximum delivery radius. + # This is only required for the local delivery shipment type. + class StoreConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Configs related to local delivery ends for the day. + # @!attribute [rw] local_cutoff_time + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Service::StoreConfig::CutoffConfig::LocalCutoffTime] + # Time that local delivery ends for the day. + # @!attribute [rw] store_close_offset_hours + # @return [::Integer] + # Only valid with local delivery fulfillment. Represents cutoff time + # as the number of hours before store closing. Mutually exclusive + # with `local_cutoff_time`. + # @!attribute [rw] no_delivery_post_cutoff + # @return [::Boolean] + # Merchants can opt-out of showing n+1 day local delivery when they have + # a shipping service configured to n day local delivery. For example, if + # the shipping service defines same-day delivery, and it's past the + # cut-off, setting this field to `true` results in the calculated + # shipping service rate returning `NO_DELIVERY_POST_CUTOFF`. In the + # same example, setting this field to `false` results in the calculated + # shipping time being one day. This is only for local delivery. + class CutoffConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Time that local delivery ends for the day. + # @!attribute [rw] hour + # @return [::Integer] + # Hour local delivery orders must be placed by to process the same + # day. + # @!attribute [rw] minute + # @return [::Integer] + # Minute local delivery orders must be placed by to process the same + # day. + class LocalCutoffTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Indicates whether all stores, or selected stores, listed by the + # merchant provide local delivery. + module StoreServiceType + # Did not specify store service type. + STORE_SERVICE_TYPE_UNSPECIFIED = 0 + + # Indicates whether all stores, current and future, listed by this + # merchant provide local delivery. + ALL_STORES = 1 + + # Indicates that only the stores listed in `store_codes` are eligible + # for local delivery. + SELECTED_STORES = 2 + end + end + + # [Loyalty program](https://support.google.com/merchants/answer/12922446) + # provided by a merchant. + # @!attribute [rw] program_label + # @return [::String] + # This is the loyalty program label set in your loyalty program settings in + # Merchant Center. This sub-attribute allows Google to map your loyalty + # program to eligible offers. + # @!attribute [rw] loyalty_program_tiers + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Service::LoyaltyProgram::LoyaltyProgramTiers>] + # Optional. Loyalty program tier of this shipping service. + class LoyaltyProgram + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Subset of a merchants loyalty program. + # @!attribute [rw] tier_label + # @return [::String] + # The tier label [tier_label] sub-attribute differentiates offer level + # benefits between each tier. This value is also set in your program + # settings in Merchant Center, and is required for data source changes + # even if your loyalty program only has 1 tier. + class LoyaltyProgramTiers + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # Shipment type of shipping service. + module ShipmentType + # This service did not specify shipment type. + SHIPMENT_TYPE_UNSPECIFIED = 0 + + # This service ships orders to an address chosen by the customer. + DELIVERY = 1 + + # This service ships orders to an address chosen by the customer. + # The order is shipped from a local store near by. + LOCAL_DELIVERY = 2 + + # This service ships orders to an address chosen by the customer. + # The order is shipped from a collection point. + COLLECTION_POINT = 3 + end + end + + # Maximum delivery radius. + # This is only required for the local delivery shipment type. + # @!attribute [rw] value + # @return [::Integer] + # Integer value of distance. + # @!attribute [rw] unit + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Distance::Unit] + # Unit can differ based on country, it is parameterized to include miles + # and kilometers. + class Distance + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Unit can differ based on country, it is parameterized to include miles + # and kilometers. + module Unit + # Unit unspecified + UNIT_UNSPECIFIED = 0 + + # Unit in miles + MILES = 1 + + # Unit in kilometers + KILOMETERS = 2 + end + end + + # A fulfillment warehouse, which stores and handles inventory. + # Next tag: 7 + # @!attribute [rw] name + # @return [::String] + # Required. The name of the warehouse. Must be unique within account. + # @!attribute [rw] shipping_address + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Address] + # Required. Shipping address of the warehouse. + # @!attribute [rw] cutoff_time + # @return [::Google::Shopping::Merchant::Accounts::V1beta::WarehouseCutoffTime] + # Required. The latest time of day that an order can be accepted and begin + # processing. Later orders will be processed in the next day. The time is + # based on the warehouse postal code. + # @!attribute [rw] handling_days + # @return [::Integer] + # Required. The number of days it takes for this warehouse to pack up and + # ship an item. This is on the warehouse level, but can be overridden on the + # offer level based on the attributes of an item. + # @!attribute [rw] business_day_config + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessDayConfig] + # Business days of the warehouse. + # If not set, will be Monday to Friday by default. + class Warehouse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The latest time of day that an order can be accepted and begin processing. + # Later orders will be processed in the next day. The time is based on the + # warehouse postal code. + # @!attribute [rw] hour + # @return [::Integer] + # Required. Hour of the cutoff time until which an order has to be placed to + # be processed in the same day by the warehouse. Hour is based on the + # timezone of warehouse. + # @!attribute [rw] minute + # @return [::Integer] + # Required. Minute of the cutoff time until which an order has to be placed + # to be processed in the same day by the warehouse. Minute is based on the + # timezone of warehouse. + class WarehouseCutoffTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Shipping address of the warehouse. + # @!attribute [rw] street_address + # @return [::String] + # Street-level part of the address. For example: `111w 31st Street`. + # @!attribute [rw] city + # @return [::String] + # Required. City, town or commune. May also include dependent localities or + # sublocalities (For example neighborhoods or suburbs). + # @!attribute [rw] administrative_area + # @return [::String] + # Required. Top-level administrative subdivision of the country. For example, + # a state like California ("CA") or a province like Quebec ("QC"). + # @!attribute [rw] postal_code + # @return [::String] + # Required. Postal code or ZIP (For example "94043"). + # @!attribute [rw] region_code + # @return [::String] + # Required. [CLDR country + # code](http://www.unicode.org/repos/cldr/tags/latest/common/main/en.xml) + # (For example "US"). + class Address + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Time spent in various aspects from order to the delivery of the product. + # @!attribute [rw] min_transit_days + # @return [::Integer] + # Minimum number of business days that is spent in transit. 0 means same + # day delivery, 1 means next day delivery. + # Either `min_transit_days`, `max_transit_days` or + # `transit_time_table` must be set, but not both. + # @!attribute [rw] max_transit_days + # @return [::Integer] + # Maximum number of business days that is spent in transit. 0 means same + # day delivery, 1 means next day delivery. Must be greater than or equal + # to `min_transit_days`. + # @!attribute [rw] cutoff_time + # @return [::Google::Shopping::Merchant::Accounts::V1beta::CutoffTime] + # Business days cutoff time definition. + # If not configured the cutoff time will be defaulted to 8AM PST. + # @!attribute [rw] min_handling_days + # @return [::Integer] + # Minimum number of business days spent before an order is shipped. + # 0 means same day shipped, 1 means next day shipped. + # @!attribute [rw] max_handling_days + # @return [::Integer] + # Maximum number of business days spent before an order is shipped. + # 0 means same day shipped, 1 means next day shipped. + # Must be greater than or equal to `min_handling_days`. + # @!attribute [rw] transit_time_table + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TransitTable] + # Transit time table, number of business days spent in transit based on row + # and column dimensions. Either `min_transit_days`, `max_transit_days` or + # `transit_time_table` can be set, but not both. + # @!attribute [rw] handling_business_day_config + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessDayConfig] + # The business days during which orders can be handled. + # If not provided, Monday to Friday business days will be assumed. + # @!attribute [rw] transit_business_day_config + # @return [::Google::Shopping::Merchant::Accounts::V1beta::BusinessDayConfig] + # The business days during which orders can be in-transit. + # If not provided, Monday to Friday business days will be assumed. + # @!attribute [rw] warehouse_based_delivery_times + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::WarehouseBasedDeliveryTime>] + # Optional. Indicates that the delivery time should be calculated per + # warehouse (shipping origin location) based on the settings of the selected + # carrier. When set, no other transit time related field in [delivery + # time][[google.shopping.content.bundles.ShippingSetting.DeliveryTime] should + # be set. + class DeliveryTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Business days cutoff time definition. + # @!attribute [rw] hour + # @return [::Integer] + # Required. Hour of the cutoff time until which an order has to be placed to + # be processed in the same day. + # @!attribute [rw] minute + # @return [::Integer] + # Required. Minute of the cutoff time until which an order has to be placed + # to be processed in the same day. + # @!attribute [rw] time_zone + # @return [::String] + # Required. [Timezone + # identifier](https://developers.google.com/adwords/api/docs/appendix/codes-formats#timezone-ids) + # For example "Europe/Zurich". + class CutoffTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Business days of the warehouse. + # @!attribute [rw] business_days + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::BusinessDayConfig::Weekday>] + # Required. Regular business days. + # May not be empty. + class BusinessDayConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + module Weekday + WEEKDAY_UNSPECIFIED = 0 + + MONDAY = 1 + + TUESDAY = 2 + + WEDNESDAY = 3 + + THURSDAY = 4 + + FRIDAY = 5 + + SATURDAY = 6 + + SUNDAY = 7 + end + end + + # Indicates that the delivery time should be calculated per warehouse + # (shipping origin location) based on the settings of the selected carrier. + # When set, no other transit time related field in `delivery_time` should be + # set. + # @!attribute [rw] carrier + # @return [::String] + # Required. Carrier, such as `"UPS"` or `"Fedex"`. + # @!attribute [rw] carrier_service + # @return [::String] + # Required. Carrier service, such as `"ground"` or `"2 days"`. The name of + # the service must be in the eddSupportedServices list. + # @!attribute [rw] warehouse + # @return [::String] + # Required. Warehouse name. This should match + # [warehouse][ShippingSetting.warehouses.name] + class WarehouseBasedDeliveryTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Shipping rate group definitions. Only the last one is allowed to have an + # empty `applicable_shipping_labels`, which means + # "everything else". The other `applicable_shipping_labels` must + # not overlap. + # @!attribute [rw] applicable_shipping_labels + # @return [::Array<::String>] + # Required. A list of [shipping + # labels](https://support.google.com/merchants/answer/6324504) defining the + # products to which this rate group applies to. This is a disjunction: only + # one of the labels has to match for the rate group to apply. May only be + # empty for the last rate group of a service. + # @!attribute [rw] single_value + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Value] + # The value of the rate group (For example flat rate $10). Can only be set + # if `main_table` and `subtables` are not set. + # @!attribute [rw] main_table + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Table] + # A table defining the rate group, when `single_value` is not + # expressive enough. Can only be set if `single_value` is not + # set. + # @!attribute [rw] subtables + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Table>] + # Optional. A list of subtables referred to by `main_table`. Can only + # be set if `main_table` is set. + # @!attribute [rw] carrier_rates + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::CarrierRate>] + # Optional. A list of carrier rates that can be referred to by + # `main_table` or `single_value`. + # @!attribute [rw] name + # @return [::String] + # Optional. Name of the rate group. + # If set has to be unique within shipping service. + class RateGroup + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # A table defining the rate group, when `single_value` is not + # expressive enough. + # @!attribute [rw] name + # @return [::String] + # Name of the table. Required for subtables, ignored for the main table. + # @!attribute [rw] row_headers + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Headers] + # Required. Headers of the table's rows. + # @!attribute [rw] column_headers + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Headers] + # Headers of the table's columns. Optional: if not set then the table has + # only one dimension. + # @!attribute [rw] rows + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Row>] + # Required. The list of rows that constitute the table. Must have the same + # length as `row_headers`. + class Table + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Transit time table, number of business days spent in transit based on row + # and column dimensions. Either `min_transit_days`, `max_transit_days` or + # `transit_time_table` can be set, but not both. + # @!attribute [rw] postal_code_group_names + # @return [::Array<::String>] + # Required. A list of region names + # {::Google::Shopping::Merchant::Accounts::V1beta::Region#name Region.name} . The + # last value can be + # `"all other locations"`. Example: + # `["zone 1", "zone 2", "all other locations"]`. The referred + # postal code groups must match the delivery country of the service. + # @!attribute [rw] transit_time_labels + # @return [::Array<::String>] + # Required. A list of transit time labels. The last value can be + # `"all other labels"`. Example: + # `["food", "electronics", "all other labels"]`. + # @!attribute [rw] rows + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::TransitTable::TransitTimeRow>] + # Required. If there's only one dimension set of `postal_code_group_names` or + # `transit_time_labels`, there are multiple rows each with one value + # for that dimension. If there are two dimensions, each row corresponds to a + # `postal_code_group_names`, and columns (values) to a + # `transit_time_labels`. + class TransitTable + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # If there's only one dimension set of `postal_code_group_names` or + # `transit_time_labels`, there are multiple rows each with one value + # for that dimension. If there are two dimensions, each row corresponds to a + # `postal_code_group_names`, and columns (values) to a + # `transit_time_labels`. + # @!attribute [rw] values + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::TransitTable::TransitTimeRow::TransitTimeValue>] + # Required. Transit time range (min-max) in business days. + class TransitTimeRow + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Transit time range (min-max) in business days. + # @!attribute [rw] min_transit_days + # @return [::Integer] + # Minimum transit time range in business days. 0 means same + # day delivery, 1 means next day delivery. + # @!attribute [rw] max_transit_days + # @return [::Integer] + # Must be greater than or equal to `min_transit_days`. + class TransitTimeValue + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + + # Table of per store minimum order values for the pickup fulfillment type. + # @!attribute [rw] store_code_set_with_movs + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::MinimumOrderValueTable::StoreCodeSetWithMov>] + # Required. A list of store code sets sharing the same minimum order value + # (MOV). At least two sets are required and the last one must be empty, which + # signifies 'MOV for all other stores'. Each store code can only appear once + # across all the sets. All prices within a service must have the same + # currency. + class MinimumOrderValueTable + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A list of store code sets sharing the same minimum order value. At least + # two sets are required and the last one must be empty, which signifies + # 'MOV for all other stores'. + # Each store code can only appear once across all the sets. + # All prices within a service must have the same currency. + # @!attribute [rw] store_codes + # @return [::Array<::String>] + # Optional. A list of unique store codes or empty for the catch all. + # @!attribute [rw] value + # @return [::Google::Shopping::Type::Price] + # The minimum order value for the given stores. + class StoreCodeSetWithMov + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + + # A non-empty list of row or column headers for a table. + # Exactly one of `prices`, `weights`, + # `num_items`, `postal_code_group_names`, or + # `location` must be set. + # @!attribute [rw] prices + # @return [::Array<::Google::Shopping::Type::Price>] + # Required. A list of inclusive order price upper bounds. The last price's + # value can be infinity by setting price amount_micros = -1. For example + # `[{"amount_micros": 10000000, "currency_code": "USD"}, + # \\{"amount_micros": 500000000, "currency_code": "USD"}, + # \\{"amount_micros": -1, "currency_code": "USD"}]` represents the headers + # "<= $10", "<= $500", and "> $500". All prices within a service must have + # the same currency. Must be non-empty. Must be positive except -1. Can only + # be set if all other fields are not set. + # @!attribute [rw] weights + # @return [::Array<::Google::Shopping::Type::Weight>] + # Required. A list of inclusive order weight upper bounds. The last weight's + # value can be infinity by setting price amount_micros = -1. For example + # `[{"amount_micros": 10000000, "unit": "kg"}, {"amount_micros": 50000000, + # "unit": "kg"}, + # \\{"amount_micros": -1, "unit": "kg"}]` represents the headers + # "<= 10kg", "<= 50kg", and "> 50kg". All weights within a service must have + # the same unit. Must be non-empty. Must be positive except -1. Can only be + # set if all other fields are not set. + # @!attribute [rw] number_of_items + # @return [::Array<::String>] + # Required. A list of inclusive number of items upper bounds. The last value + # can be + # `"infinity"`. For example + # `["10", "50", "infinity"]` represents the headers + # "<= 10 items", "<= 50 items", and "> 50 items". Must be non-empty. Can + # only be set if all other fields are not set. + # @!attribute [rw] postal_code_group_names + # @return [::Array<::String>] + # Required. A list of postal group names. The last value can be + # `"all other locations"`. Example: + # `["zone 1", "zone 2", "all other locations"]`. The referred + # postal code groups must match the delivery country of the service. Must + # be non-empty. Can only be set if all other fields are not set. + # @!attribute [rw] locations + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::LocationIdSet>] + # Required. A list of location ID sets. Must be non-empty. Can only be set if + # all other fields are not set. + class Headers + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # A list of location ID sets. Must be non-empty. Can only be set if all + # other fields are not set. + # @!attribute [rw] location_ids + # @return [::Array<::String>] + # Required. A non-empty list of + # [location + # IDs](https://developers.google.com/adwords/api/docs/appendix/geotargeting). + # They must all be of the same location type (For + # example, state). + class LocationIdSet + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Include a list of cells. + # @!attribute [rw] cells + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::Value>] + # Required. The list of cells that constitute the row. Must have the same + # length as `columnHeaders` for two-dimensional tables, a length of 1 for + # one-dimensional tables. + class Row + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The single value of a rate group or the value of a rate group table's cell. + # Exactly one of `no_shipping`, `flat_rate`, + # `price_percentage`, `carrier_rateName`, + # `subtable_name` must be set. + # @!attribute [rw] no_shipping + # @return [::Boolean] + # If true, then the product can't be shipped. Must be true when set, can only + # be set if all other fields are not set. + # @!attribute [rw] flat_rate + # @return [::Google::Shopping::Type::Price] + # A flat rate. Can only be set if all other fields are not set. + # @!attribute [rw] price_percentage + # @return [::String] + # A percentage of the price represented as a number in decimal notation + # (For example, `"5.4"`). Can only be set if all other fields are not + # set. + # @!attribute [rw] carrier_rate + # @return [::String] + # The name of a carrier rate referring to a carrier rate defined in the + # same rate group. Can only be set if all other fields are not set. + # @!attribute [rw] subtable + # @return [::String] + # The name of a subtable. Can only be set in table cells (For example, not + # for single values), and only if all other fields are not set. + class Value + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # A list of carrier rates that can be referred to by + # `main_table` or `single_value`. + # @!attribute [rw] name + # @return [::String] + # Required. Name of the carrier rate. Must be unique per rate group. + # @!attribute [rw] carrier + # @return [::String] + # Required. Carrier service, such as `"UPS"` or `"Fedex"`. + # @!attribute [rw] carrier_service + # @return [::String] + # Required. Carrier service, such as `"ground"` or `"2 days"`. + # @!attribute [rw] origin_postal_code + # @return [::String] + # Required. Shipping origin for this carrier rate. + # @!attribute [rw] percentage_adjustment + # @return [::String] + # Optional. Multiplicative shipping rate modifier as a number in decimal + # notation. Can be negative. For example `"5.4"` increases the rate by 5.4%, + # `"-3"` decreases the rate by 3%. + # @!attribute [rw] flat_adjustment + # @return [::Google::Shopping::Type::Price] + # Optional. Additive shipping rate modifier. Can be negative. For example + # `{ "amount_micros": 1, "currency_code" : "USD" }` adds $1 to the rate, + # `{ "amount_micros": -3, "currency_code" : "USD" }` removes $3 from the + # rate. + class CarrierRate + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetShippingSetting` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the shipping setting to retrieve. + # Format: `accounts/{account}/shippingsetting` + class GetShippingSettingsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `InsertShippingSetting` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account where this product will be inserted. + # Format: accounts/\\{account} + # @!attribute [rw] shipping_setting + # @return [::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings] + # Required. The new version of the account. + class InsertShippingSettingsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/tax_rule.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/tax_rule.rb new file mode 100644 index 000000000000..a5c918b534dc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/tax_rule.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # Primary type convension + # + # percent micro : 100% = 1 000 000 and 1% = 10 000 + # cannot be negative. + # + # Information about tax nexus and related parameters applicable to orders + # delivered to the area covered by a single tax admin. Nexus is created when a + # merchant is doing business in an area administered by tax admin (only US + # states are supported for nexus configuration). If merchant has nexus in a US + # state, merchant needs to pay tax to all tax authorities associated with + # the shipping destination. + # Next Id : 8 + # @!attribute [rw] location_id + # @return [::Integer] + # The admin_id or criteria_id of the region in which this rule is + # applicable. + # @!attribute [rw] post_code_range + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TaxRule::TaxPostalCodeRange] + # The range of postal codes in which this rule is applicable. + # @!attribute [rw] use_google_rate + # @return [::Boolean] + # Rate that depends on delivery location: if merchant has a nexus in + # corresponding US state, rates from authorities with jurisdiction over + # delivery area are added up. + # @!attribute [rw] self_specified_rate_micros + # @return [::Integer] + # A fixed rate specified in micros, where 100% = 1_000_000. + # Suitable for origin-based states. + # @!attribute [rw] region_code + # @return [::String] + # Region code in which this rule is applicable + # @!attribute [rw] shipping_taxed + # @return [::Boolean] + # If set, shipping charge is taxed (at the same rate as product) when + # delivering to this admin's area. + # Can only be set on US states without category. + # @!attribute [rw] effective_time_period + # @return [::Google::Type::Interval] + # Required. Time period when this rule is effective. If the duration is + # missing from effective_time listed, then it is open ended to the future. + # The start of this time period is inclusive, and the end is exclusive. + class TaxRule + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # A range of postal codes that defines the area. + # @!attribute [rw] start + # @return [::String] + # Required. The start of the postal code range, which is also the smallest + # in the range. + # @!attribute [rw] end + # @return [::String] + # The end of the postal code range. Will be the same as start if not + # specified. + class TaxPostalCodeRange + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservice.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservice.rb new file mode 100644 index 000000000000..13218d6cf509 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservice.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # A `TermsOfService`. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # @!attribute [rw] region_code + # @return [::String] + # Region code as defined by [CLDR](https://cldr.unicode.org/). This is either + # a country where the ToS applies specifically to that country or `001` when + # the same `TermsOfService` can be signed in any country. However note that + # when signing a ToS that applies globally we still expect that a specific + # country is provided (this should be merchant business country or program + # country of participation). + # @!attribute [rw] kind + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceKind] + # The Kind this terms of service version applies to. + # @!attribute [rw] file_uri + # @return [::String] + # URI for terms of service file that needs to be displayed to signing users. + # @!attribute [rw] external + # @return [::Boolean] + # Whether this terms of service version is external. External terms of + # service versions can only be agreed through external processes and not + # directly by the merchant through UI or API. + class TermsOfService + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetTermsOfService` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + class GetTermsOfServiceRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `RetrieveLatestTermsOfService` method. + # @!attribute [rw] region_code + # @return [::String] + # Region code as defined by [CLDR](https://cldr.unicode.org/). This is either + # a country when the ToS applies specifically to that country or 001 when it + # applies globally. + # @!attribute [rw] kind + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceKind] + # The Kind this terms of service version applies to. + class RetrieveLatestTermsOfServiceRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `AcceptTermsOfService` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the terms of service version. + # Format: `termsOfService/{version}` + # @!attribute [rw] account + # @return [::String] + # Required. The account for which to accept the ToS. + # @!attribute [rw] region_code + # @return [::String] + # Required. Region code as defined by [CLDR](https://cldr.unicode.org/). This + # is either a country when the ToS applies specifically to that country or + # 001 when it applies globally. + class AcceptTermsOfServiceRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.rb new file mode 100644 index 000000000000..75ad935beb9c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # This resource represents the agreement state for a given account and terms of + # service kind. + # The state is as follows: + # + # * If the merchant has accepted a terms of service: + # [accepted](TermsOfServiceAggrementState.accepted) will be populated, + # otherwise it will be empty + # * If the merchant must sign a terms of service: + # [required](TermsOfServiceAggrementState.required) will be populated, + # otherwise it will be empty. + # + # Note that both [required](TermsOfServiceAggrementState.required) and + # [accepted](TermsOfServiceAggrementState.accepted) can be present. In this + # case the `accepted` terms of services will have an expiration date set in the + # [valid_until](Accepted.valid_until) field. The `required` terms of services + # need to be accepted before `valid_until` in order for the account to continue + # having a valid agreement. When accepting new terms of services we expect 3Ps + # to display the text associated with the given terms of service agreement (the + # url to the file containing the text is added in the Required message below as + # [tos_file_uri](Accepted.tos_file_uri). The actual acceptance of the terms of + # service is done by calling accept on the [TermsOfService](TermsOfService) + # resource. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the terms of service version. + # Format: `accounts/{account}/termsOfServiceAgreementState/{identifier}` + # @!attribute [rw] region_code + # @return [::String] + # Region code as defined by https://cldr.unicode.org/. This is the + # country the current state applies to. + # @!attribute [rw] terms_of_service_kind + # @return [::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceKind] + # Terms of Service kind associated with the particular version. + # @!attribute [rw] accepted + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Accepted] + # The accepted terms of service of this kind and for the associated + # region_code + # @!attribute [rw] required + # @return [::Google::Shopping::Merchant::Accounts::V1beta::Required] + # The required terms of service + class TermsOfServiceAgreementState + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Describes the accepted terms of service. + # @!attribute [rw] terms_of_service + # @return [::String] + # The accepted + # [termsOfService](google.shopping.merchant.accounts.v1main.TermsOfService). + # @!attribute [rw] accepted_by + # @return [::String] + # The account where the acceptance was recorded. This can be the account + # itself or, in the case of subaccounts, the MCA account. + # @!attribute [rw] valid_until + # @return [::Google::Type::Date] + # When set, it states that the accepted + # [TermsOfService](google.shopping.merchant.accounts.v1main.TermsOfService) + # is only valid until the end of this date (in UTC). A new one must be + # accepted before then. The information of the required + # [TermsOfService](google.shopping.merchant.accounts.v1main.TermsOfService) + # is found in the [Required](Required) message. + class Accepted + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Describes the terms of service which are required to be accepted. + # @!attribute [rw] terms_of_service + # @return [::String] + # The + # [termsOfService](google.shopping.merchant.accounts.v1main.TermsOfService) + # that need to be accepted. + # @!attribute [rw] tos_file_uri + # @return [::String] + # Full URL to the terms of service file. This field is the same as + # [TermsOfService.file_uri](TermsOfService.file_uri), it is added + # here for convenience only. + class Required + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `GetTermsOfServiceAgreementState` method. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name of the terms of service version. + # Format: `accounts/{account}/termsOfServiceAgreementState/{identifier}` + class GetTermsOfServiceAgreementStateRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `RetrieveForApplicationTermsOfServiceAgreementState` + # method. + # @!attribute [rw] parent + # @return [::String] + # Required. The account for which to get a TermsOfServiceAgreementState + # Format: `accounts/{account}` + class RetrieveForApplicationTermsOfServiceAgreementStateRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservicekind.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservicekind.rb new file mode 100644 index 000000000000..ff1c02a9eb4c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/termsofservicekind.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # The TermsOfService Kind. + module TermsOfServiceKind + # Default value. This value is unused. + TERMS_OF_SERVICE_KIND_UNSPECIFIED = 0 + + # Merchant Center application. + MERCHANT_CENTER = 1 + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/user.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/user.rb new file mode 100644 index 000000000000..1362050a0481 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/merchant/accounts/v1beta/user.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Merchant + module Accounts + module V1beta + # A [user](https://support.google.com/merchants/answer/12160472). + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the user. + # Format: `accounts/{account}/user/{email}` + # + # Use `me` to refer to your own email address, for example + # `accounts/{account}/users/me`. + # @!attribute [r] state + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User::State] + # Output only. The state of the user. + # @!attribute [rw] access_rights + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::AccessRight>] + # Optional. The [access + # rights](https://support.google.com/merchants/answer/12160472?sjid=6789834943175119429-EU#accesstypes) + # the user has. + class User + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The possible states of a user. + module State + # Default value. This value is unused. + STATE_UNSPECIFIED = 0 + + # The user is pending confirmation. In this state, the user first needs to + # accept the invitation before performing other actions. + PENDING = 1 + + # The user is verified. + VERIFIED = 2 + end + end + + # Request message for the `GetUser` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the user to retrieve. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to retrieve the user corresponding to the caller by + # using `me` rather than an email address as in + # `accounts/{account}/users/me`. + class GetUserRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `CreateUser` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The resource name of the account for which a user will be + # created. Format: `accounts/{account}` + # @!attribute [rw] user_id + # @return [::String] + # Required. The email address of the user (for example, + # `john.doe@gmail.com`). + # @!attribute [rw] user + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # Required. The user to create. + class CreateUserRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `DeleteUser` method. + # @!attribute [rw] name + # @return [::String] + # Required. The name of the user to delete. + # Format: `accounts/{account}/users/{email}` + # + # It is also possible to delete the user corresponding to the caller by using + # `me` rather than an email address as in `accounts/{account}/users/me`. + class DeleteUserRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `UpdateUser` method. + # @!attribute [rw] user + # @return [::Google::Shopping::Merchant::Accounts::V1beta::User] + # Required. The new version of the user. + # + # Use `me` to refer to your own email address, for example + # `accounts/{account}/users/me`. + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. List of fields being updated. + class UpdateUserRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for the `ListUsers` method. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent, which owns this collection of users. + # Format: `accounts/{account}` + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of users to return. The service may return + # fewer than this value. If unspecified, at most 50 users will be returned. + # The maximum value is 100; values above 100 will be coerced to 100 + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListUsers` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListUsers` must match + # the call that provided the page token. + class ListUsersRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response message for the `ListUsers` method. + # @!attribute [rw] users + # @return [::Array<::Google::Shopping::Merchant::Accounts::V1beta::User>] + # The users from the specified account. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListUsersResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/type/types.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/type/types.rb new file mode 100644 index 000000000000..7c4fd780655b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/shopping/type/types.rb @@ -0,0 +1,210 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Shopping + module Type + # The weight represented as the value in string and the unit. + # @!attribute [rw] amount_micros + # @return [::Integer] + # Required. The weight represented as a number in micros (1 million micros is + # an equivalent to one's currency standard unit, for example, 1 kg = 1000000 + # micros). + # This field can also be set as infinity by setting to -1. + # This field only support -1 and positive value. + # @!attribute [rw] unit + # @return [::Google::Shopping::Type::Weight::WeightUnit] + # Required. The weight unit. + # Acceptable values are: kg and lb + class Weight + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The weight unit. + module WeightUnit + # unit unspecified + WEIGHT_UNIT_UNSPECIFIED = 0 + + # lb unit. + POUND = 1 + + # kg unit. + KILOGRAM = 2 + end + end + + # The price represented as a number and currency. + # @!attribute [rw] amount_micros + # @return [::Integer] + # The price represented as a number in micros (1 million micros is an + # equivalent to one's currency standard unit, for example, 1 USD = 1000000 + # micros). + # @!attribute [rw] currency_code + # @return [::String] + # The currency of the price using three-letter acronyms according to [ISO + # 4217](http://en.wikipedia.org/wiki/ISO_4217). + class Price + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # A message that represents custom attributes. Exactly one of `value` or + # `group_values` must not be empty. + # @!attribute [rw] name + # @return [::String] + # The name of the attribute. + # @!attribute [rw] value + # @return [::String] + # The value of the attribute. If `value` is not empty, `group_values` must be + # empty. + # @!attribute [rw] group_values + # @return [::Array<::Google::Shopping::Type::CustomAttribute>] + # Subattributes within this attribute group. If + # `group_values` is not empty, `value` must be empty. + class CustomAttribute + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Destinations available for a product. + # + # Destinations are used in Merchant Center to allow you to control where the + # products from your data feed should be displayed. + class Destination + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Destination values. + module DestinationEnum + # Not specified. + DESTINATION_ENUM_UNSPECIFIED = 0 + + # [Shopping ads](https://support.google.com/google-ads/answer/2454022). + SHOPPING_ADS = 1 + + # [Display ads](https://support.google.com/merchants/answer/6069387). + DISPLAY_ADS = 2 + + # [Local inventory + # ads](https://support.google.com/merchants/answer/3057972). + LOCAL_INVENTORY_ADS = 3 + + # [Free listings](https://support.google.com/merchants/answer/9199328). + FREE_LISTINGS = 4 + + # [Free local product + # listings](https://support.google.com/merchants/answer/9825611). + FREE_LOCAL_LISTINGS = 5 + + # [YouTube Shopping](https://support.google.com/merchants/answer/12362804). + YOUTUBE_SHOPPING = 6 + end + end + + # Reporting contexts that your account and product issues apply to. + # + # Reporting contexts are groups of surfaces and formats for product results on + # Google. They can represent the entire destination (for example, [Shopping + # ads](https://support.google.com/merchants/answer/6149970)) or a subset of + # formats within a destination (for example, [Demand Gen + # ads](https://support.google.com/merchants/answer/13389785)). + class ReportingContext + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Reporting context values. + module ReportingContextEnum + # Not specified. + REPORTING_CONTEXT_ENUM_UNSPECIFIED = 0 + + # [Shopping ads](https://support.google.com/merchants/answer/6149970). + SHOPPING_ADS = 1 + + # Deprecated: Use `DEMAND_GEN_ADS` instead. + # [Discovery and Demand Gen + # ads](https://support.google.com/merchants/answer/13389785). + DISCOVERY_ADS = 2 + + # [Demand Gen ads](https://support.google.com/merchants/answer/13389785). + DEMAND_GEN_ADS = 13 + + # [Demand Gen ads on Discover + # surface](https://support.google.com/merchants/answer/13389785). + DEMAND_GEN_ADS_DISCOVER_SURFACE = 14 + + # [Video ads](https://support.google.com/google-ads/answer/6340491). + VIDEO_ADS = 3 + + # [Display ads](https://support.google.com/merchants/answer/6069387). + DISPLAY_ADS = 4 + + # [Local inventory + # ads](https://support.google.com/merchants/answer/3271956). + LOCAL_INVENTORY_ADS = 5 + + # [Vehicle inventory + # ads](https://support.google.com/merchants/answer/11544533). + VEHICLE_INVENTORY_ADS = 6 + + # [Free product + # listings](https://support.google.com/merchants/answer/9199328). + FREE_LISTINGS = 7 + + # [Free local product + # listings](https://support.google.com/merchants/answer/9825611). + FREE_LOCAL_LISTINGS = 8 + + # [Free local vehicle + # listings](https://support.google.com/merchants/answer/11544533). + FREE_LOCAL_VEHICLE_LISTINGS = 9 + + # [YouTube + # Shopping](https://support.google.com/merchants/answer/13478370). + YOUTUBE_SHOPPING = 10 + + # [Cloud retail](https://cloud.google.com/solutions/retail). + CLOUD_RETAIL = 11 + + # [Local cloud retail](https://cloud.google.com/solutions/retail). + LOCAL_CLOUD_RETAIL = 12 + end + end + + # [Channel](https://support.google.com/merchants/answer/7361332) of a product. + # + # Channel is used to distinguish between online and local products. + class Channel + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Channel values. + module ChannelEnum + # Not specified. + CHANNEL_ENUM_UNSPECIFIED = 0 + + # Online product. + ONLINE = 1 + + # Local product. + LOCAL = 2 + end + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/date.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/date.rb new file mode 100644 index 000000000000..a8b78b5e8ce4 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/date.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Type + # Represents a whole or partial calendar date, such as a birthday. The time of + # day and time zone are either specified elsewhere or are insignificant. The + # date is relative to the Gregorian Calendar. This can represent one of the + # following: + # + # * A full date, with non-zero year, month, and day values + # * A month and day value, with a zero year, such as an anniversary + # * A year on its own, with zero month and day values + # * A year and month value, with a zero day, such as a credit card expiration + # date + # + # Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and + # `google.protobuf.Timestamp`. + # @!attribute [rw] year + # @return [::Integer] + # Year of the date. Must be from 1 to 9999, or 0 to specify a date without + # a year. + # @!attribute [rw] month + # @return [::Integer] + # Month of a year. Must be from 1 to 12, or 0 to specify a year without a + # month and day. + # @!attribute [rw] day + # @return [::Integer] + # Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 + # to specify a year by itself or a year and month where the day isn't + # significant. + class Date + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/datetime.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/datetime.rb new file mode 100644 index 000000000000..7be9d37b7d84 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/datetime.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Type + # Represents civil time (or occasionally physical time). + # + # This type can represent a civil time in one of a few possible ways: + # + # * When utc_offset is set and time_zone is unset: a civil time on a calendar + # day with a particular offset from UTC. + # * When time_zone is set and utc_offset is unset: a civil time on a calendar + # day in a particular time zone. + # * When neither time_zone nor utc_offset is set: a civil time on a calendar + # day in local time. + # + # The date is relative to the Proleptic Gregorian Calendar. + # + # If year is 0, the DateTime is considered not to have a specific year. month + # and day must have valid, non-zero values. + # + # This type may also be used to represent a physical time if all the date and + # time fields are set and either case of the `time_offset` oneof is set. + # Consider using `Timestamp` message for physical time instead. If your use + # case also would like to store the user's timezone, that can be done in + # another field. + # + # This type is more flexible than some applications may want. Make sure to + # document and validate your application's limitations. + # @!attribute [rw] year + # @return [::Integer] + # Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + # datetime without a year. + # @!attribute [rw] month + # @return [::Integer] + # Required. Month of year. Must be from 1 to 12. + # @!attribute [rw] day + # @return [::Integer] + # Required. Day of month. Must be from 1 to 31 and valid for the year and + # month. + # @!attribute [rw] hours + # @return [::Integer] + # Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + # may choose to allow the value "24:00:00" for scenarios like business + # closing time. + # @!attribute [rw] minutes + # @return [::Integer] + # Required. Minutes of hour of day. Must be from 0 to 59. + # @!attribute [rw] seconds + # @return [::Integer] + # Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + # API may allow the value 60 if it allows leap-seconds. + # @!attribute [rw] nanos + # @return [::Integer] + # Required. Fractions of seconds in nanoseconds. Must be from 0 to + # 999,999,999. + # @!attribute [rw] utc_offset + # @return [::Google::Protobuf::Duration] + # UTC offset. Must be whole seconds, between -18 hours and +18 hours. + # For example, a UTC offset of -4:00 would be represented as + # { seconds: -14400 }. + # @!attribute [rw] time_zone + # @return [::Google::Type::TimeZone] + # Time zone. + class DateTime + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Represents a time zone from the + # [IANA Time Zone Database](https://www.iana.org/time-zones). + # @!attribute [rw] id + # @return [::String] + # IANA Time Zone Database time zone, e.g. "America/New_York". + # @!attribute [rw] version + # @return [::String] + # Optional. IANA Time Zone Database version number, e.g. "2019a". + class TimeZone + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/interval.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/interval.rb new file mode 100644 index 000000000000..ba88575c495d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/interval.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Type + # Represents a time interval, encoded as a Timestamp start (inclusive) and a + # Timestamp end (exclusive). + # + # The start must be less than or equal to the end. + # When the start equals the end, the interval is empty (matches no time). + # When both start and end are unspecified, the interval matches any time. + # @!attribute [rw] start_time + # @return [::Google::Protobuf::Timestamp] + # Optional. Inclusive start of the interval. + # + # If specified, a Timestamp matching this interval will have to be the same + # or after the start. + # @!attribute [rw] end_time + # @return [::Google::Protobuf::Timestamp] + # Optional. Exclusive end of the interval. + # + # If specified, a Timestamp matching this interval will have to be before the + # end. + class Interval + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/phone_number.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/phone_number.rb new file mode 100644 index 000000000000..96dc01465dae --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/phone_number.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Type + # An object representing a phone number, suitable as an API wire format. + # + # This representation: + # + # - should not be used for locale-specific formatting of a phone number, such + # as "+1 (650) 253-0000 ext. 123" + # + # - is not designed for efficient storage + # - may not be suitable for dialing - specialized libraries (see references) + # should be used to parse the number for that purpose + # + # To do something meaningful with this number, such as format it for various + # use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first. + # + # For instance, in Java this would be: + # + # com.google.type.PhoneNumber wireProto = + # com.google.type.PhoneNumber.newBuilder().build(); + # com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber = + # PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ"); + # if (!wireProto.getExtension().isEmpty()) { + # phoneNumber.setExtension(wireProto.getExtension()); + # } + # + # Reference(s): + # - https://github.com/google/libphonenumber + # @!attribute [rw] e164_number + # @return [::String] + # The phone number, represented as a leading plus sign ('+'), followed by a + # phone number that uses a relaxed ITU E.164 format consisting of the + # country calling code (1 to 3 digits) and the subscriber number, with no + # additional spaces or formatting, e.g.: + # - correct: "+15552220123" + # - incorrect: "+1 (555) 222-01234 x123". + # + # The ITU E.164 format limits the latter to 12 digits, but in practice not + # all countries respect that, so we relax that restriction here. + # National-only numbers are not allowed. + # + # References: + # - https://www.itu.int/rec/T-REC-E.164-201011-I + # - https://en.wikipedia.org/wiki/E.164. + # - https://en.wikipedia.org/wiki/List_of_country_calling_codes + # @!attribute [rw] short_code + # @return [::Google::Type::PhoneNumber::ShortCode] + # A short code. + # + # Reference(s): + # - https://en.wikipedia.org/wiki/Short_code + # @!attribute [rw] extension + # @return [::String] + # The phone number's extension. The extension is not standardized in ITU + # recommendations, except for being defined as a series of numbers with a + # maximum length of 40 digits. Other than digits, some other dialing + # characters such as ',' (indicating a wait) or '#' may be stored here. + # + # Note that no regions currently use extensions with short codes, so this + # field is normally only set in conjunction with an E.164 number. It is held + # separately from the E.164 number to allow for short code extensions in the + # future. + class PhoneNumber + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # An object representing a short code, which is a phone number that is + # typically much shorter than regular phone numbers and can be used to + # address messages in MMS and SMS systems, as well as for abbreviated dialing + # (e.g. "Text 611 to see how many minutes you have remaining on your plan."). + # + # Short codes are restricted to a region and are not internationally + # dialable, which means the same short code can exist in different regions, + # with different usage and pricing, even if those regions share the same + # country calling code (e.g. US and CA). + # @!attribute [rw] region_code + # @return [::String] + # Required. The BCP-47 region code of the location where calls to this + # short code can be made, such as "US" and "BB". + # + # Reference(s): + # - http://www.unicode.org/reports/tr35/#unicode_region_subtag + # @!attribute [rw] number + # @return [::String] + # Required. The short code digits, without a leading plus ('+') or country + # calling code, e.g. "611". + class ShortCode + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/postal_address.rb b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/postal_address.rb new file mode 100644 index 000000000000..07d77c5d3183 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/proto_docs/google/type/postal_address.rb @@ -0,0 +1,135 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Type + # Represents a postal address, e.g. for postal delivery or payments addresses. + # Given a postal address, a postal service can deliver items to a premise, P.O. + # Box or similar. + # It is not intended to model geographical locations (roads, towns, + # mountains). + # + # In typical usage an address would be created via user input or from importing + # existing data, depending on the type of process. + # + # Advice on address input / editing: + # - Use an i18n-ready address widget such as + # https://github.com/google/libaddressinput) + # - Users should not be presented with UI elements for input or editing of + # fields outside countries where that field is used. + # + # For more guidance on how to use this schema, please see: + # https://support.google.com/business/answer/6397478 + # @!attribute [rw] revision + # @return [::Integer] + # The schema revision of the `PostalAddress`. This must be set to 0, which is + # the latest revision. + # + # All new revisions **must** be backward compatible with old revisions. + # @!attribute [rw] region_code + # @return [::String] + # Required. CLDR region code of the country/region of the address. This + # is never inferred and it is up to the user to ensure the value is + # correct. See http://cldr.unicode.org/ and + # http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html + # for details. Example: "CH" for Switzerland. + # @!attribute [rw] language_code + # @return [::String] + # Optional. BCP-47 language code of the contents of this address (if + # known). This is often the UI language of the input form or is expected + # to match one of the languages used in the address' country/region, or their + # transliterated equivalents. + # This can affect formatting in certain countries, but is not critical + # to the correctness of the data and will never affect any validation or + # other non-formatting related operations. + # + # If this value is not known, it should be omitted (rather than specifying a + # possibly incorrect default). + # + # Examples: "zh-Hant", "ja", "ja-Latn", "en". + # @!attribute [rw] postal_code + # @return [::String] + # Optional. Postal code of the address. Not all countries use or require + # postal codes to be present, but where they are used, they may trigger + # additional validation with other parts of the address (e.g. state/zip + # validation in the U.S.A.). + # @!attribute [rw] sorting_code + # @return [::String] + # Optional. Additional, country-specific, sorting code. This is not used + # in most regions. Where it is used, the value is either a string like + # "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number + # alone, representing the "sector code" (Jamaica), "delivery area indicator" + # (Malawi) or "post office indicator" (e.g. Côte d'Ivoire). + # @!attribute [rw] administrative_area + # @return [::String] + # Optional. Highest administrative subdivision which is used for postal + # addresses of a country or region. + # For example, this can be a state, a province, an oblast, or a prefecture. + # Specifically, for Spain this is the province and not the autonomous + # community (e.g. "Barcelona" and not "Catalonia"). + # Many countries don't use an administrative area in postal addresses. E.g. + # in Switzerland this should be left unpopulated. + # @!attribute [rw] locality + # @return [::String] + # Optional. Generally refers to the city/town portion of the address. + # Examples: US city, IT comune, UK post town. + # In regions of the world where localities are not well defined or do not fit + # into this structure well, leave locality empty and use address_lines. + # @!attribute [rw] sublocality + # @return [::String] + # Optional. Sublocality of the address. + # For example, this can be neighborhoods, boroughs, districts. + # @!attribute [rw] address_lines + # @return [::Array<::String>] + # Unstructured address lines describing the lower levels of an address. + # + # Because values in address_lines do not have type information and may + # sometimes contain multiple values in a single field (e.g. + # "Austin, TX"), it is important that the line order is clear. The order of + # address lines should be "envelope order" for the country/region of the + # address. In places where this can vary (e.g. Japan), address_language is + # used to make it explicit (e.g. "ja" for large-to-small ordering and + # "ja-Latn" or "en" for small-to-large). This way, the most specific line of + # an address can be selected based on the language. + # + # The minimum permitted structural representation of an address consists + # of a region_code with all remaining information placed in the + # address_lines. It would be possible to format such an address very + # approximately without geocoding, but no semantic reasoning could be + # made about any of the address components until it was at least + # partially resolved. + # + # Creating an address only containing a region_code and address_lines, and + # then geocoding is the recommended way to handle completely unstructured + # addresses (as opposed to guessing which parts of the address should be + # localities or administrative areas). + # @!attribute [rw] recipients + # @return [::Array<::String>] + # Optional. The recipient at the address. + # This field may, under certain circumstances, contain multiline information. + # For example, it might contain "care of" information. + # @!attribute [rw] organization + # @return [::String] + # Optional. The name of the organization at the address. + class PostalAddress + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/snippets/Gemfile b/google-shopping-merchant-accounts-v1beta/snippets/Gemfile new file mode 100644 index 000000000000..a7f73a403b3c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/Gemfile @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +source "https://rubygems.org" + +if ENV["GOOGLE_CLOUD_SAMPLES_TEST"] == "master" + gem "google-shopping-merchant-accounts-v1beta", path: "../" +else + gem "google-shopping-merchant-accounts-v1beta" +end + +group :test do + gem "google-style", "~> 1.26.1" + gem "minitest", "~> 5.16" + gem "minitest-focus", "~> 1.1" + gem "minitest-hooks", "~> 1.5" +end diff --git a/google-shopping-merchant-accounts-v1beta/snippets/account_issue_service/list_account_issues.rb b/google-shopping-merchant-accounts-v1beta/snippets/account_issue_service/list_account_issues.rb new file mode 100644 index 000000000000..803670836afb --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/account_issue_service/list_account_issues.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountIssueService_ListAccountIssues_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_account_issues call in the AccountIssueService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client#list_account_issues. +# +def list_account_issues + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new + + # Call the list_account_issues method. + result = client.list_account_issues request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssue. + p item + end +end +# [END merchantapi_v1beta_generated_AccountIssueService_ListAccountIssues_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/get_account_tax.rb b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/get_account_tax.rb new file mode 100644 index 000000000000..47f311a4bfdd --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/get_account_tax.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountTaxService_GetAccountTax_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_account_tax call in the AccountTaxService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#get_account_tax. +# +def get_account_tax + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new + + # Call the get_account_tax method. + result = client.get_account_tax request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + p result +end +# [END merchantapi_v1beta_generated_AccountTaxService_GetAccountTax_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/list_account_tax.rb b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/list_account_tax.rb new file mode 100644 index 000000000000..393588ae0a4c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/list_account_tax.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountTaxService_ListAccountTax_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_account_tax call in the AccountTaxService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#list_account_tax. +# +def list_account_tax + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new + + # Call the list_account_tax method. + result = client.list_account_tax request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + p item + end +end +# [END merchantapi_v1beta_generated_AccountTaxService_ListAccountTax_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/update_account_tax.rb b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/update_account_tax.rb new file mode 100644 index 000000000000..d369099b2c44 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/account_tax_service/update_account_tax.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountTaxService_UpdateAccountTax_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_account_tax call in the AccountTaxService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#update_account_tax. +# +def update_account_tax + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new + + # Call the update_account_tax method. + result = client.update_account_tax request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::AccountTax. + p result +end +# [END merchantapi_v1beta_generated_AccountTaxService_UpdateAccountTax_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/create_and_configure_account.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/create_and_configure_account.rb new file mode 100644 index 000000000000..3e48a32e7d1f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/create_and_configure_account.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_CreateAndConfigureAccount_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the create_and_configure_account call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#create_and_configure_account. +# +def create_and_configure_account + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new + + # Call the create_and_configure_account method. + result = client.create_and_configure_account request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + p result +end +# [END merchantapi_v1beta_generated_AccountsService_CreateAndConfigureAccount_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/delete_account.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/delete_account.rb new file mode 100644 index 000000000000..86c4e87272c7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/delete_account.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_DeleteAccount_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the delete_account call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#delete_account. +# +def delete_account + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new + + # Call the delete_account method. + result = client.delete_account request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END merchantapi_v1beta_generated_AccountsService_DeleteAccount_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/get_account.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/get_account.rb new file mode 100644 index 000000000000..3554900fd0bc --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/get_account.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_GetAccount_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_account call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#get_account. +# +def get_account + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new + + # Call the get_account method. + result = client.get_account request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + p result +end +# [END merchantapi_v1beta_generated_AccountsService_GetAccount_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_accounts.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_accounts.rb new file mode 100644 index 000000000000..1cf38d046c1a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_accounts.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_ListAccounts_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_accounts call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_accounts. +# +def list_accounts + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new + + # Call the list_accounts method. + result = client.list_accounts request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + p item + end +end +# [END merchantapi_v1beta_generated_AccountsService_ListAccounts_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_sub_accounts.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_sub_accounts.rb new file mode 100644 index 000000000000..dc943b676771 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/list_sub_accounts.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_ListSubAccounts_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_sub_accounts call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_sub_accounts. +# +def list_sub_accounts + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new + + # Call the list_sub_accounts method. + result = client.list_sub_accounts request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Account. + p item + end +end +# [END merchantapi_v1beta_generated_AccountsService_ListSubAccounts_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/update_account.rb b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/update_account.rb new file mode 100644 index 000000000000..345bd09c7136 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/accounts_service/update_account.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_AccountsService_UpdateAccount_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_account call in the AccountsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#update_account. +# +def update_account + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new + + # Call the update_account method. + result = client.update_account request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Account. + p result +end +# [END merchantapi_v1beta_generated_AccountsService_UpdateAccount_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/get_business_identity.rb b/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/get_business_identity.rb new file mode 100644 index 000000000000..03e516e753fa --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/get_business_identity.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_BusinessIdentityService_GetBusinessIdentity_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_business_identity call in the BusinessIdentityService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#get_business_identity. +# +def get_business_identity + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new + + # Call the get_business_identity method. + result = client.get_business_identity request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + p result +end +# [END merchantapi_v1beta_generated_BusinessIdentityService_GetBusinessIdentity_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/update_business_identity.rb b/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/update_business_identity.rb new file mode 100644 index 000000000000..c6a31cf864ca --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/business_identity_service/update_business_identity.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_BusinessIdentityService_UpdateBusinessIdentity_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_business_identity call in the BusinessIdentityService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#update_business_identity. +# +def update_business_identity + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new + + # Call the update_business_identity method. + result = client.update_business_identity request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity. + p result +end +# [END merchantapi_v1beta_generated_BusinessIdentityService_UpdateBusinessIdentity_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/get_business_info.rb b/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/get_business_info.rb new file mode 100644 index 000000000000..18e45e3f1cb4 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/get_business_info.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_BusinessInfoService_GetBusinessInfo_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_business_info call in the BusinessInfoService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#get_business_info. +# +def get_business_info + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new + + # Call the get_business_info method. + result = client.get_business_info request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + p result +end +# [END merchantapi_v1beta_generated_BusinessInfoService_GetBusinessInfo_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/update_business_info.rb b/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/update_business_info.rb new file mode 100644 index 000000000000..d31cd42784fd --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/business_info_service/update_business_info.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_BusinessInfoService_UpdateBusinessInfo_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_business_info call in the BusinessInfoService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#update_business_info. +# +def update_business_info + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new + + # Call the update_business_info method. + result = client.update_business_info request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo. + p result +end +# [END merchantapi_v1beta_generated_BusinessInfoService_UpdateBusinessInfo_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/get_email_preferences.rb b/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/get_email_preferences.rb new file mode 100644 index 000000000000..1ef7c40b4ed2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/get_email_preferences.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_EmailPreferencesService_GetEmailPreferences_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_email_preferences call in the EmailPreferencesService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#get_email_preferences. +# +def get_email_preferences + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new + + # Call the get_email_preferences method. + result = client.get_email_preferences request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + p result +end +# [END merchantapi_v1beta_generated_EmailPreferencesService_GetEmailPreferences_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/update_email_preferences.rb b/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/update_email_preferences.rb new file mode 100644 index 000000000000..c43a41a42c21 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/email_preferences_service/update_email_preferences.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_EmailPreferencesService_UpdateEmailPreferences_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_email_preferences call in the EmailPreferencesService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#update_email_preferences. +# +def update_email_preferences + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new + + # Call the update_email_preferences method. + result = client.update_email_preferences request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences. + p result +end +# [END merchantapi_v1beta_generated_EmailPreferencesService_UpdateEmailPreferences_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/claim_homepage.rb b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/claim_homepage.rb new file mode 100644 index 000000000000..514ec60fad9a --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/claim_homepage.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_HomepageService_ClaimHomepage_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the claim_homepage call in the HomepageService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#claim_homepage. +# +def claim_homepage + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new + + # Call the claim_homepage method. + result = client.claim_homepage request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + p result +end +# [END merchantapi_v1beta_generated_HomepageService_ClaimHomepage_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/get_homepage.rb b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/get_homepage.rb new file mode 100644 index 000000000000..8eb031e27f9c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/get_homepage.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_HomepageService_GetHomepage_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_homepage call in the HomepageService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#get_homepage. +# +def get_homepage + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new + + # Call the get_homepage method. + result = client.get_homepage request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + p result +end +# [END merchantapi_v1beta_generated_HomepageService_GetHomepage_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/unclaim_homepage.rb b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/unclaim_homepage.rb new file mode 100644 index 000000000000..eb739e8bc234 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/unclaim_homepage.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_HomepageService_UnclaimHomepage_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the unclaim_homepage call in the HomepageService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#unclaim_homepage. +# +def unclaim_homepage + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new + + # Call the unclaim_homepage method. + result = client.unclaim_homepage request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + p result +end +# [END merchantapi_v1beta_generated_HomepageService_UnclaimHomepage_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/update_homepage.rb b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/update_homepage.rb new file mode 100644 index 000000000000..5a380ce71a8d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/homepage_service/update_homepage.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_HomepageService_UpdateHomepage_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_homepage call in the HomepageService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#update_homepage. +# +def update_homepage + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new + + # Call the update_homepage method. + result = client.update_homepage request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Homepage. + p result +end +# [END merchantapi_v1beta_generated_HomepageService_UpdateHomepage_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/get_online_return_policy.rb b/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/get_online_return_policy.rb new file mode 100644 index 000000000000..f27d8326cfed --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/get_online_return_policy.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_OnlineReturnPolicyService_GetOnlineReturnPolicy_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_online_return_policy call in the OnlineReturnPolicyService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#get_online_return_policy. +# +def get_online_return_policy + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new + + # Call the get_online_return_policy method. + result = client.get_online_return_policy request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + p result +end +# [END merchantapi_v1beta_generated_OnlineReturnPolicyService_GetOnlineReturnPolicy_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/list_online_return_policies.rb b/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/list_online_return_policies.rb new file mode 100644 index 000000000000..7f4cd1cdb609 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/online_return_policy_service/list_online_return_policies.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_OnlineReturnPolicyService_ListOnlineReturnPolicies_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_online_return_policies call in the OnlineReturnPolicyService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#list_online_return_policies. +# +def list_online_return_policies + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new + + # Call the list_online_return_policies method. + result = client.list_online_return_policies request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy. + p item + end +end +# [END merchantapi_v1beta_generated_OnlineReturnPolicyService_ListOnlineReturnPolicies_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/programs_service/disable_program.rb b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/disable_program.rb new file mode 100644 index 000000000000..e89bf3cafae7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/disable_program.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ProgramsService_DisableProgram_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the disable_program call in the ProgramsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#disable_program. +# +def disable_program + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new + + # Call the disable_program method. + result = client.disable_program request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + p result +end +# [END merchantapi_v1beta_generated_ProgramsService_DisableProgram_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/programs_service/enable_program.rb b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/enable_program.rb new file mode 100644 index 000000000000..b9c032c2c807 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/enable_program.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ProgramsService_EnableProgram_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the enable_program call in the ProgramsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#enable_program. +# +def enable_program + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new + + # Call the enable_program method. + result = client.enable_program request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + p result +end +# [END merchantapi_v1beta_generated_ProgramsService_EnableProgram_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/programs_service/get_program.rb b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/get_program.rb new file mode 100644 index 000000000000..57f292103016 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/get_program.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ProgramsService_GetProgram_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_program call in the ProgramsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#get_program. +# +def get_program + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new + + # Call the get_program method. + result = client.get_program request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Program. + p result +end +# [END merchantapi_v1beta_generated_ProgramsService_GetProgram_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/programs_service/list_programs.rb b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/list_programs.rb new file mode 100644 index 000000000000..ada29e397f48 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/programs_service/list_programs.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ProgramsService_ListPrograms_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_programs call in the ProgramsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#list_programs. +# +def list_programs + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new + + # Call the list_programs method. + result = client.list_programs request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Program. + p item + end +end +# [END merchantapi_v1beta_generated_ProgramsService_ListPrograms_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/regions_service/create_region.rb b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/create_region.rb new file mode 100644 index 000000000000..6202655807c6 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/create_region.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_RegionsService_CreateRegion_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the create_region call in the RegionsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#create_region. +# +def create_region + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new + + # Call the create_region method. + result = client.create_region request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + p result +end +# [END merchantapi_v1beta_generated_RegionsService_CreateRegion_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/regions_service/delete_region.rb b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/delete_region.rb new file mode 100644 index 000000000000..76e51d641c61 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/delete_region.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_RegionsService_DeleteRegion_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the delete_region call in the RegionsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#delete_region. +# +def delete_region + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new + + # Call the delete_region method. + result = client.delete_region request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END merchantapi_v1beta_generated_RegionsService_DeleteRegion_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/regions_service/get_region.rb b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/get_region.rb new file mode 100644 index 000000000000..6ef45b60617e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/get_region.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_RegionsService_GetRegion_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_region call in the RegionsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#get_region. +# +def get_region + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new + + # Call the get_region method. + result = client.get_region request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + p result +end +# [END merchantapi_v1beta_generated_RegionsService_GetRegion_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/regions_service/list_regions.rb b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/list_regions.rb new file mode 100644 index 000000000000..540caa00776f --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/list_regions.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_RegionsService_ListRegions_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_regions call in the RegionsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#list_regions. +# +def list_regions + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new + + # Call the list_regions method. + result = client.list_regions request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::Region. + p item + end +end +# [END merchantapi_v1beta_generated_RegionsService_ListRegions_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/regions_service/update_region.rb b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/update_region.rb new file mode 100644 index 000000000000..b0c6a6bd7fab --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/regions_service/update_region.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_RegionsService_UpdateRegion_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_region call in the RegionsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#update_region. +# +def update_region + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new + + # Call the update_region method. + result = client.update_region request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::Region. + p result +end +# [END merchantapi_v1beta_generated_RegionsService_UpdateRegion_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/get_shipping_settings.rb b/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/get_shipping_settings.rb new file mode 100644 index 000000000000..fe533fe10c2e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/get_shipping_settings.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ShippingSettingsService_GetShippingSettings_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_shipping_settings call in the ShippingSettingsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#get_shipping_settings. +# +def get_shipping_settings + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new + + # Call the get_shipping_settings method. + result = client.get_shipping_settings request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + p result +end +# [END merchantapi_v1beta_generated_ShippingSettingsService_GetShippingSettings_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/insert_shipping_settings.rb b/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/insert_shipping_settings.rb new file mode 100644 index 000000000000..4fca2591ee80 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/shipping_settings_service/insert_shipping_settings.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_ShippingSettingsService_InsertShippingSettings_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the insert_shipping_settings call in the ShippingSettingsService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#insert_shipping_settings. +# +def insert_shipping_settings + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new + + # Call the insert_shipping_settings method. + result = client.insert_shipping_settings request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings. + p result +end +# [END merchantapi_v1beta_generated_ShippingSettingsService_InsertShippingSettings_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/snippet_metadata_google.shopping.merchant.accounts.v1beta.json b/google-shopping-merchant-accounts-v1beta/snippets/snippet_metadata_google.shopping.merchant.accounts.v1beta.json new file mode 100644 index 000000000000..238b13e5b448 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/snippet_metadata_google.shopping.merchant.accounts.v1beta.json @@ -0,0 +1,1735 @@ +{ + "client_library": { + "name": "google-shopping-merchant-accounts-v1beta", + "version": "", + "language": "RUBY", + "apis": [ + { + "id": "google.shopping.merchant.accounts.v1beta", + "version": "v1beta" + } + ] + }, + "snippets": [ + { + "region_tag": "merchantapi_v1beta_generated_AccountTaxService_GetAccountTax_sync", + "title": "Snippet for the get_account_tax call in the AccountTaxService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#get_account_tax.", + "file": "account_tax_service/get_account_tax.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_account_tax", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#get_account_tax", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTax", + "client": { + "short_name": "AccountTaxService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client" + }, + "method": { + "short_name": "GetAccountTax", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService.GetAccountTax", + "service": { + "short_name": "AccountTaxService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountTaxService_ListAccountTax_sync", + "title": "Snippet for the list_account_tax call in the AccountTaxService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#list_account_tax.", + "file": "account_tax_service/list_account_tax.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_account_tax", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#list_account_tax", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse", + "client": { + "short_name": "AccountTaxService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client" + }, + "method": { + "short_name": "ListAccountTax", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService.ListAccountTax", + "service": { + "short_name": "AccountTaxService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountTaxService_UpdateAccountTax_sync", + "title": "Snippet for the update_account_tax call in the AccountTaxService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#update_account_tax.", + "file": "account_tax_service/update_account_tax.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_account_tax", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client#update_account_tax", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTax", + "client": { + "short_name": "AccountTaxService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client" + }, + "method": { + "short_name": "UpdateAccountTax", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService.UpdateAccountTax", + "service": { + "short_name": "AccountTaxService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountTaxService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountIssueService_ListAccountIssues_sync", + "title": "Snippet for the list_account_issues call in the AccountIssueService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client#list_account_issues.", + "file": "account_issue_service/list_account_issues.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_account_issues", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client#list_account_issues", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse", + "client": { + "short_name": "AccountIssueService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client" + }, + "method": { + "short_name": "ListAccountIssues", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountIssueService.ListAccountIssues", + "service": { + "short_name": "AccountIssueService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountIssueService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_UserService_GetUser_sync", + "title": "Snippet for the get_user call in the UserService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#get_user.", + "file": "user_service/get_user.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_user", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#get_user", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::User", + "client": { + "short_name": "UserService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client" + }, + "method": { + "short_name": "GetUser", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService.GetUser", + "service": { + "short_name": "UserService", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_UserService_CreateUser_sync", + "title": "Snippet for the create_user call in the UserService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#create_user.", + "file": "user_service/create_user.rb", + "language": "RUBY", + "client_method": { + "short_name": "create_user", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#create_user", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::User", + "client": { + "short_name": "UserService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client" + }, + "method": { + "short_name": "CreateUser", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService.CreateUser", + "service": { + "short_name": "UserService", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_UserService_DeleteUser_sync", + "title": "Snippet for the delete_user call in the UserService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#delete_user.", + "file": "user_service/delete_user.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_user", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#delete_user", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "UserService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client" + }, + "method": { + "short_name": "DeleteUser", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService.DeleteUser", + "service": { + "short_name": "UserService", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_UserService_UpdateUser_sync", + "title": "Snippet for the update_user call in the UserService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#update_user.", + "file": "user_service/update_user.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_user", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#update_user", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::User", + "client": { + "short_name": "UserService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client" + }, + "method": { + "short_name": "UpdateUser", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService.UpdateUser", + "service": { + "short_name": "UserService", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_UserService_ListUsers_sync", + "title": "Snippet for the list_users call in the UserService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#list_users.", + "file": "user_service/list_users.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_users", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#list_users", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse", + "client": { + "short_name": "UserService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client" + }, + "method": { + "short_name": "ListUsers", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService.ListUsers", + "service": { + "short_name": "UserService", + "full_name": "google.shopping.merchant.accounts.v1beta.UserService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_GetAccount_sync", + "title": "Snippet for the get_account call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#get_account.", + "file": "accounts_service/get_account.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_account", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#get_account", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Account", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "GetAccount", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.GetAccount", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_CreateAndConfigureAccount_sync", + "title": "Snippet for the create_and_configure_account call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#create_and_configure_account.", + "file": "accounts_service/create_and_configure_account.rb", + "language": "RUBY", + "client_method": { + "short_name": "create_and_configure_account", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#create_and_configure_account", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Account", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "CreateAndConfigureAccount", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.CreateAndConfigureAccount", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_DeleteAccount_sync", + "title": "Snippet for the delete_account call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#delete_account.", + "file": "accounts_service/delete_account.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_account", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#delete_account", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "DeleteAccount", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.DeleteAccount", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_UpdateAccount_sync", + "title": "Snippet for the update_account call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#update_account.", + "file": "accounts_service/update_account.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_account", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#update_account", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Account", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "UpdateAccount", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.UpdateAccount", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_ListAccounts_sync", + "title": "Snippet for the list_accounts call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_accounts.", + "file": "accounts_service/list_accounts.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_accounts", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_accounts", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "ListAccounts", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.ListAccounts", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_AccountsService_ListSubAccounts_sync", + "title": "Snippet for the list_sub_accounts call in the AccountsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_sub_accounts.", + "file": "accounts_service/list_sub_accounts.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_sub_accounts", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client#list_sub_accounts", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse", + "client": { + "short_name": "AccountsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client" + }, + "method": { + "short_name": "ListSubAccounts", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService.ListSubAccounts", + "service": { + "short_name": "AccountsService", + "full_name": "google.shopping.merchant.accounts.v1beta.AccountsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_BusinessIdentityService_GetBusinessIdentity_sync", + "title": "Snippet for the get_business_identity call in the BusinessIdentityService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#get_business_identity.", + "file": "business_identity_service/get_business_identity.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_business_identity", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#get_business_identity", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity", + "client": { + "short_name": "BusinessIdentityService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client" + }, + "method": { + "short_name": "GetBusinessIdentity", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessIdentityService.GetBusinessIdentity", + "service": { + "short_name": "BusinessIdentityService", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessIdentityService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_BusinessIdentityService_UpdateBusinessIdentity_sync", + "title": "Snippet for the update_business_identity call in the BusinessIdentityService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#update_business_identity.", + "file": "business_identity_service/update_business_identity.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_business_identity", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client#update_business_identity", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity", + "client": { + "short_name": "BusinessIdentityService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client" + }, + "method": { + "short_name": "UpdateBusinessIdentity", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessIdentityService.UpdateBusinessIdentity", + "service": { + "short_name": "BusinessIdentityService", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessIdentityService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_BusinessInfoService_GetBusinessInfo_sync", + "title": "Snippet for the get_business_info call in the BusinessInfoService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#get_business_info.", + "file": "business_info_service/get_business_info.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_business_info", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#get_business_info", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo", + "client": { + "short_name": "BusinessInfoService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client" + }, + "method": { + "short_name": "GetBusinessInfo", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessInfoService.GetBusinessInfo", + "service": { + "short_name": "BusinessInfoService", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessInfoService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_BusinessInfoService_UpdateBusinessInfo_sync", + "title": "Snippet for the update_business_info call in the BusinessInfoService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#update_business_info.", + "file": "business_info_service/update_business_info.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_business_info", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client#update_business_info", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo", + "client": { + "short_name": "BusinessInfoService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client" + }, + "method": { + "short_name": "UpdateBusinessInfo", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessInfoService.UpdateBusinessInfo", + "service": { + "short_name": "BusinessInfoService", + "full_name": "google.shopping.merchant.accounts.v1beta.BusinessInfoService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_EmailPreferencesService_GetEmailPreferences_sync", + "title": "Snippet for the get_email_preferences call in the EmailPreferencesService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#get_email_preferences.", + "file": "email_preferences_service/get_email_preferences.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_email_preferences", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#get_email_preferences", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences", + "client": { + "short_name": "EmailPreferencesService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client" + }, + "method": { + "short_name": "GetEmailPreferences", + "full_name": "google.shopping.merchant.accounts.v1beta.EmailPreferencesService.GetEmailPreferences", + "service": { + "short_name": "EmailPreferencesService", + "full_name": "google.shopping.merchant.accounts.v1beta.EmailPreferencesService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_EmailPreferencesService_UpdateEmailPreferences_sync", + "title": "Snippet for the update_email_preferences call in the EmailPreferencesService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#update_email_preferences.", + "file": "email_preferences_service/update_email_preferences.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_email_preferences", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client#update_email_preferences", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences", + "client": { + "short_name": "EmailPreferencesService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client" + }, + "method": { + "short_name": "UpdateEmailPreferences", + "full_name": "google.shopping.merchant.accounts.v1beta.EmailPreferencesService.UpdateEmailPreferences", + "service": { + "short_name": "EmailPreferencesService", + "full_name": "google.shopping.merchant.accounts.v1beta.EmailPreferencesService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_HomepageService_GetHomepage_sync", + "title": "Snippet for the get_homepage call in the HomepageService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#get_homepage.", + "file": "homepage_service/get_homepage.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_homepage", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#get_homepage", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Homepage", + "client": { + "short_name": "HomepageService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client" + }, + "method": { + "short_name": "GetHomepage", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService.GetHomepage", + "service": { + "short_name": "HomepageService", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_HomepageService_UpdateHomepage_sync", + "title": "Snippet for the update_homepage call in the HomepageService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#update_homepage.", + "file": "homepage_service/update_homepage.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_homepage", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#update_homepage", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Homepage", + "client": { + "short_name": "HomepageService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client" + }, + "method": { + "short_name": "UpdateHomepage", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService.UpdateHomepage", + "service": { + "short_name": "HomepageService", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_HomepageService_ClaimHomepage_sync", + "title": "Snippet for the claim_homepage call in the HomepageService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#claim_homepage.", + "file": "homepage_service/claim_homepage.rb", + "language": "RUBY", + "client_method": { + "short_name": "claim_homepage", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#claim_homepage", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Homepage", + "client": { + "short_name": "HomepageService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client" + }, + "method": { + "short_name": "ClaimHomepage", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService.ClaimHomepage", + "service": { + "short_name": "HomepageService", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_HomepageService_UnclaimHomepage_sync", + "title": "Snippet for the unclaim_homepage call in the HomepageService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#unclaim_homepage.", + "file": "homepage_service/unclaim_homepage.rb", + "language": "RUBY", + "client_method": { + "short_name": "unclaim_homepage", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client#unclaim_homepage", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Homepage", + "client": { + "short_name": "HomepageService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client" + }, + "method": { + "short_name": "UnclaimHomepage", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService.UnclaimHomepage", + "service": { + "short_name": "HomepageService", + "full_name": "google.shopping.merchant.accounts.v1beta.HomepageService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_OnlineReturnPolicyService_GetOnlineReturnPolicy_sync", + "title": "Snippet for the get_online_return_policy call in the OnlineReturnPolicyService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#get_online_return_policy.", + "file": "online_return_policy_service/get_online_return_policy.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_online_return_policy", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#get_online_return_policy", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy", + "client": { + "short_name": "OnlineReturnPolicyService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client" + }, + "method": { + "short_name": "GetOnlineReturnPolicy", + "full_name": "google.shopping.merchant.accounts.v1beta.OnlineReturnPolicyService.GetOnlineReturnPolicy", + "service": { + "short_name": "OnlineReturnPolicyService", + "full_name": "google.shopping.merchant.accounts.v1beta.OnlineReturnPolicyService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_OnlineReturnPolicyService_ListOnlineReturnPolicies_sync", + "title": "Snippet for the list_online_return_policies call in the OnlineReturnPolicyService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#list_online_return_policies.", + "file": "online_return_policy_service/list_online_return_policies.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_online_return_policies", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client#list_online_return_policies", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse", + "client": { + "short_name": "OnlineReturnPolicyService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client" + }, + "method": { + "short_name": "ListOnlineReturnPolicies", + "full_name": "google.shopping.merchant.accounts.v1beta.OnlineReturnPolicyService.ListOnlineReturnPolicies", + "service": { + "short_name": "OnlineReturnPolicyService", + "full_name": "google.shopping.merchant.accounts.v1beta.OnlineReturnPolicyService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ProgramsService_GetProgram_sync", + "title": "Snippet for the get_program call in the ProgramsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#get_program.", + "file": "programs_service/get_program.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_program", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#get_program", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Program", + "client": { + "short_name": "ProgramsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client" + }, + "method": { + "short_name": "GetProgram", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService.GetProgram", + "service": { + "short_name": "ProgramsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ProgramsService_ListPrograms_sync", + "title": "Snippet for the list_programs call in the ProgramsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#list_programs.", + "file": "programs_service/list_programs.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_programs", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#list_programs", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse", + "client": { + "short_name": "ProgramsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client" + }, + "method": { + "short_name": "ListPrograms", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService.ListPrograms", + "service": { + "short_name": "ProgramsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ProgramsService_EnableProgram_sync", + "title": "Snippet for the enable_program call in the ProgramsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#enable_program.", + "file": "programs_service/enable_program.rb", + "language": "RUBY", + "client_method": { + "short_name": "enable_program", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#enable_program", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Program", + "client": { + "short_name": "ProgramsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client" + }, + "method": { + "short_name": "EnableProgram", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService.EnableProgram", + "service": { + "short_name": "ProgramsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ProgramsService_DisableProgram_sync", + "title": "Snippet for the disable_program call in the ProgramsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#disable_program.", + "file": "programs_service/disable_program.rb", + "language": "RUBY", + "client_method": { + "short_name": "disable_program", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client#disable_program", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Program", + "client": { + "short_name": "ProgramsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client" + }, + "method": { + "short_name": "DisableProgram", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService.DisableProgram", + "service": { + "short_name": "ProgramsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ProgramsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_RegionsService_GetRegion_sync", + "title": "Snippet for the get_region call in the RegionsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#get_region.", + "file": "regions_service/get_region.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_region", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#get_region", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Region", + "client": { + "short_name": "RegionsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client" + }, + "method": { + "short_name": "GetRegion", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService.GetRegion", + "service": { + "short_name": "RegionsService", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_RegionsService_CreateRegion_sync", + "title": "Snippet for the create_region call in the RegionsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#create_region.", + "file": "regions_service/create_region.rb", + "language": "RUBY", + "client_method": { + "short_name": "create_region", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#create_region", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Region", + "client": { + "short_name": "RegionsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client" + }, + "method": { + "short_name": "CreateRegion", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService.CreateRegion", + "service": { + "short_name": "RegionsService", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_RegionsService_UpdateRegion_sync", + "title": "Snippet for the update_region call in the RegionsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#update_region.", + "file": "regions_service/update_region.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_region", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#update_region", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::Region", + "client": { + "short_name": "RegionsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client" + }, + "method": { + "short_name": "UpdateRegion", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService.UpdateRegion", + "service": { + "short_name": "RegionsService", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_RegionsService_DeleteRegion_sync", + "title": "Snippet for the delete_region call in the RegionsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#delete_region.", + "file": "regions_service/delete_region.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_region", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#delete_region", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "RegionsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client" + }, + "method": { + "short_name": "DeleteRegion", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService.DeleteRegion", + "service": { + "short_name": "RegionsService", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_RegionsService_ListRegions_sync", + "title": "Snippet for the list_regions call in the RegionsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#list_regions.", + "file": "regions_service/list_regions.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_regions", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client#list_regions", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse", + "client": { + "short_name": "RegionsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client" + }, + "method": { + "short_name": "ListRegions", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService.ListRegions", + "service": { + "short_name": "RegionsService", + "full_name": "google.shopping.merchant.accounts.v1beta.RegionsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ShippingSettingsService_GetShippingSettings_sync", + "title": "Snippet for the get_shipping_settings call in the ShippingSettingsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#get_shipping_settings.", + "file": "shipping_settings_service/get_shipping_settings.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_shipping_settings", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#get_shipping_settings", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings", + "client": { + "short_name": "ShippingSettingsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client" + }, + "method": { + "short_name": "GetShippingSettings", + "full_name": "google.shopping.merchant.accounts.v1beta.ShippingSettingsService.GetShippingSettings", + "service": { + "short_name": "ShippingSettingsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ShippingSettingsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_ShippingSettingsService_InsertShippingSettings_sync", + "title": "Snippet for the insert_shipping_settings call in the ShippingSettingsService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#insert_shipping_settings.", + "file": "shipping_settings_service/insert_shipping_settings.rb", + "language": "RUBY", + "client_method": { + "short_name": "insert_shipping_settings", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client#insert_shipping_settings", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings", + "client": { + "short_name": "ShippingSettingsService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client" + }, + "method": { + "short_name": "InsertShippingSettings", + "full_name": "google.shopping.merchant.accounts.v1beta.ShippingSettingsService.InsertShippingSettings", + "service": { + "short_name": "ShippingSettingsService", + "full_name": "google.shopping.merchant.accounts.v1beta.ShippingSettingsService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_TermsOfServiceService_GetTermsOfService_sync", + "title": "Snippet for the get_terms_of_service call in the TermsOfServiceService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#get_terms_of_service.", + "file": "terms_of_service_service/get_terms_of_service.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_terms_of_service", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#get_terms_of_service", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService", + "client": { + "short_name": "TermsOfServiceService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client" + }, + "method": { + "short_name": "GetTermsOfService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService.GetTermsOfService", + "service": { + "short_name": "TermsOfServiceService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_TermsOfServiceService_RetrieveLatestTermsOfService_sync", + "title": "Snippet for the retrieve_latest_terms_of_service call in the TermsOfServiceService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#retrieve_latest_terms_of_service.", + "file": "terms_of_service_service/retrieve_latest_terms_of_service.rb", + "language": "RUBY", + "client_method": { + "short_name": "retrieve_latest_terms_of_service", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#retrieve_latest_terms_of_service", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService", + "client": { + "short_name": "TermsOfServiceService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client" + }, + "method": { + "short_name": "RetrieveLatestTermsOfService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService.RetrieveLatestTermsOfService", + "service": { + "short_name": "TermsOfServiceService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_TermsOfServiceService_AcceptTermsOfService_sync", + "title": "Snippet for the accept_terms_of_service call in the TermsOfServiceService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#accept_terms_of_service.", + "file": "terms_of_service_service/accept_terms_of_service.rb", + "language": "RUBY", + "client_method": { + "short_name": "accept_terms_of_service", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#accept_terms_of_service", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "TermsOfServiceService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client" + }, + "method": { + "short_name": "AcceptTermsOfService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService.AcceptTermsOfService", + "service": { + "short_name": "TermsOfServiceService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_GetTermsOfServiceAgreementState_sync", + "title": "Snippet for the get_terms_of_service_agreement_state call in the TermsOfServiceAgreementStateService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#get_terms_of_service_agreement_state.", + "file": "terms_of_service_agreement_state_service/get_terms_of_service_agreement_state.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_terms_of_service_agreement_state", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#get_terms_of_service_agreement_state", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState", + "client": { + "short_name": "TermsOfServiceAgreementStateService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client" + }, + "method": { + "short_name": "GetTermsOfServiceAgreementState", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateService.GetTermsOfServiceAgreementState", + "service": { + "short_name": "TermsOfServiceAgreementStateService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_RetrieveForApplicationTermsOfServiceAgreementState_sync", + "title": "Snippet for the retrieve_for_application_terms_of_service_agreement_state call in the TermsOfServiceAgreementStateService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#retrieve_for_application_terms_of_service_agreement_state.", + "file": "terms_of_service_agreement_state_service/retrieve_for_application_terms_of_service_agreement_state.rb", + "language": "RUBY", + "client_method": { + "short_name": "retrieve_for_application_terms_of_service_agreement_state", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#retrieve_for_application_terms_of_service_agreement_state", + "async": false, + "parameters": [ + { + "type": "::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest", + "name": "request" + } + ], + "result_type": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState", + "client": { + "short_name": "TermsOfServiceAgreementStateService::Client", + "full_name": "::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client" + }, + "method": { + "short_name": "RetrieveForApplicationTermsOfServiceAgreementState", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateService.RetrieveForApplicationTermsOfServiceAgreementState", + "service": { + "short_name": "TermsOfServiceAgreementStateService", + "full_name": "google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + } + ] +} \ No newline at end of file diff --git a/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/get_terms_of_service_agreement_state.rb b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/get_terms_of_service_agreement_state.rb new file mode 100644 index 000000000000..0fc5744a5775 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/get_terms_of_service_agreement_state.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_GetTermsOfServiceAgreementState_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_terms_of_service_agreement_state call in the TermsOfServiceAgreementStateService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#get_terms_of_service_agreement_state. +# +def get_terms_of_service_agreement_state + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new + + # Call the get_terms_of_service_agreement_state method. + result = client.get_terms_of_service_agreement_state request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState. + p result +end +# [END merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_GetTermsOfServiceAgreementState_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/retrieve_for_application_terms_of_service_agreement_state.rb b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/retrieve_for_application_terms_of_service_agreement_state.rb new file mode 100644 index 000000000000..88374fd77851 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_agreement_state_service/retrieve_for_application_terms_of_service_agreement_state.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_RetrieveForApplicationTermsOfServiceAgreementState_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the retrieve_for_application_terms_of_service_agreement_state call in the TermsOfServiceAgreementStateService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client#retrieve_for_application_terms_of_service_agreement_state. +# +def retrieve_for_application_terms_of_service_agreement_state + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new + + # Call the retrieve_for_application_terms_of_service_agreement_state method. + result = client.retrieve_for_application_terms_of_service_agreement_state request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState. + p result +end +# [END merchantapi_v1beta_generated_TermsOfServiceAgreementStateService_RetrieveForApplicationTermsOfServiceAgreementState_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/accept_terms_of_service.rb b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/accept_terms_of_service.rb new file mode 100644 index 000000000000..a0b07367d5a0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/accept_terms_of_service.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_TermsOfServiceService_AcceptTermsOfService_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the accept_terms_of_service call in the TermsOfServiceService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#accept_terms_of_service. +# +def accept_terms_of_service + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new + + # Call the accept_terms_of_service method. + result = client.accept_terms_of_service request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END merchantapi_v1beta_generated_TermsOfServiceService_AcceptTermsOfService_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/get_terms_of_service.rb b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/get_terms_of_service.rb new file mode 100644 index 000000000000..b5a82fb1b1ba --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/get_terms_of_service.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_TermsOfServiceService_GetTermsOfService_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_terms_of_service call in the TermsOfServiceService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#get_terms_of_service. +# +def get_terms_of_service + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new + + # Call the get_terms_of_service method. + result = client.get_terms_of_service request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + p result +end +# [END merchantapi_v1beta_generated_TermsOfServiceService_GetTermsOfService_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/retrieve_latest_terms_of_service.rb b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/retrieve_latest_terms_of_service.rb new file mode 100644 index 000000000000..6865f3b900cf --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/terms_of_service_service/retrieve_latest_terms_of_service.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_TermsOfServiceService_RetrieveLatestTermsOfService_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the retrieve_latest_terms_of_service call in the TermsOfServiceService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client#retrieve_latest_terms_of_service. +# +def retrieve_latest_terms_of_service + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new + + # Call the retrieve_latest_terms_of_service method. + result = client.retrieve_latest_terms_of_service request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::TermsOfService. + p result +end +# [END merchantapi_v1beta_generated_TermsOfServiceService_RetrieveLatestTermsOfService_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/user_service/create_user.rb b/google-shopping-merchant-accounts-v1beta/snippets/user_service/create_user.rb new file mode 100644 index 000000000000..de258e98d4c3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/user_service/create_user.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_UserService_CreateUser_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the create_user call in the UserService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#create_user. +# +def create_user + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new + + # Call the create_user method. + result = client.create_user request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + p result +end +# [END merchantapi_v1beta_generated_UserService_CreateUser_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/user_service/delete_user.rb b/google-shopping-merchant-accounts-v1beta/snippets/user_service/delete_user.rb new file mode 100644 index 000000000000..18abf463c0c5 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/user_service/delete_user.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_UserService_DeleteUser_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the delete_user call in the UserService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#delete_user. +# +def delete_user + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new + + # Call the delete_user method. + result = client.delete_user request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END merchantapi_v1beta_generated_UserService_DeleteUser_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/user_service/get_user.rb b/google-shopping-merchant-accounts-v1beta/snippets/user_service/get_user.rb new file mode 100644 index 000000000000..b92da10aba97 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/user_service/get_user.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_UserService_GetUser_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the get_user call in the UserService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#get_user. +# +def get_user + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new + + # Call the get_user method. + result = client.get_user request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + p result +end +# [END merchantapi_v1beta_generated_UserService_GetUser_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/user_service/list_users.rb b/google-shopping-merchant-accounts-v1beta/snippets/user_service/list_users.rb new file mode 100644 index 000000000000..af6283104665 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/user_service/list_users.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_UserService_ListUsers_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the list_users call in the UserService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#list_users. +# +def list_users + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new + + # Call the list_users method. + result = client.list_users request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Shopping::Merchant::Accounts::V1beta::User. + p item + end +end +# [END merchantapi_v1beta_generated_UserService_ListUsers_sync] diff --git a/google-shopping-merchant-accounts-v1beta/snippets/user_service/update_user.rb b/google-shopping-merchant-accounts-v1beta/snippets/user_service/update_user.rb new file mode 100644 index 000000000000..e48659573536 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/snippets/user_service/update_user.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START merchantapi_v1beta_generated_UserService_UpdateUser_sync] +require "google/shopping/merchant/accounts/v1beta" + +## +# Snippet for the update_user call in the UserService service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Shopping::Merchant::Accounts::V1beta::UserService::Client#update_user. +# +def update_user + # Create a client object. The client can be reused for multiple calls. + client = Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new + + # Call the update_user method. + result = client.update_user request + + # The returned object is of type Google::Shopping::Merchant::Accounts::V1beta::User. + p result +end +# [END merchantapi_v1beta_generated_UserService_UpdateUser_sync] diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_paths_test.rb new file mode 100644 index 000000000000..6618201dfb51 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/account_issue_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_rest_test.rb new file mode 100644 index 000000000000..25ee61c1fbee --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_rest_test.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/accountissue_pb" +require "google/shopping/merchant/accounts/v1beta/account_issue_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_account_issues + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + language_code = "hello world" + time_zone = {} + + list_account_issues_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::ServiceStub.stub :transcode_list_account_issues_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_account_issues_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_account_issues({ parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_account_issues parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_account_issues ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new(parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_account_issues({ parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_account_issues(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new(parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_account_issues_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_test.rb new file mode 100644 index 000000000000..d5db6e163065 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_issue_service_test.rb @@ -0,0 +1,147 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/accountissue_pb" +require "google/shopping/merchant/accounts/v1beta/accountissue_services_pb" +require "google/shopping/merchant/accounts/v1beta/account_issue_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_list_account_issues + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + language_code = "hello world" + time_zone = {} + + list_account_issues_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_account_issues, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + assert_equal "hello world", request["language_code"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Type::TimeZone), request["time_zone"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_account_issues_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_account_issues({ parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_account_issues parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_account_issues ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new(parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_account_issues({ parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_account_issues(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountIssuesRequest.new(parent: parent, page_size: page_size, page_token: page_token, language_code: language_code, time_zone: time_zone), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_account_issues_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountIssueService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_paths_test.rb new file mode 100644 index 000000000000..921d0349e9e2 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/account_tax_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_account_tax_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_tax_path account: "value0", tax: "value1" + assert_equal "accounts/value0/accounttax/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_rest_test.rb new file mode 100644 index 000000000000..bb6426b47e9c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_rest_test.rb @@ -0,0 +1,256 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/account_tax_pb" +require "google/shopping/merchant/accounts/v1beta/account_tax_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_account_tax + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_account_tax_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::ServiceStub.stub :transcode_get_account_tax_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_account_tax({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_account_tax name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_account_tax({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_account_tax_client_stub.call_count + end + end + end + + def test_list_account_tax + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_account_tax_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::ServiceStub.stub :transcode_list_account_tax_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_account_tax({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_account_tax parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_account_tax({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_account_tax_client_stub.call_count + end + end + end + + def test_update_account_tax + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + account_tax = {} + update_mask = {} + + update_account_tax_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::ServiceStub.stub :transcode_update_account_tax_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_account_tax({ account_tax: account_tax, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_account_tax account_tax: account_tax, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new(account_tax: account_tax, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_account_tax({ account_tax: account_tax, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new(account_tax: account_tax, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_account_tax_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_test.rb new file mode 100644 index 000000000000..96804d29d4e4 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/account_tax_service_test.rb @@ -0,0 +1,261 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/account_tax_pb" +require "google/shopping/merchant/accounts/v1beta/account_tax_services_pb" +require "google/shopping/merchant/accounts/v1beta/account_tax_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_account_tax + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_account_tax_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_account_tax, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_account_tax({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_account_tax name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_account_tax({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::GetAccountTaxRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_account_tax_client_stub.call_rpc_count + end + end + + def test_list_account_tax + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_account_tax_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_account_tax, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_account_tax({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_account_tax parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_account_tax({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountTaxRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_account_tax_client_stub.call_rpc_count + end + end + + def test_update_account_tax + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + account_tax = {} + update_mask = {} + + update_account_tax_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_account_tax, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::AccountTax), request["account_tax"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_account_tax_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_account_tax({ account_tax: account_tax, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_account_tax account_tax: account_tax, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_account_tax ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new(account_tax: account_tax, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_account_tax({ account_tax: account_tax, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_account_tax(::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountTaxRequest.new(account_tax: account_tax, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_account_tax_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountTaxService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_paths_test.rb new file mode 100644 index 000000000000..69028d90c946 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_paths_test.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/accounts_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_terms_of_service_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.terms_of_service_path version: "value0" + assert_equal "termsOfService/value0", path + end + end + + def test_user_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.user_path account: "value0", email: "value1" + assert_equal "accounts/value0/users/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_rest_test.rb new file mode 100644 index 000000000000..201535625594 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_rest_test.rb @@ -0,0 +1,423 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/accounts_pb" +require "google/shopping/merchant/accounts/v1beta/accounts_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_account + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_account_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_get_account_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_account({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_account name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_account ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_account({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_account(::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_account_client_stub.call_count + end + end + end + + def test_create_and_configure_account + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + account = {} + users = [{}] + accept_terms_of_service = {} + service = [{}] + + create_and_configure_account_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_create_and_configure_account_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, create_and_configure_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.create_and_configure_account({ account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.create_and_configure_account account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.create_and_configure_account ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new(account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.create_and_configure_account({ account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.create_and_configure_account(::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new(account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, create_and_configure_account_client_stub.call_count + end + end + end + + def test_delete_account + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_account_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_delete_account_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_account({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_account name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_account ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_account({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_account(::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_account_client_stub.call_count + end + end + end + + def test_update_account + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + account = {} + update_mask = {} + + update_account_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_update_account_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_account({ account: account, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_account account: account, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_account ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new(account: account, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_account({ account: account, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_account(::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new(account: account, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_account_client_stub.call_count + end + end + end + + def test_list_accounts + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + page_size = 42 + page_token = "hello world" + filter = "hello world" + + list_accounts_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_list_accounts_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_accounts_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_accounts({ page_size: page_size, page_token: page_token, filter: filter }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_accounts page_size: page_size, page_token: page_token, filter: filter do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_accounts ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new(page_size: page_size, page_token: page_token, filter: filter) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_accounts({ page_size: page_size, page_token: page_token, filter: filter }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_accounts(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new(page_size: page_size, page_token: page_token, filter: filter), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_accounts_client_stub.call_count + end + end + end + + def test_list_sub_accounts + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + provider = "hello world" + page_size = 42 + page_token = "hello world" + + list_sub_accounts_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::ServiceStub.stub :transcode_list_sub_accounts_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_sub_accounts_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_sub_accounts({ provider: provider, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_sub_accounts provider: provider, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_sub_accounts ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new(provider: provider, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_sub_accounts({ provider: provider, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_sub_accounts(::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new(provider: provider, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_sub_accounts_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_test.rb new file mode 100644 index 000000000000..5af8675e42b3 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/accounts_service_test.rb @@ -0,0 +1,451 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/accounts_pb" +require "google/shopping/merchant/accounts/v1beta/accounts_services_pb" +require "google/shopping/merchant/accounts/v1beta/accounts_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_account + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_account_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_account, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_account({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_account name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_account ::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_account({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_account(::Google::Shopping::Merchant::Accounts::V1beta::GetAccountRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_account_client_stub.call_rpc_count + end + end + + def test_create_and_configure_account + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + account = {} + users = [{}] + accept_terms_of_service = {} + service = [{}] + + create_and_configure_account_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :create_and_configure_account, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::Account), request["account"] + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, request["users"].first + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AcceptTermsOfService), request["accept_terms_of_service"] + assert request.has_accept_terms_of_service? + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest::AddAccountService, request["service"].first + refute_nil options + end + + Gapic::ServiceStub.stub :new, create_and_configure_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.create_and_configure_account({ account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.create_and_configure_account account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.create_and_configure_account ::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new(account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.create_and_configure_account({ account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.create_and_configure_account(::Google::Shopping::Merchant::Accounts::V1beta::CreateAndConfigureAccountRequest.new(account: account, users: users, accept_terms_of_service: accept_terms_of_service, service: service), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, create_and_configure_account_client_stub.call_rpc_count + end + end + + def test_delete_account + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_account_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_account, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_account({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_account name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_account ::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_account({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_account(::Google::Shopping::Merchant::Accounts::V1beta::DeleteAccountRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_account_client_stub.call_rpc_count + end + end + + def test_update_account + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Account.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + account = {} + update_mask = {} + + update_account_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_account, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::Account), request["account"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_account_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_account({ account: account, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_account account: account, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_account ::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new(account: account, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_account({ account: account, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_account(::Google::Shopping::Merchant::Accounts::V1beta::UpdateAccountRequest.new(account: account, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_account_client_stub.call_rpc_count + end + end + + def test_list_accounts + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + page_size = 42 + page_token = "hello world" + filter = "hello world" + + list_accounts_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_accounts, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest, request + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + assert_equal "hello world", request["filter"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_accounts_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_accounts({ page_size: page_size, page_token: page_token, filter: filter }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_accounts page_size: page_size, page_token: page_token, filter: filter do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_accounts ::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new(page_size: page_size, page_token: page_token, filter: filter) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_accounts({ page_size: page_size, page_token: page_token, filter: filter }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_accounts(::Google::Shopping::Merchant::Accounts::V1beta::ListAccountsRequest.new(page_size: page_size, page_token: page_token, filter: filter), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_accounts_client_stub.call_rpc_count + end + end + + def test_list_sub_accounts + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + provider = "hello world" + page_size = 42 + page_token = "hello world" + + list_sub_accounts_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_sub_accounts, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest, request + assert_equal "hello world", request["provider"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_sub_accounts_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_sub_accounts({ provider: provider, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_sub_accounts provider: provider, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_sub_accounts ::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new(provider: provider, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_sub_accounts({ provider: provider, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_sub_accounts(::Google::Shopping::Merchant::Accounts::V1beta::ListSubAccountsRequest.new(provider: provider, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_sub_accounts_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AccountsService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_paths_test.rb new file mode 100644 index 000000000000..e720ab449435 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/business_identity_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_business_identity_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.business_identity_path account: "value0" + assert_equal "accounts/value0/businessIdentity", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_rest_test.rb new file mode 100644 index 000000000000..da2020d7f3df --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_rest_test.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/businessidentity_pb" +require "google/shopping/merchant/accounts/v1beta/business_identity_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_business_identity + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_business_identity_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::ServiceStub.stub :transcode_get_business_identity_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_business_identity_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_business_identity({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_business_identity name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_business_identity ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_business_identity({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_business_identity(::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_business_identity_client_stub.call_count + end + end + end + + def test_update_business_identity + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + business_identity = {} + update_mask = {} + + update_business_identity_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::ServiceStub.stub :transcode_update_business_identity_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_business_identity_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_business_identity({ business_identity: business_identity, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_business_identity business_identity: business_identity, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_business_identity ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new(business_identity: business_identity, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_business_identity({ business_identity: business_identity, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_business_identity(::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new(business_identity: business_identity, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_business_identity_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_test.rb new file mode 100644 index 000000000000..dfaa90f4a154 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_identity_service_test.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/businessidentity_pb" +require "google/shopping/merchant/accounts/v1beta/businessidentity_services_pb" +require "google/shopping/merchant/accounts/v1beta/business_identity_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_business_identity + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_business_identity_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_business_identity, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_business_identity_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_business_identity({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_business_identity name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_business_identity ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_business_identity({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_business_identity(::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessIdentityRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_business_identity_client_stub.call_rpc_count + end + end + + def test_update_business_identity + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + business_identity = {} + update_mask = {} + + update_business_identity_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_business_identity, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentity), request["business_identity"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_business_identity_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_business_identity({ business_identity: business_identity, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_business_identity business_identity: business_identity, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_business_identity ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new(business_identity: business_identity, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_business_identity({ business_identity: business_identity, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_business_identity(::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessIdentityRequest.new(business_identity: business_identity, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_business_identity_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::BusinessIdentityService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_paths_test.rb new file mode 100644 index 000000000000..69fe1e5e6747 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/business_info_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_business_info_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.business_info_path account: "value0" + assert_equal "accounts/value0/businessInfo", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_rest_test.rb new file mode 100644 index 000000000000..7ba1b90842a0 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_rest_test.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/businessinfo_pb" +require "google/shopping/merchant/accounts/v1beta/business_info_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_business_info + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_business_info_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::ServiceStub.stub :transcode_get_business_info_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_business_info_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_business_info({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_business_info name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_business_info ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_business_info({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_business_info(::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_business_info_client_stub.call_count + end + end + end + + def test_update_business_info + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + business_info = {} + update_mask = {} + + update_business_info_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::ServiceStub.stub :transcode_update_business_info_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_business_info_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_business_info({ business_info: business_info, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_business_info business_info: business_info, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_business_info ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new(business_info: business_info, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_business_info({ business_info: business_info, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_business_info(::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new(business_info: business_info, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_business_info_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_test.rb new file mode 100644 index 000000000000..a43d3ecdea92 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/business_info_service_test.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/businessinfo_pb" +require "google/shopping/merchant/accounts/v1beta/businessinfo_services_pb" +require "google/shopping/merchant/accounts/v1beta/business_info_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_business_info + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_business_info_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_business_info, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_business_info_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_business_info({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_business_info name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_business_info ::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_business_info({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_business_info(::Google::Shopping::Merchant::Accounts::V1beta::GetBusinessInfoRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_business_info_client_stub.call_rpc_count + end + end + + def test_update_business_info + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + business_info = {} + update_mask = {} + + update_business_info_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_business_info, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfo), request["business_info"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_business_info_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_business_info({ business_info: business_info, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_business_info business_info: business_info, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_business_info ::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new(business_info: business_info, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_business_info({ business_info: business_info, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_business_info(::Google::Shopping::Merchant::Accounts::V1beta::UpdateBusinessInfoRequest.new(business_info: business_info, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_business_info_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::BusinessInfoService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_paths_test.rb new file mode 100644 index 000000000000..02d95576ad35 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/email_preferences_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_email_preferences_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.email_preferences_path account: "value0", email: "value1" + assert_equal "accounts/value0/users/value1/emailPreferences", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_rest_test.rb new file mode 100644 index 000000000000..5fabcfc3084b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_rest_test.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/emailpreferences_pb" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_email_preferences + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_email_preferences_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::ServiceStub.stub :transcode_get_email_preferences_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_email_preferences_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_email_preferences({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_email_preferences name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_email_preferences ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_email_preferences({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_email_preferences(::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_email_preferences_client_stub.call_count + end + end + end + + def test_update_email_preferences + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + email_preferences = {} + update_mask = {} + + update_email_preferences_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::ServiceStub.stub :transcode_update_email_preferences_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_email_preferences_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_email_preferences({ email_preferences: email_preferences, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_email_preferences email_preferences: email_preferences, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_email_preferences ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new(email_preferences: email_preferences, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_email_preferences({ email_preferences: email_preferences, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_email_preferences(::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new(email_preferences: email_preferences, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_email_preferences_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_test.rb new file mode 100644 index 000000000000..f287cfde7cc9 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/email_preferences_service_test.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/emailpreferences_pb" +require "google/shopping/merchant/accounts/v1beta/emailpreferences_services_pb" +require "google/shopping/merchant/accounts/v1beta/email_preferences_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_email_preferences + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_email_preferences_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_email_preferences, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_email_preferences_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_email_preferences({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_email_preferences name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_email_preferences ::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_email_preferences({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_email_preferences(::Google::Shopping::Merchant::Accounts::V1beta::GetEmailPreferencesRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_email_preferences_client_stub.call_rpc_count + end + end + + def test_update_email_preferences + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + email_preferences = {} + update_mask = {} + + update_email_preferences_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_email_preferences, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferences), request["email_preferences"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_email_preferences_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_email_preferences({ email_preferences: email_preferences, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_email_preferences email_preferences: email_preferences, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_email_preferences ::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new(email_preferences: email_preferences, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_email_preferences({ email_preferences: email_preferences, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_email_preferences(::Google::Shopping::Merchant::Accounts::V1beta::UpdateEmailPreferencesRequest.new(email_preferences: email_preferences, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_email_preferences_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::EmailPreferencesService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_paths_test.rb new file mode 100644 index 000000000000..7ec4399d7350 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/homepage_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_homepage_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.homepage_path account: "value0" + assert_equal "accounts/value0/homepage", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_rest_test.rb new file mode 100644 index 000000000000..0cb0ad97ca10 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_rest_test.rb @@ -0,0 +1,308 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/homepage_pb" +require "google/shopping/merchant/accounts/v1beta/homepage_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_homepage + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_homepage_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ServiceStub.stub :transcode_get_homepage_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_homepage({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_homepage name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_homepage ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_homepage({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_homepage(::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_homepage_client_stub.call_count + end + end + end + + def test_update_homepage + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + homepage = {} + update_mask = {} + + update_homepage_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ServiceStub.stub :transcode_update_homepage_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_homepage({ homepage: homepage, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_homepage homepage: homepage, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_homepage ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new(homepage: homepage, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_homepage({ homepage: homepage, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_homepage(::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new(homepage: homepage, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_homepage_client_stub.call_count + end + end + end + + def test_claim_homepage + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + claim_homepage_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ServiceStub.stub :transcode_claim_homepage_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, claim_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.claim_homepage({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.claim_homepage name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.claim_homepage ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.claim_homepage({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.claim_homepage(::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, claim_homepage_client_stub.call_count + end + end + end + + def test_unclaim_homepage + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + unclaim_homepage_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::ServiceStub.stub :transcode_unclaim_homepage_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, unclaim_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.unclaim_homepage({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.unclaim_homepage name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.unclaim_homepage ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.unclaim_homepage({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.unclaim_homepage(::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, unclaim_homepage_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_test.rb new file mode 100644 index 000000000000..9f1483cbb8f7 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/homepage_service_test.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/homepage_pb" +require "google/shopping/merchant/accounts/v1beta/homepage_services_pb" +require "google/shopping/merchant/accounts/v1beta/homepage_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_homepage + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_homepage_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_homepage, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_homepage({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_homepage name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_homepage ::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_homepage({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_homepage(::Google::Shopping::Merchant::Accounts::V1beta::GetHomepageRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_homepage_client_stub.call_rpc_count + end + end + + def test_update_homepage + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + homepage = {} + update_mask = {} + + update_homepage_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_homepage, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::Homepage), request["homepage"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_homepage({ homepage: homepage, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_homepage homepage: homepage, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_homepage ::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new(homepage: homepage, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_homepage({ homepage: homepage, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_homepage(::Google::Shopping::Merchant::Accounts::V1beta::UpdateHomepageRequest.new(homepage: homepage, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_homepage_client_stub.call_rpc_count + end + end + + def test_claim_homepage + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + claim_homepage_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :claim_homepage, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, claim_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.claim_homepage({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.claim_homepage name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.claim_homepage ::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.claim_homepage({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.claim_homepage(::Google::Shopping::Merchant::Accounts::V1beta::ClaimHomepageRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, claim_homepage_client_stub.call_rpc_count + end + end + + def test_unclaim_homepage + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Homepage.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + unclaim_homepage_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :unclaim_homepage, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, unclaim_homepage_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.unclaim_homepage({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.unclaim_homepage name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.unclaim_homepage ::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.unclaim_homepage({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.unclaim_homepage(::Google::Shopping::Merchant::Accounts::V1beta::UnclaimHomepageRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, unclaim_homepage_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::HomepageService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_paths_test.rb new file mode 100644 index 000000000000..21bf1b3a1d82 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_online_return_policy_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.online_return_policy_path account: "value0", return_policy: "value1" + assert_equal "accounts/value0/onlineReturnPolicies/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_rest_test.rb new file mode 100644 index 000000000000..8789e3092fec --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_rest_test.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_pb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_online_return_policy + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_online_return_policy_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::ServiceStub.stub :transcode_get_online_return_policy_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_online_return_policy_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_online_return_policy({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_online_return_policy name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_online_return_policy ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_online_return_policy({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_online_return_policy(::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_online_return_policy_client_stub.call_count + end + end + end + + def test_list_online_return_policies + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_online_return_policies_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::ServiceStub.stub :transcode_list_online_return_policies_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_online_return_policies_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_online_return_policies({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_online_return_policies parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_online_return_policies ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_online_return_policies({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_online_return_policies(::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_online_return_policies_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_test.rb new file mode 100644 index 000000000000..e0d64c60337e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/online_return_policy_service_test.rb @@ -0,0 +1,201 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/online_return_policy_pb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_services_pb" +require "google/shopping/merchant/accounts/v1beta/online_return_policy_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_online_return_policy + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicy.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_online_return_policy_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_online_return_policy, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_online_return_policy_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_online_return_policy({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_online_return_policy name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_online_return_policy ::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_online_return_policy({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_online_return_policy(::Google::Shopping::Merchant::Accounts::V1beta::GetOnlineReturnPolicyRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_online_return_policy_client_stub.call_rpc_count + end + end + + def test_list_online_return_policies + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_online_return_policies_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_online_return_policies, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_online_return_policies_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_online_return_policies({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_online_return_policies parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_online_return_policies ::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_online_return_policies({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_online_return_policies(::Google::Shopping::Merchant::Accounts::V1beta::ListOnlineReturnPoliciesRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_online_return_policies_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::OnlineReturnPolicyService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_paths_test.rb new file mode 100644 index 000000000000..b21d7cd90c27 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/programs_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_program_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.program_path account: "value0", program: "value1" + assert_equal "accounts/value0/programs/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_rest_test.rb new file mode 100644 index 000000000000..7d2f339ab53d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_rest_test.rb @@ -0,0 +1,309 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/programs_pb" +require "google/shopping/merchant/accounts/v1beta/programs_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_program + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_program_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ServiceStub.stub :transcode_get_program_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_program({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_program name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_program ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_program({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_program(::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_program_client_stub.call_count + end + end + end + + def test_list_programs + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_programs_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ServiceStub.stub :transcode_list_programs_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_programs_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_programs({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_programs parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_programs ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_programs({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_programs(::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_programs_client_stub.call_count + end + end + end + + def test_enable_program + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + enable_program_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ServiceStub.stub :transcode_enable_program_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, enable_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.enable_program({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.enable_program name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.enable_program ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.enable_program({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.enable_program(::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, enable_program_client_stub.call_count + end + end + end + + def test_disable_program + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + disable_program_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::ServiceStub.stub :transcode_disable_program_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, disable_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.disable_program({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.disable_program name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.disable_program ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.disable_program({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.disable_program(::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, disable_program_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_test.rb new file mode 100644 index 000000000000..1111d4675649 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/programs_service_test.rb @@ -0,0 +1,317 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/programs_pb" +require "google/shopping/merchant/accounts/v1beta/programs_services_pb" +require "google/shopping/merchant/accounts/v1beta/programs_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_program + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_program_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_program, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_program({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_program name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_program ::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_program({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_program(::Google::Shopping::Merchant::Accounts::V1beta::GetProgramRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_program_client_stub.call_rpc_count + end + end + + def test_list_programs + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_programs_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_programs, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_programs_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_programs({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_programs parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_programs ::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_programs({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_programs(::Google::Shopping::Merchant::Accounts::V1beta::ListProgramsRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_programs_client_stub.call_rpc_count + end + end + + def test_enable_program + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + enable_program_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :enable_program, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, enable_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.enable_program({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.enable_program name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.enable_program ::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.enable_program({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.enable_program(::Google::Shopping::Merchant::Accounts::V1beta::EnableProgramRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, enable_program_client_stub.call_rpc_count + end + end + + def test_disable_program + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Program.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + disable_program_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :disable_program, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, disable_program_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.disable_program({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.disable_program name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.disable_program ::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.disable_program({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.disable_program(::Google::Shopping::Merchant::Accounts::V1beta::DisableProgramRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, disable_program_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ProgramsService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_paths_test.rb new file mode 100644 index 000000000000..d486c39e2b01 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/regions_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_region_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.region_path account: "value0", region: "value1" + assert_equal "accounts/value0/regions/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_rest_test.rb new file mode 100644 index 000000000000..d45800d39c5c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_rest_test.rb @@ -0,0 +1,366 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/regions_pb" +require "google/shopping/merchant/accounts/v1beta/regions_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_region + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_region_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.stub :transcode_get_region_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_region({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_region name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_region ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_region({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_region(::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_region_client_stub.call_count + end + end + end + + def test_create_region + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + region_id = "hello world" + region = {} + + create_region_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.stub :transcode_create_region_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, create_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.create_region({ parent: parent, region_id: region_id, region: region }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.create_region parent: parent, region_id: region_id, region: region do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.create_region ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new(parent: parent, region_id: region_id, region: region) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.create_region({ parent: parent, region_id: region_id, region: region }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.create_region(::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new(parent: parent, region_id: region_id, region: region), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, create_region_client_stub.call_count + end + end + end + + def test_update_region + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + region = {} + update_mask = {} + + update_region_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.stub :transcode_update_region_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_region({ region: region, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_region region: region, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_region ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new(region: region, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_region({ region: region, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_region(::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new(region: region, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_region_client_stub.call_count + end + end + end + + def test_delete_region + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_region_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.stub :transcode_delete_region_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_region({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_region name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_region ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_region({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_region(::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_region_client_stub.call_count + end + end + end + + def test_list_regions + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_regions_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::ServiceStub.stub :transcode_list_regions_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_regions_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_regions({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_regions parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_regions ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_regions({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_regions(::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_regions_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_test.rb new file mode 100644 index 000000000000..5bf1524bba4e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/regions_service_test.rb @@ -0,0 +1,381 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/regions_pb" +require "google/shopping/merchant/accounts/v1beta/regions_services_pb" +require "google/shopping/merchant/accounts/v1beta/regions_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_region + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_region_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_region, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_region({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_region name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_region ::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_region({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_region(::Google::Shopping::Merchant::Accounts::V1beta::GetRegionRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_region_client_stub.call_rpc_count + end + end + + def test_create_region + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + region_id = "hello world" + region = {} + + create_region_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :create_region, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest, request + assert_equal "hello world", request["parent"] + assert_equal "hello world", request["region_id"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::Region), request["region"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, create_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.create_region({ parent: parent, region_id: region_id, region: region }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.create_region parent: parent, region_id: region_id, region: region do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.create_region ::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new(parent: parent, region_id: region_id, region: region) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.create_region({ parent: parent, region_id: region_id, region: region }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.create_region(::Google::Shopping::Merchant::Accounts::V1beta::CreateRegionRequest.new(parent: parent, region_id: region_id, region: region), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, create_region_client_stub.call_rpc_count + end + end + + def test_update_region + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::Region.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + region = {} + update_mask = {} + + update_region_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_region, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::Region), request["region"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_region({ region: region, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_region region: region, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_region ::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new(region: region, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_region({ region: region, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_region(::Google::Shopping::Merchant::Accounts::V1beta::UpdateRegionRequest.new(region: region, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_region_client_stub.call_rpc_count + end + end + + def test_delete_region + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_region_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_region, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_region_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_region({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_region name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_region ::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_region({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_region(::Google::Shopping::Merchant::Accounts::V1beta::DeleteRegionRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_region_client_stub.call_rpc_count + end + end + + def test_list_regions + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_regions_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_regions, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_regions_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_regions({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_regions parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_regions ::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_regions({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_regions(::Google::Shopping::Merchant::Accounts::V1beta::ListRegionsRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_regions_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::RegionsService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_paths_test.rb new file mode 100644 index 000000000000..3224982f7073 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_paths_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_shipping_settings_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.shipping_settings_path account: "value0" + assert_equal "accounts/value0/shippingSettings", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_rest_test.rb new file mode 100644 index 000000000000..f36675efc89b --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_rest_test.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/shippingsettings_pb" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_shipping_settings + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_shipping_settings_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::ServiceStub.stub :transcode_get_shipping_settings_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_shipping_settings_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_shipping_settings({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_shipping_settings name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_shipping_settings ::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_shipping_settings({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_shipping_settings(::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_shipping_settings_client_stub.call_count + end + end + end + + def test_insert_shipping_settings + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + shipping_setting = {} + + insert_shipping_settings_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::ServiceStub.stub :transcode_insert_shipping_settings_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, insert_shipping_settings_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.insert_shipping_settings({ parent: parent, shipping_setting: shipping_setting }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.insert_shipping_settings parent: parent, shipping_setting: shipping_setting do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.insert_shipping_settings ::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new(parent: parent, shipping_setting: shipping_setting) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.insert_shipping_settings({ parent: parent, shipping_setting: shipping_setting }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.insert_shipping_settings(::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new(parent: parent, shipping_setting: shipping_setting), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, insert_shipping_settings_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_test.rb new file mode 100644 index 000000000000..87223bf1049d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/shipping_settings_service_test.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/shippingsettings_pb" +require "google/shopping/merchant/accounts/v1beta/shippingsettings_services_pb" +require "google/shopping/merchant/accounts/v1beta/shipping_settings_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_shipping_settings + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_shipping_settings_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_shipping_settings, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_shipping_settings_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_shipping_settings({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_shipping_settings name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_shipping_settings ::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_shipping_settings({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_shipping_settings(::Google::Shopping::Merchant::Accounts::V1beta::GetShippingSettingsRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_shipping_settings_client_stub.call_rpc_count + end + end + + def test_insert_shipping_settings + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + shipping_setting = {} + + insert_shipping_settings_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :insert_shipping_settings, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest, request + assert_equal "hello world", request["parent"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettings), request["shipping_setting"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, insert_shipping_settings_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.insert_shipping_settings({ parent: parent, shipping_setting: shipping_setting }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.insert_shipping_settings parent: parent, shipping_setting: shipping_setting do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.insert_shipping_settings ::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new(parent: parent, shipping_setting: shipping_setting) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.insert_shipping_settings({ parent: parent, shipping_setting: shipping_setting }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.insert_shipping_settings(::Google::Shopping::Merchant::Accounts::V1beta::InsertShippingSettingsRequest.new(parent: parent, shipping_setting: shipping_setting), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, insert_shipping_settings_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ShippingSettingsService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_paths_test.rb new file mode 100644 index 000000000000..99b4d0ad207d --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_terms_of_service_agreement_state_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.terms_of_service_agreement_state_path account: "value0", identifier: "value1" + assert_equal "accounts/value0/termsOfServiceAgreementStates/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_rest_test.rb new file mode 100644 index 000000000000..b120328e5d57 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_rest_test.rb @@ -0,0 +1,199 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_terms_of_service_agreement_state + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_terms_of_service_agreement_state_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::ServiceStub.stub :transcode_get_terms_of_service_agreement_state_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_terms_of_service_agreement_state_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_terms_of_service_agreement_state({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_terms_of_service_agreement_state name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_terms_of_service_agreement_state ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_terms_of_service_agreement_state({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_terms_of_service_agreement_state(::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_terms_of_service_agreement_state_client_stub.call_count + end + end + end + + def test_retrieve_for_application_terms_of_service_agreement_state + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + + retrieve_for_application_terms_of_service_agreement_state_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::ServiceStub.stub :transcode_retrieve_for_application_terms_of_service_agreement_state_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, retrieve_for_application_terms_of_service_agreement_state_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.retrieve_for_application_terms_of_service_agreement_state({ parent: parent }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.retrieve_for_application_terms_of_service_agreement_state parent: parent do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.retrieve_for_application_terms_of_service_agreement_state ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new(parent: parent) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.retrieve_for_application_terms_of_service_agreement_state({ parent: parent }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.retrieve_for_application_terms_of_service_agreement_state(::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new(parent: parent), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, retrieve_for_application_terms_of_service_agreement_state_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_test.rb new file mode 100644 index 000000000000..fcbf04634f37 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service_test.rb @@ -0,0 +1,192 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_pb" +require "google/shopping/merchant/accounts/v1beta/termsofserviceagreementstate_services_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_agreement_state_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_terms_of_service_agreement_state + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_terms_of_service_agreement_state_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_terms_of_service_agreement_state, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_terms_of_service_agreement_state_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_terms_of_service_agreement_state({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_terms_of_service_agreement_state name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_terms_of_service_agreement_state ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_terms_of_service_agreement_state({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_terms_of_service_agreement_state(::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceAgreementStateRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_terms_of_service_agreement_state_client_stub.call_rpc_count + end + end + + def test_retrieve_for_application_terms_of_service_agreement_state + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementState.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + + retrieve_for_application_terms_of_service_agreement_state_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :retrieve_for_application_terms_of_service_agreement_state, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest, request + assert_equal "hello world", request["parent"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, retrieve_for_application_terms_of_service_agreement_state_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.retrieve_for_application_terms_of_service_agreement_state({ parent: parent }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.retrieve_for_application_terms_of_service_agreement_state parent: parent do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.retrieve_for_application_terms_of_service_agreement_state ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new(parent: parent) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.retrieve_for_application_terms_of_service_agreement_state({ parent: parent }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.retrieve_for_application_terms_of_service_agreement_state(::Google::Shopping::Merchant::Accounts::V1beta::RetrieveForApplicationTermsOfServiceAgreementStateRequest.new(parent: parent), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, retrieve_for_application_terms_of_service_agreement_state_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceAgreementStateService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_paths_test.rb new file mode 100644 index 000000000000..848c067d8fb8 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_terms_of_service_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.terms_of_service_path version: "value0" + assert_equal "termsOfService/value0", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_rest_test.rb new file mode 100644 index 000000000000..38eb7a91dc75 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_rest_test.rb @@ -0,0 +1,256 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/termsofservice_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_terms_of_service + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_terms_of_service_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::ServiceStub.stub :transcode_get_terms_of_service_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_terms_of_service({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_terms_of_service name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_terms_of_service({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_terms_of_service_client_stub.call_count + end + end + end + + def test_retrieve_latest_terms_of_service + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + region_code = "hello world" + kind = :TERMS_OF_SERVICE_KIND_UNSPECIFIED + + retrieve_latest_terms_of_service_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::ServiceStub.stub :transcode_retrieve_latest_terms_of_service_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, retrieve_latest_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.retrieve_latest_terms_of_service({ region_code: region_code, kind: kind }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.retrieve_latest_terms_of_service region_code: region_code, kind: kind do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.retrieve_latest_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new(region_code: region_code, kind: kind) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.retrieve_latest_terms_of_service({ region_code: region_code, kind: kind }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.retrieve_latest_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new(region_code: region_code, kind: kind), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, retrieve_latest_terms_of_service_client_stub.call_count + end + end + end + + def test_accept_terms_of_service + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + account = "hello world" + region_code = "hello world" + + accept_terms_of_service_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::ServiceStub.stub :transcode_accept_terms_of_service_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, accept_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.accept_terms_of_service({ name: name, account: account, region_code: region_code }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.accept_terms_of_service name: name, account: account, region_code: region_code do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.accept_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new(name: name, account: account, region_code: region_code) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.accept_terms_of_service({ name: name, account: account, region_code: region_code }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.accept_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new(name: name, account: account, region_code: region_code), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, accept_terms_of_service_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_test.rb new file mode 100644 index 000000000000..3216ad495d06 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/terms_of_service_service_test.rb @@ -0,0 +1,256 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/termsofservice_pb" +require "google/shopping/merchant/accounts/v1beta/termsofservice_services_pb" +require "google/shopping/merchant/accounts/v1beta/terms_of_service_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_terms_of_service + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_terms_of_service_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_terms_of_service, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_terms_of_service({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_terms_of_service name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_terms_of_service({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::GetTermsOfServiceRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_terms_of_service_client_stub.call_rpc_count + end + end + + def test_retrieve_latest_terms_of_service + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfService.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + region_code = "hello world" + kind = :TERMS_OF_SERVICE_KIND_UNSPECIFIED + + retrieve_latest_terms_of_service_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :retrieve_latest_terms_of_service, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest, request + assert_equal "hello world", request["region_code"] + assert_equal :TERMS_OF_SERVICE_KIND_UNSPECIFIED, request["kind"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, retrieve_latest_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.retrieve_latest_terms_of_service({ region_code: region_code, kind: kind }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.retrieve_latest_terms_of_service region_code: region_code, kind: kind do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.retrieve_latest_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new(region_code: region_code, kind: kind) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.retrieve_latest_terms_of_service({ region_code: region_code, kind: kind }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.retrieve_latest_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::RetrieveLatestTermsOfServiceRequest.new(region_code: region_code, kind: kind), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, retrieve_latest_terms_of_service_client_stub.call_rpc_count + end + end + + def test_accept_terms_of_service + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + account = "hello world" + region_code = "hello world" + + accept_terms_of_service_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :accept_terms_of_service, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest, request + assert_equal "hello world", request["name"] + assert_equal "hello world", request["account"] + assert_equal "hello world", request["region_code"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, accept_terms_of_service_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.accept_terms_of_service({ name: name, account: account, region_code: region_code }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.accept_terms_of_service name: name, account: account, region_code: region_code do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.accept_terms_of_service ::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new(name: name, account: account, region_code: region_code) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.accept_terms_of_service({ name: name, account: account, region_code: region_code }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.accept_terms_of_service(::Google::Shopping::Merchant::Accounts::V1beta::AcceptTermsOfServiceRequest.new(name: name, account: account, region_code: region_code), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, accept_terms_of_service_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::TermsOfServiceService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_paths_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_paths_test.rb new file mode 100644 index 000000000000..27213f06602e --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_paths_test.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/user_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::UserService::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_account_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.account_path account: "value0" + assert_equal "accounts/value0", path + end + end + + def test_user_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.user_path account: "value0", email: "value1" + assert_equal "accounts/value0/users/value1", path + end + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_rest_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_rest_test.rb new file mode 100644 index 000000000000..28cbf4645d8c --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_rest_test.rb @@ -0,0 +1,366 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/shopping/merchant/accounts/v1beta/user_pb" +require "google/shopping/merchant/accounts/v1beta/user_service/rest" + + +class ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {} + make_http_request :get, uri: uri, body: nil, params: params, options: options + end + + def make_delete_request uri:, params: {}, options: {} + make_http_request :delete, uri: uri, body: nil, params: params, options: options + end + + def make_post_request uri:, body: nil, params: {}, options: {} + make_http_request :post, uri: uri, body: body, params: params, options: options + end + + def make_patch_request uri:, body:, params: {}, options: {} + make_http_request :patch, uri: uri, body: body, params: params, options: options + end + + def make_put_request uri:, body:, params: {}, options: {} + make_http_request :put, uri: uri, body: body, params: params, options: options + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_user + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_user_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.stub :transcode_get_user_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_user({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_user name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_user ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_user({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_user(::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_user_client_stub.call_count + end + end + end + + def test_create_user + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + user_id = "hello world" + user = {} + + create_user_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.stub :transcode_create_user_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, create_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.create_user({ parent: parent, user_id: user_id, user: user }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.create_user parent: parent, user_id: user_id, user: user do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.create_user ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new(parent: parent, user_id: user_id, user: user) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.create_user({ parent: parent, user_id: user_id, user: user }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.create_user(::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new(parent: parent, user_id: user_id, user: user), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, create_user_client_stub.call_count + end + end + end + + def test_delete_user + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_user_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.stub :transcode_delete_user_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_user({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_user name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_user ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_user({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_user(::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_user_client_stub.call_count + end + end + end + + def test_update_user + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + user = {} + update_mask = {} + + update_user_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.stub :transcode_update_user_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_user({ user: user, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_user user: user, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_user ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new(user: user, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_user({ user: user, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_user(::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new(user: user, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_user_client_stub.call_count + end + end + end + + def test_list_users + # Create test objects. + client_result = ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_users_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::ServiceStub.stub :transcode_list_users_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_users_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_users({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_users parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_users ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_users({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_users(::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_users_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Rest::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_test.rb b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_test.rb new file mode 100644 index 000000000000..3b036c1b3f45 --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/google/shopping/merchant/accounts/v1beta/user_service_test.rb @@ -0,0 +1,381 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/shopping/merchant/accounts/v1beta/user_pb" +require "google/shopping/merchant/accounts/v1beta/user_services_pb" +require "google/shopping/merchant/accounts/v1beta/user_service" + +class ::Google::Shopping::Merchant::Accounts::V1beta::UserService::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + yield @response, @operation if block_given? + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + end + + def test_get_user + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_user_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_user, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_user({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_user name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_user ::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_user({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_user(::Google::Shopping::Merchant::Accounts::V1beta::GetUserRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_user_client_stub.call_rpc_count + end + end + + def test_create_user + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + user_id = "hello world" + user = {} + + create_user_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :create_user, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest, request + assert_equal "hello world", request["parent"] + assert_equal "hello world", request["user_id"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::User), request["user"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, create_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.create_user({ parent: parent, user_id: user_id, user: user }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.create_user parent: parent, user_id: user_id, user: user do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.create_user ::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new(parent: parent, user_id: user_id, user: user) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.create_user({ parent: parent, user_id: user_id, user: user }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.create_user(::Google::Shopping::Merchant::Accounts::V1beta::CreateUserRequest.new(parent: parent, user_id: user_id, user: user), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, create_user_client_stub.call_rpc_count + end + end + + def test_delete_user + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_user_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_user, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_user({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_user name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_user ::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_user({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_user(::Google::Shopping::Merchant::Accounts::V1beta::DeleteUserRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_user_client_stub.call_rpc_count + end + end + + def test_update_user + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::User.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + user = {} + update_mask = {} + + update_user_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_user, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Shopping::Merchant::Accounts::V1beta::User), request["user"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_user_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_user({ user: user, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_user user: user, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_user ::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new(user: user, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_user({ user: user, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_user(::Google::Shopping::Merchant::Accounts::V1beta::UpdateUserRequest.new(user: user, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_user_client_stub.call_rpc_count + end + end + + def test_list_users + # Create GRPC objects. + grpc_response = ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + + list_users_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_users, name + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_users_client_stub do + # Create client + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_users({ parent: parent, page_size: page_size, page_token: page_token }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_users parent: parent, page_size: page_size, page_token: page_token do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_users ::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_users({ parent: parent, page_size: page_size, page_token: page_token }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_users(::Google::Shopping::Merchant::Accounts::V1beta::ListUsersRequest.new(parent: parent, page_size: page_size, page_token: page_token), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_users_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Shopping::Merchant::Accounts::V1beta::UserService::Client::Configuration, config + end +end diff --git a/google-shopping-merchant-accounts-v1beta/test/helper.rb b/google-shopping-merchant-accounts-v1beta/test/helper.rb new file mode 100644 index 000000000000..48407bca7edb --- /dev/null +++ b/google-shopping-merchant-accounts-v1beta/test/helper.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "minitest/autorun" +require "minitest/focus" +require "minitest/rg" + +require "grpc" + +require "ostruct" diff --git a/release-please-config.json b/release-please-config.json index f9b6dcc0420b..ed7830ed6487 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1647,6 +1647,10 @@ "component": "google-maps-fleet_engine-v1", "version_file": "lib/google/maps/fleet_engine/v1/version.rb" }, + "google-shopping-merchant-accounts-v1beta": { + "component": "google-shopping-merchant-accounts-v1beta", + "version_file": "lib/google/shopping/merchant/accounts/v1beta/version.rb" + }, "google-shopping-merchant-conversions": { "component": "google-shopping-merchant-conversions", "version_file": "lib/google/shopping/merchant/conversions/version.rb"