Sha256: ddc4732f4fb2a06997478194124f20f16b1ba82e5216eb127e5bb8574ed59ce7

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 KB

Contents

module CandyCheck
  module PlayStore
    # Configure the usage of the official Google API SDK client
    class Config < Utils::Config
      # @return [String] your application name
      attr_reader :application_name
      # @return [String] your application's version
      attr_reader :application_version
      # @return [String] an optional file to cache the discovery API result
      attr_reader :cache_file
      # @return [String] your issuer's service account e-mail
      attr_reader :issuer
      # @return [String] the path to your local *.p12 certificate file
      attr_reader :key_file
      # @return [String] the secret to load your certificate file
      attr_reader :key_secret

      # Initializes a new configuration from a hash
      # @param attributes [Hash]
      # @example Initialize with a discovery cache file
      #   ClientConfig.new(
      #     application_name: 'YourApplication',
      #     application_version: '1.0',
      #     cache_file: 'tmp/google_api_cache',
      #     issuer: 'abcdefg@developer.gserviceaccount.com',
      #     key_file: 'local/google.p12',
      #     key_secret: 'notasecret'
      #   )
      def initialize(attributes)
        super
      end

      # @return [String] the decrypted API key from Google
      def api_key
        @api_key ||= begin
          Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)
        end
      end

      private

      def validate!
        validates_presence(:application_name)
        validates_presence(:application_version)
        validates_presence(:issuer)
        validates_presence(:key_file)
        validates_presence(:key_secret)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
candy_check-0.1.2 lib/candy_check/play_store/config.rb
candy_check-0.1.1 lib/candy_check/play_store/config.rb
candy_check-0.1.0.pre lib/candy_check/play_store/config.rb
candy_check-0.0.5 lib/candy_check/play_store/config.rb
candy_check-0.0.3 lib/candy_check/play_store/config.rb
candy_check-0.0.2 lib/candy_check/play_store/config.rb
candy_check-0.0.1 lib/candy_check/play_store/config.rb