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

        hist = management_history(ident, :ebooks, 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
          books =
            if a_status == :installed
              instbooks = []
              hist[a_status].each do |src, books_from_src|
                real_src =
                  case src
                  when HIST_RAW_SOURCE_EBOOK_IN_HOUSE then HIST_SOURCE_IN_HOUSE
                  when HIST_RAW_SOURCE_IBOOKSTORE then HIST_SOURCE_IBOOKSTORE
                  else HIST_SOURCE_OTHER
                  end # case src
                instbooks += books_from_src.map! { |book| book[:source] = real_src }
              end
              instbooks
            else
              hist[a_status]
            end
          # now 'books' is an array of hashes of books with the same status
          # and if they are :installed, their source is in the hash

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

        result
      end
# The history of ebooks 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::EBook>] An array of EBook
#
The history of ebooks for a mobile device
The history of ebooks for a mobile device
def ebook_history(ident, status = nil, api: JSS.api)
        raise JSS::UnsupportedError, 'Only mobile devices have ebooks' unless self == JSS::MobileDevice
        hist = management_history(ident, :ebooks, 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|
          books =
            if a_status == :installed
              instbooks = []
              hist[a_status].each do |src, books_from_src|
                real_src =
                  case src
                  when HIST_RAW_SOURCE_EBOOK_IN_HOUSE then HIST_SOURCE_IN_HOUSE
                  when HIST_RAW_SOURCE_IBOOKSTORE then HIST_SOURCE_IBOOKSTORE
                  else HIST_SOURCE_OTHER
                  end 
                instbooks += books_from_src.map! { |book| book[:source] = real_src }
              end
              instbooks
            else
              hist[a_status]
            end
          result += books.map! do |book|
            book[:status] = a_status
            JSS::ManagementHistory::EBook.new book
          end 
        end 
        result
      end
def ebook_history ( ident , status = nil , api : JSS . api ) raise JSS :: UnsupportedError , 'Only mobile devices have ebooks' unless self == JSS :: MobileDevice hist = management_history ( ident , :ebooks , 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 | books = if a_status == :installed instbooks = [ ] hist [ a_status ] . each do | src , books_from_src | real_src = case src when HIST_RAW_SOURCE_EBOOK_IN_HOUSE then HIST_SOURCE_IN_HOUSE when HIST_RAW_SOURCE_IBOOKSTORE then HIST_SOURCE_IBOOKSTORE else HIST_SOURCE_OTHER end instbooks += books_from_src . map! { | book | book [ :source ] = real_src } end instbooks else hist [ a_status ] end result += books . map! do | book | book [ :status ] = a_status JSS :: ManagementHistory :: EBook . new book end end result end
The history of ebooks for a mobile device
The history of ebooks for a mobile device
# if status # merge the sources of installed apps into their hashes # case src # now 'books' is an array of hashes of books with the same status # and if they are :installed, their source is in the hash # merge the statuses of the books into their hashes # set the :status in the hash # map do |books| # statuses_to_do.each do |a_status|
An array of EBook
An array of EBook
Array<JSS::ManagementHistory::EBook>
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