Sha256: 1c42fba3db7faf761ce9ff7756892ddd0f70749181e2a1cf482de61491e3cc18

Contents?: true

Size: 891 Bytes

Versions: 14

Compression:

Stored size: 891 Bytes

Contents

require 'addressable/uri'

module Poms
  module Api
    module Uris
      # URI for the /schedule API
      module Schedule
        API_PATH = '/v1/api/schedule'.freeze

        module_function

        def now(base_uri, channel)
          uri_for_path(
            base_uri,
            "/channel/#{channel}",
            stop: Time.now.iso8601,
            sort: 'desc',
            max: 1
          )
        end

        def next(base_uri, channel)
          uri_for_path(
            base_uri,
            "/channel/#{channel}",
            start: Time.now.iso8601,
            sort: 'asc',
            max: 1
          )
        end

        def uri_for_path(base_uri, path = nil, query = {})
          uri = base_uri.merge(path: "#{API_PATH}#{path}")
          uri.query_values = query
          uri
        end

        private_class_method :uri_for_path
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
poms-3.0.0 lib/poms/api/uris/schedule.rb
poms-2.6.0 lib/poms/api/uris/schedule.rb
poms-2.5.1 lib/poms/api/uris/schedule.rb
poms-2.5.0 lib/poms/api/uris/schedule.rb
poms-2.4.0 lib/poms/api/uris/schedule.rb
poms-2.3.1 lib/poms/api/uris/schedule.rb
poms-2.3.0 lib/poms/api/uris/schedule.rb
poms-2.2.1 lib/poms/api/uris/schedule.rb
poms-2.2.0 lib/poms/api/uris/schedule.rb
poms-2.1.3 lib/poms/api/uris/schedule.rb
poms-2.1.2.1 lib/poms/api/uris/schedule.rb
poms-2.1.2 lib/poms/api/uris/schedule.rb
poms-2.1.1 lib/poms/api/uris/schedule.rb
poms-2.1.0 lib/poms/api/uris/schedule.rb