Пример #1
0
		/// <summary>
		/// Updates an app.
		/// <para>The update can contain an new configuration for the app, addition of new fields as well as updates to the configuration of existing fields. Fields not included will not be deleted.
		/// To delete a field use the "delete field" operation</para><para>Podio API Reference: https://developers.podio.com/doc/applications/update-app-22352 </para>
		/// </summary>
		/// <example>
		/// <![CDATA[
		///		//Example Usage: Updating an App by adding a new Category Field and Updating a Text Field
		///		             
		///		var application = new Application();
		///		application.AppId = APP_ID;
		///		application.Config = new ApplicationConfiguration
		///		{
		///		    Name = "Application Name",
		///		    Icon = "230.png",
		///		    ItemName = "Single item",
		///		    Description = "My Description"
		///		};
		///		              
		///		//For Updating Existing field (provide 'FieldId')
		///		var textField = application.Field<TextApplicationField>();
		///		textField.FieldId = 123456;
		///		textField.Config.Label = "Sample Text Field Updated";
		///		textField.Config.Label = "Sample Text Field Description Updated";
		///		textField.Size = "small";
		///		               
		///		//For adding new field
		///		var categoryField = application.Field<CategoryApplicationField>();
		///		categoryField.Config.Label = "New Sample Category Field";
		///		categoryField.Options = new List<CategoryItemField.Answer>()
		///		{
		///		    new CategoryItemField.Answer{ Text = "Option One "},
		///		    new CategoryItemField.Answer{ Text = "Option Two "}
		///		};
		///		categoryField.Multiple = true;
		///		categoryField.Display = "list";
		///		int newAppID = podio.ApplicationService.UpdateApp(application);
		/// ]]>
		/// </example>
		/// <param name="application">The application.</param>
		/// <returns>Task.</returns>
		public async Task UpdateApp(Application application)
		{
			string url = string.Format("/app/{0}", application.AppId);
			var requestData = new ApplicationCreateUpdateRequest()
			{
				Config = application.Config,
				Fields = application.Fields
			};
			await _podio.PutAsync<dynamic>(url, requestData);
		}
Пример #2
0
		/// <summary>
		/// Creates a new app on a space.
		/// <para>Podio API Reference:https://developers.podio.com/doc/applications/add-new-app-22351 </para>
		/// </summary>
		/// <example>
		/// <![CDATA[
		///		//Example Usage: Adding a new application with a text field and category field.
		///		             
		///		var application = new Application();
		///		application.SpaceId = SPACE_ID;
		///		application.Config = new ApplicationConfiguration
		///		{
		///		    Name = "Application Name",
		///		    Icon = "230.png",
		///		    ItemName = "Single item",
		///		    Description = "My Description"
		///		};
		///		var textField = application.Field<TextApplicationField>();
		///		textField.Config.Label = "Sample Text Field";
		///		textField.Config.Label = "Sample Text Field Description";
		///		textField.Size = "small";
		///		             
		///		var categoryField = application.Field<CategoryApplicationField>();
		///		categoryField.Config.Label = "Sample Category Field";
		///		categoryField.Options = new List<CategoryItemField.Answer>()
		///		{
		///		    new CategoryItemField.Answer{ Text = "Option One "},
		///		    new CategoryItemField.Answer{ Text = "Option Two "}
		///		};
		///		categoryField.Multiple = true;
		///		categoryField.Display = "list";
		///		int newAppID = podio.ApplicationService.AddNewApp(application);
		/// ]]>
		/// </example>
		/// <param name="application"></param>
		/// <returns>The id of the newly created app</returns>
		public async Task<int> AddNewApp(Application application)
		{
			string url = "/app/";
			var requestDate = new ApplicationCreateUpdateRequest()
			{
				SpaceId = application.SpaceId,
				Config = application.Config,
				Fields = application.Fields
			};
			dynamic response = await _podio.PostAsync<dynamic>(url, requestDate);
			return (int)response["app_id"];
		}