Sha256: f54e223661946b76d28ad0c6fd816bb5df6bed2d2fb407f3aeb4ca6edbaf0206

Contents?: true

Size: 734 Bytes

Versions: 3

Compression:

Stored size: 734 Bytes

Contents

class YouTrack::Client::Request
  def find(collection, id, options={})
    service.data.fetch(collection)[id] ||
      service.response(status: 404, body: {"error" => "#{collection.to_s.gsub(/s\Z/, "").capitalize} not found."})
  end

  def require_parameters(_params, *_requirements)
    params       = Cistern::Hash.stringify_keys(_params)
    requirements = _requirements.map(&:to_s)

    requirements.each do |requirement|
      unless !params[requirement].nil?
        response(
          :status => 400,
          :body   => {"error" => "Bad Request"})
      end
    end
    values = params.values_at(*requirements)
    values.size == 1 ? values.first : values
  end

  def ms_time(time=Time.now)
    time.to_i * 1000
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
you_track-0.4.7 lib/you_track/client/request.rb
you_track-0.4.6 lib/you_track/client/request.rb
you_track-0.4.5 lib/you_track/client/request.rb