MarketingRecommendationsDataSourcePoller
extends DataSourcePoller
in package
Specs data source poller class for marketing recommendations.
Table of Contents
- DATA_SOURCES = array('https://woocommerce.com/wp-json/wccom/marketing-tab/1.3/recommendations.json')
- Default data sources array.
- FILTER_NAME = 'data_source_poller_data_sources'
- Name of data sources filter.
- FILTER_NAME_SPECS = 'data_source_poller_specs'
- Name of data source specs filter.
- ID = 'marketing_recommendations'
- Data Source Poller ID.
- $args : array<string|int, mixed>
- Default args.
- $data_sources : array<string|int, mixed>
- Default data sources array.
- $id : string
- Id of DataSourcePoller.
- $instance : Analytics
- Class instance.
- $logger : WC_Logger|null
- The logger instance.
- __construct() : mixed
- Constructor.
- delete_specs_transient() : bool
- Delete the specs transient.
- get_instance() : mixed
- Get class instance.
- get_specs_from_data_sources() : array<string|int, mixed>
- Reads the data sources for specs and persists those specs.
- read_specs_from_data_sources() : bool
- Reads the data sources for specs and persists those specs.
- set_specs_transient() : mixed
- Set the specs transient.
- get_logger() : WC_Logger
- Get the logger instance.
- get_spec_key() : string|bool
- Returns the key identifier of spec, this can easily be overwritten. Defaults to id.
- merge_specs() : mixed
- Merge the specs.
- read_data_source() : array<string|int, mixed>
- Read a single data source and return the read specs
- validate_spec() : bool
- Validate the spec.
Constants
DATA_SOURCES
Default data sources array.
public
mixed
DATA_SOURCES
= array('https://woocommerce.com/wp-json/wccom/marketing-tab/1.3/recommendations.json')
FILTER_NAME
Name of data sources filter.
public
mixed
FILTER_NAME
= 'data_source_poller_data_sources'
FILTER_NAME_SPECS
Name of data source specs filter.
public
mixed
FILTER_NAME_SPECS
= 'data_source_poller_specs'
ID
Data Source Poller ID.
public
mixed
ID
= 'marketing_recommendations'
Properties
$args
Default args.
protected
array<string|int, mixed>
$args
= array()
$data_sources
Default data sources array.
protected
array<string|int, mixed>
$data_sources
= array()
$id
Id of DataSourcePoller.
protected
string
$id
= array()
$instance
Class instance.
protected
static Analytics
$instance
= null
$logger
The logger instance.
protected
static WC_Logger|null
$logger
= null
Methods
__construct()
Constructor.
public
__construct(string $id[, array<string|int, mixed> $data_sources = array() ][, array<string|int, mixed> $args = array() ]) : mixed
Parameters
- $id : string
-
id of DataSourcePoller.
- $data_sources : array<string|int, mixed> = array()
-
urls for data sources.
- $args : array<string|int, mixed> = array()
-
Options for DataSourcePoller.
Return values
mixed —delete_specs_transient()
Delete the specs transient.
public
delete_specs_transient() : bool
Return values
bool — success of failure of transient deletion.get_instance()
Get class instance.
public
static get_instance() : mixed
Return values
mixed —get_specs_from_data_sources()
Reads the data sources for specs and persists those specs.
public
get_specs_from_data_sources() : array<string|int, mixed>
Return values
array<string|int, mixed> — list of specs.read_specs_from_data_sources()
Reads the data sources for specs and persists those specs.
public
read_specs_from_data_sources() : bool
Return values
bool — Whether any specs were read.set_specs_transient()
Set the specs transient.
public
set_specs_transient(array<string|int, mixed> $specs, int $expiration) : mixed
Parameters
- $specs : array<string|int, mixed>
-
The specs to set in the transient.
- $expiration : int
-
The expiration time for the transient.
Return values
mixed —get_logger()
Get the logger instance.
protected
static get_logger() : WC_Logger
Return values
WC_Logger —get_spec_key()
Returns the key identifier of spec, this can easily be overwritten. Defaults to id.
protected
get_spec_key(mixed $spec) : string|bool
Parameters
- $spec : mixed
-
a JSON parsed spec coming from the JSON feed.
Return values
string|bool —merge_specs()
Merge the specs.
protected
merge_specs(array<string|int, mixed> $specs_to_merge_in, array<string|int, mixed> &$specs, string $url) : mixed
Parameters
- $specs_to_merge_in : array<string|int, mixed>
-
The specs to merge in to $specs.
- $specs : array<string|int, mixed>
-
The list of specs being merged into.
- $url : string
-
The url of the feed being merged in (for error reporting).
Return values
mixed —read_data_source()
Read a single data source and return the read specs
protected
static read_data_source(string $url) : array<string|int, mixed>
Parameters
- $url : string
-
The URL to read the specs from.
Return values
array<string|int, mixed> — The specs that have been read from the data source.validate_spec()
Validate the spec.
protected
validate_spec(object $spec, string $url) : bool
Parameters
- $spec : object
-
The spec to validate.
- $url : string
-
The url of the feed that provided the spec.