Class: RallyAPI::LookbackAPIQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/rally_api/lookback_api_query.rb

Overview

query info is the master hash instead of a bunch of instance variables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_hash = nil) ⇒ LookbackAPIQuery

Returns a new instance of LookbackAPIQuery.



21
22
23
24
25
# File 'lib/rally_api/lookback_api_query.rb', line 21

def initialize(query_hash = nil)
  @query_info = nil
  parse_query_hash(query_hash) if !query_hash.nil?
  self
end

Instance Attribute Details

#query_infoObject

Returns the value of attribute query_info.



19
20
21
# File 'lib/rally_api/lookback_api_query.rb', line 19

def query_info
  @query_info
end

Instance Method Details

#make_query_paramsObject



27
28
29
30
31
32
33
34
# File 'lib/rally_api/lookback_api_query.rb', line 27

def make_query_params
  query_params = {}
  query_params[:find]      = @query_string
  query_params[:workspace]  = @workspace["_ref"] if !@workspace.nil?
  query

  query_params
end

#validate(allowed_objects) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rally_api/lookback_api_query.rb', line 36

def validate(allowed_objects)
  errors = []

  if @type.nil?
    errors.push("Object type for query cannot be nil")
  end

  if @limit < 0
    errors.push("Stop after - #{@stop_after} - must be a number")
  end

  if @page_size < 0
    errors.push("Page size - #{@page_size} - must be a number")
  end

  if !@workspace.nil?
    errors.push("Workspace - #{@workspace} - must have a ref") if @workspace["_ref"].nil?
  end

  if !@project.nil?
    errors.push("Project - #{@project} - must have a ref") if @project["_ref"].nil?
  end

  if (allowed_objects[@type].nil?)
    errors.push( "Object Type #{@type} is not query-able: inspect RallyRestJson.rally_objects for allowed types" )
  end

  errors
end