package com.aspose.tasks.cloud.assinments;

import java.nio.file.Path;

import com.aspose.storage.api.StorageApi;
import com.aspose.tasks.api.TasksApi;
import com.aspose.tasks.cloud.Configuration;
import com.aspose.tasks.cloud.Utils;
import com.aspose.tasks.cloud.calendars.DeleteCalendarFromProjectExample;
import com.aspose.tasks.model.AssignmentItemResponse;

public class AddAssignmentToProjectExample {

	public static void main(String[] args) {
		//ExStart: AddAssignmentToProjectExample
		// Set input file name            
		String name = "sample-project.mpp";
		int taskUid = 1;
		int resourceUid = 1;
		Double units = 1.0;
		String fileName = "";
		String storage = "";
		String folder = "";
		Path inputFile = Utils.getPath(DeleteCalendarFromProjectExample.class, name);

		try
		{
			StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
			// Instantiate Aspose Words API SDK
			TasksApi tasksApi = new TasksApi(Configuration.apiKey, Configuration.appSID, true);
		    // Upload source file to aspose cloud storage
		    storageApi.PutCreate(name, "", "", inputFile.toFile());

		    // Invoke Aspose.Tasks Cloud SDK API to add assignment to project
		    AssignmentItemResponse apiResponse = tasksApi.PostProjectAssignment(name, taskUid, resourceUid, units, fileName, storage, folder);

		    if (apiResponse != null && apiResponse.getStatus().equals("OK"))
		    {
		    	System.out.println("Add Assignment to Project , Done!");
		    }
		}
		catch (Exception ex)
		{
			 ex.printStackTrace();
		}
		//ExEnd: AddAssignmentToProjectExample
	}
}
