Snuze classes for Reddit "thing" objects
Namespace
The classes described here are in the \snuze\Reddit\Thing
namespace hierarchy.
One "thing" leads to another
Most first-class Reddit entities have a similar basic data structure, which Reddit calls a "thing." These objects share a set of common properties:
kind
: A discriminator to identify the type of thing; one ofid
: A base36 identifier, e.g.ewla66x
fullname
: Thekind
and theid
combined, separated by an underscore, e.g.t1_ewla66x
created
: The unix epoch timestamp when the object was created, e.g.1154470244.0
In Snuze, "thing" entities are represented by classes in the \snuze\Reddit\Thing
namespace. Snuze returns objects of these types from many of
its fetch...()
methods,
which retrieve data from the Reddit API.
The Thing
class
The \snuze\Reddit\Thing\Thing
class is an abstract class defining the
common properties and methods shared by all of the "thing" subtypes. As mentioned
above, these include the kind
, id
, fullname
, and the created
timestamp.
This class also provides methods called toJson()
and fromJson()
, which
let you get the JSON representing a given object, or create a new object from a
JSON string, respectively. Subtypes of Thing
will occasionally override these
two methods if any special tweaking of the JSON is needed.
Account
and its subtypes
The Reddit API lets you fetch information about two types of accounts: your own account (the one Snuze is using to talk to the API), and other users' accounts.
The Account
class
The \snuze\Reddit\Thing\Account\Account
class is an abstract class that
holds shared properties common to both account types.
The MyAccount
class
The \snuze\Reddit\Thing\Account\MyAccount
class extends Account
to expose all of the attributes of your own account (the one Snuze is using to
talk to the API). The data returned from this API endpoint is not actually
a "thing" entity, but Snuze treats it as one.
The UserAccount
class
The \snuze\Reddit\Thing\Account\UserAccount
class extends Account
to expose the limited public attributes available for other users' accounts.
The Link
class
The \snuze\Reddit\Thing\Link
class represents the attributes of a
link, otherwise known as a post or a submission.
The Subreddit
class
The \snuze\Reddit\Thing\Subreddit
class represents the significant
attributes of a subreddit.
-
Subreddit API fields in the unofficial Reddit API reference