Class: FuelSDK::ET_GetSupportRest

Inherits:
ET_BaseObject show all
Defined in:
lib/new.rb

Direct Known Subclasses

ET_CUDSupportRest

Instance Attribute Summary collapse

Attributes inherited from ET_BaseObject

#authStub, #endpoint, #lastRequestID, #obj, #props

Instance Method Summary collapse

Methods inherited from ET_BaseObject

#initialize

Constructor Details

This class inherits a constructor from FuelSDK::ET_BaseObject

Instance Attribute Details

#lastPageNumberObject (readonly)

Returns the value of attribute lastPageNumber.



655
656
657
# File 'lib/new.rb', line 655

def lastPageNumber
  @lastPageNumber
end

#urlPropsObject (readonly)

Returns the value of attribute urlProps.



655
656
657
# File 'lib/new.rb', line 655

def urlProps
  @urlProps
end

#urlPropsRequiredObject (readonly)

Returns the value of attribute urlPropsRequired.



655
656
657
# File 'lib/new.rb', line 655

def urlPropsRequired
  @urlPropsRequired
end

Instance Method Details

#get(props = nil) ⇒ Object



657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'lib/new.rb', line 657

def get(props = nil)
  if props and props.is_a? Hash then
    @props = props
  end

  completeURL = @endpoint
  additionalQS = {}

  if @props and @props.is_a? Hash then
    @props.each do |k,v|
      if @urlProps.include?(k) then
        completeURL.sub!("{#{k}}", v)
      else
        additionalQS[k] = v
      end
    end
  end

  @urlPropsRequired.each do |value|
    if !@props || !@props.has_key?(value) then
      raise "Unable to process request due to missing required prop: #{value}"
    end
  end

  @urlProps.each do |value|
    completeURL.sub!("/{#{value}}", "")
  end

  obj = ET_GetRest.new(@authStub, completeURL,additionalQS)

  if obj.results.has_key?('page') then
    @lastPageNumber = obj.results['page']
    pageSize = obj.results['pageSize']
    if obj.results.has_key?('count') then
      count = obj.results['count']
    elsif obj.results.has_key?('totalCount') then
      count = obj.results['totalCount']
    end

    if !count.nil? && count > (@lastPageNumber * pageSize)  then
      obj.moreResults = true
    end
  end
  return obj
end

#getMoreResultsObject



703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/new.rb', line 703

def getMoreResults()
  if props and props.is_a? Hash then
    @props = props
  end

  originalPageValue = "1"
  removePageFromProps = false

  if !@props.nil? && @props.has_key?('$page') then
    originalPageValue = @props['page']
  else
    removePageFromProps = true
  end

  if @props.nil?
    @props = {}
  end

  @props['$page'] = @lastPageNumber + 1

  obj = self.get

  if removePageFromProps then
    @props.delete('$page')
  else
    @props['$page'] = originalPageValue
  end

  return obj
end