lib/jss/api_object/management_history.rb
def mobile_device_app_history(ident, status = nil, api: JSS.api)
        raise JSS::UnsupportedError, 'Only mobile devices have mobile device apps' unless self == JSS::MobileDevice

        hist = management_history(ident, :applications, api: api)
        if status
          raise JSS::InvalidDataError, 'status must be one of :installed, :pending, or :failed' unless HIST_APP_STATUSES.include? status
          statuses_to_do = [status]
        else
          statuses_to_do = HIST_APP_STATUSES
        end # if status

        result = []

        statuses_to_do.each do |a_status|
          # merge the sources of installed apps into their hashes
          apps =
            if a_status == :installed
              instapps = []
              hist[a_status].each do |src, apps_from_src|
                real_src =
                  case src
                  when HIST_RAW_SOURCE_APP_IN_HOUSE then HIST_SOURCE_IN_HOUSE
                  when HIST_RAW_SOURCE_APP_STORE then HIST_SOURCE_APP_STORE
                  else HIST_SOURCE_OTHER
                  end # case src
                instapps += apps_from_src.map! { |iapp| iapp[:source] = real_src }
              end
              instapps
            else
              hist[a_status]
            end
          # now 'apps' is an array of hashes of apps with the same status
          # and if they are :installed, their source is in the hash

          # merge the statuses of the apps into their hashes
          result += apps.map! do |app|
            # set the :status in the hash
            app[:status] = a_status
            JSS::ManagementHistory::MobileDeviceApp.new app
          end # map do |cmd|
        end # statuses_to_do.each do |a_status|

        result
      end
# The history of apps for a mobile device
#
# @param ident [Type] The identifier for the object - id, name, sn, udid, etc.
#
# @param status [Symbol] Return only the :installed, :pending, or :failed apps
#
# @param api [JSS::APIConnection] The API connection to use for the query
#   defaults to the currently active connection
#
# @return [Array<JSS::ManagementHistory::MobileDeviceApp>] An array of MobileDeviceApp
#
The history of apps for a mobile device
The history of apps for a mobile device
def mobile_device_app_history(ident, status = nil, api: JSS.api)
        raise JSS::UnsupportedError, 'Only mobile devices have mobile device apps' unless self == JSS::MobileDevice
        hist = management_history(ident, :applications, api: api)
        if status
          raise JSS::InvalidDataError, 'status must be one of :installed, :pending, or :failed' unless HIST_APP_STATUSES.include? status
          statuses_to_do = [status]
        else
          statuses_to_do = HIST_APP_STATUSES
        end 
        result = []
        statuses_to_do.each do |a_status|
          apps =
            if a_status == :installed
              instapps = []
              hist[a_status].each do |src, apps_from_src|
                real_src =
                  case src
                  when HIST_RAW_SOURCE_APP_IN_HOUSE then HIST_SOURCE_IN_HOUSE
                  when HIST_RAW_SOURCE_APP_STORE then HIST_SOURCE_APP_STORE
                  else HIST_SOURCE_OTHER
                  end 
                instapps += apps_from_src.map! { |iapp| iapp[:source] = real_src }
              end
              instapps
            else
              hist[a_status]
            end
          result += apps.map! do |app|
            app[:status] = a_status
            JSS::ManagementHistory::MobileDeviceApp.new app
          end 
        end 
        result
      end
def mobile_device_app_history ( ident , status = nil , api : JSS . api ) raise JSS :: UnsupportedError , 'Only mobile devices have mobile device apps' unless self == JSS :: MobileDevice hist = management_history ( ident , :applications , api : api ) if status raise JSS :: InvalidDataError , 'status must be one of :installed, :pending, or :failed' unless HIST_APP_STATUSES . include? status statuses_to_do = [ status ] else statuses_to_do = HIST_APP_STATUSES end result = [ ] statuses_to_do . each do | a_status | apps = if a_status == :installed instapps = [ ] hist [ a_status ] . each do | src , apps_from_src | real_src = case src when HIST_RAW_SOURCE_APP_IN_HOUSE then HIST_SOURCE_IN_HOUSE when HIST_RAW_SOURCE_APP_STORE then HIST_SOURCE_APP_STORE else HIST_SOURCE_OTHER end instapps += apps_from_src . map! { | iapp | iapp [ :source ] = real_src } end instapps else hist [ a_status ] end result += apps . map! do | app | app [ :status ] = a_status JSS :: ManagementHistory :: MobileDeviceApp . new app end end result end
The history of apps for a mobile device
The history of apps for a mobile device
# if status # merge the sources of installed apps into their hashes # case src # now 'apps' is an array of hashes of apps with the same status # and if they are :installed, their source is in the hash # merge the statuses of the apps into their hashes # set the :status in the hash # map do |cmd| # statuses_to_do.each do |a_status|
An array of MobileDeviceApp
An array of MobileDeviceApp
Array<JSS::ManagementHistory::MobileDeviceApp>
ident
The identifier for the object - id, name, sn, udid, etc.
The identifier for the object - id name sn udid etc .
status
Return only the :installed, :pending, or :failed apps
Return only the : installed : pending or : failed apps
api
The API connection to use for the query defaults to the currently active connection
The API connection to use for the query defaults to the currently active connection
the currently active connection