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