Skip to content

Commit

Permalink
Merge pull request #94 from akirk/break-out/status
Browse files Browse the repository at this point in the history
Add basic status entities
  • Loading branch information
MatzeKitt authored Mar 16, 2024
2 parents c76e325 + f01b3aa commit 2a619d2
Show file tree
Hide file tree
Showing 4 changed files with 576 additions and 0 deletions.
55 changes: 55 additions & 0 deletions includes/entity/class-application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Application entity.
*
* This contains the Application entity.
*
* @package Enable_Mastodon_Apps
*/

namespace Enable_Mastodon_Apps\Entity;

/**
* This is the class that implements the Application entity.
*
* @since 0.7.0
*
* @package Enable_Mastodon_Apps
*/
class Application extends Entity {
protected $_types = array(
'name' => 'string',
'client_id' => 'string',
'client_secret' => 'string',

'website' => 'string?',
);

/**
* The name of the application.
*
* @var string
*/
public string $name = '';

/**
* Client ID key, to be used for obtaining OAuth tokens.
*
* @var string
*/
public string $client_id = '';

/**
* Client secret key, to be used for obtaining OAuth tokens.
*
* @var string
*/
public string $client_secret = '';

/**
* The website associated with your application.
*
* @var null|string
*/
public ?string $website = null;
}
111 changes: 111 additions & 0 deletions includes/entity/class-poll.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php
/**
* Poll entity.
*
* This contains the Poll entity.
*
* @package Enable_Mastodon_Apps
*/

namespace Enable_Mastodon_Apps\Entity;

/**
* This is the class that implements the Poll entity.
*
* @since 0.7.0
*
* @package Enable_Mastodon_Apps
*/
class Poll extends Entity {
protected $_types = array(
'id' => 'string',

'expires_at' => 'string?',

'expired' => 'bool',
'multiple' => 'bool',
'voted' => 'bool',

'votes_count' => 'int',

'voters_count' => 'int?',

'options' => 'array',
'emojis' => 'array',
'own_votes' => 'array',
);

/**
* The ID of the poll in the database
*
* @var string
*/
public string $id;

/**
* When the poll ends.
*
* @var null|string
*/
public ?string $expires_at;

/**
* Is the poll currently expired?
*
* @var bool
*/
public bool $expired;

/**
* Does the poll allow multiple-choice answers?
*
* @var bool
*/
public bool $multiple;

/**
* How many votes have been received.
*
* @var int
*/
public int $votes_count;

/**
* How many unique accounts have voted on a multiple-choice poll.
* TODO: validate whether null is only returned if $multiple is false
*
* @var null|int
*/
public ?int $voters_count = 0;

/**
* Possible answers for the poll.
* TODO: implement as list of Poll_Option objects
*
* @var array
*/
public array $options;

/**
* Custom emoji to be used for rendering poll options.
* TODO: implement as list of CustomEmoji objects
*
* @var array
*/
public array $emojis;

/**
* When called with a user token, has the authorized user voted?
*
* @var bool
*/
public bool $voted = false;

/**
* When called with a user token, which options has the authorized user chosen?
* TODO: validate if all items are integers
*
* @var int[]
*/
public array $own_votes = array();
}
137 changes: 137 additions & 0 deletions includes/entity/class-preview-card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
* Preview Card entity.
*
* This contains the Preview Card entity.
*
* @package Enable_Mastodon_Apps
*/

namespace Enable_Mastodon_Apps\Entity;

/**
* This is the class that implements the Preview Card entity.
*
* @since 0.7.0
*
* @package Enable_Mastodon_Apps
*/
class Preview_Card extends Entity {
protected $_types = array(
'url' => 'string',
'title' => 'string',
'description' => 'string',
'type' => 'string',
'author_name' => 'string',
'author_url' => 'string',
'provider_name' => 'string',
'provider_url' => 'string',
'html' => 'string',
'embed_url' => 'string',

'blurhash' => 'string?',
'image' => 'string?',

'width' => 'int',
'height' => 'int',
);

/**
* Location of linked resource.
*
* @var string
*/
public string $url;

/**
* Title of linked resource.
*
* @var string
*/
public string $title;

/**
* Description of preview.
*
* @var string
*/
public string $description;

/**
* The type of the preview card.
*
* @var string
*/
public string $type;

/**
* The author of the original resource.
*
* @var string
*/
public string $author_name;

/**
* A link to the author of the original resource.
*
* @var string
*/
public string $author_url;

/**
* The provider of the original resource.
*
* @var string
*/
public string $provider_name;

/**
* A link to the provider of the original resource.
*
* @var string
*/
public string $provider_url;

/**
* HTML to be used for generating the preview card.
*
* @var string
*/
public string $html;

/**
* Used for photo embeds, instead of custom html.
*
* @var string
*/
public string $embed_url;

/**
* A hash for generating colorful preview thumbnails when media has not been
* downloaded yet.
*
* @var null|string
*/
public ?string $blurhash = null;

/**
* Preview thumbnail.
*
* @var null|string
*/
public ?string $image = null;

/**
* Width of preview, in pixels.
*
* @var int
*/
public int $width;

/**
* Height of preview, in pixels.
*
* @var int
*/
public int $height;
}
Loading

0 comments on commit 2a619d2

Please sign in to comment.