class Projects::Parser::FolderParser

Public Instance Methods

getFolder(response) click to toggle source
  • Parse the JSON response and make it into Folder object.

Parameters

  • response
    • This JSON response contains the details of a folder.

Returns

  • Folder object.

# File lib/projects/parser/FolderParser.rb, line 42
def getFolder(response)
        folder_json = JSON.parse response
        folder_array = folder_json["folders"]
        return jsonToFolder(folder_array[0])
end
getFolders(response) click to toggle source
  • Parse the JSON response and make it into List of Folder object.

Parameters

  • response
    • This JSON response contains the details of folders.

Returns

  • List of Folder object.

# File lib/projects/parser/FolderParser.rb, line 22
def getFolders(response)
        folders_all_json = JSON.parse response
        folders_all_array = folders_all_json["folders"]
        folders_class_array = Array.new
        for i in 0...folders_all_array.length
                folders_class_array.push(jsonToFolder(folders_all_array[i]))
        end
        return folders_class_array
end
getResult(response) click to toggle source
  • Parse the JSON response and get the success message.

Parameters

  • response
    • This JSON response contains the success message.

Returns

  • String object.

# File lib/projects/parser/FolderParser.rb, line 92
def getResult(response)
        jsonObject = JSON.parse response
        result = jsonObject["response"]
        return result
end
jsonToFolder(jsonObject) click to toggle source
  • Parse the JSONObject into Folder object.

Parameters

  • jsonObject
    • JSONObject contains the details of a folder.

Returns

  • Folder object.

# File lib/projects/parser/FolderParser.rb, line 58
def jsonToFolder(jsonObject)
        folder = Folder.new
        
        if jsonObject.has_key?("id")
                folder.setId(jsonObject["id"])
        end
        if jsonObject.has_key?("name")
                folder.setName(jsonObject["name"])
        end
        if jsonObject.has_key?("is_discussion")
                folder.setIsDicussion(jsonObject["is_discussion"])
        end
        
        if jsonObject.has_key?("link")
                link = jsonObject["link"]
                
                if link.has_key?("self")
                        folder.setURL(link["self"]["url"])
                end
        end
        
        return folder
end