Sha256: ae6250fd1e09392fcbcf515d3fc81c2f9689ab77b5a4d974d101f2ffc34da2af

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

begin
  require 'GiphyClient'

  module Giphy
    module Config
      extend self

      attr_writer :api_key
      attr_writer :rating

      def api_key
        @api_key ||= ENV['GIPHY_API_KEY']
      end

      def rating
        @rating ||= 'G'
      end
    end

    class << self
      def configure
        block_given? ? yield(Config) : Config
      end

      def config
        Config
      end

      def client
        @client ||= GiphyClient::DefaultApi.new
      end

      def random(keywords)
        client.gifs_random_get(config.api_key, tag: keywords, rating: config.rating).data
      end
    end
  end
rescue LoadError
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-bot-0.12.0 lib/initializers/giphy_client.rb
slack-ruby-bot-0.11.2 lib/initializers/giphy_client.rb
slack-ruby-bot-0.11.1 lib/initializers/giphy_client.rb