Sha256: 2b57781f6f639c1192991dceec26a233421614b1445ba734e3c2c9f0b05f8d4f

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require "google/ads/google_ads/version_alternate"

require "google/ads/google_ads/factories/v10/resources"
require "google/ads/google_ads/factories/v10/services"
require "google/ads/google_ads/factories/v10/enums"
require "google/ads/google_ads/factories/v10/operations"

require "google/ads/google_ads/factories/v11/resources"
require "google/ads/google_ads/factories/v11/services"
require "google/ads/google_ads/factories/v11/enums"
require "google/ads/google_ads/factories/v11/operations"

module Google
  module Ads
    module GoogleAds
      module Factories
        Factory = Struct.new(:resources, :services, :enums, :operations)

        FACTORY_V10 = Factory.new(
          V10::Resources,
          V10::Services,
          V10::Enums,
          V10::Operations
        ).freeze

        FACTORY_V11 = Factory.new(
          V11::Resources,
          V11::Services,
          V11::Enums,
          V11::Operations
        ).freeze

        VERSIONS = [

          :V10,

          :V11

        ]

        HIGHEST_VERSION = :V11

        def self.version_alternate_for(type)
          unless [:resources, :services, :enums, :operations].include?(type)
            raise ArgumentError.new(
              "Dont have version alternate for #{type}, valid values are :resources, :services, :enums, :operations,  got #{type}"
            )
          end

          VersionAlternate.new(
            FACTORY_V11.public_send(type),
            {

              V10: FACTORY_V10.public_send(type),

              V11: FACTORY_V11.public_send(type)

            }
          )
        end

        def self.versions
        end

        def self.at_version(version)
          case version

          when :V10
            FACTORY_V10

          when :V11
            FACTORY_V11

          else
            raise ArgumentError.new("Got unkown version: #{version}")
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google-ads-googleads-19.0.0 lib/google/ads/google_ads/factories.rb