194 lines
5.8 KiB
C#
194 lines
5.8 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace LineMessaging
|
|
{
|
|
public interface ILineFlexObject
|
|
{
|
|
FlexObjectType Type { get; }
|
|
}
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum FlexObjectType
|
|
{
|
|
[EnumMember(Value = "box")]
|
|
Box,
|
|
[EnumMember(Value = "button")]
|
|
Button,
|
|
[EnumMember(Value = "image")]
|
|
Image,
|
|
[EnumMember(Value = "video")]
|
|
Video,
|
|
[EnumMember(Value = "icon")]
|
|
Icon,
|
|
[EnumMember(Value = "text")]
|
|
Text,
|
|
[EnumMember(Value = "span")]
|
|
Span,
|
|
[EnumMember(Value = "separator")]
|
|
Separator,
|
|
[EnumMember(Value = "filler")]
|
|
Filler,
|
|
}
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum FlexObjectBoxLayout
|
|
{
|
|
[EnumMember(Value = "vertical")]
|
|
Vertical,
|
|
[EnumMember(Value = "horizontal")]
|
|
Horizontal,
|
|
[EnumMember(Value = "baseline")]
|
|
Baseline,
|
|
}
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum FlexObjectButtonStype
|
|
{
|
|
[EnumMember(Value = "link")]
|
|
Link,
|
|
[EnumMember(Value = "primary")]
|
|
Primary,
|
|
[EnumMember(Value = "secondary")]
|
|
Secondary,
|
|
}
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum FlexObjectSize
|
|
{
|
|
xxs,
|
|
xs,
|
|
sm,
|
|
md,
|
|
lg,
|
|
xl,
|
|
xxl,
|
|
[EnumMember(Value = "3xl")]
|
|
xxxl,
|
|
[EnumMember(Value = "4xl")]
|
|
xxxxl,
|
|
[EnumMember(Value = "5xl")]
|
|
xxxxxl,
|
|
full
|
|
}
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum FlexObjectTextWeidht
|
|
{
|
|
[EnumMember(Value = "regular")]
|
|
Regular,
|
|
[EnumMember(Value = "bold")]
|
|
Bold,
|
|
}
|
|
public class LineFlexBox : ILineFlexObject
|
|
{
|
|
public LineFlexBox()
|
|
{
|
|
Layout = FlexObjectBoxLayout.Vertical;
|
|
Contents = new List<ILineFlexObject>();
|
|
}
|
|
public FlexObjectType Type => FlexObjectType.Box;
|
|
public FlexObjectBoxLayout Layout { get; set; }
|
|
public ICollection<ILineFlexObject> Contents { get; set; }
|
|
//public FlexObjectSize Height { get; set; }
|
|
//public string JustifyContent => "space-evenly";
|
|
//public string AlignItems => "center";
|
|
public string PaddingAll { get; set; }
|
|
public string PaddingTop { get; set; }
|
|
public string PaddingBottom{ get; set; }
|
|
public string PaddingStart { get; set; }
|
|
public string PaddingEnd { get; set; }
|
|
|
|
}
|
|
public class LineFlexButton : ILineFlexObject
|
|
{
|
|
public FlexObjectType Type => FlexObjectType.Button;
|
|
[JsonRequired]
|
|
public ILineAction Action { get; set; }
|
|
public FlexObjectButtonStype Style { get; set; }
|
|
//public FlexObjectSize Size { get; set; }
|
|
}
|
|
public class LineFlexImage : ILineFlexObject
|
|
{
|
|
public LineFlexImage(string url)
|
|
{
|
|
AspectRatio = "1.91:1";
|
|
Url = url;
|
|
Size = FlexObjectSize.md;
|
|
}
|
|
public FlexObjectType Type => FlexObjectType.Image;
|
|
[JsonRequired]
|
|
public string Url { get; set; }
|
|
public FlexObjectSize Size { get; set; }
|
|
public string AspectRatio { get; set; }
|
|
public ILineAction Action { get; set; }
|
|
|
|
}
|
|
public class LineFlexText : ILineFlexObject
|
|
{
|
|
public LineFlexText()
|
|
{
|
|
Size = FlexObjectSize.md;
|
|
Weight = FlexObjectTextWeidht.Regular;
|
|
}
|
|
public LineFlexText(string text)
|
|
{
|
|
Text = text;
|
|
Size = FlexObjectSize.md;
|
|
Weight = FlexObjectTextWeidht.Regular;
|
|
}
|
|
public FlexObjectType Type => FlexObjectType.Text;
|
|
[JsonRequired]
|
|
public string Text { get; set; }
|
|
public int Flex { get; set; }
|
|
//public ILineAction Action { get; set; }
|
|
//public FlexObjectButtonStype Style { get; set; }
|
|
public FlexObjectSize Size { get; set; }
|
|
public FlexObjectSize? OffsetTop { get; set; }
|
|
public FlexObjectSize? OffsetBottom { get; set; }
|
|
public FlexObjectSize? OffsetStart { get; set; }
|
|
public FlexObjectSize? OffsetEnd { get; set; }
|
|
|
|
public FlexObjectTextWeidht Weight { get; set; }
|
|
public string Color { get; set; }
|
|
/// <summary>
|
|
/// true to wrap text. The default value is false. If set to true, you can use a new line character (\n) to begin on a new line. For more information, see Wrapping text in the Messaging API documentation.
|
|
/// </summary>
|
|
public bool Wrap { get; set; }
|
|
|
|
/// <summary>
|
|
/// Style of the text. Specify one of these values: normal: Normal italic: Italic The default value is normal.
|
|
/// </summary>
|
|
public string Style { get; set; }
|
|
/// <summary>
|
|
/// Decoration of the text. Specify one of these values:
|
|
// none: No decoration
|
|
// underline: Underline
|
|
// line-through: Strikethrough
|
|
// The default value is none.
|
|
/// </summary>
|
|
public string Decoration { get; set; }
|
|
/// <summary>
|
|
/// start: Left-aligned, end: Right-aligned, center: Center-aligned(default value)
|
|
/// </summary>
|
|
public string Align { get; set; }
|
|
}
|
|
public class LineFlexSeparator : ILineFlexObject
|
|
{
|
|
public LineFlexSeparator()
|
|
{
|
|
Margin = FlexObjectSize.md;
|
|
}
|
|
public FlexObjectType Type => FlexObjectType.Separator;
|
|
public FlexObjectSize Margin { get; set; }
|
|
|
|
}
|
|
|
|
}
|