Initial commit
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public interface ILineAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
ActionType Type { get; }
|
||||
}
|
||||
|
||||
public class PostbackAction : ILineAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Postback;
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("data")]
|
||||
public string Data { get; set; }
|
||||
|
||||
[JsonProperty("displayText")]
|
||||
public string DisplayText { get; set; }
|
||||
|
||||
[JsonProperty("inputOption")]
|
||||
public string InputOption { get; set; }
|
||||
|
||||
[JsonProperty("fillInText")]
|
||||
public string FillInText { get; set; }
|
||||
}
|
||||
|
||||
public class MessageAction : ILineAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Message;
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
public class UriAction : ILineAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Uri;
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
[JsonProperty("uri")]
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
|
||||
public class DatetimepickerAction : ILineAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Datetimepicker;
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("data")]
|
||||
public string Data { get; set; }
|
||||
|
||||
[JsonProperty("mode")]
|
||||
public string Mode { get; set; }
|
||||
|
||||
[JsonProperty("initial")]
|
||||
public string Initial { get; set; }
|
||||
|
||||
[JsonProperty("max")]
|
||||
public string Max { get; set; }
|
||||
|
||||
[JsonProperty("min")]
|
||||
public string Min { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineAreaBounds
|
||||
{
|
||||
[JsonProperty("x")]
|
||||
public int X { get; set; }
|
||||
|
||||
[JsonProperty("y")]
|
||||
public int Y { get; set; }
|
||||
|
||||
[JsonProperty("width")]
|
||||
public int Width { get; set; }
|
||||
|
||||
[JsonProperty("height")]
|
||||
public int Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineAudioMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Audio;
|
||||
|
||||
[JsonProperty("originalContentUrl")]
|
||||
public string OriginalContentUrl { get; set; }
|
||||
|
||||
[JsonProperty("duration")]
|
||||
public long Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum FlexContentType
|
||||
{
|
||||
[EnumMember(Value = "bubble")]
|
||||
Bubble,
|
||||
}
|
||||
public class LineFlexMessage : ILineMessage
|
||||
{
|
||||
public LineFlexMessage()
|
||||
{
|
||||
Contents = new LineFlexContent();
|
||||
//Contents.Body = new LineFlexBox();
|
||||
}
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Flex;
|
||||
|
||||
[JsonProperty("altText")]
|
||||
public string AltText { get; set; }
|
||||
[JsonProperty("contents")]
|
||||
public LineFlexContent Contents { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public class LineFlexContent
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public FlexContentType Type => FlexContentType.Bubble;
|
||||
[JsonProperty("header")]
|
||||
public ILineFlexObject Header { get; set; }
|
||||
[JsonProperty("hero")]
|
||||
public ILineFlexObject Hero { get; set; }
|
||||
|
||||
[JsonProperty("body")]
|
||||
public ILineFlexObject Body { get; set; }
|
||||
|
||||
[JsonProperty("footer")]
|
||||
public ILineFlexObject Footer { get; set; }
|
||||
|
||||
public ICollection<ILineFlexObject> InitHeader()
|
||||
{
|
||||
var FlexBox = new LineFlexBox();
|
||||
this.Header = FlexBox;
|
||||
FlexBox.PaddingAll = "sm";
|
||||
return FlexBox.Contents;
|
||||
}
|
||||
|
||||
public ICollection<ILineFlexObject> InitHero()
|
||||
{
|
||||
var FlexBox = new LineFlexBox();
|
||||
this.Hero = FlexBox;
|
||||
return FlexBox.Contents;
|
||||
}
|
||||
public ICollection<ILineFlexObject> InitBody()
|
||||
{
|
||||
var FlexBox = new LineFlexBox();
|
||||
FlexBox.PaddingBottom = "none";
|
||||
this.Body = FlexBox;
|
||||
return FlexBox.Contents;
|
||||
}
|
||||
|
||||
public ICollection<ILineFlexObject> InitFooter()
|
||||
{
|
||||
var FlexBox = new LineFlexBox();
|
||||
this.Footer = FlexBox;
|
||||
FlexBox.PaddingAll = "none";
|
||||
return FlexBox.Contents;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineImageMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Image;
|
||||
|
||||
[JsonProperty("originalContentUrl")]
|
||||
public string OriginalContentUrl { get; set; }
|
||||
|
||||
[JsonProperty("previewImageUrl")]
|
||||
public string PreviewImageUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineImagemapMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Imagemap;
|
||||
|
||||
[JsonProperty("baseUrl")]
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
[JsonProperty("altText")]
|
||||
public string AltText { get; set; }
|
||||
|
||||
[JsonProperty("baseSize")]
|
||||
public LineSizeObject BaseSize { get; set; }
|
||||
|
||||
[JsonProperty("actions")]
|
||||
public IAction[] Actions { get; set; }
|
||||
|
||||
public interface IAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
ActionType Type { get; }
|
||||
|
||||
[JsonProperty("area")]
|
||||
LineAreaBounds Area { get; set; }
|
||||
}
|
||||
|
||||
public class LinkActionObject : IAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Uri;
|
||||
|
||||
[JsonProperty("linkUri")]
|
||||
public string LinkUri { get; set; }
|
||||
|
||||
[JsonProperty("area")]
|
||||
public LineAreaBounds Area { get; set; }
|
||||
}
|
||||
|
||||
public class MessageActionObject : IAction
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ActionType Type => ActionType.Message;
|
||||
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
|
||||
[JsonProperty("area")]
|
||||
public LineAreaBounds Area { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineLocationMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Location;
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("address")]
|
||||
public string Address { get; set; }
|
||||
|
||||
[JsonProperty("latitude")]
|
||||
public double Latitude { get; set; }
|
||||
|
||||
[JsonProperty("longitude")]
|
||||
public double Longitude { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum MessageType
|
||||
{
|
||||
[EnumMember(Value = "text")]
|
||||
Text,
|
||||
|
||||
[EnumMember(Value = "image")]
|
||||
Image,
|
||||
|
||||
[EnumMember(Value = "video")]
|
||||
Video,
|
||||
|
||||
[EnumMember(Value = "audio")]
|
||||
Audio,
|
||||
|
||||
[EnumMember(Value = "file")]
|
||||
File,
|
||||
|
||||
[EnumMember(Value = "location")]
|
||||
Location,
|
||||
|
||||
[EnumMember(Value = "sticker")]
|
||||
Sticker,
|
||||
|
||||
[EnumMember(Value = "imagemap")]
|
||||
Imagemap,
|
||||
|
||||
[EnumMember(Value = "template")]
|
||||
Template,
|
||||
|
||||
[EnumMember(Value = "flex")]
|
||||
Flex
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum TemplateType
|
||||
{
|
||||
[EnumMember(Value = "buttons")]
|
||||
Buttons,
|
||||
|
||||
[EnumMember(Value = "confirm")]
|
||||
Confirm,
|
||||
|
||||
[EnumMember(Value = "carousel")]
|
||||
Carousel,
|
||||
|
||||
[EnumMember(Value = "image_carousel")]
|
||||
ImageCarousel,
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ActionType
|
||||
{
|
||||
[EnumMember(Value = "postback")]
|
||||
Postback,
|
||||
|
||||
[EnumMember(Value = "message")]
|
||||
Message,
|
||||
|
||||
[EnumMember(Value = "uri")]
|
||||
Uri,
|
||||
|
||||
[EnumMember(Value = "datetimepicker")]
|
||||
Datetimepicker
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineMulticastMessage
|
||||
{
|
||||
[JsonProperty("to")]
|
||||
public IEnumerable<string> To { get; set; }
|
||||
|
||||
[JsonProperty("messages")]
|
||||
public IEnumerable<ILineMessage> Messages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LinePushMessage
|
||||
{
|
||||
[JsonProperty("to")]
|
||||
public string To { get; set; }
|
||||
|
||||
[JsonProperty("messages")]
|
||||
public IEnumerable<ILineMessage> Messages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineReplyMessage
|
||||
{
|
||||
[JsonProperty("replyToken")]
|
||||
public string ReplyToken { get; set; }
|
||||
|
||||
[JsonProperty("messages")]
|
||||
public IEnumerable<ILineMessage> Messages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineRichMenu
|
||||
{
|
||||
[JsonProperty("size")]
|
||||
public LineSizeObject Size { get; set; }
|
||||
|
||||
[JsonProperty("selected")]
|
||||
public bool Selected { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("charBarText")]
|
||||
public string CharBarText { get; set; }
|
||||
|
||||
[JsonProperty("areas")]
|
||||
public BoundsObject[] Areas { get; set; }
|
||||
|
||||
public class BoundsObject
|
||||
{
|
||||
[JsonProperty("bounds")]
|
||||
public LineAreaBounds Bounds { get; set; }
|
||||
|
||||
[JsonProperty("action")]
|
||||
public ILineAction Action { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineRichMenuResponse : LineRichMenu
|
||||
{
|
||||
[JsonProperty("richMenuId")]
|
||||
public string RichMenuId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineSizeObject
|
||||
{
|
||||
[JsonProperty("width")]
|
||||
public int Width { get; set; }
|
||||
|
||||
[JsonProperty("height")]
|
||||
public int Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineStickerMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Sticker;
|
||||
|
||||
[JsonProperty("packageId")]
|
||||
public string PackageId { get; set; }
|
||||
|
||||
[JsonProperty("stickerId")]
|
||||
public string StickerId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
|
||||
|
||||
|
||||
public interface ITemplateObject
|
||||
{
|
||||
|
||||
[JsonProperty("type")]
|
||||
TemplateType Type { get; }
|
||||
}
|
||||
|
||||
public class ButtonTemplateObject : ITemplateObject
|
||||
{
|
||||
|
||||
public ButtonTemplateObject()
|
||||
{
|
||||
Actions = new List<ILineAction>();
|
||||
ImageSize = "cover";
|
||||
ImageBackgroundColor = "#FFFFFF";
|
||||
ImageAspectRatio = "rectangle";
|
||||
}
|
||||
[JsonProperty("type")]
|
||||
public TemplateType Type => TemplateType.Buttons;
|
||||
|
||||
[JsonProperty("thumbnailImageUrl")]
|
||||
public string ThumbnailImageUrl { get; set; }
|
||||
|
||||
[JsonProperty("imageAspectRatio")]
|
||||
public string ImageAspectRatio { get; set; }
|
||||
|
||||
[JsonProperty("imageSize")]
|
||||
public string ImageSize { get; set; }
|
||||
|
||||
[JsonProperty("imageBackgroundColor")]
|
||||
public string ImageBackgroundColor { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
|
||||
[JsonProperty("defaultAction")]
|
||||
public ILineAction DefaultAction { get; set; }
|
||||
|
||||
[JsonProperty("actions")]
|
||||
public List<ILineAction> Actions { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineTemplateMessage<T> : ILineMessage where T: ITemplateObject,new ()
|
||||
{
|
||||
public LineTemplateMessage()
|
||||
{
|
||||
Template = new T();
|
||||
}
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Template;
|
||||
|
||||
[JsonProperty("altText")]
|
||||
public string AltText { get; set; }
|
||||
|
||||
[JsonProperty("template")]
|
||||
public T Template { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineTextMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Text;
|
||||
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
[JsonProperty("emojis")]
|
||||
public List<Emoji> Emojis { get; set; }
|
||||
public void AddEmoji(int index, string productId, string emojiId)
|
||||
{
|
||||
if (Emojis == null) Emojis = new List<Emoji>();
|
||||
Emojis.Add(new Emoji()
|
||||
{
|
||||
Index = index,
|
||||
ProductId = productId,
|
||||
EmojiId = emojiId
|
||||
});
|
||||
}
|
||||
public void AddEmoji(int indexStart, int indexEnd, string productId, string emojiId)
|
||||
{
|
||||
if (Emojis == null) Emojis = new List<Emoji>();
|
||||
for (int i = indexStart; i < indexEnd; i++)
|
||||
{
|
||||
Emojis.Add(new Emoji()
|
||||
{
|
||||
Index = i,
|
||||
ProductId = productId,
|
||||
EmojiId = emojiId
|
||||
});
|
||||
}
|
||||
}
|
||||
public void AddEmoji(string replaceSymbol, string productId, string emojiId)
|
||||
{
|
||||
if (Emojis == null) Emojis = new List<Emoji>();
|
||||
this.Text = this.Text.Replace(replaceSymbol, "|");
|
||||
|
||||
foreach (var i in AllIndexesOf(this.Text, "|"))
|
||||
{
|
||||
Emojis.Add(new Emoji()
|
||||
{
|
||||
Index = i,
|
||||
ProductId = productId,
|
||||
EmojiId = emojiId
|
||||
});
|
||||
}
|
||||
this.Text = this.Text.Replace("|", "$");
|
||||
}
|
||||
private IEnumerable<int> AllIndexesOf(string str, string searchstring)
|
||||
{
|
||||
int minIndex = str.IndexOf(searchstring);
|
||||
while (minIndex != -1)
|
||||
{
|
||||
yield return minIndex;
|
||||
minIndex = str.IndexOf(searchstring, minIndex + searchstring.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Emoji
|
||||
{
|
||||
[JsonProperty("index")]
|
||||
public int Index { get; set; }
|
||||
|
||||
[JsonProperty("productId")]
|
||||
public string ProductId { get; set; }
|
||||
|
||||
[JsonProperty("emojiId")]
|
||||
public string EmojiId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineVideoMessage : ILineMessage
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public MessageType Type => MessageType.Video;
|
||||
|
||||
[JsonProperty("originalContentUrl")]
|
||||
public string OriginalContentUrl { get; set; }
|
||||
|
||||
[JsonProperty("previewImageUrl")]
|
||||
public string PreviewImageUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public interface ILineMessage
|
||||
{
|
||||
MessageType Type { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user