Class: DynamicsCRM::XML::PageInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamics_crm/xml/page_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count: 20, page_number: 1, paging_cookie: nil, return_total_record_count: false) ⇒ PageInfo

Returns a new instance of PageInfo.



6
7
8
9
10
11
# File 'lib/dynamics_crm/xml/page_info.rb', line 6

def initialize(count: 20, page_number: 1, paging_cookie: nil, return_total_record_count: false)
  @count = count
  @page_number = page_number
  @paging_cookie = paging_cookie
  @return_total_record_count = return_total_record_count
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



4
5
6
# File 'lib/dynamics_crm/xml/page_info.rb', line 4

def count
  @count
end

#page_numberObject

Returns the value of attribute page_number.



4
5
6
# File 'lib/dynamics_crm/xml/page_info.rb', line 4

def page_number
  @page_number
end

Returns the value of attribute paging_cookie.



4
5
6
# File 'lib/dynamics_crm/xml/page_info.rb', line 4

def paging_cookie
  @paging_cookie
end

#return_total_record_countObject

Returns the value of attribute return_total_record_count.



4
5
6
# File 'lib/dynamics_crm/xml/page_info.rb', line 4

def return_total_record_count
  @return_total_record_count
end

Instance Method Details

#to_hashObject



31
32
33
34
35
36
37
38
# File 'lib/dynamics_crm/xml/page_info.rb', line 31

def to_hash
  {
    :count => count,
    :page_number => page_number,
    :paging_cookie => paging_cookie,
    :return_total_record_count => return_total_record_count
  }
end

#to_xmlObject

Using Entity vs entity causes the error: Value cannot be null.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dynamics_crm/xml/page_info.rb', line 14

def to_xml
  cookie = if paging_cookie.nil?
    '<b:PagingCookie i:nil="true" />'
  else
    %(<b:PagingCookie>#{CGI.escapeHTML(paging_cookie)}</b:PagingCookie>)
  end

  %(
  <b:PageInfo>
    <b:Count>#{count}</b:Count>
    <b:PageNumber>#{page_number}</b:PageNumber>
    #{cookie}
    <b:ReturnTotalRecordCount>#{return_total_record_count}</b:ReturnTotalRecordCount>
  </b:PageInfo>
  )
end