diff --git a/libraries/Microsoft.Bot.Builder/SharePoint/SharePointActivityHandler.cs b/libraries/Microsoft.Bot.Builder/SharePoint/SharePointActivityHandler.cs new file mode 100644 index 0000000000..e3e9b98a21 --- /dev/null +++ b/libraries/Microsoft.Bot.Builder/SharePoint/SharePointActivityHandler.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Bot.Connector; +using Microsoft.Bot.Schema; +using Microsoft.Bot.Schema.SharePoint; +using Microsoft.Bot.Schema.Teams; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Builder.SharePoint +{ + /// + /// The SharePointActivityHandler is derived from ActivityHandler. It adds support for + /// the SharePoint specific events and interactions. + /// + public class SharePointActivityHandler : ActivityHandler + { + /// + /// Invoked when an invoke activity is received from the connector. + /// Invoke activities can be used to communicate many different things. + /// + /// A strongly-typed context object for this turn. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A task that represents the work queued to execute. + /// + /// Invoke activities communicate programmatic commands from a client or channel to a bot. + /// The meaning of an invoke activity is defined by the property, + /// which is meaningful within the scope of a channel. + /// + protected override async Task OnInvokeActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) + { + try + { + if (turnContext.Activity.Name == null) + { + throw new NotSupportedException(); + } + else + { + switch (turnContext.Activity.Name) + { + case "cardExtension/getCardView": + return CreateInvokeResponse(await OnSharePointTaskGetCardViewAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); + + case "cardExtension/getQuickView": + return CreateInvokeResponse(await OnSharePointTaskGetQuickViewAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); + + case "cardExtension/getPropertyPaneConfiguration": + return CreateInvokeResponse(await OnSharePointTaskGetPropertyPaneConfigurationAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); + + case "cardExtension/setPropertyPaneConfiguration": + BaseHandleActionResponse setPropPaneConfigResponse = await OnSharePointTaskSetPropertyPaneConfigurationAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false); + ValidateSetPropertyPaneConfigurationResponse(setPropPaneConfigResponse); + return CreateInvokeResponse(setPropPaneConfigResponse); + + case "cardExtension/handleAction": + return CreateInvokeResponse(await OnSharePointTaskHandleActionAsync(turnContext, SafeCast(turnContext.Activity.Value), cancellationToken).ConfigureAwait(false)); + } + } + } + catch (InvokeResponseException e) + { + return e.CreateInvokeResponse(); + } + + return await base.OnInvokeActivityAsync(turnContext, cancellationToken).ConfigureAwait(false); + } + + /// + /// Override this in a derived class to provide logic for when a card view is fetched. + /// + /// A strongly-typed context object for this turn. + /// The ACE invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A Card View Response for the request. + protected virtual Task OnSharePointTaskGetCardViewAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Override this in a derived class to provide logic for when a quick view is fetched. + /// + /// A strongly-typed context object for this turn. + /// The ACE invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A Quick View Response for the request. + protected virtual Task OnSharePointTaskGetQuickViewAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Override this in a derived class to provide logic for getting configuration pane properties. + /// + /// A strongly-typed context object for this turn. + /// The ACE invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A Property Pane Configuration Response for the request. + protected virtual Task OnSharePointTaskGetPropertyPaneConfigurationAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Override this in a derived class to provide logic for setting configuration pane properties. + /// + /// A strongly-typed context object for this turn. + /// The ACE invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// Card view or no-op action response. + /// The handler will fail with 500 status code if the response is of type . + protected virtual Task OnSharePointTaskSetPropertyPaneConfigurationAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Override this in a derived class to provide logic for handling ACE actions. + /// + /// A strongly-typed context object for this turn. + /// The ACE invoke request value payload. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A handle action response. + protected virtual Task OnSharePointTaskHandleActionAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + throw new InvokeResponseException(HttpStatusCode.NotImplemented); + } + + /// + /// Safely casts an object to an object of type . + /// + /// The object to be casted. + /// The object casted in the new type. + private static T SafeCast(object value) + { + var obj = value as JObject; + if (obj == null) + { + throw new InvokeResponseException(HttpStatusCode.BadRequest, $"expected type '{value.GetType().Name}'"); + } + + return obj.ToObject(); + } + + private void ValidateSetPropertyPaneConfigurationResponse(BaseHandleActionResponse response) + { + if (response is QuickViewHandleActionResponse) + { + throw new InvokeResponseException(HttpStatusCode.InternalServerError, "Response for SetPropertyPaneConfiguration action can't be of QuickView type."); + } + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/Microsoft.Bot.Schema.csproj b/libraries/Microsoft.Bot.Schema/Microsoft.Bot.Schema.csproj index 391948ee07..4ef13581dc 100644 --- a/libraries/Microsoft.Bot.Schema/Microsoft.Bot.Schema.csproj +++ b/libraries/Microsoft.Bot.Schema/Microsoft.Bot.Schema.csproj @@ -25,6 +25,7 @@ + diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/AceData.cs b/libraries/Microsoft.Bot.Schema/SharePoint/AceData.cs new file mode 100644 index 0000000000..b5640c8951 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/AceData.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint Ace Data object. + /// + public class AceData + { + /// + /// Initializes a new instance of the class. + /// + public AceData() + { + // Do nothing + } + + /// + /// This enum contains the different types of card templates available in the SPFx framework. + /// + public enum AceCardSize + { + /// + /// Medium + /// + Medium, + + /// + /// Large + /// + Large + } + + /// + /// Gets or Sets the card size of the adaptive card extension of type enum. + /// + /// This value is the size of the adaptive card extension. + [JsonProperty(PropertyName = "cardSize")] + [JsonConverter(typeof(StringEnumConverter))] + public AceCardSize CardSize { get; set; } + + /// + /// Gets or Sets the version of the data of type . + /// + /// This value is the version of the adaptive card extension. + /// Although there is no restriction on the format of this property, it is recommended to use semantic versioning. + [JsonProperty(PropertyName = "dataVersion")] + public string DataVersion { get; set; } + + /// + /// Gets or Sets the unique id (Guid) of type . + /// + /// This value is the ID of the adaptive card extension. + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets the title of type . + /// + /// This value is the title of the adaptive card extension. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or Sets the description of type . + /// + /// This value is the description of the adaptive card extension. + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or Sets the icon property of type . + /// + /// This value is the icon of the adaptive card extension. + [JsonProperty(PropertyName = "iconProperty")] + public string IconProperty { get; set; } + + /// + /// Gets or Sets the property bag of type . + /// + /// This value is the property bag of the adaptive card extension. + [JsonProperty(PropertyName = "properties")] +#pragma warning disable CA2227 + public JObject Properties { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/AceRequest.cs b/libraries/Microsoft.Bot.Schema/SharePoint/AceRequest.cs new file mode 100644 index 0000000000..75230f5c90 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/AceRequest.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// ACE invoke request payload. + /// + public class AceRequest + { + /// + /// Initializes a new instance of the class. + /// + public AceRequest() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// ACE request data. + /// ACE properties data. + public AceRequest(object data = default, object properties = default) + { + Data = data; + Properties = properties; + } + + /// + /// Gets or sets user ACE request data. + /// + /// The ACE request data. + [JsonProperty(PropertyName = "data")] + public object Data { get; set; } + + /// + /// Gets or sets ACE properties data. Free payload with key-value pairs. + /// + /// ACE Properties object. + [JsonProperty(PropertyName = "properties")] + public object Properties { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/BaseAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/BaseAction.cs new file mode 100644 index 0000000000..eff1ad9b19 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/BaseAction.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Base Action. + /// + public class BaseAction + { + [JsonProperty(PropertyName = "type")] + private readonly string type; + + /// + /// Initializes a new instance of the class. + /// + /// Type of the action. + protected BaseAction(string actionType) + { + this.type = actionType; + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ConfirmationDialog.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ConfirmationDialog.cs new file mode 100644 index 0000000000..ed311ffcae --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ConfirmationDialog.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint Confirmation Dialog object. + /// + public class ConfirmationDialog + { + /// + /// Initializes a new instance of the class. + /// + public ConfirmationDialog() + { + // Do nothing + } + + /// + /// Gets or Sets the title of type . + /// + /// This value is the title to display. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or Sets the message of type . + /// + /// This value is the message to display. + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExecuteAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExecuteAction.cs new file mode 100644 index 0000000000..664f53b4a9 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExecuteAction.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Action.Execute. + /// + public class ExecuteAction : BaseAction, IAction + { + /// + /// Initializes a new instance of the class. + /// + public ExecuteAction() + : base("Execute") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + #pragma warning disable CA2227 + public Dictionary Parameters { get; set; } + + /// + /// Gets or Sets the verb associated with this action of type . + /// + /// This value is the verb associated with the action. + [JsonProperty(PropertyName = "verb")] + public string Verb { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkAction.cs new file mode 100644 index 0000000000..85feea0325 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkAction.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint external link action. + /// + public class ExternalLinkAction : BaseAction, IAction, IOnCardSelectionAction + { + /// + /// Initializes a new instance of the class. + /// + public ExternalLinkAction() + : base("ExternalLink") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + public ExternalLinkActionParameters Parameters { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkActionParameters.cs new file mode 100644 index 0000000000..a0b0851aa8 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ExternalLinkActionParameters.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint parameters for an External Link action. + /// + public class ExternalLinkActionParameters + { + /// + /// Initializes a new instance of the class. + /// + public ExternalLinkActionParameters() + { + // Do nothing + } + + /// + /// Gets or Sets a value indicating whether this is a teams deep link property of type . + /// + /// This value indicates whether this is a Teams Deep Link. + [JsonProperty(PropertyName = "isTeamsDeepLink")] + public bool IsTeamsDeepLink { get; set; } + + /// + /// Gets or Sets the target of type . + /// + /// This value is external link to navigate to. + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/FocusParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/FocusParameters.cs new file mode 100644 index 0000000000..847c14ddeb --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/FocusParameters.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint focus parameters. + /// + public class FocusParameters + { + /// + /// Initializes a new instance of the class. + /// + public FocusParameters() + { + // Do nothing + } + + /// + /// This enum contains the different types of aria live options available in the SPFx framework. + /// + public enum AriaLiveOption + { + /// + /// Polite + /// + [EnumMember(Value = "polite")] + Polite, + + /// + /// Assertive + /// + [EnumMember(Value = "assertive")] + Assertive, + + /// + /// Off + /// + [EnumMember(Value = "off")] + Off + } + + /// + /// Gets or Sets the focus target of type . + /// + /// This value is the focus target. + [JsonProperty(PropertyName = "focusTarget")] + public string FocusTarget { get; set; } + + /// + /// Gets or Sets the aria live property of type . + /// + /// This value sets the accessibility reading of the contents within the focus target. + [JsonProperty(PropertyName = "ariaLive")] + [JsonConverter(typeof(StringEnumConverter))] + public AriaLiveOption AriaLive { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationAction.cs new file mode 100644 index 0000000000..5eb12f2d35 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationAction.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint get location action. + /// + public class GetLocationAction : BaseAction, IAction, IOnCardSelectionAction + { + /// + /// Initializes a new instance of the class. + /// + public GetLocationAction() + : base("VivaAction.GetLocation") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + public GetLocationActionParameters Parameters { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationActionParameters.cs new file mode 100644 index 0000000000..76193688c5 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/GetLocationActionParameters.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint parameters for a Get Location action. + /// + public class GetLocationActionParameters + { + /// + /// Initializes a new instance of the class. + /// + public GetLocationActionParameters() + { + // Do nothing + } + + /// + /// Gets or Sets a value indicating whether the location on the map can be chosen of type . + /// + /// This value indicates whether a location on the map can be chosen. + [JsonProperty(PropertyName = "chooseLocationOnMap")] + public bool ChooseLocationOnMap { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IAction.cs new file mode 100644 index 0000000000..c0bec1ae34 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IAction.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Interface for actions. + /// +#pragma warning disable CA1040 // Avoid empty interfaces + public interface IAction +#pragma warning restore CA1040 // Avoid empty interfaces + { + // This interface has no common methods. + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ICardActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ICardActionParameters.cs new file mode 100644 index 0000000000..d19327323f --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ICardActionParameters.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Interface for card action parameters. + /// +#pragma warning disable CA1040 // Avoid empty interfaces + public interface ICardActionParameters +#pragma warning restore CA1040 // Avoid empty interfaces + { + // This interface has no common methods. + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IOnCardSelectionAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IOnCardSelectionAction.cs new file mode 100644 index 0000000000..4ff488cee3 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/IOnCardSelectionAction.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Interface for action upon card selection. + /// +#pragma warning disable CA1040 // Avoid empty interfaces + public interface IOnCardSelectionAction +#pragma warning restore CA1040 // Avoid empty interfaces + { + // This interface has no common methods. + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/Location.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/Location.cs new file mode 100644 index 0000000000..2f84cbd654 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/Location.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Sharepoint Location object. + /// + public class Location + { + /// + /// Initializes a new instance of the class. + /// + public Location() + { + // Do nothing + } + + /// + /// Gets or Sets latitutde of the location of type . + /// + /// This value is the latitude of the location. + [JsonProperty(PropertyName = "latitude")] + public int Latitude { get; set; } + + /// + /// Gets or Sets longitude of the location of type . + /// + /// This value is the longitude of the location. + [JsonProperty(PropertyName = "longitude")] + public int Longitude { get; set; } + + /// + /// Gets or Sets timestamp of the location of type . + /// + /// This value is the timestamp of the location. + [JsonProperty(PropertyName = "timestamp")] + public int Timestamp { get; set; } + + /// + /// Gets or Sets accuracy of the location of type . + /// + /// This value is the accuracy of the location. + [JsonProperty(PropertyName = "accuracy")] + public int Accuracy { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewAction.cs new file mode 100644 index 0000000000..38a4b4f5c5 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewAction.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint Quick View action. + /// + public class QuickViewAction : BaseAction, IAction, IOnCardSelectionAction + { + /// + /// Initializes a new instance of the class. + /// + public QuickViewAction() + : base("QuickView") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + public QuickViewActionParameters Parameters { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewActionParameters.cs new file mode 100644 index 0000000000..507685e31a --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/QuickViewActionParameters.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint parameters for an quick view action. + /// + public class QuickViewActionParameters + { + /// + /// Initializes a new instance of the class. + /// + public QuickViewActionParameters() + { + // Do nothing + } + + /// + /// Gets or Sets the quick view id to be opened as part of the action of type . + /// + /// This value is quick view id to open. + [JsonProperty(PropertyName = "view")] + public string View { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaAction.cs new file mode 100644 index 0000000000..dc45e971ec --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaAction.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint select media action. + /// + public class SelectMediaAction : BaseAction, IAction, IOnCardSelectionAction + { + /// + /// Initializes a new instance of the class. + /// + public SelectMediaAction() + : base("VivaAction.SelectMedia") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + public SelectMediaActionParameters Parameters { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaActionParameters.cs new file mode 100644 index 0000000000..cb62ec013c --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SelectMediaActionParameters.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint parameters for a select media action. + /// + public class SelectMediaActionParameters + { + /// + /// Initializes a new instance of the class. + /// + public SelectMediaActionParameters() + { + // Do nothing + } + + /// + /// This enum contains the different types of media that can be selected. + /// + public enum MediaTypeOption + { + /// + /// Image + /// + Image = 1, + + /// + /// Audio + /// + Audio = 4, + + /// + /// Document + /// + Document = 8 + } + + /// + /// Gets or Sets type of media to be selected of type . + /// + /// This value is the type of media to be selected. + [JsonProperty(PropertyName = "mediaType")] + public MediaTypeOption MediaType { get; set; } + + /// + /// Gets or sets a value indicating whether the allow multiple capture property is enabled of type . + /// + /// This value indicates whether multiple files can be selected. + [JsonProperty(PropertyName = "allowMultipleCapture")] + public bool AllowMultipleCapture { get; set; } + + /// + /// Gets or Sets the max size per file selected of type . + /// + /// This value is the max size per file selected. + [JsonProperty(PropertyName = "maxSizePerFile")] + public int MaxSizePerFile { get; set; } + + /// + /// Gets or Sets the supported file formats of select media action of type . + /// + /// This value is the supported file formats of select media action. + [JsonProperty(PropertyName = "supportedFileFormats")] + public IEnumerable SupportedFileFormats { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationAction.cs new file mode 100644 index 0000000000..72b6d9afc6 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationAction.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint show location action. + /// + public class ShowLocationAction : BaseAction, IAction, IOnCardSelectionAction + { + /// + /// Initializes a new instance of the class. + /// + public ShowLocationAction() + : base("VivaAction.ShowLocation") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + public ShowLocationActionParameters Parameters { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationActionParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationActionParameters.cs new file mode 100644 index 0000000000..cf695d43e0 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/ShowLocationActionParameters.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint parameters for a show location action. + /// + public class ShowLocationActionParameters + { + /// + /// Initializes a new instance of the class. + /// + public ShowLocationActionParameters() + { + // Do nothing + } + + /// + /// Gets or Sets the location coordinates of type . + /// + /// This value is the location to be shown. + [JsonProperty(PropertyName = "locationCoordinates")] + public Location LocationCoordinates { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SubmitAction.cs b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SubmitAction.cs new file mode 100644 index 0000000000..bbd34cc78d --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/Actions/SubmitAction.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Action.Submit. + /// + public class SubmitAction : BaseAction, IAction + { + /// + /// Initializes a new instance of the class. + /// + public SubmitAction() + : base("Submit") + { + // Do nothing + } + + /// + /// Gets or Sets the action parameters of type . + /// + /// This value is the parameters of the action. + [JsonProperty(PropertyName = "parameters")] + #pragma warning disable CA2227 + public Dictionary Parameters { get; set; } + + /// + /// Gets or Sets confirmation dialog associated with this action of type . + /// + /// This value is the confirmation dialog associated with this action. + [JsonProperty(PropertyName = "confirmationDialog")] + public ConfirmationDialog ConfirmationDialog { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/BaseHandleActionResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/BaseHandleActionResponse.cs new file mode 100644 index 0000000000..1be7543313 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/BaseHandleActionResponse.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension View response type. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ViewResponseType + { + /// + /// Render card view. + /// + Card, + + /// + /// Render quick view. + /// + QuickView, + + /// + /// No operation. + /// + NoOp + } + + /// + /// Response returned when handling a client-side action on an Adaptive Card Extension. + /// + public abstract class BaseHandleActionResponse + { + /// + /// Gets the response type. + /// + /// Response type. + [JsonProperty(PropertyName = "responseType")] + public abstract ViewResponseType ResponseType { get; } + + /// + /// Gets or sets render arguments. + /// + /// Render arguments. + [JsonProperty(PropertyName = "renderArguments")] + public object RenderArguments { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/BaseCardComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/BaseCardComponent.cs new file mode 100644 index 0000000000..2f71901d2a --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/BaseCardComponent.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Base class for Adaptive Card Extensions card view components. + /// + public class BaseCardComponent + { + /// + /// Component name. + /// + [JsonProperty(PropertyName = "componentName")] + private readonly CardComponentName cardComponentName; + + /// + /// Initializes a new instance of the class. + /// + /// Component name. + protected BaseCardComponent(CardComponentName cardComponentName) + { + this.cardComponentName = cardComponentName; + } + + /// + /// Gets or sets optional unique identifier of the component's instance. + /// + /// The value is a unique string identifier of the component. + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardBarComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardBarComponent.cs new file mode 100644 index 0000000000..4cc5d2254b --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardBarComponent.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension card bar component. + /// + public class CardBarComponent : BaseCardComponent + { + /// + /// Initializes a new instance of the class. + /// + public CardBarComponent() + : base(CardComponentName.CardBar) + { + } + + /// + /// Gets or sets the title to display. + /// + /// Title value to display in the card bar. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or sets the icon to display. + /// + /// Icon to display in the card bar. + [JsonProperty(PropertyName = "icon")] + public CardImage Icon { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardButtonComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardButtonComponent.cs new file mode 100644 index 0000000000..c4f4e78311 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardButtonComponent.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Names of the supported Adaptive Card Extension Card View button styles. + /// + [JsonConverter(typeof(StringEnumConverter), /*camelCase*/ true)] + public enum CardButtonStyle + { + /// + /// Default style. + /// + Default, + + /// + /// Positive (primary) style. + /// + Positive + } + + /// + /// Adaptive Card Extension card button component. + /// + public class CardButtonComponent : BaseCardComponent, ICardButtonBase + { + /// + /// Initializes a new instance of the class. + /// + public CardButtonComponent() + : base(CardComponentName.CardButton) + { + } + + /// + /// Gets or sets the button's action. + /// + /// Button's action. + [JsonProperty(PropertyName = "action")] + public IAction Action { get; set; } + + /// + /// Gets or sets the text to display. + /// + /// Text value to display in the card button. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or sets the style of the button. + /// + /// Style of the button. + [JsonProperty(PropertyName = "style")] + public CardButtonStyle Style { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardComponentName.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardComponentName.cs new file mode 100644 index 0000000000..0b3b399e02 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardComponentName.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Names of the supported Adaptive Card Extension Card View Components. + /// + [JsonConverter(typeof(StringEnumConverter), /*camelCase*/ true)] + public enum CardComponentName + { + /// + /// Text component. + /// + Text, + + /// + /// Card button component. + /// + CardButton, + + /// + /// Card bar component. + /// + CardBar, + + /// + /// Text input component. + /// + TextInput, + + /// + /// Search box component. + /// + SearchBox, + + /// + /// Search footer component. + /// + SearchFooter + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardImage.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardImage.cs new file mode 100644 index 0000000000..d1d43832a7 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardImage.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Properties for the image rendered in a card view. + /// + public class CardImage + { + /// + /// Gets or sets the URL to display as image or icon name. + /// + /// image URL or icon name. + [JsonProperty(PropertyName = "url")] + public string Image { get; set; } + + /// + /// Gets or sets the alt text for the image. + /// + /// Alt text for the image. + [JsonProperty(PropertyName = "altText")] + public string AltText { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxButton.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxButton.cs new file mode 100644 index 0000000000..1fa53a5a1e --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxButton.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Card Search box button. + /// + public class CardSearchBoxButton : ICardButtonBase + { + /// + /// Gets or sets the button's action. + /// + /// Button's action. + [JsonProperty(PropertyName = "action")] + public IAction Action { get; set; } + + /// + /// Gets or sets unique Id of the button. + /// + /// Unique Id of the button. + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxComponent.cs new file mode 100644 index 0000000000..c8963b4685 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchBoxComponent.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension search box component. + /// + public class CardSearchBoxComponent : BaseCardComponent + { + /// + /// Initializes a new instance of the class. + /// + public CardSearchBoxComponent() + : base(CardComponentName.SearchBox) + { + } + + /// + /// Gets or sets the placeholder text to display in the sarch box. + /// + /// Placeholder text to display. + [JsonProperty(PropertyName = "placeholder")] + public string Placeholder { get; set; } + + /// + /// Gets or sets the default text value of the search box. + /// + /// Default value to display in the search box. + [JsonProperty(PropertyName = "defaultValue")] + public string DefaultValue { get; set; } + + /// + /// Gets or sets the search box's button configuration. + /// + /// Searh box's button configuration. + [JsonProperty(PropertyName = "button")] + public CardSearchBoxButton Button { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchFooterComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchFooterComponent.cs new file mode 100644 index 0000000000..04b673b560 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardSearchFooterComponent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension search footer component. + /// + public class CardSearchFooterComponent : BaseCardComponent + { + /// + /// Initializes a new instance of the class. + /// + public CardSearchFooterComponent() + : base(CardComponentName.SearchFooter) + { + // this.ComponentName = CardComponentName.SearchFooter; + } + + /// + /// Gets or sets the title to display. + /// + /// Title value to display in the search footer. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or sets url to the image to use, should be a square aspect ratio and big enough to fit in the image area. + /// + /// Image Url to display in the footer. + [JsonProperty(PropertyName = "imageUrl")] + public Uri ImageUrl { get; set; } + + /// + /// Gets or sets the initials to display in the image area when there is no image. + /// + /// Initials to display in the image area when there is no image. + [JsonProperty(PropertyName = "imageInitials")] + public string ImageInitials { get; set; } + + /// + /// Gets or sets the primary text to display. For example, name of the person for people search. + /// + /// Primary text to display. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or sets action to invoke when the footer is selected. + /// + /// Selection action. + [JsonProperty(PropertyName = "onSelection")] + public IAction OnSelection { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextComponent.cs new file mode 100644 index 0000000000..29544f10e2 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextComponent.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension card text component. + /// + public class CardTextComponent : BaseCardComponent + { + /// + /// Initializes a new instance of the class. + /// + public CardTextComponent() + : base(CardComponentName.Text) + { + } + + /// + /// Gets or sets the text to display. + /// + /// Text to display. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputBaseButton.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputBaseButton.cs new file mode 100644 index 0000000000..0511e72b19 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputBaseButton.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Base Card text input button class. + /// + public class CardTextInputBaseButton : ICardButtonBase + { + /// + /// Gets or sets the button's action. + /// + /// Button's action. + [JsonProperty(PropertyName = "action")] + public IAction Action { get; set; } + + /// + /// Gets or sets unique Id of the button. + /// + /// Unique Id of the button. + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputComponent.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputComponent.cs new file mode 100644 index 0000000000..7c78146405 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputComponent.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension text input component. + /// + public class CardTextInputComponent : BaseCardComponent + { + /// + /// Initializes a new instance of the class. + /// + public CardTextInputComponent() + : base(CardComponentName.TextInput) + { + } + + /// + /// Gets or sets the placeholder text to display in the text input. + /// + /// Placeholder text to display. + [JsonProperty(PropertyName = "placeholder")] + public string Placeholder { get; set; } + + /// + /// Gets or sets the default text value of the text input. + /// + /// Default value to display in the text input. + [JsonProperty(PropertyName = "defaultValue")] + public string DefaultValue { get; set; } + + /// + /// Gets or sets the text input's button configuration. + /// + /// Text input's button configuration. + [JsonProperty(PropertyName = "button")] + public CardTextInputBaseButton Button { get; set; } + + /// + /// Gets or sets properties for an optional icon, displayed in the left end of the text input. + /// + /// Properties for an optional icon. + [JsonProperty(PropertyName = "iconBefore")] + public CardImage IconBefore { get; set; } + + /// + /// Gets or sets properties for an optional icon, displayed in the right end of the text input. + /// + /// Properties for an optional icon. + [JsonProperty(PropertyName = "iconAfter")] + public CardImage IconAfter { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputIconButton.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputIconButton.cs new file mode 100644 index 0000000000..e283c08ca5 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputIconButton.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Card text input button with icon. + /// + public class CardTextInputIconButton : CardTextInputBaseButton + { + /// + /// Gets or sets the icon to display. + /// + /// Icon to display in the button. + [JsonProperty(PropertyName = "icon")] + public CardImage Icon { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputTitleButton.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputTitleButton.cs new file mode 100644 index 0000000000..46c1eed9b4 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardTextInputTitleButton.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Card text input button with text. + /// + public class CardTextInputTitleButton : CardTextInputBaseButton + { + /// + /// Gets or sets the text to display. + /// + /// Text value to display in the button. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardViewParameters.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardViewParameters.cs new file mode 100644 index 0000000000..a29b51cc0e --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/CardViewParameters.cs @@ -0,0 +1,392 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension Card View Parameters. + /// + public class CardViewParameters + { + /// + /// Initializes a new instance of the class. + /// + protected CardViewParameters() + { + } + + /// + /// Gets or sets card view type. + /// + /// Card view type. + [JsonProperty(PropertyName = "cardViewType")] + public string CardViewType { get; set; } + + /// + /// Gets or sets image displayed on the card. + /// + /// Image displayed on the card. + [JsonProperty(PropertyName = "image")] + public CardImage Image { get; set; } + + /// + /// Gets or sets card view title area (card bar) components. + /// + /// Card bar area components. + [JsonProperty(PropertyName = "cardBar")] +#pragma warning disable CA2227 + public IList CardBar { get; set; } +#pragma warning restore CA2227 + + /// + /// Gets or sets card view header area components. + /// + /// Card header area components. + [JsonProperty(PropertyName = "header")] + public IEnumerable Header { get; set; } + + /// + /// Gets or sets card view body area components. + /// + /// Card body area components. + [JsonProperty(PropertyName = "body")] + public IEnumerable Body { get; set; } + + /// + /// Gets or sets card footer area components. + /// + /// Card footer area components. + [JsonProperty(PropertyName = "footer")] + public IEnumerable Footer { get; set; } + + /// + /// Helper method to create a Basic Text Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Up to two buttons or text input to display as footer. + /// Card view configuration. + /// The Basic Text card view displays the following: + /// - Card bar + /// - One primary text field + /// - Zero or one button in the Medium card size, up to two buttons in Large card size; or text input. + /// + public static CardViewParameters BasicCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + IList footer) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + ValidateGenericCardViewFooterConfiguration(footer); + + return new CardViewParameters() + { + CardViewType = "text", + CardBar = new List { cardBar }, + Header = new List { header }, + Footer = footer + }; + } + + /// + /// Helper method to create a Primary Text Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Text component to display as body. + /// Up to two buttons or text input to display as footer. + /// Card view configuration. + /// The Primary Text card view displays the following: + /// - Card bar + /// - One primary text field + /// - One description text field + /// - Zero or one button in the Medium card size, up to two buttons in Large card size; or text input. + /// + public static CardViewParameters PrimaryTextCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + CardTextComponent body, + IList footer) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + if (body == null) + { + throw new ArgumentNullException(nameof(header)); + } + + ValidateGenericCardViewFooterConfiguration(footer); + + return new CardViewParameters() + { + CardViewType = "text", + CardBar = new List { cardBar }, + Header = new List { header }, + Body = new List { body }, + Footer = footer + }; + } + + /// + /// Helper method to create an Image Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Up to two buttons or text input to display as footer. + /// Image to display. + /// Card view configuration. + /// The Image Card view displays the following: + /// - Card bar + /// - One primary text field + /// - One image + /// - Zero buttons in the Medium card size, up to two buttons in Large card size; or text input. + /// + public static CardViewParameters ImageCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + IList footer, + CardImage image) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + if (image == null) + { + throw new ArgumentNullException(nameof(image)); + } + + ValidateGenericCardViewFooterConfiguration(footer); + + return new CardViewParameters() + { + CardViewType = "text", + CardBar = new List { cardBar }, + Header = new List { header }, + Image = image, + Footer = footer + }; + } + + /// + /// Helper method to create a Text Input Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Text input component to display as body. + /// Up to two buttons to display as footer. + /// Optional image to display. + /// Card view configuration. + /// /// The Text Input Card view displays the following: + /// - Card bar + /// - One primary text field + /// - Zero or one image + /// - Zero text input in Medium card size if image is presented, one text input in Medium card size if no image is presented, one text input in Large card size + /// - Zero buttons in the Medium card size if image is presented, one button in Medium card size if no image is presented, up to two buttons in Large card size; or text input. + /// + public static CardViewParameters TextInputCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + CardTextInputComponent body, + IList footer, + CardImage image) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + if (body == null) + { + throw new ArgumentNullException(nameof(body)); + } + + if (footer.Count > 2) + { + throw new ArgumentException("Card view footer must contain up to two buttons.", nameof(footer)); + } + + return new CardViewParameters() + { + CardViewType = "textInput", + CardBar = new List { cardBar }, + Header = new List { header }, + Body = new List { body }, + Image = image, + Footer = footer + }; + } + + /// + /// Helper method to create a Search Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Search box to display as body. + /// Search footer component to display as footer. + /// Card view configuration. + /// /// The Search Card view displays the following: + /// - Card bar + /// - One primary text field + /// - One search box + /// - One search box footer. + /// + public static CardViewParameters SearchCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + CardSearchBoxComponent body, + CardSearchFooterComponent footer) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + if (body == null) + { + throw new ArgumentNullException(nameof(body)); + } + + if (footer == null) + { + throw new ArgumentNullException(nameof(footer)); + } + + return new CardViewParameters() + { + CardViewType = "search", + CardBar = new List { cardBar }, + Header = new List { header }, + Body = new List { body }, + Footer = new List { footer } + }; + } + + /// + /// Helper method to create a Sign In Card View. + /// + /// Card bar component. + /// Text component to display as header. + /// Text component to display as body. + /// Complete Sign in button. + /// Card view configuration. + public static CardViewParameters SignInCardViewParameters( + CardBarComponent cardBar, + CardTextComponent header, + CardTextComponent body, + CardButtonComponent footer) + { + // Validate parameters + if (cardBar == null) + { + throw new ArgumentNullException(nameof(cardBar)); + } + + if (header == null) + { + throw new ArgumentNullException(nameof(header)); + } + + if (body == null) + { + throw new ArgumentNullException(nameof(body)); + } + + if (footer == null) + { + throw new ArgumentNullException(nameof(footer)); + } + + return new CardViewParameters() + { + CardViewType = "signIn", + CardBar = new List { cardBar }, + Header = new List { header }, + Body = new List { body }, + Footer = new List { footer } + }; + } + + private static void ValidateGenericCardViewFooterConfiguration(IList footer) + { + if (footer == null) + { + // footer can be empty + return; + } + + int componentsCount = footer.Count; + + bool hasError; + + if (componentsCount == 0) + { + return; + } + else if (componentsCount > 2) + { + // we don't support more than 2 components in the footer. + hasError = true; + } + else if (componentsCount == 2) + { + // both components should be buttons. + hasError = !(footer[0] is CardButtonComponent) || !(footer[1] is CardButtonComponent); + } + else + { + // single component should be either a button or a text input + hasError = !(footer[0] is CardButtonComponent) && !(footer[0] is CardTextInputComponent); + } + + if (hasError) + { + throw new ArgumentException("Card view footer must contain up to two buttons or text input", nameof(footer)); + } + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardView/ICardButtonBase.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/ICardButtonBase.cs new file mode 100644 index 0000000000..9cb8f88f0c --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardView/ICardButtonBase.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Base properties for the buttons used in Adaptive Card Extensions card view components. + /// + public interface ICardButtonBase + { + /// + /// Gets or sets the button's action. + /// + /// Button's action. + [JsonProperty(PropertyName = "action")] + public IAction Action { get; set; } + + /// + /// Gets or sets unique Id of the button. + /// + /// Unique Id of the button. + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardViewHandleActionResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardViewHandleActionResponse.cs new file mode 100644 index 0000000000..aa4558cbb1 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardViewHandleActionResponse.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension Client-side action response to render card view. + /// + public class CardViewHandleActionResponse : BaseHandleActionResponse + { + /// + /// Gets the response type. + /// + /// Card. + [JsonProperty(PropertyName = "responseType")] + public override ViewResponseType ResponseType => ViewResponseType.Card; + + /// + /// Gets or sets card view render arguments. + /// + /// Card view render arguments. + [JsonProperty(PropertyName = "renderArguments")] + public new CardViewResponse RenderArguments { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/CardViewResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/CardViewResponse.cs new file mode 100644 index 0000000000..4a1907bf62 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/CardViewResponse.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint Card View Data object. + /// + public class CardViewResponse + { + /// + /// Initializes a new instance of the class. + /// + public CardViewResponse() + { + // Do nothing + } + + /// + /// Gets or Sets AceData for the card view of type . + /// + /// This value is the ace data of the card view response. + [JsonProperty(PropertyName = "aceData")] + public AceData AceData { get; set; } + + /// + /// Gets or sets the card view configuration. + /// + /// Card view configuration. + [JsonProperty(PropertyName = "cardViewParameters")] + public CardViewParameters CardViewParameters { get; set; } + + /// + /// Gets or sets action to invoke when the card is selected. + /// + /// Action to invoke. + [JsonProperty(PropertyName = "onCardSelection")] + public IOnCardSelectionAction OnCardSelection { get; set; } + + /// + /// Gets or Sets the view Id of type . + /// + /// This value is the view id of the card view. + [JsonProperty(PropertyName = "viewId")] + public string ViewId { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/GetPropertyPaneConfigurationResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/GetPropertyPaneConfigurationResponse.cs new file mode 100644 index 0000000000..3a76f020c7 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/GetPropertyPaneConfigurationResponse.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using AdaptiveCards; +using Microsoft.Bot.Schema.Teams; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint GetPropertyPaneConfiguration response object. + /// + public class GetPropertyPaneConfigurationResponse + { + /// + /// Initializes a new instance of the class. + /// + public GetPropertyPaneConfigurationResponse() + { + // Do nothing + } + + /// + /// Gets or Sets the pages of type . + /// + /// This value is the pages of the property pane. + [JsonProperty(PropertyName = "pages")] + public IEnumerable Pages { get; set; } + + /// + /// Gets or Sets the current page of type . + /// + /// This value is the current page of the property pane. + [JsonProperty(PropertyName = "currentPage")] + public int CurrentPage { get; set; } + + /// + /// Gets or Sets the loading indicator delay time of type . + /// + /// This value is the loading indicator delay time of the property pane. + [JsonProperty(PropertyName = "loadingIndicatorDelayTime")] + public int LoadingIndicatorDelayTime { get; set; } + + /// + /// Gets or Sets a value indicating whether the loading indicator should be displayed on top of the property pane or not of type . + /// + /// This value sets whether the loading indicator is shown for the property pane. + [JsonProperty(PropertyName = "showLoadingIndicator")] + public bool ShowLoadingIndicator { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneFieldProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneFieldProperties.cs new file mode 100644 index 0000000000..2e894f589f --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneFieldProperties.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Interface for property pane field properties. + /// +#pragma warning disable CA1040 // Avoid empty interfaces + public interface IPropertyPaneFieldProperties +#pragma warning restore CA1040 // Avoid empty interfaces + { + // This interface has no common methods. + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneGroupOrConditionalGroup.cs b/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneGroupOrConditionalGroup.cs new file mode 100644 index 0000000000..b4b3619d07 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/IPropertyPaneGroupOrConditionalGroup.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Interface for property pane group or conditional group. + /// +#pragma warning disable CA1040 // Avoid empty interfaces + public interface IPropertyPaneGroupOrConditionalGroup +#pragma warning restore CA1040 // Avoid empty interfaces + { + // This interface has no common methods. + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/NoOpHandleActionResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/NoOpHandleActionResponse.cs new file mode 100644 index 0000000000..214036414f --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/NoOpHandleActionResponse.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension Client-side action no-op response. + /// + public class NoOpHandleActionResponse : BaseHandleActionResponse + { + /// + /// Gets the response type. + /// + /// Card. + [JsonProperty(PropertyName = "responseType")] + public override ViewResponseType ResponseType => ViewResponseType.NoOp; + + /// + /// Gets or sets card view render arguments. + /// + /// Card view render arguments. + [JsonProperty(PropertyName = "renderArguments")] + public new object RenderArguments + { + get => null; + set { } + } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneCheckboxProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneCheckboxProperties.cs new file mode 100644 index 0000000000..d394f06304 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneCheckboxProperties.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane checkbox properties object. + /// + public class PropertyPaneCheckboxProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneCheckboxProperties() + { + // Do nothing + } + + /// + /// Gets or Sets the label to display next to the checkbox of type . + /// + /// This value is the text of the checkbox property. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates if the control is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets a value indicating whether the property pane checkbox is checked or not of type . + /// + /// This value indicates if the control is checked. + [JsonProperty(PropertyName = "checked")] + public bool Checked { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupIconProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupIconProperties.cs new file mode 100644 index 0000000000..c8f4522c86 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupIconProperties.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane choice group icon properties object. + /// + public class PropertyPaneChoiceGroupIconProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneChoiceGroupIconProperties() + { + // Do nothing + } + + /// + /// Gets or Sets the name of the icon to use from the Office Fabric icon set of type . + /// + /// This value is the office fabric icon font name of the choice group. + [JsonProperty(PropertyName = "officeFabricIconFontName")] + public string OfficeFabricIconFontName { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupImageSize.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupImageSize.cs new file mode 100644 index 0000000000..2dcc4cca8a --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupImageSize.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane choice group image size object. + /// + public class PropertyPaneChoiceGroupImageSize + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneChoiceGroupImageSize() + { + // Do nothing + } + + /// + /// Gets or Sets the width of the image of type . + /// + /// This value is the width of the choice group. + [JsonProperty(PropertyName = "width")] + public int Width { get; set; } + + /// + /// Gets or Sets the height of the image of type . + /// + /// This value is the height of the choice group. + [JsonProperty(PropertyName = "height")] + public int Height { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupOption.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupOption.cs new file mode 100644 index 0000000000..547723654f --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupOption.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using static Microsoft.Bot.Schema.SharePoint.PropertyPaneDropDownOption; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane choice group option object. + /// + public class PropertyPaneChoiceGroupOption + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneChoiceGroupOption() + { + // Do nothing + } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the choice group. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets a value indicating whether the property pane choice group option is checked or not of type . + /// + /// This value indicates whether the control is checked. + [JsonProperty(PropertyName = "checked")] + public bool Checked { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the control is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets the Icon component props for choice field of type . + /// + /// This value is the icon properties of the choice group. + [JsonProperty(PropertyName = "iconProps")] + public PropertyPaneChoiceGroupIconProperties IconProps { get; set; } + + /// + /// Gets or Sets the width and height of the image in px for choice field of type . + /// + /// This value is the image size of the choice group. + [JsonProperty(PropertyName = "imageSize")] + public PropertyPaneChoiceGroupImageSize ImageSize { get; set; } + + /// + /// Gets or Sets the src of image for choice field of type . + /// + /// This value is the image source of the choice group. + [JsonProperty(PropertyName = "imageSrc")] + public string ImageSrc { get; set; } + + /// + /// Gets or Sets a key to uniquely identify this option of type . + /// + /// This value is the key of the choice group. + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } + + /// + /// Gets or Sets text to render for this option of type . + /// + /// This value is the text of the choice group. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupProperties.cs new file mode 100644 index 0000000000..77d433a7a4 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneChoiceGroupProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane choice group properties object. + /// + public class PropertyPaneChoiceGroupProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneChoiceGroupProperties() + { + // Do nothing + } + + /// + /// Gets or Sets the label of type . + /// + /// This value is the label of the choice group. + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets the collection of options for this choice group of type . + /// + /// This value is the icon properties of the choice group. + [JsonProperty(PropertyName = "options")] + public IEnumerable Options { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownOption.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownOption.cs new file mode 100644 index 0000000000..60440e7fac --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownOption.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane drop down option object. + /// + public class PropertyPaneDropDownOption + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneDropDownOption() + { + // Do nothing + } + + /// + /// This enum contains the different types of fields. + /// + public enum DropDownOptionType + { + /// + /// Render normal menu item. + /// + Normal = 0, + + /// + /// Render a divider. + /// + Divider = 1, + + /// + /// Render menu item as a header. + /// + Header = 2 + } + + /// + /// Gets or Sets index for this option of type . + /// + /// This value is the index of the drop down. + [JsonProperty(PropertyName = "index")] + public int Index { get; set; } + + /// + /// Gets or Sets a key to uniquely identify this option of type . + /// + /// This value is the key of the drop down. + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } + + /// + /// Gets or Sets text to render for this option of type . + /// + /// This value is the text of the drop down. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or Sets the type of option. If omitted, the default is PropertyPaneDropdownMenuItemType.Normal of type . + /// + /// This value is the type of the drop down. + [JsonProperty(PropertyName = "type")] + public DropDownOptionType Type { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownProperties.cs new file mode 100644 index 0000000000..08f0d92ee4 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneDropDownProperties.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane drop down properties object. + /// + public class PropertyPaneDropDownProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneDropDownProperties() + { + // Do nothing + } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the drop down. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets an element's number or position in the current set of controls. Maps to native aria-positionset attribute. It starts from 1 of type . + /// + /// This value is the aria position in set of the drop down. + [JsonProperty(PropertyName = "ariaPositionInSet")] + public int AriaPositionInSet { get; set; } + + /// + /// Gets or Sets the number of items in the current set of controls. Maps to native aria-setsize attribute of type . + /// + /// This value is the aria set size of the drop down. + [JsonProperty(PropertyName = "ariaSetSize")] + public int AriaSetSize { get; set; } + + /// + /// Gets or Sets the label of type . + /// + /// This value is the label of the drop down. + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the property is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets the error message of type . + /// + /// This value is the error message of the drop down. + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; set; } + + /// + /// Gets or Sets the key of the initially selected option of type . + /// + /// This value is the selected key of the drop down. + [JsonProperty(PropertyName = "selectedKey")] + public string SelectedKey { get; set; } + + /// + /// Gets or Sets the collection of options for this Dropdown of type . + /// + /// This value is the options of the drop down. + [JsonProperty(PropertyName = "options")] + public IEnumerable Options { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroup.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroup.cs new file mode 100644 index 0000000000..f59f10c4b6 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroup.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane group object. + /// + public class PropertyPaneGroup : IPropertyPaneGroupOrConditionalGroup + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneGroup() + { + // Do nothing + } + + /// + /// Gets or Sets the group fields of type . + /// + /// This value is the group fields of the property pane group. + [JsonProperty(PropertyName = "groupFields")] + public IEnumerable GroupFields { get; set; } + + /// + /// Gets or Sets the group name of type . + /// + /// This value is the group name of the property pane group. + [JsonProperty(PropertyName = "groupName")] + public string GroupName { get; set; } + + /// + /// Gets or Sets a value indicating whether the PropertyPane group is collapsed or not of type . + /// + /// This value indicates whether the property pane group is collapsed. + [JsonProperty(PropertyName = "isCollapsed")] + public bool IsCollapsed { get; set; } + + /// + /// Gets or Sets a value indicating whether group name should be hidden of type . + /// + /// This value indicates whether the property pane group is hidden. + [JsonProperty(PropertyName = "isGroupNameHidden")] + public bool IsGroupNameHidden { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroupField.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroupField.cs new file mode 100644 index 0000000000..b05e5eb98a --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneGroupField.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane group field object. + /// + public class PropertyPaneGroupField + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneGroupField() + { + // Do nothing + } + + /// + /// This enum contains the different types of fields. + /// + public enum FieldType + { + /// + /// Checkbox field. + /// + CheckBox = 2, + + /// + /// TextField field. + /// + TextField = 3, + + /// + /// Toggle field. + /// + Toggle = 5, + + /// + /// Dropdown field. + /// + Dropdown = 6, + + /// + /// Label field. + /// + Label = 7, + + /// + /// Slider field. + /// + Slider = 8, + + /// + /// ChoiceGroup field. + /// + ChoiceGroup = 10, + + /// + /// Horizontal Rule field. + /// + HorizontalRule = 12, + + /// + /// Link field. + /// + Link = 13 + } + + /// + /// Gets or Sets the type of field enum. + /// + /// This value is the type of the property pane field. + [JsonProperty(PropertyName = "type")] + public FieldType Type { get; set; } + + /// + /// Gets or Sets the properties property of type . + /// + /// This value is the properties of the property pane field. + [JsonProperty(PropertyName = "properties")] + public IPropertyPaneFieldProperties Properties { get; set; } + + /// + /// Gets or Sets a value indicating whether this control should be focused of type . + /// + /// This value indicates whether the property pane field should focus. + [JsonProperty(PropertyName = "shouldFocus")] + public bool ShouldFocus { get; set; } + + /// + /// Gets or Sets the target property of type . + /// + /// This value is the target property of the property pane field. + [JsonProperty(PropertyName = "targetProperty")] + public string TargetProperty { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLabelProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLabelProperties.cs new file mode 100644 index 0000000000..b27aa7159b --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLabelProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane label properties object. + /// + public class PropertyPaneLabelProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneLabelProperties() + { + // Do nothing + } + + /// + /// Gets or Sets the display text for the label of type . + /// + /// This value is the text of the property pane label. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Gets or Sets a value indicating whether the associated form field is required or not. of type . + /// + /// This value indicates whether the property pane field is required. + [JsonProperty(PropertyName = "required")] + public bool Required { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkPopupWindowProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkPopupWindowProperties.cs new file mode 100644 index 0000000000..9e364592be --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkPopupWindowProperties.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using static Microsoft.Bot.Schema.SharePoint.PropertyPaneGroupField; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane link popup window properties object. + /// + public class PropertyPaneLinkPopupWindowProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneLinkPopupWindowProperties() + { + // Do nothing + } + + /// + /// This enum contains the different types of fields. + /// + public enum PopupWindowPosition + { + /// + /// Center. + /// + Center = 0, + + /// + /// Right Top. + /// + RightTop = 1, + + /// + /// Left Top . + /// + LeftTop = 2, + + /// + /// Right Bottom. + /// + RightBottom = 3, + + /// + /// Left Bottom. + /// + LeftBottom = 4, + } + + /// + /// Gets or Sets the height of the pop up window of type . + /// + /// This value is the height of the property pane popup. + [JsonProperty(PropertyName = "height")] + public int Height { get; set; } + + /// + /// Gets or Sets the position of pop up window enum. + /// + /// This value is the window position of the property pane popup. + [JsonProperty(PropertyName = "positionWindowPosition")] + public PopupWindowPosition PositionWindowPosition { get; set; } + + /// + /// Gets or Sets the title of pop up window of type . + /// + /// This value is the title of the property pane popup. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or Sets the width of the pop up window of type . + /// + /// This value is the width of the property pane popup. + [JsonProperty(PropertyName = "width")] + public int Width { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkProperties.cs new file mode 100644 index 0000000000..6927373c4c --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneLinkProperties.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane link properties object. + /// + public class PropertyPaneLinkProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneLinkProperties() + { + // Do nothing + } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the property pane link. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the property pane link is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets the location to which the link is targeted to of type . + /// + /// This value is the href of the property pane link. + [JsonProperty(PropertyName = "href")] + public string Href { get; set; } + + /// + /// Gets or Sets the props of popup window. of type . + /// + /// This value is the popup window properties of the property pane link. + [JsonProperty(PropertyName = "popupWindowProps")] + public PropertyPaneLinkPopupWindowProperties PopupWindowProps { get; set; } + + /// + /// Gets or Sets where to display the linked resource of type . + /// + /// This value is the target of the property pane link. + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + + /// + /// Gets or Sets the display text for the link of type . + /// + /// This value is the text of the property pane link. + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePage.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePage.cs new file mode 100644 index 0000000000..1a9ae76a43 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePage.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane page object. + /// + public class PropertyPanePage + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPanePage() + { + // Do nothing + } + + /// + /// Gets or Sets the groups of type . + /// + /// This value is the groups of the property pane page. + [JsonProperty(PropertyName = "groups")] + public IEnumerable Groups { get; set; } + + /// + /// Gets or Sets a value indicating whether the groups on the PropertyPanePage are displayed as accordion or not of type . + /// + /// This value indicates whether the property pane page is displayed as an accordion. + [JsonProperty(PropertyName = "displayGroupsAsAccordion")] + public bool DisplayGroupsAsAccordion { get; set; } + + /// + /// Gets or Sets the header for the property pane of type . + /// + /// This value is the header of the property pane page. + [JsonProperty(PropertyName = "header")] + public PropertyPanePageHeader Header { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePageHeader.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePageHeader.cs new file mode 100644 index 0000000000..45b7086d34 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPanePageHeader.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane page header object. + /// + public class PropertyPanePageHeader + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPanePageHeader() + { + // Do nothing + } + + /// + /// Gets or Sets the description of type . + /// + /// This value is the description of the property pane page header. + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneSliderProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneSliderProperties.cs new file mode 100644 index 0000000000..5a993949b2 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneSliderProperties.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane slider properties object. + /// + public class PropertyPaneSliderProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneSliderProperties() + { + this.Step = 1; + } + + /// + /// Gets or Sets the label of type . + /// + /// This value is the label of the slider. + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets the value of type . + /// + /// This value is the value of the slider. + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the slider. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the slider is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets the max value of the Slider of type . + /// + /// This value is the max value of the slider. + [JsonProperty(PropertyName = "max")] + public int Max { get; set; } + + /// + /// Gets or Sets the min value of the Slider of type . + /// + /// This value is the min value of the slider. + [JsonProperty(PropertyName = "min")] + public int Min { get; set; } + + /// + /// Gets or Sets a value indicating whether to show the value on the right of the Slider of type . + /// + /// This value indicates whether the value of the slider should be shown. + [JsonProperty(PropertyName = "showValue")] + public bool ShowValue { get; set; } + + /// + /// Gets or Sets the difference between the two adjacent values of the Slider. Defaults to 1. of type . + /// + /// This value is the step amount of the slider. + [JsonProperty(PropertyName = "step")] + public int Step { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneTextFieldProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneTextFieldProperties.cs new file mode 100644 index 0000000000..984217cae2 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneTextFieldProperties.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane text field properties object. + /// + public class PropertyPaneTextFieldProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneTextFieldProperties() + { + // Do nothing + } + + /// + /// Gets or Sets the label of type . + /// + /// This value is the label of the text field. + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets the value of type . + /// + /// This value is the value of the text field. + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the text field. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets the description of type . + /// + /// This value is the description of the text field. + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the text field is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets the error message of type . + /// + /// This value is the error message of the text field. + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; set; } + + /// + /// Gets or Sets the name used to log PropertyPaneTextField value changes for engagement tracking of type . + /// + /// This value is the log name of the text field. + [JsonProperty(PropertyName = "logName")] + public string LogName { get; set; } + + /// + /// Gets or Sets the maximum number of characters that the PropertyPaneTextField can have of type . + /// + /// This value is the max length of the text field. + [JsonProperty(PropertyName = "maxLength")] + public int MaxLength { get; set; } + + /// + /// Gets or Sets a value indicating whether or not the text field is a multiline text field of type . + /// + /// This value indicates whether the text field is multiline. + [JsonProperty(PropertyName = "multiline")] + public bool Multiline { get; set; } + + /// + /// Gets or Sets the placeholder text to be displayed in the text field of type . + /// + /// This value is the place holder of the text field. + [JsonProperty(PropertyName = "placeholder")] + public string Placeholder { get; set; } + + /// + /// Gets or Sets a value indicating whether or not the multiline text field is resizable of type . + /// + /// This value indicates whether the text field is resiable. + [JsonProperty(PropertyName = "resizable")] + public bool Resizable { get; set; } + + /// + /// Gets or Sets the value that specifies the visible height of a text area(multiline text TextField), in lines.maximum number of characters that the PropertyPaneTextField can have of type . + /// + /// This value is the number of rows of the text field. + [JsonProperty(PropertyName = "rows")] + public int Rows { get; set; } + + /// + /// Gets or Sets a value indicating whether or not the text field is underlined of type . + /// + /// This value indicates whether the text field is underlined. + [JsonProperty(PropertyName = "underlined")] + public bool Underlined { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneToggleProperties.cs b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneToggleProperties.cs new file mode 100644 index 0000000000..d69f34521e --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/PropertyPaneToggleProperties.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint property pane toggle properties object. + /// + public class PropertyPaneToggleProperties : IPropertyPaneFieldProperties + { + /// + /// Initializes a new instance of the class. + /// + public PropertyPaneToggleProperties() + { + // Do nothing + } + + /// + /// Gets or Sets optional ariaLabel flag. Text for screen-reader to announce regardless of toggle state. Of type . + /// + /// This value is the aria label of the toggle field. + [JsonProperty(PropertyName = "ariaLabel")] + public string AriaLabel { get; set; } + + /// + /// Gets or Sets the label of type . + /// + /// This value is the label of the toggle field. + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets a value indicating whether this control is enabled or not of type . + /// + /// This value indicates whether the toggle field is disabled. + [JsonProperty(PropertyName = "disabled")] + public bool Disabled { get; set; } + + /// + /// Gets or Sets a value indicating whether the property pane checkbox is checked or not of type . + /// + /// This value indicates whether the toggle field is checked. + [JsonProperty(PropertyName = "checked")] + public bool Checked { get; set; } + + /// + /// Gets or Sets a key to uniquely identify the field of type . + /// + /// This value is the key of the toggle field. + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } + + /// + /// Gets or Sets text to display when toggle is OFF of type . + /// + /// This value is the label of the toggle field when off. + [JsonProperty(PropertyName = "offText")] + public string OffText { get; set; } + + /// + /// Gets or Sets text to display when toggle is ON of type . + /// + /// This value is the label of the toggle field when on. + [JsonProperty(PropertyName = "onText")] + public string OnText { get; set; } + + /// + /// Gets or Sets text for screen-reader to announce when toggle is OFF of type . + /// + /// This value is the aria label of the toggle field when off. + [JsonProperty(PropertyName = "offAriaLabel")] + public string OffAriaLabel { get; set; } + + /// + /// Gets or Sets text for screen-reader to announce when toggle is ON of type . + /// + /// This value is the aria label of the toggle field when on. + [JsonProperty(PropertyName = "onAriaLabel")] + public string OnAriaLabel { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewData.cs b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewData.cs new file mode 100644 index 0000000000..e77b074993 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewData.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint Quick View Data object. + /// + public class QuickViewData + { + /// + /// Initializes a new instance of the class. + /// + public QuickViewData() + { + // Do nothing + } + + /// + /// Gets or Sets the title of type . + /// + /// This value is the title of the quick view data. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or Sets the description of type . + /// + /// This value is the description of the quick view data. + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewHandleActionResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewHandleActionResponse.cs new file mode 100644 index 0000000000..dd89c9ce13 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewHandleActionResponse.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// Adaptive Card Extension Client-side action response to render quick view. + /// + public class QuickViewHandleActionResponse : BaseHandleActionResponse + { + /// + /// Gets the response type. + /// + /// Card. + [JsonProperty(PropertyName = "responseType")] + public override ViewResponseType ResponseType => ViewResponseType.QuickView; + + /// + /// Gets or sets card view render arguments. + /// + /// Card view render arguments. + [JsonProperty(PropertyName = "renderArguments")] + public new QuickViewResponse RenderArguments { get; set; } + } +} diff --git a/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewResponse.cs b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewResponse.cs new file mode 100644 index 0000000000..27e1ce417d --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/SharePoint/QuickViewResponse.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; +using AdaptiveCards; +using Microsoft.Bot.Schema.Teams; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Bot.Schema.SharePoint +{ + /// + /// SharePoint GetQuickView response object. + /// + public class QuickViewResponse + { + /// + /// Initializes a new instance of the class. + /// + public QuickViewResponse() + { + // Do nothing + } + + /// + /// Gets or Sets data for the quick view. + /// + /// This value is the data of the quick view response. + [JsonProperty(PropertyName = "data")] + public object Data { get; set; } + + /// + /// Gets or Sets data for the quick view template of type . + /// + /// This value is the template of the quick view response. + [JsonProperty(PropertyName = "template")] + public AdaptiveCard Template { get; set; } + + /// + /// Gets or Sets view Id of type . + /// + /// This value is the view Id of the quick view response. + [JsonProperty(PropertyName = "viewId")] + public string ViewId { get; set; } + + /// + /// Gets or Sets title of type . + /// + /// This value is the title of the quick view response. + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or Sets the external link parameters of type . + /// + /// This value is the external link parameters of the quick view response. + [JsonProperty(PropertyName = "externalLink")] + public ExternalLinkActionParameters ExternalLink { get; set; } + + /// + /// Gets or Sets focus parameters of type . + /// + /// This value is the focus parameters of the quick view response. + [JsonProperty(PropertyName = "focusParameters")] + public FocusParameters FocusParameters { get; set; } + } +} diff --git a/tests/Microsoft.Bot.Builder.Tests/SharePoint/SharePointActivityHandlerTests.cs b/tests/Microsoft.Bot.Builder.Tests/SharePoint/SharePointActivityHandlerTests.cs new file mode 100644 index 0000000000..58c0f27c27 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Tests/SharePoint/SharePointActivityHandlerTests.cs @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Bot.Builder.Tests; +using Microsoft.Bot.Connector; +using Microsoft.Bot.Connector.Authentication; +using Microsoft.Bot.Schema; +using Microsoft.Bot.Schema.SharePoint; +using Microsoft.Bot.Schema.Teams; +using Microsoft.Rest.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; +using Xunit; + +namespace Microsoft.Bot.Builder.SharePoint.Tests +{ + public class SharePointActivityHandlerTests + { + [Fact] + public async Task TestSharePointGetCardViewAction() + { + // Arrange + var activity = new Activity + { + Type = ActivityTypes.Invoke, + Name = "cardExtension/getCardView", + Value = JObject.FromObject(new object()), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Single(bot.Record); + Assert.Equal("OnSharePointTaskGetCardViewAsync", bot.Record[0]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.IsType(activitiesToSend[0].Value); + Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status); + } + + [Fact] + public async Task TestSharePointGetQuickViewAction() + { + // Arrange + var activity = new Activity + { + Type = ActivityTypes.Invoke, + Name = "cardExtension/getQuickView", + Value = JObject.FromObject(new object()), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Single(bot.Record); + Assert.Equal("OnSharePointTaskGetQuickViewAsync", bot.Record[0]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.IsType(activitiesToSend[0].Value); + Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status); + } + + [Fact] + public async Task TestSharePointGetPropertyPaneConfigurationAction() + { + // Arrange + var activity = new Activity + { + Type = ActivityTypes.Invoke, + Name = "cardExtension/getPropertyPaneConfiguration", + Value = JObject.FromObject(new object()), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Single(bot.Record); + Assert.Equal("OnSharePointTaskGetPropertyPaneConfigurationAsync", bot.Record[0]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.IsType(activitiesToSend[0].Value); + Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status); + } + + [Fact] + public async Task TestSharePointSetPropertyPaneConfigurationAction() + { + // Arrange + var activity = new Activity + { + Type = ActivityTypes.Invoke, + Name = "cardExtension/setPropertyPaneConfiguration", + Value = JObject.FromObject(new object()), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Single(bot.Record); + Assert.Equal("OnSharePointTaskSetPropertyPaneConfigurationAsync", bot.Record[0]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.IsType(activitiesToSend[0].Value); + Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status); + } + + [Fact] + public async Task TestSharePointHandleActionAction() + { + // Arrange + var activity = new Activity + { + Type = ActivityTypes.Invoke, + Name = "cardExtension/handleAction", + Value = JObject.FromObject(new object()), + }; + + Activity[] activitiesToSend = null; + void CaptureSend(Activity[] arg) + { + activitiesToSend = arg; + } + + var turnContext = new TurnContext(new SimpleAdapter(CaptureSend), activity); + + // Act + var bot = new TestActivityHandler(); + await ((IBot)bot).OnTurnAsync(turnContext); + + // Assert + Assert.Single(bot.Record); + Assert.Equal("OnSharePointTaskHandleActionAsync", bot.Record[0]); + Assert.NotNull(activitiesToSend); + Assert.Single(activitiesToSend); + Assert.IsType(activitiesToSend[0].Value); + Assert.Equal(200, ((InvokeResponse)activitiesToSend[0].Value).Status); + } + + private class TestActivityHandler : SharePointActivityHandler + { + public List Record { get; } = new List(); + + // Invoke + protected override Task OnSharePointTaskGetCardViewAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + return Task.FromResult(new CardViewResponse()); + } + + protected override Task OnSharePointTaskGetPropertyPaneConfigurationAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + return Task.FromResult(new GetPropertyPaneConfigurationResponse()); + } + + protected override Task OnSharePointTaskGetQuickViewAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + return Task.FromResult(new QuickViewResponse()); + } + + protected override Task OnSharePointTaskSetPropertyPaneConfigurationAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + return Task.FromResult(new NoOpHandleActionResponse()); + } + + protected override Task OnSharePointTaskHandleActionAsync(ITurnContext turnContext, AceRequest aceRequest, CancellationToken cancellationToken) + { + Record.Add(MethodBase.GetCurrentMethod().Name); + return Task.FromResult(new NoOpHandleActionResponse()); + } + } + } +}