Sha256: ff4d2af0ad99757fa731c0ebadfffffb00efde398a542ca9e671123ae510866e

Contents?: true

Size: 947 Bytes

Versions: 29

Compression:

Stored size: 947 Bytes

Contents

module SlackRubyBotServer
  module Api
    module Presenters
      module RootPresenter
        include Roar::JSON::HAL
        include Roar::Hypermedia
        include Grape::Roar::Representer

        link :self do |opts|
          "#{base_url(opts)}/api"
        end

        link :status do |opts|
          "#{base_url(opts)}/api/status"
        end

        link :teams do |opts|
          {
            href: "#{base_url(opts)}/api/teams/#{link_params(Helpers::PaginationParameters::ALL, :active)}",
            templated: true
          }
        end

        link :team do |opts|
          {
            href: "#{base_url(opts)}/api/teams/{id}",
            templated: true
          }
        end

        private

        def base_url(opts)
          request = Grape::Request.new(opts[:env])
          request.base_url
        end

        def link_params(*args)
          "{?#{args.join(',')}}"
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
slack-ruby-bot-server-2.1.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-2.1.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-2.0.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-1.2.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-1.2.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-1.1.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-1.0.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.12.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.11.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.11.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.10.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.9.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.8.3 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.8.2 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.8.1 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.8.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb
slack-ruby-bot-server-0.7.0 lib/slack-ruby-bot-server/api/presenters/root_presenter.rb