ArticleResponse
in package
Complete response from Create, Read, and Update Article endpoints.
This class provides a typed representation of the article data returned by the Apple News API, including metadata, state information, throttling data, and any warnings generated during processing.
Tags
Table of Contents
Properties
- $createdAt : DateTimeImmutable|null
- $id : string
- $isCandidateToBeFeatured : bool|null
- $isHidden : bool|null
- $isPreview : bool|null
- $isSponsored : bool|null
- $links : ArticleLinks|null
- $maturityRating : string|null
- $meta : Meta|null
- $modifiedAt : DateTimeImmutable|null
- $rawData : array<string, mixed>
- $revision : string
- $shareUrl : string|null
- $state : ArticleState|null
- $title : string
- $type : string
- $warnings : array<string|int, mixed>
Methods
- __construct() : mixed
- Create a new ArticleResponse instance.
- fromApiResponse() : self
- Create an ArticleResponse instance from the raw API response.
- getThrottling() : Throttling|null
- Get throttling information from the response.
- hasWarnings() : bool
- Check if the response contains any warnings.
Properties
$createdAt read-only
public
DateTimeImmutable|null
$createdAt
= null
$id read-only
public
string
$id
$isCandidateToBeFeatured read-only
public
bool|null
$isCandidateToBeFeatured
= null
$isHidden read-only
public
bool|null
$isHidden
= null
$isPreview read-only
public
bool|null
$isPreview
= null
$isSponsored read-only
public
bool|null
$isSponsored
= null
$links read-only
public
ArticleLinks|null
$links
= null
$maturityRating read-only
public
string|null
$maturityRating
= null
$meta read-only
public
Meta|null
$meta
= null
$modifiedAt read-only
public
DateTimeImmutable|null
$modifiedAt
= null
$rawData read-only
public
array<string, mixed>
$rawData
= []
Raw response data for any fields not explicitly mapped
$revision read-only
public
string
$revision
$shareUrl read-only
public
string|null
$shareUrl
= null
$state read-only
public
ArticleState|null
$state
= null
$title read-only
public
string
$title
$type read-only
public
string
$type
$warnings read-only
public
array<string|int, mixed>
$warnings
= []
Methods
__construct()
Create a new ArticleResponse instance.
public
__construct(string $id, string $type, string $title, string $revision[, ArticleState|null $state = null ][, string|null $shareUrl = null ][, DateTimeImmutable|null $createdAt = null ][, DateTimeImmutable|null $modifiedAt = null ][, bool|null $isSponsored = null ][, bool|null $isPreview = null ][, bool|null $isCandidateToBeFeatured = null ][, bool|null $isHidden = null ][, string|null $maturityRating = null ][, ArticleLinks|null $links = null ][, Meta|null $meta = null ][, array<int, Warning> $warnings = [] ][, array<string, mixed> $rawData = [] ]) : mixed
Parameters
- $id : string
-
The unique identifier for the article.
- $type : string
-
The resource type (always "article").
- $title : string
-
The article title from the Apple News Format document.
- $revision : string
-
The current revision token for optimistic locking.
- $state : ArticleState|null = null
-
The current processing state of the article.
- $shareUrl : string|null = null
-
The public URL to the article in Apple News.
- $createdAt : DateTimeImmutable|null = null
-
When the article was first created.
- $modifiedAt : DateTimeImmutable|null = null
-
When the article was last modified.
- $isSponsored : bool|null = null
-
Whether the article is marked as sponsored content.
- $isPreview : bool|null = null
-
Whether the article is in preview mode.
- $isCandidateToBeFeatured : bool|null = null
-
Whether the article can be featured in Apple News.
- $isHidden : bool|null = null
-
Whether the article is hidden from feeds.
- $maturityRating : string|null = null
-
Content maturity rating (KIDS, GENERAL, MATURE).
- $links : ArticleLinks|null = null
-
Related API resource URLs.
- $meta : Meta|null = null
-
Metadata including throttling information.
- $warnings : array<int, Warning> = []
-
Non-fatal warnings from the API.
- $rawData : array<string, mixed> = []
-
Raw response data for unmapped fields.
fromApiResponse()
Create an ArticleResponse instance from the raw API response.
public
static fromApiResponse(array<string, mixed> $response) : self
This factory method handles the nested structure of the API response, extracting data from the 'data', 'links', and 'meta' keys as appropriate.
Parameters
- $response : array<string, mixed>
-
The full API response array.
Return values
self —A new ArticleResponse instance populated with the response data.
getThrottling()
Get throttling information from the response.
public
getThrottling() : Throttling|null
Convenience method to access throttling data without navigating through the meta object.
Return values
Throttling|null —The throttling information, or null if not available.
hasWarnings()
Check if the response contains any warnings.
public
hasWarnings() : bool
Return values
bool —True if there are one or more warnings.