Class: Zernio::RedditPost
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Zernio::RedditPost
- Defined in:
- lib/zernio-sdk/models/reddit_post.rb
Overview
A normalized Reddit post returned by the feed and search endpoints
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#created_utc ⇒ Object
Unix timestamp of post creation.
-
#flair_text ⇒ Object
Link flair text if set.
-
#fullname ⇒ Object
Reddit fullname (e.g. t3_abc123).
-
#gallery_images ⇒ Object
Individual image URLs for gallery posts (only present when isGallery is true).
-
#id ⇒ Object
Reddit post ID (without type prefix).
-
#is_gallery ⇒ Object
Whether the post is a gallery with multiple images.
-
#num_comments ⇒ Object
Returns the value of attribute num_comments.
-
#over18 ⇒ Object
Whether the post is marked NSFW.
-
#permalink ⇒ Object
Full permalink to the Reddit post.
-
#score ⇒ Object
Returns the value of attribute score.
-
#selftext ⇒ Object
Self-post body text (empty string for link posts).
-
#stickied ⇒ Object
Returns the value of attribute stickied.
-
#subreddit ⇒ Object
Returns the value of attribute subreddit.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Post URL (may be a gallery URL, external link, or self-post URL).
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ RedditPost
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ RedditPost
Initializes the object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 124 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::RedditPost` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::RedditPost`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'fullname') self.fullname = attributes[:'fullname'] end if attributes.key?(:'title') self.title = attributes[:'title'] end if attributes.key?(:'author') self. = attributes[:'author'] end if attributes.key?(:'subreddit') self.subreddit = attributes[:'subreddit'] end if attributes.key?(:'url') self.url = attributes[:'url'] end if attributes.key?(:'permalink') self.permalink = attributes[:'permalink'] end if attributes.key?(:'selftext') self.selftext = attributes[:'selftext'] end if attributes.key?(:'created_utc') self.created_utc = attributes[:'created_utc'] end if attributes.key?(:'score') self.score = attributes[:'score'] end if attributes.key?(:'num_comments') self.num_comments = attributes[:'num_comments'] end if attributes.key?(:'over18') self.over18 = attributes[:'over18'] end if attributes.key?(:'stickied') self.stickied = attributes[:'stickied'] end if attributes.key?(:'flair_text') self.flair_text = attributes[:'flair_text'] end if attributes.key?(:'is_gallery') self.is_gallery = attributes[:'is_gallery'] end if attributes.key?(:'gallery_images') if (value = attributes[:'gallery_images']).is_a?(Array) self.gallery_images = value end end end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
27 28 29 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 27 def @author end |
#created_utc ⇒ Object
Unix timestamp of post creation
41 42 43 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 41 def created_utc @created_utc end |
#flair_text ⇒ Object
Link flair text if set
53 54 55 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 53 def flair_text @flair_text end |
#fullname ⇒ Object
Reddit fullname (e.g. t3_abc123)
23 24 25 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 23 def fullname @fullname end |
#gallery_images ⇒ Object
Individual image URLs for gallery posts (only present when isGallery is true)
59 60 61 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 59 def gallery_images @gallery_images end |
#id ⇒ Object
Reddit post ID (without type prefix)
20 21 22 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 20 def id @id end |
#is_gallery ⇒ Object
Whether the post is a gallery with multiple images
56 57 58 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 56 def is_gallery @is_gallery end |
#num_comments ⇒ Object
Returns the value of attribute num_comments.
45 46 47 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 45 def num_comments @num_comments end |
#over18 ⇒ Object
Whether the post is marked NSFW
48 49 50 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 48 def over18 @over18 end |
#permalink ⇒ Object
Full permalink to the Reddit post
35 36 37 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 35 def permalink @permalink end |
#score ⇒ Object
Returns the value of attribute score.
43 44 45 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 43 def score @score end |
#selftext ⇒ Object
Self-post body text (empty string for link posts)
38 39 40 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 38 def selftext @selftext end |
#stickied ⇒ Object
Returns the value of attribute stickied.
50 51 52 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 50 def stickied @stickied end |
#subreddit ⇒ Object
Returns the value of attribute subreddit.
29 30 31 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 29 def subreddit @subreddit end |
#title ⇒ Object
Returns the value of attribute title.
25 26 27 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 25 def title @title end |
#url ⇒ Object
Post URL (may be a gallery URL, external link, or self-post URL)
32 33 34 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 32 def url @url end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
84 85 86 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 84 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
89 90 91 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 89 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 62 def self.attribute_map { :'id' => :'id', :'fullname' => :'fullname', :'title' => :'title', :'author' => :'author', :'subreddit' => :'subreddit', :'url' => :'url', :'permalink' => :'permalink', :'selftext' => :'selftext', :'created_utc' => :'createdUtc', :'score' => :'score', :'num_comments' => :'numComments', :'over18' => :'over18', :'stickied' => :'stickied', :'flair_text' => :'flairText', :'is_gallery' => :'isGallery', :'gallery_images' => :'galleryImages' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 258 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
116 117 118 119 120 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 116 def self.openapi_nullable Set.new([ :'flair_text', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 94 def self.openapi_types { :'id' => :'String', :'fullname' => :'String', :'title' => :'String', :'author' => :'String', :'subreddit' => :'String', :'url' => :'String', :'permalink' => :'String', :'selftext' => :'String', :'created_utc' => :'Float', :'score' => :'Integer', :'num_comments' => :'Integer', :'over18' => :'Boolean', :'stickied' => :'Boolean', :'flair_text' => :'String', :'is_gallery' => :'Boolean', :'gallery_images' => :'Array<String>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 222 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && fullname == o.fullname && title == o.title && == o. && subreddit == o.subreddit && url == o.url && permalink == o.permalink && selftext == o.selftext && created_utc == o.created_utc && score == o.score && num_comments == o.num_comments && over18 == o.over18 && stickied == o.stickied && flair_text == o.flair_text && is_gallery == o.is_gallery && gallery_images == o.gallery_images end |
#eql?(o) ⇒ Boolean
245 246 247 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 245 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
251 252 253 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 251 def hash [id, fullname, title, , subreddit, url, permalink, selftext, created_utc, score, num_comments, over18, stickied, flair_text, is_gallery, gallery_images].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
207 208 209 210 211 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 207 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 280 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
215 216 217 218 |
# File 'lib/zernio-sdk/models/reddit_post.rb', line 215 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' true end |