Sha256: 677e49e9bc99ac1ea94486e42f089abca7559c5d85d57eea8cbce245f3817026

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/v15/resources"
require "google/ads/google_ads/factories/v15/services"
require "google/ads/google_ads/factories/v15/enums"
require "google/ads/google_ads/factories/v15/operations"

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

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

        FACTORY_V15 = Factory.new(
          V15::Resources,
          V15::Services,
          V15::Enums,
          V15::Operations
        ).freeze

        FACTORY_V16 = Factory.new(
          V16::Resources,
          V16::Services,
          V16::Enums,
          V16::Operations
        ).freeze

        VERSIONS = [

          :V15,

          :V16

        ]

        HIGHEST_VERSION = :V16

        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_V16.public_send(type),
            {

              V15: FACTORY_V15.public_send(type),

              V16: FACTORY_V16.public_send(type)

            }
          )
        end

        def self.versions
        end

        def self.at_version(version)
          case version

          when :V15
            FACTORY_V15

          when :V16
            FACTORY_V16

          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-28.0.0 lib/google/ads/google_ads/factories.rb