Sha256: 678d955c0e93c9a4d3712071698e3be0987c0069ac7b3529a85092bc76167a82

Contents?: true

Size: 812 Bytes

Versions: 22

Compression:

Stored size: 812 Bytes

Contents

require 'google/protobuf/well_known_types'

module Google
  module Ads
    module GoogleAds
      class StatusDecoder
        # decodes the details field from a Google::Rpc::Status instance to
        # an array of meaningful objects
        #
        # Return an Array of protobuf objects, typed depending on what was
        # in the passed object (which will mostly be Google::Protobuf::Any,
        # so the types could be any valid protobuf type)
        def self.decode(status)
          status.details.select { |detail|
            Google::Protobuf::Any === detail
          }.map { |detail|
            type = Google::Protobuf::DescriptorPool.generated_pool.lookup(
              detail.type_name
            ).msgclass
            detail.unpack(type)
          }
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
google-ads-googleads-16.0.0 lib/google/ads/google_ads/status_decoder.rb
google-ads-googleads-15.0.0 lib/google/ads/google_ads/status_decoder.rb