Sha256: b59e22598d4103a51cddfc12d96096a8d9273b4ad376f859bb8724d2db13b958

Contents?: true

Size: 710 Bytes

Versions: 13

Compression:

Stored size: 710 Bytes

Contents

module Boty
  module Slack
    module URL
      def self.included(base)
        base.instance_eval do
          def url(url); @_url = url end
          def _url; @_url end
        end
      end

      def self.get(url)
        JSON.parse Net::HTTP.get(URI(url)) || "{}"
      end

      private

      def parameterize(user_parameters, path: nil)
        url = path ? self.class._url + path : self.class._url
        parameters = {token: ENV["SLACK_BOT_API_TOKEN"]}.merge user_parameters
        parameters.reduce(url + "?") { |_url, param|
          parameter = param[0]
          value = URI.encode param[1].to_s
          "#{_url}#{parameter}=#{value}&"
        }.gsub(/&$/, "")
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
boty-0.1.0 lib/boty/slack/url.rb
boty-0.0.17.1 lib/boty/slack/url.rb
boty-0.0.17 lib/boty/slack/url.rb
boty-0.0.16 lib/boty/slack/url.rb
boty-0.0.15 lib/boty/slack/url.rb
boty-0.0.14 lib/boty/slack/url.rb
boty-0.0.13 lib/boty/slack/url.rb
boty-0.0.12 lib/boty/slack/url.rb
boty-0.0.11 lib/boty/slack/url.rb
boty-0.0.10 lib/boty/slack/url.rb
boty-0.0.9 lib/boty/slack/url.rb
boty-0.0.7 lib/boty/slack/url.rb
boty-0.0.6 lib/boty/slack/url.rb