commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
a0a843
|
17 |
|
H |
18 |
#import <Foundation/Foundation.h> |
|
19 |
#import <TwitterKit/TWTRJSONConvertible.h> |
|
20 |
|
|
21 |
@class TWTRTweet; |
|
22 |
@class TWTRUser; |
|
23 |
|
|
24 |
NS_ASSUME_NONNULL_BEGIN |
|
25 |
|
|
26 |
/** |
|
27 |
* `TWTRTweet` is an immutable representation of a Tweet. |
|
28 |
*/ |
|
29 |
@interface TWTRTweet : NSObject <NSCoding, TWTRJSONConvertible> |
|
30 |
|
|
31 |
#pragma mark - Properties |
|
32 |
|
|
33 |
/** |
|
34 |
* The ID of the Twitter Tweet. |
|
35 |
* @warning This represents the id_str field, which could differ from the value of the id field. |
|
36 |
*/ |
|
37 |
@property (nonatomic, copy, readonly) NSString *tweetID; |
|
38 |
|
|
39 |
/** |
|
40 |
* The date when this Tweet was created. |
|
41 |
*/ |
|
42 |
@property (nonatomic, copy, readonly) NSDate *createdAt; |
|
43 |
|
|
44 |
/** |
|
45 |
* The text of the Tweet. |
|
46 |
*/ |
|
47 |
@property (nonatomic, copy, readonly) NSString *text; |
|
48 |
|
|
49 |
/** |
|
50 |
* The Author of the Tweet. |
|
51 |
*/ |
|
52 |
@property (nonatomic, readonly) TWTRUser *author; |
|
53 |
|
|
54 |
/** |
|
55 |
* ID of the authenticated Twitter user this Tweet was loaded for. Some Tweet properties e.g. `isLiked` |
|
56 |
* can vary depending on the authenticated user. Nil means the Tweet was loaded from the perspective |
|
57 |
* of a logged-out user or the authenticated user could not be determined. |
|
58 |
*/ |
|
59 |
@property (nonatomic, readonly, nullable) NSString *perspectivalUserID; |
|
60 |
|
|
61 |
/** |
|
62 |
* The number of times this Tweet was liked. |
|
63 |
*/ |
|
64 |
@property (nonatomic, readonly) long long likeCount; |
|
65 |
|
|
66 |
/** |
|
67 |
* The number of times this Tweet was retweeted. |
|
68 |
*/ |
|
69 |
@property (nonatomic, readonly) long long retweetCount; |
|
70 |
|
|
71 |
/** |
|
72 |
* The language of the Tweet. |
|
73 |
*/ |
|
74 |
@property (nonatomic, copy, readonly) NSString *languageCode; |
|
75 |
|
|
76 |
/** |
|
77 |
* The Tweet this Tweet was a reply to. |
|
78 |
*/ |
|
79 |
@property (nonatomic, copy, readonly, nullable) NSString *inReplyToTweetID; |
|
80 |
|
|
81 |
/** |
|
82 |
* The User ID this Tweet was a reply to. |
|
83 |
*/ |
|
84 |
@property (nonatomic, copy, readonly, nullable) NSString *inReplyToUserID; |
|
85 |
|
|
86 |
/** |
|
87 |
* The screen name of the user this Tweet was a reply to. |
|
88 |
* @note This doesn't contain the `@` sign before the screen name. |
|
89 |
*/ |
|
90 |
@property (nonatomic, copy, readonly, nullable) NSString *inReplyToScreenName; |
|
91 |
|
|
92 |
/** |
|
93 |
* The permalink URL for this Tweet. |
|
94 |
* |
|
95 |
* Suitable for loading in a `UIWebView`, `WKWebView` or passing to Safari: |
|
96 |
* |
|
97 |
* `[[UIApplication sharedApplication] openURL:tweet.permalink];` |
|
98 |
*/ |
|
99 |
@property (nonatomic, copy, readonly) NSURL *permalink; |
|
100 |
|
|
101 |
/** |
|
102 |
* Whether this Tweet was liked by the authenticated user. |
|
103 |
* |
|
104 |
* @warning The value of this property depends on the authenticated user. |
|
105 |
*/ |
|
106 |
@property (nonatomic, readonly) BOOL isLiked; |
|
107 |
|
|
108 |
/** |
|
109 |
* Whether this Tweet was retweeted by the authenticated user. |
|
110 |
* |
|
111 |
* @warning The value of this property depends on the authenticated user. |
|
112 |
*/ |
|
113 |
@property (nonatomic, readonly) BOOL isRetweeted; |
|
114 |
|
|
115 |
/** |
|
116 |
* The Tweet ID of the authenticated user's retweet of this Tweet. This will be `nil` if there is no |
|
117 |
* authenticated user or the user has not retweeted this Tweet. |
|
118 |
* |
|
119 |
* @warning The value of this property depends on the authenticated user. |
|
120 |
*/ |
|
121 |
@property (nonatomic, copy, readonly, nullable) NSString *retweetID; |
|
122 |
|
|
123 |
/** |
|
124 |
* The original, fully-hydrated Tweet that was retweeted. This corresponds to the `retweeted_status` API field. |
|
125 |
* This is `nil` unless `self.isRetweet == YES`. |
|
126 |
*/ |
|
127 |
@property (nonatomic, readonly, nullable) TWTRTweet *retweetedTweet; |
|
128 |
|
|
129 |
/** |
|
130 |
* Indicates whether this Tweet is a retweet of another Tweet. |
|
131 |
*/ |
|
132 |
@property (nonatomic, readonly) BOOL isRetweet; |
|
133 |
|
|
134 |
/** |
|
135 |
* Indicates whether this Tweet is a Quote Tweet. |
|
136 |
*/ |
|
137 |
@property (nonatomic, readonly) BOOL isQuoteTweet; |
|
138 |
|
|
139 |
/** |
|
140 |
* The original, fully-hydrated Tweet that was quoted. |
|
141 |
* This is `nil` unless `self.isRetweet == YES`. |
|
142 |
*/ |
|
143 |
@property (nonatomic, readonly, nullable) TWTRTweet *quotedTweet; |
|
144 |
|
|
145 |
/** |
|
146 |
* Creates an array of TWTRTweet instances from the array of Twitter API JSON response. |
|
147 |
* |
|
148 |
* @param array A parsed array of Tweet API JSON responses. |
|
149 |
* @return An array of TWTRTweet instances. |
|
150 |
*/ |
|
151 |
+ (NSArray *)tweetsWithJSONArray:(nullable NSArray *)array; |
|
152 |
|
|
153 |
/** |
|
154 |
* Creates a new Tweet instance with a new value for the `isLiked` boolean |
|
155 |
* value which is the opposite of the current value. |
|
156 |
*/ |
|
157 |
- (TWTRTweet *)tweetWithLikeToggled; |
|
158 |
|
|
159 |
/** |
|
160 |
* Tweet objects should be hyrdrated from a valid JSON object. See TWTRJSONConvertible for more information. |
|
161 |
*/ |
|
162 |
- (instancetype)init NS_UNAVAILABLE; |
|
163 |
|
|
164 |
@end |
|
165 |
|
|
166 |
NS_ASSUME_NONNULL_END |