OSDN Git Service

TwitterApi.EscapeJsonStringメソッドをJsonUtilsクラスへ移動
[opentween/open-tween.git] / OpenTween / Api / DataModel / TwitterUploadMediaResult.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2014 spx (@5px)
3 // All rights reserved.
4 //
5 // This file is part of OpenTween.
6 //
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // for more details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
21
22 using System;
23 using System.Collections.Generic;
24 using System.Linq;
25 using System.Runtime.Serialization;
26 using System.Text;
27 using System.Threading.Tasks;
28
29 namespace OpenTween.Api.DataModel
30 {
31     // 参照: https://dev.twitter.com/docs/platform-objects/entities
32     //       https://dev.twitter.com/docs/api/multiple-media-extended-entities
33
34     [DataContract]
35     public class TwitterUploadMediaInit
36     {
37         [DataMember(Name = "expires_after_secs")]
38         public int ExpiresAfterSecs { get; set; }
39
40         [DataMember(Name = "media_id")]
41         public long MediaId { get; set; }
42
43         [DataMember(Name = "media_id_string")]
44         public string MediaIdStr { get; set; }
45
46         /// <exception cref="SerializationException"/>
47         public static TwitterUploadMediaInit ParseJson(string json)
48             => MyCommon.CreateDataFromJson<TwitterUploadMediaInit>(json);
49     }
50
51     [DataContract]
52     public class TwitterUploadMediaResult
53     {
54         [DataMember(Name = "expires_after_secs")]
55         public int ExpiresAfterSecs { get; set; }
56
57         [DataContract]
58         public class ImageInfo
59         {
60             [DataMember(Name = "w")]
61             public int Width { get; set; }
62
63             [DataMember(Name = "h")]
64             public int Height { get; set; }
65
66             [DataMember(Name = "image_type")]
67             public string ImageType { get; set; }
68         }
69
70         [DataMember(Name = "image", IsRequired = false)]
71         public ImageInfo Image { get; set; }
72
73         [DataMember(Name = "media_id")]
74         public long MediaId { get; set; }
75
76         [DataMember(Name = "media_id_string")]
77         public string MediaIdStr { get; set; }
78
79         [DataContract]
80         public class MediaProcessingInfo
81         {
82             [DataMember(Name = "check_after_secs", IsRequired = false)]
83             public int? CheckAfterSecs { get; set; }
84
85             [DataContract]
86             public class MediaProcessingError
87             {
88                 [DataMember(Name = "code")]
89                 public int Code { get; set; }
90
91                 [DataMember(Name = "name")]
92                 public string Name { get; set; }
93
94                 [DataMember(Name = "message")]
95                 public string Message { get; set; }
96             }
97
98             [DataMember(Name = "error", IsRequired = false)]
99             public MediaProcessingError Error { get; set; }
100
101             [DataMember(Name = "progress_percent")]
102             public int ProgressPercent { get; set; }
103
104             [DataMember(Name = "state")]
105             public string State { get; set; }
106         }
107
108         [DataMember(Name = "processing_info", IsRequired = false)]
109         public MediaProcessingInfo ProcessingInfo { get; set; }
110
111         [DataMember(Name = "size", IsRequired = false)]
112         public long? Size { get; set; }
113
114         [DataContract]
115         public class VideoInfo
116         {
117             [DataMember(Name = "video_type")]
118             public string VideoType { get; set; }
119         }
120
121         [DataMember(Name = "video", IsRequired = false)]
122         public VideoInfo Video { get; set; }
123
124         /// <exception cref="SerializationException"/>
125         public static TwitterUploadMediaResult ParseJson(string json)
126             => MyCommon.CreateDataFromJson<TwitterUploadMediaResult>(json);
127     }
128 }