diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..dde4ac0 --- /dev/null +++ b/.env.test @@ -0,0 +1,7 @@ +CUSTOMER_ID=CUSTOMER_ID +CUSTOMER_ACCOUNT_ID=CUSTOMER_ACCOUNT_ID +DEVELOPER_TOKEN=DEVELOPER_TOKEN +OAUTH2_CLIENT_ID=OAUTH2_CLIENT_ID +OAUTH2_CLIENT_SECRET=OAUTH2_CLIENT_SECRET +ACCESS_TOKEN=ACCESS_TOKEN +REFRESH_TOKEN=REFRESH_TOKEN \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3850fba --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d55b3f1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build +on: [pull_request] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Read ruby version + id: ruby-version + run: | + content=`cat ./.ruby-version` + echo "::set-output name=content::$content" + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ steps.ruby-version.outputs.content }} + bundler-cache: true + cache-version: 1 + - name: Run tests + run: bundle exec rspec diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 0000000..bd30ca9 --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,9 @@ +name: Find Secrets +on: [pull_request] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: max/secret-scan@master diff --git a/.gitignore b/.gitignore index 2c1ec71..6eaad1e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ bing_ads_api.yml /*.0.1.gem /*.0.2.gem /*.0.*.gem -/test.rb \ No newline at end of file +/test.rb +.env*.local \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..adc8416 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,3 @@ +require: + - rubocop-rake + - rubocop-rspec \ No newline at end of file diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..743af5e --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.6.8 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6b4a0c7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM ruby:2.6.9-slim-bullseye +RUN DEBIAN_FRONTEND=noninteractive apt-get -y -q update && apt-get -y -q install build-essential + +ENV APP_HOME /usr/share/dgvz +WORKDIR $APP_HOME + +# load the app +COPY . $APP_HOME + +RUN bundle install diff --git a/Gemfile b/Gemfile index 3a9eea8..6c60d06 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,13 @@ source "http://rubygems.org" # Declare your gem's dependencies in semrush.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. + +group :development do + gem 'guard' + gem 'guard-rspec', require: false + gem 'rubocop' + gem 'rubocop-rspec', require: false + gem 'rubocop-rake', require: false +end + gemspec \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index dfc5cce..1d5a1dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,52 +1,128 @@ PATH remote: . specs: - bing_ads_api_v9 (0.0.8) + bing_ads_api (0.0.8) activesupport (>= 3.1.0) - addressable (~> 2.3.8) - google-ads-common (~> 0.9.3) - savon (~> 1.2.0) + addressable + google-ads-common + savon GEM remote: http://rubygems.org/ specs: - activesupport (4.2.6) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) + activesupport (6.1.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.3.8) - akami (1.2.2) + akami (1.3.1) gyoku (>= 0.4.0) nokogiri - builder (3.2.2) - diff-lcs (1.2.5) - extlib (0.9.16) - faraday (0.9.2) + ast (2.4.2) + builder (3.2.4) + coderay (1.1.3) + concurrent-ruby (1.1.10) + crack (0.4.5) + rexml + diff-lcs (1.5.0) + dotenv (2.7.6) + faraday (1.10.0) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.3) multipart-post (>= 1.2, < 3) - google-ads-common (0.9.9) - httpi (~> 1.1.0) - savon (~> 1.2.0) - signet (~> 0.6.0) - gyoku (0.4.6) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + ffi (1.15.5) + formatador (1.1.0) + google-ads-common (1.0.3) + google-ads-savon (~> 1.0, >= 1.0.2) + httpclient (~> 2.7) + httpi (~> 2.3) + signet (~> 0.7) + google-ads-savon (1.0.4) + akami (~> 1.2) + builder (~> 3.0) + gyoku (~> 1.2) + httpi (~> 2.3) + nokogiri (~> 1.6) + nori (~> 2.6) + wasabi (~> 3.4) + guard (2.18.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.13.0) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) + gyoku (1.4.0) builder (>= 2.1.2) - httpi (1.1.1) + rexml (~> 3.0) + hashdiff (1.0.1) + httpclient (2.8.3) + httpi (2.5.0) rack - i18n (0.7.0) - json (1.8.3) - jwt (1.5.4) - mini_portile2 (2.4.0) - minitest (5.9.0) - multi_json (1.12.1) - multipart-post (2.0.0) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) - nokogiri (1.10.8-x86-mingw32) - mini_portile2 (~> 2.4.0) - nori (1.1.5) - rack (1.6.12) - rake (10.4.2) + socksify + i18n (1.10.0) + concurrent-ruby (~> 1.0) + jwt (2.3.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + lumberjack (1.2.8) + method_source (1.0.0) + mini_portile2 (2.8.0) + minitest (5.15.0) + multi_json (1.15.0) + multipart-post (2.1.1) + nenv (0.3.0) + nokogiri (1.13.6) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + nori (2.6.0) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) + parallel (1.22.1) + parser (3.1.2.0) + ast (~> 2.4.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.6.0) + rack (2.2.3) + rainbow (3.1.1) + rake (10.5.0) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (2.4.0) + rexml (3.2.5) rspec (2.99.0) rspec-core (~> 2.99.0) rspec-expectations (~> 2.99.0) @@ -54,37 +130,70 @@ GEM rspec-core (2.99.2) rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.3) - savon (1.2.0) - akami (~> 1.2.0) + rspec-mocks (2.99.4) + rubocop (1.29.0) + parallel (~> 1.10) + parser (>= 3.1.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.17.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.17.0) + parser (>= 3.1.1.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.10.0) + rubocop (~> 1.19) + ruby-progressbar (1.11.0) + ruby2_keywords (0.0.5) + savon (2.12.1) + akami (~> 1.2) builder (>= 2.1.2) - gyoku (~> 0.4.5) - httpi (~> 1.1.0) - nokogiri (>= 1.4.0) - nori (~> 1.1.0) - wasabi (~> 2.5.0) - signet (0.6.1) + gyoku (~> 1.2) + httpi (~> 2.3) + nokogiri (>= 1.8.1) + nori (~> 2.4) + wasabi (~> 3.4) + shellany (0.0.1) + signet (0.15.0) addressable (~> 2.3) - extlib (~> 0.9) - faraday (~> 0.9) - jwt (~> 1.5) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - thread_safe (0.3.5) - tzinfo (1.2.2) - thread_safe (~> 0.1) - wasabi (2.5.1) - httpi (~> 1.0) - nokogiri (>= 1.4.0) + socksify (1.7.1) + thor (1.2.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + unicode-display_width (2.1.0) + vcr (6.1.0) + wasabi (3.7.0) + addressable + httpi (~> 2.0) + nokogiri (>= 1.4.2) + webmock (3.13.0) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + zeitwerk (2.5.4) PLATFORMS ruby - x86-mingw32 DEPENDENCIES - bing_ads_api_v9! + bing_ads_api! + dotenv + guard + guard-rspec rack (>= 1.6.12) rake rspec (~> 2.8) + rubocop + rubocop-rake + rubocop-rspec + vcr + webmock BUNDLED WITH - 1.16.6 + 1.17.2 diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..d5d471e --- /dev/null +++ b/Guardfile @@ -0,0 +1,70 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +directories %w(lib spec) \ + .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' + +guard :rspec, cmd: "bundle exec rspec" do + require "guard/rspec/dsl" + dsl = Guard::RSpec::Dsl.new(self) + + # Feel free to open issues for suggestions and improvements + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Rails files + rails = dsl.rails(view_extensions: %w(erb haml slim)) + dsl.watch_spec_files_for(rails.app_files) + dsl.watch_spec_files_for(rails.views) + + watch(rails.controllers) do |m| + [ + rspec.spec.call("routing/#{m[1]}_routing"), + rspec.spec.call("controllers/#{m[1]}_controller"), + rspec.spec.call("acceptance/#{m[1]}") + ] + end + + # Rails config changes + watch(rails.spec_helper) { rspec.spec_dir } + watch(rails.routes) { "#{rspec.spec_dir}/routing" } + watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } + + # Capybara features specs + watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } + watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| + Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" + end +end diff --git a/bing_ads_api_v9.gemspec b/bing_ads_api.gemspec similarity index 80% rename from bing_ads_api_v9.gemspec rename to bing_ads_api.gemspec index c71cd1c..0bc8a32 100644 --- a/bing_ads_api_v9.gemspec +++ b/bing_ads_api.gemspec @@ -23,11 +23,11 @@ $:.unshift lib unless $:.include?(lib) require 'bing_ads_api/version' Gem::Specification.new do |s| - s.name = 'bing_ads_api_v9' + s.name = 'bing_ads_api' s.version = BingAdsApi::ApiConfig::CLIENT_LIB_VERSION s.summary = 'Ruby wrapper for Bing Ads API v9' s.description = 'Ruby wrapper for Bing Ads API v9' - s.homepage = 'https://github.com/tomhammond/bing_ads_api_v9' + s.homepage = 'https://github.com/digivizer/bing_ads_api' s.authors = ['Tom Hammond'] s.email = ['thomas.hammond89@gmail.com'] s.require_path = 'lib' @@ -35,11 +35,13 @@ Gem::Specification.new do |s| s.license = 'MIT' s.add_dependency('activesupport', '>= 3.1.0') - s.add_dependency('addressable', '~> 2.3.8') - s.add_dependency('google-ads-common', '~> 0.9.3') - # s.add_dependency('httpi', '1.1.0')# problem with httpi 1.1.0 or savon 1.2.0 - s.add_dependency('savon', '~>1.2.0')# problem with httpi 1.1.0 or savon 1.2.0 + s.add_dependency('addressable') + s.add_dependency('google-ads-common') + s.add_dependency('savon') s.add_development_dependency('rack', '>= 1.6.12') s.add_development_dependency 'rake' s.add_development_dependency 'rspec', '~> 2.8' + s.add_development_dependency 'dotenv' + s.add_development_dependency 'vcr' + s.add_development_dependency 'webmock' end diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..74c394c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,6 @@ +version: "3.7" +services: + api: + build: . + volumes: + - .:/usr/share/dgvz diff --git a/lib/ads_common/auth/client_login_handler.rb b/lib/ads_common/auth/client_login_handler.rb new file mode 100644 index 0000000..5e5a69f --- /dev/null +++ b/lib/ads_common/auth/client_login_handler.rb @@ -0,0 +1,198 @@ +# Encoding: utf-8 +# +# Authors:: api.dklimkin@gmail.com (Danial Klimkin) +# +# Copyright:: Copyright 2010, Google Inc. All Rights Reserved. +# +# License:: 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. +# +# This module manages ClientLogin authentication. It either uses a user-provided +# auth token, or automatically connects to Google's ClientLogin service and +# generates an auth token that can be used to login to an API. + +require 'cgi' +require 'ads_common/http' +require 'ads_common/auth/base_handler' +require 'ads_common/errors' + +module AdsCommon + module Auth + + # Credentials class to handle ClientLogin authentication. + class ClientLoginHandler < AdsCommon::Auth::BaseHandler + ACCOUNT_TYPE = 'GOOGLE' + AUTH_PATH = '/accounts/ClientLogin' + AUTH_PREFIX = 'GoogleLogin auth=' + CAPTCHA_PATH = '/accounts/' + + # Initializes the ClientLoginHandler with all the necessary details. + def initialize(config, auth_server, service_name) + super(config) + @server = auth_server + @service_name = service_name + end + + # Invalidates the stored token if the email, password or provided auth + # token have changed. + def property_changed(prop, value) + if [:email, :password].include?(prop) + @token = nil + end + if :auth_token.eql?(prop) + @token = create_token_from_string(value) + end + end + + # Handle specific ClientLogin errors. + def handle_error(error) + # TODO: Add support for automatically regenerating auth tokens when they + # expire. + get_logger().error(error) + raise error + end + + # Returns authorization string. + def auth_string(credentials) + return [AUTH_PREFIX, get_token(credentials)].join + end + + private + + # Auxiliary method to validate the credentials for token generation. + # + # Args: + # - credentials: a hash with the credentials for the account being + # accessed + # + # Raises: + # - AdsCommon::Errors::AuthError if validation fails + # + def validate_credentials(credentials) + if credentials.nil? + raise AdsCommon::Errors::AuthError, 'No credentials supplied.' + end + + if credentials[:auth_token].nil? + if credentials[:email].nil? + raise AdsCommon::Errors::AuthError, + 'Email address not included in credentials.' + end + if credentials[:password].nil? + raise AdsCommon::Errors::AuthError, + 'Password not included in credentials.' + end + else + if credentials[:email] and credentials[:password] + get_logger().warn('Both auth_token and login credentials present' + + ', preferring auth_token.') + end + end + end + + # Auxiliary method to generate an authentication token for login in via + # the ClientLogin API. + # + # Args: + # - credentials: a hash with the credentials for the account being + # accessed + # + # Returns: + # - The auth token for the account + # + # Raises: + # - AdsCommon::Errors::AuthError if authentication fails + # + def create_token(credentials) + token = credentials.include?(:auth_token) ? + create_token_from_string(credentials[:auth_token]) : + generate_token(credentials) + return token + end + + # Creates token for provided auth string. Trivial for this handler. + def create_token_from_string(token_string) + return token_string + end + + # Prepares POST data for ClientLogin request. + def get_login_data(credentials) + email = CGI.escape(credentials[:email]) + password = CGI.escape(credentials[:password]) + service_name = @service_name + data = "accountType=%s&Email=%s&Passwd=%s&service=%s" % + [ACCOUNT_TYPE, email, password, service_name] + if credentials[:logintoken] and credentials[:logincaptcha] + data += "&logintoken=%s&logincaptcha=%s" % + [CGI.escape(credentials[:logintoken]), + CGI.escape(credentials[:logincaptcha])] + end + return data + end + + # Generates new client login token based on credentials. + def generate_token(credentials) + validate_credentials(credentials) + + url = @server + AUTH_PATH + data = get_login_data(credentials) + headers = {'Content-Type' => 'application/x-www-form-urlencoded'} + + response = AdsCommon::Http.post_response(url, data, @config, headers) + results = parse_token_text(response.body) + + if response.code == 200 and results.include?('Auth') + return results['Auth'] + else + handle_login_error(credentials, response, results) + end + end + + # Raises relevant error based on response and parsed results. + def handle_login_error(credentials, response, results) + # Handling for known errors. + if 'CaptchaRequired'.eql?(results['Error']) + captcha_url = @server + CAPTCHA_PATH + results['CaptchaUrl'] + raise AdsCommon::Errors::CaptchaRequiredError.new(results['Error'], + results['CaptchaToken'], captcha_url, results['Url']) + end + # For other errors throwing a generic error. + error_message = "ClientLogin failed for email '%s': HTTP code %d." % + [credentials[:email], response.code] + error_str = results['Error'] || response.body + error_message += " Error: %s." % error_str if error_str + if results.include?('Info') + error_message += " Info: %s." % results['Info'] + end + raise AdsCommon::Errors::AuthError.new(error_message, error_str, + results['Info']) + end + + # Extracts key-value pairs from ClientLogin server response. + # + # Args: + # - text: server response string + # + # Returns: + # Hash of key-value pairs + # + def parse_token_text(text) + return text.split("\n").inject({}) do |result, line| + key, *values = line.split('=') + result[key] = values.join('=') + result + end + end + end + end +end diff --git a/lib/ads_common_for_bing_ads.rb b/lib/ads_common_for_bing_ads.rb index 57f0e41..322050e 100644 --- a/lib/ads_common_for_bing_ads.rb +++ b/lib/ads_common_for_bing_ads.rb @@ -6,10 +6,11 @@ require 'ads_common/savon_service' require 'ads_common/parameters_validator' require 'ads_common/build/savon_generator' +require 'ads_common/build/savon_service_generator' require 'ads_common/build/savon_registry' require 'ads_common/savon_headers/base_header_handler' require 'ads_common/savon_headers/oauth_header_handler' -require 'ads_common/auth/client_login_handler.rb' +require 'ads_common/auth/client_login_handler' ####### AdsCommon Overriden for Bing Ads ######### module AdsCommonForBingAds @@ -45,4 +46,51 @@ class OAuthHeaderHandler < AdsCommon::SavonHeaders::OAuthHeaderHandler; end # httpi_request_proxy is ::OAuth::RequestProxy::HTTPIRequest < OAuth::RequestProxy::Base end -end \ No newline at end of file +end + +AdsCommon::Build::SavonRegistry.class_eval do + def extract_input_parameters(op_node, doc) + output_element = REXML::XPath.first(op_node, 'descendant::wsdl:input') + output_name = get_element_name(output_element) + output_fields = find_sequence_fields(output_name, doc) + return {:name => output_name.snakecase, :fields => output_fields} + end +end + +AdsCommon::Build::SavonServiceGenerator::SERVICE_TEMPLATE = %q{<% %> + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright <%= @year %>, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # <%= @generator_stamp %> + require 'ads_common/savon_service' + require '<%= @require_path %>/<%= @service_name.to_s.snakecase %>_registry' + + <%= @modules_open_string %> + class <%= @service_name %> < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = '<%= @namespace %>' + super(config, endpoint, namespace, :<%= @version %>) + end + + <% @actions.each do |action| %> + def <%= action %>(*args, &block) + return execute_action('<%= action %>', args, &block) + end + + <% end %> + private + + def get_service_registry() + return <%= @service_name %>Registry + end + + def get_module() + return <%= [@api_name, @version.to_s.upcase, @service_name].join('::') %> + end + end + <%= @modules_close_string %> + }.gsub(/^ /, '') \ No newline at end of file diff --git a/lib/ads_common_for_bing_ads/api_config.rb b/lib/ads_common_for_bing_ads/api_config.rb index 64452f1..451837a 100644 --- a/lib/ads_common_for_bing_ads/api_config.rb +++ b/lib/ads_common_for_bing_ads/api_config.rb @@ -10,7 +10,9 @@ # Returns: # The endpoint URL # - def endpoint(environment, version, service) + def endpoint(version, service) + environment = :PRODUCTION + if !address_config().nil? address_config()[version][service][environment].to_s else diff --git a/lib/ads_common_for_bing_ads/auth/oauth2_handler.rb b/lib/ads_common_for_bing_ads/auth/oauth2_handler.rb index b4dc8cc..c63b504 100644 --- a/lib/ads_common_for_bing_ads/auth/oauth2_handler.rb +++ b/lib/ads_common_for_bing_ads/auth/oauth2_handler.rb @@ -12,6 +12,7 @@ class OAuth2Handler } def auth_string(credentials) + @scopes = ['msads.manage'] token = get_token(credentials) token[:access_token] end diff --git a/lib/ads_common_for_bing_ads/parameters_validator.rb b/lib/ads_common_for_bing_ads/parameters_validator.rb index d7cbebb..f41d29c 100644 --- a/lib/ads_common_for_bing_ads/parameters_validator.rb +++ b/lib/ads_common_for_bing_ads/parameters_validator.rb @@ -13,6 +13,10 @@ def validate_args(action_name, args) return args_hash end + def extra_namespaces + {"xmlns:arr"=>"http://schemas.microsoft.com/2003/10/Serialization/Arrays"} + end + private # Validates given arguments based on provided fields list. diff --git a/lib/ads_common_for_bing_ads/savon_headers/base_header_handler.rb b/lib/ads_common_for_bing_ads/savon_headers/base_header_handler.rb index 9eaee44..47bc9e7 100644 --- a/lib/ads_common_for_bing_ads/savon_headers/base_header_handler.rb +++ b/lib/ads_common_for_bing_ads/savon_headers/base_header_handler.rb @@ -3,6 +3,8 @@ module SavonHeaders class BaseHeaderHandler + DEFAULT_NAMESPACE = :v13 + # Generates SOAP headers with the default request header element. def generate_headers(request, soap) soap.header.merge!(generate_request_header()) diff --git a/lib/ads_common_for_bing_ads/savon_headers/oauth_header_handler.rb b/lib/ads_common_for_bing_ads/savon_headers/oauth_header_handler.rb index 9f789a0..8cf87b2 100644 --- a/lib/ads_common_for_bing_ads/savon_headers/oauth_header_handler.rb +++ b/lib/ads_common_for_bing_ads/savon_headers/oauth_header_handler.rb @@ -21,9 +21,10 @@ def generate_headers(request, soap) request.url = soap.endpoint - soap.header['wsdl:AuthenticationToken'] = @auth_handler.auth_string(credentials) - soap.header['wsdl:DeveloperToken'] = credentials[:developer_token] - soap.header['wsdl:CustomerAccountId'] = credentials[:customer_account_id] + soap.header['v13:AuthenticationToken'] = @auth_handler.auth_string(credentials) + soap.header['v13:DeveloperToken'] = credentials[:developer_token] + soap.header['v13:CustomerAccountId'] = credentials[:customer_account_id] + soap.header['v13:CustomerId'] = credentials[:customer_id] end end diff --git a/lib/ads_common_for_bing_ads/savon_service.rb b/lib/ads_common_for_bing_ads/savon_service.rb index 8611fc1..8ee2473 100644 --- a/lib/ads_common_for_bing_ads/savon_service.rb +++ b/lib/ads_common_for_bing_ads/savon_service.rb @@ -1,4 +1,5 @@ ####### Overriden for Bing Ads ######### +require 'savon' class AdsCommonForBingAds::SavonService < AdsCommon::SavonService @@ -14,7 +15,7 @@ def execute_action(action_name, args, &block) args = validator.validate_args(action_name, args) response = execute_soap_request( action_name.to_sym, args, validator.extra_namespaces) - log_headers(response.http.headers) + # log_headers(response.http.headers) handle_errors(response) extractor = AdsCommon::ResultsExtractor.new(registry) result = extractor.extract_result(response, action_name, &block) @@ -37,6 +38,7 @@ def prepend_namespace(str, namespace = AdsCommonForBingAds::SavonHeaders::BaseHe # Executes the SOAP request with original SOAP name. def execute_soap_request(action, args, extra_namespaces) ns = AdsCommonForBingAds::SavonHeaders::BaseHeaderHandler::DEFAULT_NAMESPACE + original_input_name = get_service_registry.get_method_signature(action)[:input][:name].to_s.camelize original_action_name = get_service_registry.get_method_signature(action)[:original_name].to_s.camelize original_action_name = action if original_action_name.nil? @@ -73,15 +75,24 @@ def prepend_namespace_to_hash h, namespace # Creates and sets up Savon client. def create_savon_client(endpoint, namespace) - Nori.advanced_typecasting = false - client = Savon::Client.new do |wsdl, httpi| + # Nori.advanced_typecasting = false + # client = ::Savon::Client.new do |wsdl, httpi| + # wsdl.endpoint = endpoint + # wsdl.namespace = namespace + # wsdl.element_form_default = :qualified + # AdsCommonForBingAds::Http.configure_httpi(@config, httpi) + # end + # client.config.raise_errors = false + # client.config.logger.subject = get_logger() + # return client + + client = GoogleAdsSavon::Client.new do |wsdl, httpi| wsdl.endpoint = endpoint wsdl.namespace = namespace - wsdl.element_form_default = :qualified - AdsCommonForBingAds::Http.configure_httpi(@config, httpi) + AdsCommon::Http.configure_httpi(@config, httpi) end client.config.raise_errors = false - client.config.logger.subject = get_logger() + client.config.logger.subject = NoopLogger.new return client end diff --git a/lib/bing_ads_api.rb b/lib/bing_ads_api.rb index 69b5abb..a1b3ce6 100644 --- a/lib/bing_ads_api.rb +++ b/lib/bing_ads_api.rb @@ -1,4 +1,3 @@ -require 'savon' require 'httpi' require 'active_support/inflector' diff --git a/lib/bing_ads_api/api_config.rb b/lib/bing_ads_api/api_config.rb index dd385e6..45b5868 100644 --- a/lib/bing_ads_api/api_config.rb +++ b/lib/bing_ads_api/api_config.rb @@ -14,9 +14,9 @@ class << ApiConfig end # Set defaults - DEFAULT_VERSION = :v9 + DEFAULT_VERSION = :v13 DEFAULT_ENVIRONMENT = :PRODUCTION - LATEST_VERSION = :v10 + LATEST_VERSION = :v13 # Set other constants API_NAME = 'BingAdsApi' @@ -48,6 +48,14 @@ class << ApiConfig :AdInsightService, :BulkService, :CampaignManagementService + ], + :v13 => [ + :AdInsightService, + :BulkService, + :CampaignManagementService, + :CustomerBillingService, + :CustomerManagementService, + :ReportingService ] } @@ -58,14 +66,16 @@ class << ApiConfig :header_ns => 'https://adcenter.microsoft.com/api/adcenter/', :v8 => '', :v9 => '', - :v10 => '' + :v10 => '', + :v13 => '' }, :SANDBOX => { :oauth_scope => '', :header_ns => 'https://adcenter.microsoft.com/api/adcenter/', :v8 => '', :v9 => '', - :v10 => '' + :v10 => '', + :v13 => '' } } @@ -74,6 +84,14 @@ class << ApiConfig @@subdir_config = {} @@address_config = { + :v13 => { + :AdInsightService => {:PRODUCTION => "https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl", :SANDBOX => "https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl"}, + :BulkService => {:PRODUCTION => "https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl", :SANDBOX => "https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl"}, + :CampaignManagementService => {:PRODUCTION => "https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl", :SANDBOX => "https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl"}, + :CustomerBillingService => {:PRODUCTION => "https://clientcenter.api.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?wsdl", :SANDBOX => "https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl"}, + :CustomerManagementService => {:PRODUCTION => "https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl", :SANDBOX => "https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"}, + :ReportingService => {:PRODUCTION => "https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl", :SANDBOX => "https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl"} + }, :v10 => { :AdInsightService => {:PRODUCTION => "https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/V10/AdInsightService.svc?wsdl", :SANDBOX => "https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/V10/AdInsightService.svc?wsdl"}, :BulkService => {:PRODUCTION => "https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/BulkService.svc?wsdl", :SANDBOX => "https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/BulkService.svc?wsdl"}, @@ -156,6 +174,14 @@ def self.headers_config @@headers_config end + def self.has_version(version) + address_config().keys.include?(version) + end + + def self.config(key) + environment_config(:PRODUCTION, key) + end + # Get the download URL for Ad Hoc reports. # # Args: @@ -173,4 +199,4 @@ def self.adhoc_report_download_url(environment, version) return base end end -end \ No newline at end of file +end diff --git a/lib/bing_ads_api/errors.rb b/lib/bing_ads_api/errors.rb index f85c158..58489f3 100644 --- a/lib/bing_ads_api/errors.rb +++ b/lib/bing_ads_api/errors.rb @@ -106,7 +106,7 @@ def initialize(http_code, message) "1027" => "CampaignServiceCashBackStatusRequired", "1028" => "CampaignServiceCashbackInfoShouldBeNullForBackwardCompatability", "1029" => "CampaignServiceCustomerIdHasToBeSpecified", - "1033" => "CampaignServiceAccountIdHasToBeSpecified", + "1030" => "CampaignServiceAccountIdHasToBeSpecified", "1031" => "CampaignServiceCannotPerformCurrentOperation", "2928" => "CampaignServiceCustomerDataBeingMigrated", "1032" => "CampaignServiceNegativeKeywordsLimitExceeded", diff --git a/lib/bing_ads_api/v13/ad_insight_service.rb b/lib/bing_ads_api/v13/ad_insight_service.rb new file mode 100644 index 0000000..21c9e14 --- /dev/null +++ b/lib/bing_ads_api/v13/ad_insight_service.rb @@ -0,0 +1,117 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:02:53. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/ad_insight_service_registry' + + module BingAdsApi; module V13; module AdInsightService + class AdInsightService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/AdInsight/v13' + super(config, endpoint, namespace, :v13) + end + + def get_bid_opportunities(*args, &block) + return execute_action('get_bid_opportunities', args, &block) + end + + def get_budget_opportunities(*args, &block) + return execute_action('get_budget_opportunities', args, &block) + end + + def get_keyword_opportunities(*args, &block) + return execute_action('get_keyword_opportunities', args, &block) + end + + def get_estimated_bid_by_keyword_ids(*args, &block) + return execute_action('get_estimated_bid_by_keyword_ids', args, &block) + end + + def get_estimated_position_by_keyword_ids(*args, &block) + return execute_action('get_estimated_position_by_keyword_ids', args, &block) + end + + def get_estimated_bid_by_keywords(*args, &block) + return execute_action('get_estimated_bid_by_keywords', args, &block) + end + + def get_estimated_position_by_keywords(*args, &block) + return execute_action('get_estimated_position_by_keywords', args, &block) + end + + def get_bid_landscape_by_ad_group_ids(*args, &block) + return execute_action('get_bid_landscape_by_ad_group_ids', args, &block) + end + + def get_bid_landscape_by_keyword_ids(*args, &block) + return execute_action('get_bid_landscape_by_keyword_ids', args, &block) + end + + def get_historical_keyword_performance(*args, &block) + return execute_action('get_historical_keyword_performance', args, &block) + end + + def get_historical_search_count(*args, &block) + return execute_action('get_historical_search_count', args, &block) + end + + def get_keyword_categories(*args, &block) + return execute_action('get_keyword_categories', args, &block) + end + + def get_keyword_demographics(*args, &block) + return execute_action('get_keyword_demographics', args, &block) + end + + def get_keyword_locations(*args, &block) + return execute_action('get_keyword_locations', args, &block) + end + + def suggest_keywords_for_url(*args, &block) + return execute_action('suggest_keywords_for_url', args, &block) + end + + def suggest_keywords_from_existing_keywords(*args, &block) + return execute_action('suggest_keywords_from_existing_keywords', args, &block) + end + + def get_auction_insight_data(*args, &block) + return execute_action('get_auction_insight_data', args, &block) + end + + def get_domain_categories(*args, &block) + return execute_action('get_domain_categories', args, &block) + end + + def put_metric_data(*args, &block) + return execute_action('put_metric_data', args, &block) + end + + def get_keyword_idea_categories(*args, &block) + return execute_action('get_keyword_idea_categories', args, &block) + end + + def get_keyword_ideas(*args, &block) + return execute_action('get_keyword_ideas', args, &block) + end + + def get_keyword_traffic_estimates(*args, &block) + return execute_action('get_keyword_traffic_estimates', args, &block) + end + + private + + def get_service_registry() + return AdInsightServiceRegistry + end + + def get_module() + return BingAdsApi::V13::AdInsightService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/ad_insight_service_registry.rb b/lib/bing_ads_api/v13/ad_insight_service_registry.rb new file mode 100644 index 0000000..0856520 --- /dev/null +++ b/lib/bing_ads_api/v13/ad_insight_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:02:53. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module AdInsightService + class AdInsightServiceRegistry + ADINSIGHTSERVICE_METHODS = {:get_bid_opportunities=>{:input=>{:name=>"get_bid_opportunities_request", :fields=>[]}, :output=>{:name=>"get_bid_opportunities_response", :fields=>[]}, :original_name=>"GetBidOpportunities"}, :get_budget_opportunities=>{:input=>{:name=>"get_budget_opportunities_request", :fields=>[]}, :output=>{:name=>"get_budget_opportunities_response", :fields=>[]}, :original_name=>"GetBudgetOpportunities"}, :get_keyword_opportunities=>{:input=>{:name=>"get_keyword_opportunities_request", :fields=>[]}, :output=>{:name=>"get_keyword_opportunities_response", :fields=>[]}, :original_name=>"GetKeywordOpportunities"}, :get_estimated_bid_by_keyword_ids=>{:input=>{:name=>"get_estimated_bid_by_keyword_ids_request", :fields=>[]}, :output=>{:name=>"get_estimated_bid_by_keyword_ids_response", :fields=>[]}, :original_name=>"GetEstimatedBidByKeywordIds"}, :get_estimated_position_by_keyword_ids=>{:input=>{:name=>"get_estimated_position_by_keyword_ids_request", :fields=>[]}, :output=>{:name=>"get_estimated_position_by_keyword_ids_response", :fields=>[]}, :original_name=>"GetEstimatedPositionByKeywordIds"}, :get_estimated_bid_by_keywords=>{:input=>{:name=>"get_estimated_bid_by_keywords_request", :fields=>[]}, :output=>{:name=>"get_estimated_bid_by_keywords_response", :fields=>[]}, :original_name=>"GetEstimatedBidByKeywords"}, :get_estimated_position_by_keywords=>{:input=>{:name=>"get_estimated_position_by_keywords_request", :fields=>[]}, :output=>{:name=>"get_estimated_position_by_keywords_response", :fields=>[]}, :original_name=>"GetEstimatedPositionByKeywords"}, :get_bid_landscape_by_ad_group_ids=>{:input=>{:name=>"get_bid_landscape_by_ad_group_ids_request", :fields=>[]}, :output=>{:name=>"get_bid_landscape_by_ad_group_ids_response", :fields=>[]}, :original_name=>"GetBidLandscapeByAdGroupIds"}, :get_bid_landscape_by_keyword_ids=>{:input=>{:name=>"get_bid_landscape_by_keyword_ids_request", :fields=>[]}, :output=>{:name=>"get_bid_landscape_by_keyword_ids_response", :fields=>[]}, :original_name=>"GetBidLandscapeByKeywordIds"}, :get_historical_keyword_performance=>{:input=>{:name=>"get_historical_keyword_performance_request", :fields=>[]}, :output=>{:name=>"get_historical_keyword_performance_response", :fields=>[]}, :original_name=>"GetHistoricalKeywordPerformance"}, :get_historical_search_count=>{:input=>{:name=>"get_historical_search_count_request", :fields=>[]}, :output=>{:name=>"get_historical_search_count_response", :fields=>[]}, :original_name=>"GetHistoricalSearchCount"}, :get_keyword_categories=>{:input=>{:name=>"get_keyword_categories_request", :fields=>[]}, :output=>{:name=>"get_keyword_categories_response", :fields=>[]}, :original_name=>"GetKeywordCategories"}, :get_keyword_demographics=>{:input=>{:name=>"get_keyword_demographics_request", :fields=>[]}, :output=>{:name=>"get_keyword_demographics_response", :fields=>[]}, :original_name=>"GetKeywordDemographics"}, :get_keyword_locations=>{:input=>{:name=>"get_keyword_locations_request", :fields=>[]}, :output=>{:name=>"get_keyword_locations_response", :fields=>[]}, :original_name=>"GetKeywordLocations"}, :suggest_keywords_for_url=>{:input=>{:name=>"suggest_keywords_for_url_request", :fields=>[]}, :output=>{:name=>"suggest_keywords_for_url_response", :fields=>[]}, :original_name=>"SuggestKeywordsForUrl"}, :suggest_keywords_from_existing_keywords=>{:input=>{:name=>"suggest_keywords_from_existing_keywords_request", :fields=>[]}, :output=>{:name=>"suggest_keywords_from_existing_keywords_response", :fields=>[]}, :original_name=>"SuggestKeywordsFromExistingKeywords"}, :get_auction_insight_data=>{:input=>{:name=>"get_auction_insight_data_request", :fields=>[]}, :output=>{:name=>"get_auction_insight_data_response", :fields=>[]}, :original_name=>"GetAuctionInsightData"}, :get_domain_categories=>{:input=>{:name=>"get_domain_categories_request", :fields=>[]}, :output=>{:name=>"get_domain_categories_response", :fields=>[]}, :original_name=>"GetDomainCategories"}, :put_metric_data=>{:input=>{:name=>"put_metric_data_request", :fields=>[]}, :output=>{:name=>"put_metric_data_response", :fields=>[]}, :original_name=>"PutMetricData"}, :get_keyword_idea_categories=>{:input=>{:name=>"get_keyword_idea_categories_request", :fields=>[]}, :output=>{:name=>"get_keyword_idea_categories_response", :fields=>[]}, :original_name=>"GetKeywordIdeaCategories"}, :get_keyword_ideas=>{:input=>{:name=>"get_keyword_ideas_request", :fields=>[]}, :output=>{:name=>"get_keyword_ideas_response", :fields=>[]}, :original_name=>"GetKeywordIdeas"}, :get_keyword_traffic_estimates=>{:input=>{:name=>"get_keyword_traffic_estimates_request", :fields=>[]}, :output=>{:name=>"get_keyword_traffic_estimates_response", :fields=>[]}, :original_name=>"GetKeywordTrafficEstimates"}} + ADINSIGHTSERVICE_TYPES = {} + ADINSIGHTSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return ADINSIGHTSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return ADINSIGHTSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return ADINSIGHTSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/lib/bing_ads_api/v13/bulk_service.rb b/lib/bing_ads_api/v13/bulk_service.rb new file mode 100644 index 0000000..9d81fbe --- /dev/null +++ b/lib/bing_ads_api/v13/bulk_service.rb @@ -0,0 +1,53 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:03:13. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/bulk_service_registry' + + module BingAdsApi; module V13; module BulkService + class BulkService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/CampaignManagement/v13' + super(config, endpoint, namespace, :v13) + end + + def download_campaigns_by_account_ids(*args, &block) + return execute_action('download_campaigns_by_account_ids', args, &block) + end + + def download_campaigns_by_campaign_ids(*args, &block) + return execute_action('download_campaigns_by_campaign_ids', args, &block) + end + + def get_bulk_download_status(*args, &block) + return execute_action('get_bulk_download_status', args, &block) + end + + def get_bulk_upload_url(*args, &block) + return execute_action('get_bulk_upload_url', args, &block) + end + + def get_bulk_upload_status(*args, &block) + return execute_action('get_bulk_upload_status', args, &block) + end + + def upload_entity_records(*args, &block) + return execute_action('upload_entity_records', args, &block) + end + + private + + def get_service_registry() + return BulkServiceRegistry + end + + def get_module() + return BingAdsApi::V13::BulkService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/bulk_service_registry.rb b/lib/bing_ads_api/v13/bulk_service_registry.rb new file mode 100644 index 0000000..2dea7ac --- /dev/null +++ b/lib/bing_ads_api/v13/bulk_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:03:13. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module BulkService + class BulkServiceRegistry + BULKSERVICE_METHODS = {:download_campaigns_by_account_ids=>{:input=>{:name=>"download_campaigns_by_account_ids_request", :fields=>[]}, :output=>{:name=>"download_campaigns_by_account_ids_response", :fields=>[]}, :original_name=>"DownloadCampaignsByAccountIds"}, :download_campaigns_by_campaign_ids=>{:input=>{:name=>"download_campaigns_by_campaign_ids_request", :fields=>[]}, :output=>{:name=>"download_campaigns_by_campaign_ids_response", :fields=>[]}, :original_name=>"DownloadCampaignsByCampaignIds"}, :get_bulk_download_status=>{:input=>{:name=>"get_bulk_download_status_request", :fields=>[]}, :output=>{:name=>"get_bulk_download_status_response", :fields=>[]}, :original_name=>"GetBulkDownloadStatus"}, :get_bulk_upload_url=>{:input=>{:name=>"get_bulk_upload_url_request", :fields=>[]}, :output=>{:name=>"get_bulk_upload_url_response", :fields=>[]}, :original_name=>"GetBulkUploadUrl"}, :get_bulk_upload_status=>{:input=>{:name=>"get_bulk_upload_status_request", :fields=>[]}, :output=>{:name=>"get_bulk_upload_status_response", :fields=>[]}, :original_name=>"GetBulkUploadStatus"}, :upload_entity_records=>{:input=>{:name=>"upload_entity_records_request", :fields=>[]}, :output=>{:name=>"upload_entity_records_response", :fields=>[]}, :original_name=>"UploadEntityRecords"}} + BULKSERVICE_TYPES = {} + BULKSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return BULKSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return BULKSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return BULKSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/lib/bing_ads_api/v13/campaign_management_service.rb b/lib/bing_ads_api/v13/campaign_management_service.rb new file mode 100644 index 0000000..43ffa13 --- /dev/null +++ b/lib/bing_ads_api/v13/campaign_management_service.rb @@ -0,0 +1,525 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:03:16. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/campaign_management_service_registry' + + module BingAdsApi; module V13; module CampaignManagementService + class CampaignManagementService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/CampaignManagement/v13' + super(config, endpoint, namespace, :v13) + end + + def add_campaigns(*args, &block) + return execute_action('add_campaigns', args, &block) + end + + def get_campaigns_by_account_id(*args, &block) + return execute_action('get_campaigns_by_account_id', args, &block) + end + + def get_campaigns_by_ids(*args, &block) + return execute_action('get_campaigns_by_ids', args, &block) + end + + def delete_campaigns(*args, &block) + return execute_action('delete_campaigns', args, &block) + end + + def update_campaigns(*args, &block) + return execute_action('update_campaigns', args, &block) + end + + def get_negative_sites_by_campaign_ids(*args, &block) + return execute_action('get_negative_sites_by_campaign_ids', args, &block) + end + + def set_negative_sites_to_campaigns(*args, &block) + return execute_action('set_negative_sites_to_campaigns', args, &block) + end + + def get_config_value(*args, &block) + return execute_action('get_config_value', args, &block) + end + + def get_bsc_countries(*args, &block) + return execute_action('get_bsc_countries', args, &block) + end + + def add_ad_groups(*args, &block) + return execute_action('add_ad_groups', args, &block) + end + + def delete_ad_groups(*args, &block) + return execute_action('delete_ad_groups', args, &block) + end + + def get_ad_groups_by_ids(*args, &block) + return execute_action('get_ad_groups_by_ids', args, &block) + end + + def get_ad_groups_by_campaign_id(*args, &block) + return execute_action('get_ad_groups_by_campaign_id', args, &block) + end + + def update_ad_groups(*args, &block) + return execute_action('update_ad_groups', args, &block) + end + + def get_negative_sites_by_ad_group_ids(*args, &block) + return execute_action('get_negative_sites_by_ad_group_ids', args, &block) + end + + def set_negative_sites_to_ad_groups(*args, &block) + return execute_action('set_negative_sites_to_ad_groups', args, &block) + end + + def get_geo_locations_file_url(*args, &block) + return execute_action('get_geo_locations_file_url', args, &block) + end + + def add_ads(*args, &block) + return execute_action('add_ads', args, &block) + end + + def delete_ads(*args, &block) + return execute_action('delete_ads', args, &block) + end + + def get_ads_by_editorial_status(*args, &block) + return execute_action('get_ads_by_editorial_status', args, &block) + end + + def get_ads_by_ids(*args, &block) + return execute_action('get_ads_by_ids', args, &block) + end + + def get_ads_by_ad_group_id(*args, &block) + return execute_action('get_ads_by_ad_group_id', args, &block) + end + + def update_ads(*args, &block) + return execute_action('update_ads', args, &block) + end + + def add_keywords(*args, &block) + return execute_action('add_keywords', args, &block) + end + + def delete_keywords(*args, &block) + return execute_action('delete_keywords', args, &block) + end + + def get_keywords_by_editorial_status(*args, &block) + return execute_action('get_keywords_by_editorial_status', args, &block) + end + + def get_keywords_by_ids(*args, &block) + return execute_action('get_keywords_by_ids', args, &block) + end + + def get_keywords_by_ad_group_id(*args, &block) + return execute_action('get_keywords_by_ad_group_id', args, &block) + end + + def update_keywords(*args, &block) + return execute_action('update_keywords', args, &block) + end + + def appeal_editorial_rejections(*args, &block) + return execute_action('appeal_editorial_rejections', args, &block) + end + + def get_editorial_reasons_by_ids(*args, &block) + return execute_action('get_editorial_reasons_by_ids', args, &block) + end + + def get_account_migration_statuses(*args, &block) + return execute_action('get_account_migration_statuses', args, &block) + end + + def set_account_properties(*args, &block) + return execute_action('set_account_properties', args, &block) + end + + def get_account_properties(*args, &block) + return execute_action('get_account_properties', args, &block) + end + + def add_ad_extensions(*args, &block) + return execute_action('add_ad_extensions', args, &block) + end + + def get_ad_extensions_by_ids(*args, &block) + return execute_action('get_ad_extensions_by_ids', args, &block) + end + + def update_ad_extensions(*args, &block) + return execute_action('update_ad_extensions', args, &block) + end + + def delete_ad_extensions(*args, &block) + return execute_action('delete_ad_extensions', args, &block) + end + + def get_ad_extensions_editorial_reasons(*args, &block) + return execute_action('get_ad_extensions_editorial_reasons', args, &block) + end + + def set_ad_extensions_associations(*args, &block) + return execute_action('set_ad_extensions_associations', args, &block) + end + + def get_ad_extensions_associations(*args, &block) + return execute_action('get_ad_extensions_associations', args, &block) + end + + def delete_ad_extensions_associations(*args, &block) + return execute_action('delete_ad_extensions_associations', args, &block) + end + + def get_ad_extension_ids_by_account_id(*args, &block) + return execute_action('get_ad_extension_ids_by_account_id', args, &block) + end + + def add_media(*args, &block) + return execute_action('add_media', args, &block) + end + + def delete_media(*args, &block) + return execute_action('delete_media', args, &block) + end + + def get_media_meta_data_by_account_id(*args, &block) + return execute_action('get_media_meta_data_by_account_id', args, &block) + end + + def get_media_meta_data_by_ids(*args, &block) + return execute_action('get_media_meta_data_by_ids', args, &block) + end + + def get_media_associations(*args, &block) + return execute_action('get_media_associations', args, &block) + end + + def get_ad_group_criterions_by_ids(*args, &block) + return execute_action('get_ad_group_criterions_by_ids', args, &block) + end + + def add_ad_group_criterions(*args, &block) + return execute_action('add_ad_group_criterions', args, &block) + end + + def update_ad_group_criterions(*args, &block) + return execute_action('update_ad_group_criterions', args, &block) + end + + def delete_ad_group_criterions(*args, &block) + return execute_action('delete_ad_group_criterions', args, &block) + end + + def apply_product_partition_actions(*args, &block) + return execute_action('apply_product_partition_actions', args, &block) + end + + def get_bmc_stores_by_customer_id(*args, &block) + return execute_action('get_bmc_stores_by_customer_id', args, &block) + end + + def add_negative_keywords_to_entities(*args, &block) + return execute_action('add_negative_keywords_to_entities', args, &block) + end + + def get_negative_keywords_by_entity_ids(*args, &block) + return execute_action('get_negative_keywords_by_entity_ids', args, &block) + end + + def delete_negative_keywords_from_entities(*args, &block) + return execute_action('delete_negative_keywords_from_entities', args, &block) + end + + def get_shared_entities_by_account_id(*args, &block) + return execute_action('get_shared_entities_by_account_id', args, &block) + end + + def get_shared_entities(*args, &block) + return execute_action('get_shared_entities', args, &block) + end + + def add_shared_entity(*args, &block) + return execute_action('add_shared_entity', args, &block) + end + + def get_list_items_by_shared_list(*args, &block) + return execute_action('get_list_items_by_shared_list', args, &block) + end + + def add_list_items_to_shared_list(*args, &block) + return execute_action('add_list_items_to_shared_list', args, &block) + end + + def update_shared_entities(*args, &block) + return execute_action('update_shared_entities', args, &block) + end + + def delete_list_items_from_shared_list(*args, &block) + return execute_action('delete_list_items_from_shared_list', args, &block) + end + + def set_shared_entity_associations(*args, &block) + return execute_action('set_shared_entity_associations', args, &block) + end + + def delete_shared_entity_associations(*args, &block) + return execute_action('delete_shared_entity_associations', args, &block) + end + + def get_shared_entity_associations_by_shared_entity_ids(*args, &block) + return execute_action('get_shared_entity_associations_by_shared_entity_ids', args, &block) + end + + def get_shared_entity_associations_by_entity_ids(*args, &block) + return execute_action('get_shared_entity_associations_by_entity_ids', args, &block) + end + + def delete_shared_entities(*args, &block) + return execute_action('delete_shared_entities', args, &block) + end + + def get_campaign_sizes_by_account_id(*args, &block) + return execute_action('get_campaign_sizes_by_account_id', args, &block) + end + + def add_campaign_criterions(*args, &block) + return execute_action('add_campaign_criterions', args, &block) + end + + def update_campaign_criterions(*args, &block) + return execute_action('update_campaign_criterions', args, &block) + end + + def delete_campaign_criterions(*args, &block) + return execute_action('delete_campaign_criterions', args, &block) + end + + def get_campaign_criterions_by_ids(*args, &block) + return execute_action('get_campaign_criterions_by_ids', args, &block) + end + + def add_budgets(*args, &block) + return execute_action('add_budgets', args, &block) + end + + def update_budgets(*args, &block) + return execute_action('update_budgets', args, &block) + end + + def delete_budgets(*args, &block) + return execute_action('delete_budgets', args, &block) + end + + def get_budgets_by_ids(*args, &block) + return execute_action('get_budgets_by_ids', args, &block) + end + + def get_campaign_ids_by_budget_ids(*args, &block) + return execute_action('get_campaign_ids_by_budget_ids', args, &block) + end + + def add_bid_strategies(*args, &block) + return execute_action('add_bid_strategies', args, &block) + end + + def update_bid_strategies(*args, &block) + return execute_action('update_bid_strategies', args, &block) + end + + def delete_bid_strategies(*args, &block) + return execute_action('delete_bid_strategies', args, &block) + end + + def get_bid_strategies_by_ids(*args, &block) + return execute_action('get_bid_strategies_by_ids', args, &block) + end + + def get_campaign_ids_by_bid_strategy_ids(*args, &block) + return execute_action('get_campaign_ids_by_bid_strategy_ids', args, &block) + end + + def add_audiences(*args, &block) + return execute_action('add_audiences', args, &block) + end + + def update_audiences(*args, &block) + return execute_action('update_audiences', args, &block) + end + + def delete_audiences(*args, &block) + return execute_action('delete_audiences', args, &block) + end + + def get_audiences_by_ids(*args, &block) + return execute_action('get_audiences_by_ids', args, &block) + end + + def get_uet_tags_by_ids(*args, &block) + return execute_action('get_uet_tags_by_ids', args, &block) + end + + def add_uet_tags(*args, &block) + return execute_action('add_uet_tags', args, &block) + end + + def update_uet_tags(*args, &block) + return execute_action('update_uet_tags', args, &block) + end + + def get_conversion_goals_by_ids(*args, &block) + return execute_action('get_conversion_goals_by_ids', args, &block) + end + + def get_conversion_goals_by_tag_ids(*args, &block) + return execute_action('get_conversion_goals_by_tag_ids', args, &block) + end + + def add_conversion_goals(*args, &block) + return execute_action('add_conversion_goals', args, &block) + end + + def update_conversion_goals(*args, &block) + return execute_action('update_conversion_goals', args, &block) + end + + def apply_offline_conversions(*args, &block) + return execute_action('apply_offline_conversions', args, &block) + end + + def apply_offline_conversion_adjustments(*args, &block) + return execute_action('apply_offline_conversion_adjustments', args, &block) + end + + def add_labels(*args, &block) + return execute_action('add_labels', args, &block) + end + + def delete_labels(*args, &block) + return execute_action('delete_labels', args, &block) + end + + def update_labels(*args, &block) + return execute_action('update_labels', args, &block) + end + + def get_labels_by_ids(*args, &block) + return execute_action('get_labels_by_ids', args, &block) + end + + def set_label_associations(*args, &block) + return execute_action('set_label_associations', args, &block) + end + + def delete_label_associations(*args, &block) + return execute_action('delete_label_associations', args, &block) + end + + def get_label_associations_by_entity_ids(*args, &block) + return execute_action('get_label_associations_by_entity_ids', args, &block) + end + + def get_label_associations_by_label_ids(*args, &block) + return execute_action('get_label_associations_by_label_ids', args, &block) + end + + def add_experiments(*args, &block) + return execute_action('add_experiments', args, &block) + end + + def delete_experiments(*args, &block) + return execute_action('delete_experiments', args, &block) + end + + def update_experiments(*args, &block) + return execute_action('update_experiments', args, &block) + end + + def get_experiments_by_ids(*args, &block) + return execute_action('get_experiments_by_ids', args, &block) + end + + def get_profile_data_file_url(*args, &block) + return execute_action('get_profile_data_file_url', args, &block) + end + + def search_companies(*args, &block) + return execute_action('search_companies', args, &block) + end + + def get_file_import_upload_url(*args, &block) + return execute_action('get_file_import_upload_url', args, &block) + end + + def add_import_jobs(*args, &block) + return execute_action('add_import_jobs', args, &block) + end + + def get_import_results(*args, &block) + return execute_action('get_import_results', args, &block) + end + + def get_import_jobs_by_ids(*args, &block) + return execute_action('get_import_jobs_by_ids', args, &block) + end + + def delete_import_jobs(*args, &block) + return execute_action('delete_import_jobs', args, &block) + end + + def get_import_entity_ids_mapping(*args, &block) + return execute_action('get_import_entity_ids_mapping', args, &block) + end + + def update_import_jobs(*args, &block) + return execute_action('update_import_jobs', args, &block) + end + + def add_videos(*args, &block) + return execute_action('add_videos', args, &block) + end + + def delete_videos(*args, &block) + return execute_action('delete_videos', args, &block) + end + + def get_videos_by_ids(*args, &block) + return execute_action('get_videos_by_ids', args, &block) + end + + def update_videos(*args, &block) + return execute_action('update_videos', args, &block) + end + + def add_campaign_conversion_goals(*args, &block) + return execute_action('add_campaign_conversion_goals', args, &block) + end + + def delete_campaign_conversion_goals(*args, &block) + return execute_action('delete_campaign_conversion_goals', args, &block) + end + + private + + def get_service_registry() + return CampaignManagementServiceRegistry + end + + def get_module() + return BingAdsApi::V13::CampaignManagementService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/campaign_management_service_registry.rb b/lib/bing_ads_api/v13/campaign_management_service_registry.rb new file mode 100644 index 0000000..2a5541d --- /dev/null +++ b/lib/bing_ads_api/v13/campaign_management_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:03:16. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module CampaignManagementService + class CampaignManagementServiceRegistry + CAMPAIGNMANAGEMENTSERVICE_METHODS = {:add_campaigns=>{:input=>{:name=>"add_campaigns_request", :fields=>[]}, :output=>{:name=>"add_campaigns_response", :fields=>[]}, :original_name=>"AddCampaigns"}, :get_campaigns_by_account_id=>{:input=>{:name=>"get_campaigns_by_account_id_request", :fields=>[]}, :output=>{:name=>"get_campaigns_by_account_id_response", :fields=>[]}, :original_name=>"GetCampaignsByAccountId"}, :get_campaigns_by_ids=>{:input=>{:name=>"get_campaigns_by_ids_request", :fields=>[]}, :output=>{:name=>"get_campaigns_by_ids_response", :fields=>[]}, :original_name=>"GetCampaignsByIds"}, :delete_campaigns=>{:input=>{:name=>"delete_campaigns_request", :fields=>[]}, :output=>{:name=>"delete_campaigns_response", :fields=>[]}, :original_name=>"DeleteCampaigns"}, :update_campaigns=>{:input=>{:name=>"update_campaigns_request", :fields=>[]}, :output=>{:name=>"update_campaigns_response", :fields=>[]}, :original_name=>"UpdateCampaigns"}, :get_negative_sites_by_campaign_ids=>{:input=>{:name=>"get_negative_sites_by_campaign_ids_request", :fields=>[]}, :output=>{:name=>"get_negative_sites_by_campaign_ids_response", :fields=>[]}, :original_name=>"GetNegativeSitesByCampaignIds"}, :set_negative_sites_to_campaigns=>{:input=>{:name=>"set_negative_sites_to_campaigns_request", :fields=>[]}, :output=>{:name=>"set_negative_sites_to_campaigns_response", :fields=>[]}, :original_name=>"SetNegativeSitesToCampaigns"}, :get_config_value=>{:input=>{:name=>"get_config_value_request", :fields=>[]}, :output=>{:name=>"get_config_value_response", :fields=>[]}, :original_name=>"GetConfigValue"}, :get_bsc_countries=>{:input=>{:name=>"get_bsc_countries_request", :fields=>[]}, :output=>{:name=>"get_bsc_countries_response", :fields=>[]}, :original_name=>"GetBSCCountries"}, :add_ad_groups=>{:input=>{:name=>"add_ad_groups_request", :fields=>[]}, :output=>{:name=>"add_ad_groups_response", :fields=>[]}, :original_name=>"AddAdGroups"}, :delete_ad_groups=>{:input=>{:name=>"delete_ad_groups_request", :fields=>[]}, :output=>{:name=>"delete_ad_groups_response", :fields=>[]}, :original_name=>"DeleteAdGroups"}, :get_ad_groups_by_ids=>{:input=>{:name=>"get_ad_groups_by_ids_request", :fields=>[]}, :output=>{:name=>"get_ad_groups_by_ids_response", :fields=>[]}, :original_name=>"GetAdGroupsByIds"}, :get_ad_groups_by_campaign_id=>{:input=>{:name=>"get_ad_groups_by_campaign_id_request", :fields=>[]}, :output=>{:name=>"get_ad_groups_by_campaign_id_response", :fields=>[]}, :original_name=>"GetAdGroupsByCampaignId"}, :update_ad_groups=>{:input=>{:name=>"update_ad_groups_request", :fields=>[]}, :output=>{:name=>"update_ad_groups_response", :fields=>[]}, :original_name=>"UpdateAdGroups"}, :get_negative_sites_by_ad_group_ids=>{:input=>{:name=>"get_negative_sites_by_ad_group_ids_request", :fields=>[]}, :output=>{:name=>"get_negative_sites_by_ad_group_ids_response", :fields=>[]}, :original_name=>"GetNegativeSitesByAdGroupIds"}, :set_negative_sites_to_ad_groups=>{:input=>{:name=>"set_negative_sites_to_ad_groups_request", :fields=>[]}, :output=>{:name=>"set_negative_sites_to_ad_groups_response", :fields=>[]}, :original_name=>"SetNegativeSitesToAdGroups"}, :get_geo_locations_file_url=>{:input=>{:name=>"get_geo_locations_file_url_request", :fields=>[]}, :output=>{:name=>"get_geo_locations_file_url_response", :fields=>[]}, :original_name=>"GetGeoLocationsFileUrl"}, :add_ads=>{:input=>{:name=>"add_ads_request", :fields=>[]}, :output=>{:name=>"add_ads_response", :fields=>[]}, :original_name=>"AddAds"}, :delete_ads=>{:input=>{:name=>"delete_ads_request", :fields=>[]}, :output=>{:name=>"delete_ads_response", :fields=>[]}, :original_name=>"DeleteAds"}, :get_ads_by_editorial_status=>{:input=>{:name=>"get_ads_by_editorial_status_request", :fields=>[]}, :output=>{:name=>"get_ads_by_editorial_status_response", :fields=>[]}, :original_name=>"GetAdsByEditorialStatus"}, :get_ads_by_ids=>{:input=>{:name=>"get_ads_by_ids_request", :fields=>[]}, :output=>{:name=>"get_ads_by_ids_response", :fields=>[]}, :original_name=>"GetAdsByIds"}, :get_ads_by_ad_group_id=>{:input=>{:name=>"get_ads_by_ad_group_id_request", :fields=>[]}, :output=>{:name=>"get_ads_by_ad_group_id_response", :fields=>[]}, :original_name=>"GetAdsByAdGroupId"}, :update_ads=>{:input=>{:name=>"update_ads_request", :fields=>[]}, :output=>{:name=>"update_ads_response", :fields=>[]}, :original_name=>"UpdateAds"}, :add_keywords=>{:input=>{:name=>"add_keywords_request", :fields=>[]}, :output=>{:name=>"add_keywords_response", :fields=>[]}, :original_name=>"AddKeywords"}, :delete_keywords=>{:input=>{:name=>"delete_keywords_request", :fields=>[]}, :output=>{:name=>"delete_keywords_response", :fields=>[]}, :original_name=>"DeleteKeywords"}, :get_keywords_by_editorial_status=>{:input=>{:name=>"get_keywords_by_editorial_status_request", :fields=>[]}, :output=>{:name=>"get_keywords_by_editorial_status_response", :fields=>[]}, :original_name=>"GetKeywordsByEditorialStatus"}, :get_keywords_by_ids=>{:input=>{:name=>"get_keywords_by_ids_request", :fields=>[]}, :output=>{:name=>"get_keywords_by_ids_response", :fields=>[]}, :original_name=>"GetKeywordsByIds"}, :get_keywords_by_ad_group_id=>{:input=>{:name=>"get_keywords_by_ad_group_id_request", :fields=>[]}, :output=>{:name=>"get_keywords_by_ad_group_id_response", :fields=>[]}, :original_name=>"GetKeywordsByAdGroupId"}, :update_keywords=>{:input=>{:name=>"update_keywords_request", :fields=>[]}, :output=>{:name=>"update_keywords_response", :fields=>[]}, :original_name=>"UpdateKeywords"}, :appeal_editorial_rejections=>{:input=>{:name=>"appeal_editorial_rejections_request", :fields=>[]}, :output=>{:name=>"appeal_editorial_rejections_response", :fields=>[]}, :original_name=>"AppealEditorialRejections"}, :get_editorial_reasons_by_ids=>{:input=>{:name=>"get_editorial_reasons_by_ids_request", :fields=>[]}, :output=>{:name=>"get_editorial_reasons_by_ids_response", :fields=>[]}, :original_name=>"GetEditorialReasonsByIds"}, :get_account_migration_statuses=>{:input=>{:name=>"get_account_migration_statuses_request", :fields=>[]}, :output=>{:name=>"get_account_migration_statuses_response", :fields=>[]}, :original_name=>"GetAccountMigrationStatuses"}, :set_account_properties=>{:input=>{:name=>"set_account_properties_request", :fields=>[]}, :output=>{:name=>"set_account_properties_response", :fields=>[]}, :original_name=>"SetAccountProperties"}, :get_account_properties=>{:input=>{:name=>"get_account_properties_request", :fields=>[]}, :output=>{:name=>"get_account_properties_response", :fields=>[]}, :original_name=>"GetAccountProperties"}, :add_ad_extensions=>{:input=>{:name=>"add_ad_extensions_request", :fields=>[]}, :output=>{:name=>"add_ad_extensions_response", :fields=>[]}, :original_name=>"AddAdExtensions"}, :get_ad_extensions_by_ids=>{:input=>{:name=>"get_ad_extensions_by_ids_request", :fields=>[]}, :output=>{:name=>"get_ad_extensions_by_ids_response", :fields=>[]}, :original_name=>"GetAdExtensionsByIds"}, :update_ad_extensions=>{:input=>{:name=>"update_ad_extensions_request", :fields=>[]}, :output=>{:name=>"update_ad_extensions_response", :fields=>[]}, :original_name=>"UpdateAdExtensions"}, :delete_ad_extensions=>{:input=>{:name=>"delete_ad_extensions_request", :fields=>[]}, :output=>{:name=>"delete_ad_extensions_response", :fields=>[]}, :original_name=>"DeleteAdExtensions"}, :get_ad_extensions_editorial_reasons=>{:input=>{:name=>"get_ad_extensions_editorial_reasons_request", :fields=>[]}, :output=>{:name=>"get_ad_extensions_editorial_reasons_response", :fields=>[]}, :original_name=>"GetAdExtensionsEditorialReasons"}, :set_ad_extensions_associations=>{:input=>{:name=>"set_ad_extensions_associations_request", :fields=>[]}, :output=>{:name=>"set_ad_extensions_associations_response", :fields=>[]}, :original_name=>"SetAdExtensionsAssociations"}, :get_ad_extensions_associations=>{:input=>{:name=>"get_ad_extensions_associations_request", :fields=>[]}, :output=>{:name=>"get_ad_extensions_associations_response", :fields=>[]}, :original_name=>"GetAdExtensionsAssociations"}, :delete_ad_extensions_associations=>{:input=>{:name=>"delete_ad_extensions_associations_request", :fields=>[]}, :output=>{:name=>"delete_ad_extensions_associations_response", :fields=>[]}, :original_name=>"DeleteAdExtensionsAssociations"}, :get_ad_extension_ids_by_account_id=>{:input=>{:name=>"get_ad_extension_ids_by_account_id_request", :fields=>[]}, :output=>{:name=>"get_ad_extension_ids_by_account_id_response", :fields=>[]}, :original_name=>"GetAdExtensionIdsByAccountId"}, :add_media=>{:input=>{:name=>"add_media_request", :fields=>[]}, :output=>{:name=>"add_media_response", :fields=>[]}, :original_name=>"AddMedia"}, :delete_media=>{:input=>{:name=>"delete_media_request", :fields=>[]}, :output=>{:name=>"delete_media_response", :fields=>[]}, :original_name=>"DeleteMedia"}, :get_media_meta_data_by_account_id=>{:input=>{:name=>"get_media_meta_data_by_account_id_request", :fields=>[]}, :output=>{:name=>"get_media_meta_data_by_account_id_response", :fields=>[]}, :original_name=>"GetMediaMetaDataByAccountId"}, :get_media_meta_data_by_ids=>{:input=>{:name=>"get_media_meta_data_by_ids_request", :fields=>[]}, :output=>{:name=>"get_media_meta_data_by_ids_response", :fields=>[]}, :original_name=>"GetMediaMetaDataByIds"}, :get_media_associations=>{:input=>{:name=>"get_media_associations_request", :fields=>[]}, :output=>{:name=>"get_media_associations_response", :fields=>[]}, :original_name=>"GetMediaAssociations"}, :get_ad_group_criterions_by_ids=>{:input=>{:name=>"get_ad_group_criterions_by_ids_request", :fields=>[]}, :output=>{:name=>"get_ad_group_criterions_by_ids_response", :fields=>[]}, :original_name=>"GetAdGroupCriterionsByIds"}, :add_ad_group_criterions=>{:input=>{:name=>"add_ad_group_criterions_request", :fields=>[]}, :output=>{:name=>"add_ad_group_criterions_response", :fields=>[]}, :original_name=>"AddAdGroupCriterions"}, :update_ad_group_criterions=>{:input=>{:name=>"update_ad_group_criterions_request", :fields=>[]}, :output=>{:name=>"update_ad_group_criterions_response", :fields=>[]}, :original_name=>"UpdateAdGroupCriterions"}, :delete_ad_group_criterions=>{:input=>{:name=>"delete_ad_group_criterions_request", :fields=>[]}, :output=>{:name=>"delete_ad_group_criterions_response", :fields=>[]}, :original_name=>"DeleteAdGroupCriterions"}, :apply_product_partition_actions=>{:input=>{:name=>"apply_product_partition_actions_request", :fields=>[]}, :output=>{:name=>"apply_product_partition_actions_response", :fields=>[]}, :original_name=>"ApplyProductPartitionActions"}, :get_bmc_stores_by_customer_id=>{:input=>{:name=>"get_bmc_stores_by_customer_id_request", :fields=>[]}, :output=>{:name=>"get_bmc_stores_by_customer_id_response", :fields=>[]}, :original_name=>"GetBMCStoresByCustomerId"}, :add_negative_keywords_to_entities=>{:input=>{:name=>"add_negative_keywords_to_entities_request", :fields=>[]}, :output=>{:name=>"add_negative_keywords_to_entities_response", :fields=>[]}, :original_name=>"AddNegativeKeywordsToEntities"}, :get_negative_keywords_by_entity_ids=>{:input=>{:name=>"get_negative_keywords_by_entity_ids_request", :fields=>[]}, :output=>{:name=>"get_negative_keywords_by_entity_ids_response", :fields=>[]}, :original_name=>"GetNegativeKeywordsByEntityIds"}, :delete_negative_keywords_from_entities=>{:input=>{:name=>"delete_negative_keywords_from_entities_request", :fields=>[]}, :output=>{:name=>"delete_negative_keywords_from_entities_response", :fields=>[]}, :original_name=>"DeleteNegativeKeywordsFromEntities"}, :get_shared_entities_by_account_id=>{:input=>{:name=>"get_shared_entities_by_account_id_request", :fields=>[]}, :output=>{:name=>"get_shared_entities_by_account_id_response", :fields=>[]}, :original_name=>"GetSharedEntitiesByAccountId"}, :get_shared_entities=>{:input=>{:name=>"get_shared_entities_request", :fields=>[]}, :output=>{:name=>"get_shared_entities_response", :fields=>[]}, :original_name=>"GetSharedEntities"}, :add_shared_entity=>{:input=>{:name=>"add_shared_entity_request", :fields=>[]}, :output=>{:name=>"add_shared_entity_response", :fields=>[]}, :original_name=>"AddSharedEntity"}, :get_list_items_by_shared_list=>{:input=>{:name=>"get_list_items_by_shared_list_request", :fields=>[]}, :output=>{:name=>"get_list_items_by_shared_list_response", :fields=>[]}, :original_name=>"GetListItemsBySharedList"}, :add_list_items_to_shared_list=>{:input=>{:name=>"add_list_items_to_shared_list_request", :fields=>[]}, :output=>{:name=>"add_list_items_to_shared_list_response", :fields=>[]}, :original_name=>"AddListItemsToSharedList"}, :update_shared_entities=>{:input=>{:name=>"update_shared_entities_request", :fields=>[]}, :output=>{:name=>"update_shared_entities_response", :fields=>[]}, :original_name=>"UpdateSharedEntities"}, :delete_list_items_from_shared_list=>{:input=>{:name=>"delete_list_items_from_shared_list_request", :fields=>[]}, :output=>{:name=>"delete_list_items_from_shared_list_response", :fields=>[]}, :original_name=>"DeleteListItemsFromSharedList"}, :set_shared_entity_associations=>{:input=>{:name=>"set_shared_entity_associations_request", :fields=>[]}, :output=>{:name=>"set_shared_entity_associations_response", :fields=>[]}, :original_name=>"SetSharedEntityAssociations"}, :delete_shared_entity_associations=>{:input=>{:name=>"delete_shared_entity_associations_request", :fields=>[]}, :output=>{:name=>"delete_shared_entity_associations_response", :fields=>[]}, :original_name=>"DeleteSharedEntityAssociations"}, :get_shared_entity_associations_by_shared_entity_ids=>{:input=>{:name=>"get_shared_entity_associations_by_shared_entity_ids_request", :fields=>[]}, :output=>{:name=>"get_shared_entity_associations_by_shared_entity_ids_response", :fields=>[]}, :original_name=>"GetSharedEntityAssociationsBySharedEntityIds"}, :get_shared_entity_associations_by_entity_ids=>{:input=>{:name=>"get_shared_entity_associations_by_entity_ids_request", :fields=>[]}, :output=>{:name=>"get_shared_entity_associations_by_entity_ids_response", :fields=>[]}, :original_name=>"GetSharedEntityAssociationsByEntityIds"}, :delete_shared_entities=>{:input=>{:name=>"delete_shared_entities_request", :fields=>[]}, :output=>{:name=>"delete_shared_entities_response", :fields=>[]}, :original_name=>"DeleteSharedEntities"}, :get_campaign_sizes_by_account_id=>{:input=>{:name=>"get_campaign_sizes_by_account_id_request", :fields=>[]}, :output=>{:name=>"get_campaign_sizes_by_account_id_response", :fields=>[]}, :original_name=>"GetCampaignSizesByAccountId"}, :add_campaign_criterions=>{:input=>{:name=>"add_campaign_criterions_request", :fields=>[]}, :output=>{:name=>"add_campaign_criterions_response", :fields=>[]}, :original_name=>"AddCampaignCriterions"}, :update_campaign_criterions=>{:input=>{:name=>"update_campaign_criterions_request", :fields=>[]}, :output=>{:name=>"update_campaign_criterions_response", :fields=>[]}, :original_name=>"UpdateCampaignCriterions"}, :delete_campaign_criterions=>{:input=>{:name=>"delete_campaign_criterions_request", :fields=>[]}, :output=>{:name=>"delete_campaign_criterions_response", :fields=>[]}, :original_name=>"DeleteCampaignCriterions"}, :get_campaign_criterions_by_ids=>{:input=>{:name=>"get_campaign_criterions_by_ids_request", :fields=>[]}, :output=>{:name=>"get_campaign_criterions_by_ids_response", :fields=>[]}, :original_name=>"GetCampaignCriterionsByIds"}, :add_budgets=>{:input=>{:name=>"add_budgets_request", :fields=>[]}, :output=>{:name=>"add_budgets_response", :fields=>[]}, :original_name=>"AddBudgets"}, :update_budgets=>{:input=>{:name=>"update_budgets_request", :fields=>[]}, :output=>{:name=>"update_budgets_response", :fields=>[]}, :original_name=>"UpdateBudgets"}, :delete_budgets=>{:input=>{:name=>"delete_budgets_request", :fields=>[]}, :output=>{:name=>"delete_budgets_response", :fields=>[]}, :original_name=>"DeleteBudgets"}, :get_budgets_by_ids=>{:input=>{:name=>"get_budgets_by_ids_request", :fields=>[]}, :output=>{:name=>"get_budgets_by_ids_response", :fields=>[]}, :original_name=>"GetBudgetsByIds"}, :get_campaign_ids_by_budget_ids=>{:input=>{:name=>"get_campaign_ids_by_budget_ids_request", :fields=>[]}, :output=>{:name=>"get_campaign_ids_by_budget_ids_response", :fields=>[]}, :original_name=>"GetCampaignIdsByBudgetIds"}, :add_bid_strategies=>{:input=>{:name=>"add_bid_strategies_request", :fields=>[]}, :output=>{:name=>"add_bid_strategies_response", :fields=>[]}, :original_name=>"AddBidStrategies"}, :update_bid_strategies=>{:input=>{:name=>"update_bid_strategies_request", :fields=>[]}, :output=>{:name=>"update_bid_strategies_response", :fields=>[]}, :original_name=>"UpdateBidStrategies"}, :delete_bid_strategies=>{:input=>{:name=>"delete_bid_strategies_request", :fields=>[]}, :output=>{:name=>"delete_bid_strategies_response", :fields=>[]}, :original_name=>"DeleteBidStrategies"}, :get_bid_strategies_by_ids=>{:input=>{:name=>"get_bid_strategies_by_ids_request", :fields=>[]}, :output=>{:name=>"get_bid_strategies_by_ids_response", :fields=>[]}, :original_name=>"GetBidStrategiesByIds"}, :get_campaign_ids_by_bid_strategy_ids=>{:input=>{:name=>"get_campaign_ids_by_bid_strategy_ids_request", :fields=>[]}, :output=>{:name=>"get_campaign_ids_by_bid_strategy_ids_response", :fields=>[]}, :original_name=>"GetCampaignIdsByBidStrategyIds"}, :add_audiences=>{:input=>{:name=>"add_audiences_request", :fields=>[]}, :output=>{:name=>"add_audiences_response", :fields=>[]}, :original_name=>"AddAudiences"}, :update_audiences=>{:input=>{:name=>"update_audiences_request", :fields=>[]}, :output=>{:name=>"update_audiences_response", :fields=>[]}, :original_name=>"UpdateAudiences"}, :delete_audiences=>{:input=>{:name=>"delete_audiences_request", :fields=>[]}, :output=>{:name=>"delete_audiences_response", :fields=>[]}, :original_name=>"DeleteAudiences"}, :get_audiences_by_ids=>{:input=>{:name=>"get_audiences_by_ids_request", :fields=>[]}, :output=>{:name=>"get_audiences_by_ids_response", :fields=>[]}, :original_name=>"GetAudiencesByIds"}, :get_uet_tags_by_ids=>{:input=>{:name=>"get_uet_tags_by_ids_request", :fields=>[]}, :output=>{:name=>"get_uet_tags_by_ids_response", :fields=>[]}, :original_name=>"GetUetTagsByIds"}, :add_uet_tags=>{:input=>{:name=>"add_uet_tags_request", :fields=>[]}, :output=>{:name=>"add_uet_tags_response", :fields=>[]}, :original_name=>"AddUetTags"}, :update_uet_tags=>{:input=>{:name=>"update_uet_tags_request", :fields=>[]}, :output=>{:name=>"update_uet_tags_response", :fields=>[]}, :original_name=>"UpdateUetTags"}, :get_conversion_goals_by_ids=>{:input=>{:name=>"get_conversion_goals_by_ids_request", :fields=>[]}, :output=>{:name=>"get_conversion_goals_by_ids_response", :fields=>[]}, :original_name=>"GetConversionGoalsByIds"}, :get_conversion_goals_by_tag_ids=>{:input=>{:name=>"get_conversion_goals_by_tag_ids_request", :fields=>[]}, :output=>{:name=>"get_conversion_goals_by_tag_ids_response", :fields=>[]}, :original_name=>"GetConversionGoalsByTagIds"}, :add_conversion_goals=>{:input=>{:name=>"add_conversion_goals_request", :fields=>[]}, :output=>{:name=>"add_conversion_goals_response", :fields=>[]}, :original_name=>"AddConversionGoals"}, :update_conversion_goals=>{:input=>{:name=>"update_conversion_goals_request", :fields=>[]}, :output=>{:name=>"update_conversion_goals_response", :fields=>[]}, :original_name=>"UpdateConversionGoals"}, :apply_offline_conversions=>{:input=>{:name=>"apply_offline_conversions_request", :fields=>[]}, :output=>{:name=>"apply_offline_conversions_response", :fields=>[]}, :original_name=>"ApplyOfflineConversions"}, :apply_offline_conversion_adjustments=>{:input=>{:name=>"apply_offline_conversion_adjustments_request", :fields=>[]}, :output=>{:name=>"apply_offline_conversion_adjustments_response", :fields=>[]}, :original_name=>"ApplyOfflineConversionAdjustments"}, :add_labels=>{:input=>{:name=>"add_labels_request", :fields=>[]}, :output=>{:name=>"add_labels_response", :fields=>[]}, :original_name=>"AddLabels"}, :delete_labels=>{:input=>{:name=>"delete_labels_request", :fields=>[]}, :output=>{:name=>"delete_labels_response", :fields=>[]}, :original_name=>"DeleteLabels"}, :update_labels=>{:input=>{:name=>"update_labels_request", :fields=>[]}, :output=>{:name=>"update_labels_response", :fields=>[]}, :original_name=>"UpdateLabels"}, :get_labels_by_ids=>{:input=>{:name=>"get_labels_by_ids_request", :fields=>[]}, :output=>{:name=>"get_labels_by_ids_response", :fields=>[]}, :original_name=>"GetLabelsByIds"}, :set_label_associations=>{:input=>{:name=>"set_label_associations_request", :fields=>[]}, :output=>{:name=>"set_label_associations_response", :fields=>[]}, :original_name=>"SetLabelAssociations"}, :delete_label_associations=>{:input=>{:name=>"delete_label_associations_request", :fields=>[]}, :output=>{:name=>"delete_label_associations_response", :fields=>[]}, :original_name=>"DeleteLabelAssociations"}, :get_label_associations_by_entity_ids=>{:input=>{:name=>"get_label_associations_by_entity_ids_request", :fields=>[]}, :output=>{:name=>"get_label_associations_by_entity_ids_response", :fields=>[]}, :original_name=>"GetLabelAssociationsByEntityIds"}, :get_label_associations_by_label_ids=>{:input=>{:name=>"get_label_associations_by_label_ids_request", :fields=>[]}, :output=>{:name=>"get_label_associations_by_label_ids_response", :fields=>[]}, :original_name=>"GetLabelAssociationsByLabelIds"}, :add_experiments=>{:input=>{:name=>"add_experiments_request", :fields=>[]}, :output=>{:name=>"add_experiments_response", :fields=>[]}, :original_name=>"AddExperiments"}, :delete_experiments=>{:input=>{:name=>"delete_experiments_request", :fields=>[]}, :output=>{:name=>"delete_experiments_response", :fields=>[]}, :original_name=>"DeleteExperiments"}, :update_experiments=>{:input=>{:name=>"update_experiments_request", :fields=>[]}, :output=>{:name=>"update_experiments_response", :fields=>[]}, :original_name=>"UpdateExperiments"}, :get_experiments_by_ids=>{:input=>{:name=>"get_experiments_by_ids_request", :fields=>[]}, :output=>{:name=>"get_experiments_by_ids_response", :fields=>[]}, :original_name=>"GetExperimentsByIds"}, :get_profile_data_file_url=>{:input=>{:name=>"get_profile_data_file_url_request", :fields=>[]}, :output=>{:name=>"get_profile_data_file_url_response", :fields=>[]}, :original_name=>"GetProfileDataFileUrl"}, :search_companies=>{:input=>{:name=>"search_companies_request", :fields=>[]}, :output=>{:name=>"search_companies_response", :fields=>[]}, :original_name=>"SearchCompanies"}, :get_file_import_upload_url=>{:input=>{:name=>"get_file_import_upload_url_request", :fields=>[]}, :output=>{:name=>"get_file_import_upload_url_response", :fields=>[]}, :original_name=>"GetFileImportUploadUrl"}, :add_import_jobs=>{:input=>{:name=>"add_import_jobs_request", :fields=>[]}, :output=>{:name=>"add_import_jobs_response", :fields=>[]}, :original_name=>"AddImportJobs"}, :get_import_results=>{:input=>{:name=>"get_import_results_request", :fields=>[]}, :output=>{:name=>"get_import_results_response", :fields=>[]}, :original_name=>"GetImportResults"}, :get_import_jobs_by_ids=>{:input=>{:name=>"get_import_jobs_by_ids_request", :fields=>[]}, :output=>{:name=>"get_import_jobs_by_ids_response", :fields=>[]}, :original_name=>"GetImportJobsByIds"}, :delete_import_jobs=>{:input=>{:name=>"delete_import_jobs_request", :fields=>[]}, :output=>{:name=>"delete_import_jobs_response", :fields=>[]}, :original_name=>"DeleteImportJobs"}, :get_import_entity_ids_mapping=>{:input=>{:name=>"get_import_entity_ids_mapping_request", :fields=>[]}, :output=>{:name=>"get_import_entity_ids_mapping_response", :fields=>[]}, :original_name=>"GetImportEntityIdsMapping"}, :update_import_jobs=>{:input=>{:name=>"update_import_jobs_request", :fields=>[]}, :output=>{:name=>"update_import_jobs_response", :fields=>[]}, :original_name=>"UpdateImportJobs"}, :add_videos=>{:input=>{:name=>"add_videos_request", :fields=>[]}, :output=>{:name=>"add_videos_response", :fields=>[]}, :original_name=>"AddVideos"}, :delete_videos=>{:input=>{:name=>"delete_videos_request", :fields=>[]}, :output=>{:name=>"delete_videos_response", :fields=>[]}, :original_name=>"DeleteVideos"}, :get_videos_by_ids=>{:input=>{:name=>"get_videos_by_ids_request", :fields=>[]}, :output=>{:name=>"get_videos_by_ids_response", :fields=>[]}, :original_name=>"GetVideosByIds"}, :update_videos=>{:input=>{:name=>"update_videos_request", :fields=>[]}, :output=>{:name=>"update_videos_response", :fields=>[]}, :original_name=>"UpdateVideos"}, :add_campaign_conversion_goals=>{:input=>{:name=>"add_campaign_conversion_goals_request", :fields=>[]}, :output=>{:name=>"add_campaign_conversion_goals_response", :fields=>[]}, :original_name=>"AddCampaignConversionGoals"}, :delete_campaign_conversion_goals=>{:input=>{:name=>"delete_campaign_conversion_goals_request", :fields=>[]}, :output=>{:name=>"delete_campaign_conversion_goals_response", :fields=>[]}, :original_name=>"DeleteCampaignConversionGoals"}} + CAMPAIGNMANAGEMENTSERVICE_TYPES = {} + CAMPAIGNMANAGEMENTSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return CAMPAIGNMANAGEMENTSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return CAMPAIGNMANAGEMENTSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return CAMPAIGNMANAGEMENTSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/lib/bing_ads_api/v13/customer_billing_service.rb b/lib/bing_ads_api/v13/customer_billing_service.rb new file mode 100644 index 0000000..7785473 --- /dev/null +++ b/lib/bing_ads_api/v13/customer_billing_service.rb @@ -0,0 +1,65 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:02. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/customer_billing_service_registry' + + module BingAdsApi; module V13; module CustomerBillingService + class CustomerBillingService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/Billing/v13' + super(config, endpoint, namespace, :v13) + end + + def get_billing_documents_info(*args, &block) + return execute_action('get_billing_documents_info', args, &block) + end + + def get_billing_documents(*args, &block) + return execute_action('get_billing_documents', args, &block) + end + + def add_insertion_order(*args, &block) + return execute_action('add_insertion_order', args, &block) + end + + def update_insertion_order(*args, &block) + return execute_action('update_insertion_order', args, &block) + end + + def search_insertion_orders(*args, &block) + return execute_action('search_insertion_orders', args, &block) + end + + def get_account_monthly_spend(*args, &block) + return execute_action('get_account_monthly_spend', args, &block) + end + + def dispatch_coupons(*args, &block) + return execute_action('dispatch_coupons', args, &block) + end + + def redeem_coupon(*args, &block) + return execute_action('redeem_coupon', args, &block) + end + + def search_coupons(*args, &block) + return execute_action('search_coupons', args, &block) + end + + private + + def get_service_registry() + return CustomerBillingServiceRegistry + end + + def get_module() + return BingAdsApi::V13::CustomerBillingService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/customer_billing_service_registry.rb b/lib/bing_ads_api/v13/customer_billing_service_registry.rb new file mode 100644 index 0000000..8dbf1c4 --- /dev/null +++ b/lib/bing_ads_api/v13/customer_billing_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:02. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module CustomerBillingService + class CustomerBillingServiceRegistry + CUSTOMERBILLINGSERVICE_METHODS = {:get_billing_documents_info=>{:input=>{:name=>"get_billing_documents_info_request", :fields=>[]}, :output=>{:name=>"get_billing_documents_info_response", :fields=>[]}, :original_name=>"GetBillingDocumentsInfo"}, :get_billing_documents=>{:input=>{:name=>"get_billing_documents_request", :fields=>[]}, :output=>{:name=>"get_billing_documents_response", :fields=>[]}, :original_name=>"GetBillingDocuments"}, :add_insertion_order=>{:input=>{:name=>"add_insertion_order_request", :fields=>[]}, :output=>{:name=>"add_insertion_order_response", :fields=>[]}, :original_name=>"AddInsertionOrder"}, :update_insertion_order=>{:input=>{:name=>"update_insertion_order_request", :fields=>[]}, :output=>{:name=>"update_insertion_order_response", :fields=>[]}, :original_name=>"UpdateInsertionOrder"}, :search_insertion_orders=>{:input=>{:name=>"search_insertion_orders_request", :fields=>[]}, :output=>{:name=>"search_insertion_orders_response", :fields=>[]}, :original_name=>"SearchInsertionOrders"}, :get_account_monthly_spend=>{:input=>{:name=>"get_account_monthly_spend_request", :fields=>[]}, :output=>{:name=>"get_account_monthly_spend_response", :fields=>[]}, :original_name=>"GetAccountMonthlySpend"}, :dispatch_coupons=>{:input=>{:name=>"dispatch_coupons_request", :fields=>[]}, :output=>{:name=>"dispatch_coupons_response", :fields=>[]}, :original_name=>"DispatchCoupons"}, :redeem_coupon=>{:input=>{:name=>"redeem_coupon_request", :fields=>[]}, :output=>{:name=>"redeem_coupon_response", :fields=>[]}, :original_name=>"RedeemCoupon"}, :search_coupons=>{:input=>{:name=>"search_coupons_request", :fields=>[]}, :output=>{:name=>"search_coupons_response", :fields=>[]}, :original_name=>"SearchCoupons"}} + CUSTOMERBILLINGSERVICE_TYPES = {} + CUSTOMERBILLINGSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return CUSTOMERBILLINGSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return CUSTOMERBILLINGSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return CUSTOMERBILLINGSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/lib/bing_ads_api/v13/customer_management_service.rb b/lib/bing_ads_api/v13/customer_management_service.rb new file mode 100644 index 0000000..d463aa4 --- /dev/null +++ b/lib/bing_ads_api/v13/customer_management_service.rb @@ -0,0 +1,177 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:05. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/customer_management_service_registry' + + module BingAdsApi; module V13; module CustomerManagementService + class CustomerManagementService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/Customer/v13' + super(config, endpoint, namespace, :v13) + end + + def get_accounts_info(*args, &block) + return execute_action('get_accounts_info', args, &block) + end + + def find_accounts(*args, &block) + return execute_action('find_accounts', args, &block) + end + + def add_account(*args, &block) + return execute_action('add_account', args, &block) + end + + def update_account(*args, &block) + return execute_action('update_account', args, &block) + end + + def get_customer(*args, &block) + return execute_action('get_customer', args, &block) + end + + def update_customer(*args, &block) + return execute_action('update_customer', args, &block) + end + + def signup_customer(*args, &block) + return execute_action('signup_customer', args, &block) + end + + def get_account(*args, &block) + return execute_action('get_account', args, &block) + end + + def get_customers_info(*args, &block) + return execute_action('get_customers_info', args, &block) + end + + def delete_account(*args, &block) + return execute_action('delete_account', args, &block) + end + + def delete_customer(*args, &block) + return execute_action('delete_customer', args, &block) + end + + def update_user(*args, &block) + return execute_action('update_user', args, &block) + end + + def update_user_roles(*args, &block) + return execute_action('update_user_roles', args, &block) + end + + def get_user(*args, &block) + return execute_action('get_user', args, &block) + end + + def get_current_user(*args, &block) + return execute_action('get_current_user', args, &block) + end + + def delete_user(*args, &block) + return execute_action('delete_user', args, &block) + end + + def get_users_info(*args, &block) + return execute_action('get_users_info', args, &block) + end + + def get_customer_pilot_features(*args, &block) + return execute_action('get_customer_pilot_features', args, &block) + end + + def get_account_pilot_features(*args, &block) + return execute_action('get_account_pilot_features', args, &block) + end + + def get_pilot_features_countries(*args, &block) + return execute_action('get_pilot_features_countries', args, &block) + end + + def get_accessible_customer(*args, &block) + return execute_action('get_accessible_customer', args, &block) + end + + def find_accounts_or_customers_info(*args, &block) + return execute_action('find_accounts_or_customers_info', args, &block) + end + + def upgrade_customer_to_agency(*args, &block) + return execute_action('upgrade_customer_to_agency', args, &block) + end + + def add_prepay_account(*args, &block) + return execute_action('add_prepay_account', args, &block) + end + + def update_prepay_account(*args, &block) + return execute_action('update_prepay_account', args, &block) + end + + def map_customer_id_to_external_customer_id(*args, &block) + return execute_action('map_customer_id_to_external_customer_id', args, &block) + end + + def map_account_id_to_external_account_ids(*args, &block) + return execute_action('map_account_id_to_external_account_ids', args, &block) + end + + def search_customers(*args, &block) + return execute_action('search_customers', args, &block) + end + + def add_client_links(*args, &block) + return execute_action('add_client_links', args, &block) + end + + def update_client_links(*args, &block) + return execute_action('update_client_links', args, &block) + end + + def search_client_links(*args, &block) + return execute_action('search_client_links', args, &block) + end + + def search_accounts(*args, &block) + return execute_action('search_accounts', args, &block) + end + + def send_user_invitation(*args, &block) + return execute_action('send_user_invitation', args, &block) + end + + def search_user_invitations(*args, &block) + return execute_action('search_user_invitations', args, &block) + end + + def validate_address(*args, &block) + return execute_action('validate_address', args, &block) + end + + def get_linked_accounts_and_customers_info(*args, &block) + return execute_action('get_linked_accounts_and_customers_info', args, &block) + end + + def get_user_mfa_status(*args, &block) + return execute_action('get_user_mfa_status', args, &block) + end + + private + + def get_service_registry() + return CustomerManagementServiceRegistry + end + + def get_module() + return BingAdsApi::V13::CustomerManagementService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/customer_management_service_registry.rb b/lib/bing_ads_api/v13/customer_management_service_registry.rb new file mode 100644 index 0000000..dc48c46 --- /dev/null +++ b/lib/bing_ads_api/v13/customer_management_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:05. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module CustomerManagementService + class CustomerManagementServiceRegistry + CUSTOMERMANAGEMENTSERVICE_METHODS = {:get_accounts_info=>{:input=>{:name=>"get_accounts_info_request", :fields=>[]}, :output=>{:name=>"get_accounts_info_response", :fields=>[]}, :original_name=>"GetAccountsInfo"}, :find_accounts=>{:input=>{:name=>"find_accounts_request", :fields=>[]}, :output=>{:name=>"find_accounts_response", :fields=>[]}, :original_name=>"FindAccounts"}, :add_account=>{:input=>{:name=>"add_account_request", :fields=>[]}, :output=>{:name=>"add_account_response", :fields=>[]}, :original_name=>"AddAccount"}, :update_account=>{:input=>{:name=>"update_account_request", :fields=>[]}, :output=>{:name=>"update_account_response", :fields=>[]}, :original_name=>"UpdateAccount"}, :get_customer=>{:input=>{:name=>"get_customer_request", :fields=>[]}, :output=>{:name=>"get_customer_response", :fields=>[]}, :original_name=>"GetCustomer"}, :update_customer=>{:input=>{:name=>"update_customer_request", :fields=>[]}, :output=>{:name=>"update_customer_response", :fields=>[]}, :original_name=>"UpdateCustomer"}, :signup_customer=>{:input=>{:name=>"signup_customer_request", :fields=>[]}, :output=>{:name=>"signup_customer_response", :fields=>[]}, :original_name=>"SignupCustomer"}, :get_account=>{:input=>{:name=>"get_account_request", :fields=>[]}, :output=>{:name=>"get_account_response", :fields=>[]}, :original_name=>"GetAccount"}, :get_customers_info=>{:input=>{:name=>"get_customers_info_request", :fields=>[]}, :output=>{:name=>"get_customers_info_response", :fields=>[]}, :original_name=>"GetCustomersInfo"}, :delete_account=>{:input=>{:name=>"delete_account_request", :fields=>[]}, :output=>{:name=>"delete_account_response", :fields=>[]}, :original_name=>"DeleteAccount"}, :delete_customer=>{:input=>{:name=>"delete_customer_request", :fields=>[]}, :output=>{:name=>"delete_customer_response", :fields=>[]}, :original_name=>"DeleteCustomer"}, :update_user=>{:input=>{:name=>"update_user_request", :fields=>[]}, :output=>{:name=>"update_user_response", :fields=>[]}, :original_name=>"UpdateUser"}, :update_user_roles=>{:input=>{:name=>"update_user_roles_request", :fields=>[]}, :output=>{:name=>"update_user_roles_response", :fields=>[]}, :original_name=>"UpdateUserRoles"}, :get_user=>{:input=>{:name=>"get_user_request", :fields=>[]}, :output=>{:name=>"get_user_response", :fields=>[]}, :original_name=>"GetUser"}, :get_current_user=>{:input=>{:name=>"get_current_user_request", :fields=>[]}, :output=>{:name=>"get_current_user_response", :fields=>[]}, :original_name=>"GetCurrentUser"}, :delete_user=>{:input=>{:name=>"delete_user_request", :fields=>[]}, :output=>{:name=>"delete_user_response", :fields=>[]}, :original_name=>"DeleteUser"}, :get_users_info=>{:input=>{:name=>"get_users_info_request", :fields=>[]}, :output=>{:name=>"get_users_info_response", :fields=>[]}, :original_name=>"GetUsersInfo"}, :get_customer_pilot_features=>{:input=>{:name=>"get_customer_pilot_features_request", :fields=>[]}, :output=>{:name=>"get_customer_pilot_features_response", :fields=>[]}, :original_name=>"GetCustomerPilotFeatures"}, :get_account_pilot_features=>{:input=>{:name=>"get_account_pilot_features_request", :fields=>[]}, :output=>{:name=>"get_account_pilot_features_response", :fields=>[]}, :original_name=>"GetAccountPilotFeatures"}, :get_pilot_features_countries=>{:input=>{:name=>"get_pilot_features_countries_request", :fields=>[]}, :output=>{:name=>"get_pilot_features_countries_response", :fields=>[]}, :original_name=>"GetPilotFeaturesCountries"}, :get_accessible_customer=>{:input=>{:name=>"get_accessible_customer_request", :fields=>[]}, :output=>{:name=>"get_accessible_customer_response", :fields=>[]}, :original_name=>"GetAccessibleCustomer"}, :find_accounts_or_customers_info=>{:input=>{:name=>"find_accounts_or_customers_info_request", :fields=>[]}, :output=>{:name=>"find_accounts_or_customers_info_response", :fields=>[]}, :original_name=>"FindAccountsOrCustomersInfo"}, :upgrade_customer_to_agency=>{:input=>{:name=>"upgrade_customer_to_agency_request", :fields=>[]}, :output=>{:name=>"upgrade_customer_to_agency_response", :fields=>[]}, :original_name=>"UpgradeCustomerToAgency"}, :add_prepay_account=>{:input=>{:name=>"add_prepay_account_request", :fields=>[]}, :output=>{:name=>"add_prepay_account_response", :fields=>[]}, :original_name=>"AddPrepayAccount"}, :update_prepay_account=>{:input=>{:name=>"update_prepay_account_request", :fields=>[]}, :output=>{:name=>"update_prepay_account_response", :fields=>[]}, :original_name=>"UpdatePrepayAccount"}, :map_customer_id_to_external_customer_id=>{:input=>{:name=>"map_customer_id_to_external_customer_id_request", :fields=>[]}, :output=>{:name=>"map_customer_id_to_external_customer_id_response", :fields=>[]}, :original_name=>"MapCustomerIdToExternalCustomerId"}, :map_account_id_to_external_account_ids=>{:input=>{:name=>"map_account_id_to_external_account_ids_request", :fields=>[]}, :output=>{:name=>"map_account_id_to_external_account_ids_response", :fields=>[]}, :original_name=>"MapAccountIdToExternalAccountIds"}, :search_customers=>{:input=>{:name=>"search_customers_request", :fields=>[]}, :output=>{:name=>"search_customers_response", :fields=>[]}, :original_name=>"SearchCustomers"}, :add_client_links=>{:input=>{:name=>"add_client_links_request", :fields=>[]}, :output=>{:name=>"add_client_links_response", :fields=>[]}, :original_name=>"AddClientLinks"}, :update_client_links=>{:input=>{:name=>"update_client_links_request", :fields=>[]}, :output=>{:name=>"update_client_links_response", :fields=>[]}, :original_name=>"UpdateClientLinks"}, :search_client_links=>{:input=>{:name=>"search_client_links_request", :fields=>[]}, :output=>{:name=>"search_client_links_response", :fields=>[]}, :original_name=>"SearchClientLinks"}, :search_accounts=>{:input=>{:name=>"search_accounts_request", :fields=>[]}, :output=>{:name=>"search_accounts_response", :fields=>[]}, :original_name=>"SearchAccounts"}, :send_user_invitation=>{:input=>{:name=>"send_user_invitation_request", :fields=>[]}, :output=>{:name=>"send_user_invitation_response", :fields=>[]}, :original_name=>"SendUserInvitation"}, :search_user_invitations=>{:input=>{:name=>"search_user_invitations_request", :fields=>[]}, :output=>{:name=>"search_user_invitations_response", :fields=>[]}, :original_name=>"SearchUserInvitations"}, :validate_address=>{:input=>{:name=>"validate_address_request", :fields=>[]}, :output=>{:name=>"validate_address_response", :fields=>[]}, :original_name=>"ValidateAddress"}, :get_linked_accounts_and_customers_info=>{:input=>{:name=>"get_linked_accounts_and_customers_info_request", :fields=>[]}, :output=>{:name=>"get_linked_accounts_and_customers_info_response", :fields=>[]}, :original_name=>"GetLinkedAccountsAndCustomersInfo"}, :get_user_mfa_status=>{:input=>{:name=>"get_user_mfa_status_request", :fields=>[]}, :output=>{:name=>"get_user_mfa_status_response", :fields=>[]}, :original_name=>"GetUserMFAStatus"}} + CUSTOMERMANAGEMENTSERVICE_TYPES = {} + CUSTOMERMANAGEMENTSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return CUSTOMERMANAGEMENTSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return CUSTOMERMANAGEMENTSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return CUSTOMERMANAGEMENTSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/lib/bing_ads_api/v13/reporting_service.rb b/lib/bing_ads_api/v13/reporting_service.rb new file mode 100644 index 0000000..2b25588 --- /dev/null +++ b/lib/bing_ads_api/v13/reporting_service.rb @@ -0,0 +1,37 @@ + # Encoding: utf-8 + # + # This is auto-generated code, changes will be overwritten. + # + # Copyright:: Copyright 2022, Google Inc. All Rights Reserved. + # License:: Licensed under the Apache License, Version 2.0. + # + # Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:11. + require 'ads_common/savon_service' + require 'bing_ads_api/v13/reporting_service_registry' + + module BingAdsApi; module V13; module ReportingService + class ReportingService < AdsCommonForBingAds::SavonService + def initialize(config, endpoint) + namespace = 'https://bingads.microsoft.com/Reporting/v13' + super(config, endpoint, namespace, :v13) + end + + def submit_generate_report(*args, &block) + return execute_action('submit_generate_report', args, &block) + end + + def poll_generate_report(*args, &block) + return execute_action('poll_generate_report', args, &block) + end + + private + + def get_service_registry() + return ReportingServiceRegistry + end + + def get_module() + return BingAdsApi::V13::ReportingService + end + end + end; end; end \ No newline at end of file diff --git a/lib/bing_ads_api/v13/reporting_service_registry.rb b/lib/bing_ads_api/v13/reporting_service_registry.rb new file mode 100644 index 0000000..6bee822 --- /dev/null +++ b/lib/bing_ads_api/v13/reporting_service_registry.rb @@ -0,0 +1,30 @@ +# Encoding: utf-8 +# +# This is auto-generated code, changes will be overwritten. +# +# Copyright:: Copyright 2022, Google Inc. All Rights Reserved. +# License:: Licensed under the Apache License, Version 2.0. +# +# Code generated by AdsCommon library 1.0.3 on 2022-05-12 03:04:11. + +require 'bing_ads_api/errors' + +module BingAdsApi; module V13; module ReportingService + class ReportingServiceRegistry + REPORTINGSERVICE_METHODS = {:submit_generate_report=>{:input=>{:name=>"submit_generate_report_request", :fields=>[]}, :output=>{:name=>"submit_generate_report_response", :fields=>[]}, :original_name=>"SubmitGenerateReport"}, :poll_generate_report=>{:input=>{:name=>"poll_generate_report_request", :fields=>[]}, :output=>{:name=>"poll_generate_report_response", :fields=>[]}, :original_name=>"PollGenerateReport"}} + REPORTINGSERVICE_TYPES = {} + REPORTINGSERVICE_NAMESPACES = [] + + def self.get_method_signature(method_name) + return REPORTINGSERVICE_METHODS[method_name.to_sym] + end + + def self.get_type_signature(type_name) + return REPORTINGSERVICE_TYPES[type_name.to_sym] + end + + def self.get_namespace(index) + return REPORTINGSERVICE_NAMESPACES[index] + end + end +end; end; end diff --git a/rakefile.rb b/rakefile.rb index e81bacf..8ab6a56 100644 --- a/rakefile.rb +++ b/rakefile.rb @@ -9,6 +9,8 @@ require 'rake' require 'rdoc/task' require "rspec/core/rake_task" +require 'dotenv' +require 'net/http' desc "Run all test with spec" RSpec::Core::RakeTask.new('spec') do |spec| @@ -41,7 +43,7 @@ logger = Logger.new(STDOUT) logger.level = Logger::INFO api_config = BingAdsApi::ApiConfig - versions = api_config.versions() + versions = [:v13] versions.each do |version| code_path = 'lib/%s/%s' % [api_config.api_name.to_s.snakecase, version] wsdls = BingAdsApi::ApiConfig.get_wsdls(version) @@ -52,3 +54,29 @@ end end end + +task :refresh_dotenv do + FILENAME = ".env.test.local" + + env = Dotenv::Parser.new(File.read(FILENAME)).call + + uri = URI("https://login.microsoftonline.com/common/oauth2/v2.0/token") + params = { + :grant_type => 'refresh_token', + :refresh_token => env["REFRESH_TOKEN"], + :client_id => env["OAUTH2_CLIENT_ID"], + :client_secret => env["OAUTH2_CLIENT_SECRET"] + } + + json = Net::HTTP.post_form(uri, params).body + + refreshed_credential_values = JSON.parse(json) + + env['ACCESS_TOKEN'] = refreshed_credential_values['access_token'] + + env_file = env.map { |row| row.join('=') }.join("\n") + + File.write(FILENAME, env_file) + + puts "Written new token to #{FILENAME}" +end \ No newline at end of file diff --git a/spec/bing_ads_api_spec.rb b/spec/bing_ads_api_spec.rb index 67c28d0..72689c5 100644 --- a/spec/bing_ads_api_spec.rb +++ b/spec/bing_ads_api_spec.rb @@ -1,114 +1,203 @@ require 'spec_helper' describe BingAdsApi do - it "comes from a module" do #simple test to init tests - BingAdsApi.should be_a_kind_of(Module) - end -end + let(:customer_id) { ENV.fetch('CUSTOMER_ID') } + let(:customer_account_id) { ENV.fetch('CUSTOMER_ACCOUNT_ID') } + let(:developer_token) { ENV.fetch('DEVELOPER_TOKEN') } + let(:oauth2_client_id) { ENV.fetch('OAUTH2_CLIENT_ID') } + let(:oauth2_client_secret) { ENV.fetch('OAUTH2_CLIENT_SECRET') } + let(:access_token) { ENV.fetch('ACCESS_TOKEN') } + let(:refresh_token) { ENV.fetch('REFRESH_TOKEN') } -describe BingAdsApi do - before(:all) do #once (and could be modified by the following tests) - $default_customer_id = '8000081' - $default_customer_account_id = '138537' - #$default_customer_id = '18007506' - #$default_customer_account_id = '1671592' - Savon.configure do |config| - config.pretty_print_xml = true - end + let(:bing_ads) do + BingAdsApi::Api.new( + authentication: { + method: :OAuth2, + developer_token: developer_token, + customer_id: customer_id, + customer_account_id: customer_account_id, + oauth2_client_id: oauth2_client_id, + oauth2_client_secret: oauth2_client_secret, + oauth2_token: { + :access_token => access_token, + :refresh_token => refresh_token + } + }, + service: { environment: 'PRODUCTION' }, + library: { log_level: 'DEBUG' } + ) end - it "authenticates" do - lambda{ - $bing_ads = BingAdsApi::Api.new({ - :authentication => { - :method => 'ClientLogin', - :developer_token => 'DEVELOPER_TOKEN', - :password => 'PASSWORD', - :user_name => 'USERNAME', - :customer_id => $default_customer_id, - :customer_account_id => $default_customer_account_id - }, - :service => {:environment => 'SANDBOX'}, - :library => {:log_level => 'DEBUG'} - }) - }.should_not raise_error + + it 'comes from a module' do # simple test to init tests + BingAdsApi.should be_a_kind_of(Module) end - context "handles AdministrationService V7: " do - it "selects the service" do - lambda{ $admin_srv7 = $bing_ads.service(:AdministrationService, :v7)}.should_not raise_error - end - it "get_assigned_quota" do - $admin_srv7.get_assigned_quota().should be_a_kind_of(Hash) - end - it "get_remaining_quota" do - $admin_srv7.get_remaining_quota().should be_a_kind_of(Hash) - end + it 'authenticates' do + expect { bing_ads }.to_not raise_error end - context "handles CampaignManagementService V7: " do - it "selects the service" do - lambda{ $campaign_srv7 = $bing_ads.service(:CampaignManagementService, :v7)}.should_not raise_error - end - it "add_campaigns" do - $campaign_srv7.add_campaigns({:account_id => $default_customer_account_id, - :campaigns => {:campaign => [{:budget_type => "DailyBudgetWithMaximumMonthlySpend", - :conversion_tracking_enabled => false, - :daily_budget => 5, - :daylight_saving => false, - :description => "A perfect new campaign", - :monthly_budget => 50, - :name => "perfectcampaign", - :time_zone => "BrusselsCopenhagenMadridParis"}]}}).should be_a_kind_of(Hash) - end - it "get_campaigns_by_account_id" do - $campaign_srv7.get_campaigns_by_account_id({:account_id => $default_customer_account_id}).should be_a_kind_of(Hash) - end + let(:service) do + bing_ads.service(svc, version) end - context "handles CustomerManagementService V7: " do - # get_account, add_account, update_account, delete_account - # get_customers_info, get_customer, update_customer, signup_customer, delete_customer, get_customer_pilot_feature - # add_user, update_user, update_user_roles, get_user, delete_user, get_users_info - it "selects the service" do - lambda{ $customer_srv7 = $bing_ads.service(:CustomerManagementService, :v7)}.should_not raise_error - end - it "get_customer" do - $customer = $customer_srv7.get_customer({:customer_id => $default_customer_id}) - $customer.should be_a_kind_of(Hash) - puts "$customer=#{$customer}" - end - it "get_user" do - $user = $customer_srv7.get_user({:user_id => '226562'}) - $user.should be_a_kind_of(Hash) + context 'v13' do + let(:version) { :v13 } + + context 'CampaignManagementService' do + let(:svc) { :CampaignManagementService } + + it 'selects the service' do + expect { service }.to_not raise_error + end + + xit 'add_campaigns' do + service.add_campaigns( + account_id: customer_account_id, + campaigns: { + campaign: [ + { + budget_type: 'DailyBudgetWithMaximumMonthlySpend', + conversion_tracking_enabled: false, + daily_budget: 5, + daylight_saving: false, + description: 'A perfect new campaign', + monthly_budget: 50, + name: 'perfectcampaign', + time_zone: 'BrusselsCopenhagenMadridParis' + } + ] + } + ).should be_a_kind_of(Hash) + end + + xit 'get_campaigns_by_account_id' do + service.get_campaigns_by_account_id({ account_id: customer_account_id }).should be_a_kind_of(Hash) + end end - it "get_accounts_info" do - $customer_accounts = $customer_srv7.get_accounts_info({:customer_id => $default_customer_id}) - $customer_accounts.should be_a_kind_of(Hash) + + context 'CampaignManagementService' do + let(:svc) { :CampaignManagementService } + + it 'get_campaigns_by_account_id' do + VCR.use_cassette('CampaignManagementService') do + campaigns = service.get_campaigns_by_account_id({ account_id: customer_account_id}) + #campaigns.should be_a_kind_of(Hash) + puts "campaigns=#{campaigns}" + end + end end - it "get_account" do - $customer_account = $customer_srv7.get_account({:account_id => $customer_accounts[:accounts_info][:account_info][:id]}) - $customer_account.should be_a_kind_of(Hash) + + context 'ReportingService' do + let(:svc) { :ReportingService } + + let(:message) do + { + :report_request => { + :format => "Tsv", + :language => "English", + :report_name => "MyReport", + :return_only_complete_data => false, + :aggregation => "Daily", + :columns => { + :campaign_performance_report_column => [ + "AccountId", + "AccountName", + "CampaignId", + "CampaignName", + "DeliveredMatchType", + "AverageCpc", + "AdDistribution", + "CurrencyCode", + "Impressions", + "Clicks", + "Ctr", + "CostPerConversion", + "Spend", + "AveragePosition", + "TimePeriod", + "CampaignStatus", + "DeviceType" + ], + }, + :scope => { + :account_ids => {'arr:long' => customer_account_id}, + }, + :time => { + :custom_date_range_end => { + :day => 3, + :month => 3, + :year => 2022, + }, + :custom_date_range_start => { + :day => 1, + :month => 3, + :year => 2022, + }, + } + }, + :attributes! => { + :report_request => { 'xsi:type' => 'CampaignPerformanceReportRequest', 'xsi:nil' => false} + } + } + end + + it 'submit_generate_report' do + VCR.use_cassette('ReportingService') do + report = service.submit_generate_report(message) + puts "report=#{report}" + end + end end - #it "get_users_info" do #DOES NOT WORK IN SANDBOX - # $users_info = $customer_srv7.get_users_info({:customer_id => $default_customer_id}) - # $users_info.should be_a_kind_of(Hash) - #end - #it "get customers info" do #DOES NOT WORK IN SANDBOX - # $customers_infos = $customer_srv7.get_customers_info({}) - # $customers_infos.should be_a_kind_of(Hash) - #end - #it "signup_customer" do #DOES NOT WORK IN SANDBOX - # $customer_srv7.signup_customer({:account => {}, - # :application_scope => "Advertiser", - # :customer => {:id => c[:id], :customer_address => c[:customer_address], :industry => c[:industry], :market => c[:market], :name => c[:name], :time_stamp => c[:time_stamp]}, - # :parent_customer_id => $customer[:customer][:id], - # :user => {}}).should be_a_kind_of(Hash) - #end - #it "update_customer" do #DOES NOT WORK IN SANDBOX - # c = $customer[:customer] - # $customer_srv7.update_customer({:customer => {:id => c[:id], :customer_address => c[:customer_address], :industry => c[:industry], :market => c[:market], :name => c[:name], :time_stamp => c[:time_stamp]}}).should be_a_kind_of(Hash) - #end - end + context 'CustomerManagementService' do + let(:svc) { :CustomerManagementService } + + # get_account, add_account, update_account, delete_account + # get_customers_info, get_customer, update_customer, signup_customer, delete_customer, get_customer_pilot_feature + # add_user, update_user, update_user_roles, get_user, delete_user, get_users_info + xit 'get_customer' do + customer = service.get_customer({ customer_id: customer_id}) + customer.should be_a_kind_of(Hash) + puts "customer=#{customer}" + end + + xit 'get_user' do + user = service.get_user({ user_id: '226562' }) + user.should be_a_kind_of(Hash) + end -end \ No newline at end of file + xit 'get_accounts_info' do + customer_accounts = service.get_accounts_info({ customer_id: customer_id}) + customer_accounts.should be_a_kind_of(Hash) + end + + xit 'get_account' do + customer_account = service.get_account({ account_id: $customer_accounts[:accounts_info][:account_info][:id] }) + customer_account.should be_a_kind_of(Hash) + end + + xit "get_users_info" do #DOES NOT WORK IN SANDBOX + users_info = service.get_users_info({:customer_id => customer_id}) + users_info.should be_a_kind_of(Hash) + end + + xit "get customers info" do #DOES NOT WORK IN SANDBOX + customers_infos = service.get_customers_info({}) + customers_infos.should be_a_kind_of(Hash) + end + + xit "signup_customer" do #DOES NOT WORK IN SANDBOX + service.signup_customer({:account => {}, + :application_scope => "Advertiser", + :customer => {:id => c[:id], :customer_address => c[:customer_address], :industry => c[:industry], :market => c[:market], :name => c[:name], :time_stamp => c[:time_stamp]}, + :parent_customer_id => $customer[:customer][:id], + :user => {}}).should be_a_kind_of(Hash) + end + + xit "update_customer" do #DOES NOT WORK IN SANDBOX + c = $customer[:customer] + $customer_srv13.update_customer({:customer => {:id => c[:id], :customer_address => c[:customer_address], :industry => c[:industry], :market => c[:market], :name => c[:name], :time_stamp => c[:time_stamp]}}).should be_a_kind_of(Hash) + end + end + end +end diff --git a/spec/fixtures/cassettes/CampaignManagementService.yml b/spec/fixtures/cassettes/CampaignManagementService.yml new file mode 100644 index 0000000..f705dec --- /dev/null +++ b/spec/fixtures/cassettes/CampaignManagementService.yml @@ -0,0 +1,98 @@ +--- +http_interactions: +- request: + method: post + uri: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl + body: + encoding: UTF-8 + string: + headers: + User-Agent: + - rspec (AwApi-Ruby/0.0.8, Common-Ruby/1.0.3, GoogleAdsSavon/1.0.4, ruby/2.6.9, + HTTPI/2.5.0, httpclient) + Accept: + - "*/*" + Date: + - Fri, 13 May 2022 01:19:32 GMT + Soapaction: + - '"GetCampaignsByAccountId"' + Content-Type: + - text/xml;charset=UTF-8 + Content-Length: + - '2612' + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Date: + - Fri, 13 May 2022 01:19:32 GMT + Content-Type: + - text/xml; charset=utf-8 + Server: + - Kestrel + Content-Length: + - '7965' + X-Ms-Requestid: + - 63c5f3ee-41a9-4532-8eac-b47a9eb4e384 + X-Ms-Trackingid: + - 63c5f3ee-41a9-4532-8eac-b47a9eb4e384 + body: + encoding: UTF-8 + string: 63c5f3ee-41a9-4532-8eac-b47a9eb4e3840MaxConversions1DailyBudgetStandard1424877224Tofu + | Branded Keywords | USPausedHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndexEnglish0MaxConversions1.6DailyBudgetStandard5424877225Tofu + | Physio Terms | USActiveHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndexEnglish0MaxConversions2DailyBudgetStandard25424877226Tofu + | A Terms | USPausedHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndex10239202361382English0MaxConversions1.6DailyBudgetStandard10424877227Tofu + | Device Terms | USActiveHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndexEnglish0MaxConversions1.6DailyBudgetStandard10424877228ToFu + | M Device Terms | USBudgetPausedHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndexEnglish0MaxConversions1.6DailyBudgetStandard5424877229Tofu + | Strength Terms | USActiveHobartSearchDynamicSearchAdsSettingretailer.globalEnglishSystemIndexEnglish0MaxConversions1.6DailyBudgetStandard5424877230ToFu + | CD Terms | USActiveHobartSearchEnglish + recorded_at: Fri, 13 May 2022 01:19:33 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/fixtures/cassettes/ReportingService.yml b/spec/fixtures/cassettes/ReportingService.yml new file mode 100644 index 0000000..c980bb2 --- /dev/null +++ b/spec/fixtures/cassettes/ReportingService.yml @@ -0,0 +1,52 @@ +--- +http_interactions: +- request: + method: post + uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl + body: + encoding: UTF-8 + string: TsvEnglishMyReportfalseDailyAccountIdAccountNameCampaignIdCampaignNameDeliveredMatchTypeAverageCpcAdDistributionCurrencyCodeImpressionsClicksCtrCostPerConversionSpendAveragePositionTimePeriodCampaignStatusDeviceType332022132022 + headers: + User-Agent: + - rspec (AwApi-Ruby/0.0.8, Common-Ruby/1.0.3, GoogleAdsSavon/1.0.4, ruby/2.6.9, + HTTPI/2.5.0, httpclient) + Accept: + - "*/*" + Date: + - Thu, 12 May 2022 07:36:03 GMT + Soapaction: + - '"SubmitGenerateReport"' + Content-Type: + - text/xml;charset=UTF-8 + Content-Length: + - '4690' + response: + status: + code: 200 + message: OK + headers: + Connection: + - keep-alive + Date: + - Thu, 12 May 2022 07:36:03 GMT + Content-Type: + - text/xml; charset=utf-8 + Server: + - Kestrel + Content-Length: + - '408' + X-Ms-Requestid: + - b64c5564-6897-49a8-95b7-8a4ea26b73fb + X-Ms-Trackingid: + - b64c5564-6897-49a8-95b7-8a4ea26b73fb + body: + encoding: UTF-8 + string: b64c5564-6897-49a8-95b7-8a4ea26b73fb351021_1530689 + recorded_at: Thu, 12 May 2022 07:36:04 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 670f7f5..031befc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,24 @@ require 'rubygems' require 'bundler/setup' +require 'bing_ads_api' +require 'dotenv' +require 'vcr' -require 'bing_ads_api' # and any other gems you need +Dotenv.load('.env.test.local', '.env.test') + +VCR.configure do |config| + config.hook_into :webmock + config.cassette_library_dir = 'spec/fixtures/cassettes' + config.default_cassette_options = { record: :new_episodes, allow_playback_repeats: true, + match_requests_on: %i[method uri body] } + config.hook_into :webmock + + %w[CUSTOMER_ID CUSTOMER_ACCOUNT_ID DEVELOPER_TOKEN OAUTH2_CLIENT_ID OAUTH2_CLIENT_SECRET ACCESS_TOKEN + REFRESH_TOKEN].each do |value| + config.filter_sensitive_data("<#{value}>") { ENV[value] } + end +end RSpec.configure do |config| - # some (optional) config here -end \ No newline at end of file + config.full_backtrace = true +end