EDD_Licensing implements License_API

This class provides an interface to the EDD Software Licensing API. API requests are handled on the Barn2 website by the EDD Software Licensing plugin.

Tags
author

Barn2 Plugins [email protected]

license

GPL-3.0

copyright

Barn2 Media Ltd

version
1.1

Interfaces, Classes and Traits

License_API
Interface to represent an API wrapper for a license system.

Table of Contents

API_TIMEOUT  = 20
EDD_LICENSING_ENDPOINT  = 'https://barn2.com/edd-sl'
$_instance  : EDD_Licensing
activate_license()  : stdClass
Activate the specified license key.
check_license()  : stdClass
Checks the specified license key.
deactivate_license()  : stdClass
Deactivate the specified license key.
get_latest_version()  : stdClass
Gets the latest version information for the specified plugin.
instance()  : mixed
api_request()  : mixed
get_api_error_message()  : mixed
is_api_error()  : mixed

Constants

API_TIMEOUT

public int API_TIMEOUT = 20

API timeout in seconds.

EDD_LICENSING_ENDPOINT

public string EDD_LICENSING_ENDPOINT = 'https://barn2.com/edd-sl'

The URL of the EDD Software Licensing API.

Properties

Methods

activate_license()

Activate the specified license key.

public activate_license(string $license_key, int $item_id, mixed $url) : stdClass

Returns a stdClass object containing two properties:

  • success: true or false. Whether the request returned successfully.
  • response: If success is true, it will contain the JSON-decoded response (an object) from the server containing the result. If success if false, it will contain an error message (string) indicating why the request failed.
Parameters
$license_key : string

The license key to activate.

$item_id : int

The download ID for the item to check.

$url : mixed
Return values
stdClass

The result object (see above).

check_license()

Checks the specified license key.

public check_license(string $license_key, int $item_id, mixed $url) : stdClass

Returns a stdClass object containing two properties:

  • success: true or false. Whether the request returned successfully.
  • response: If success is true, it will contain the JSON-decoded response (an object) from the server containing the license information. If success if false, it will contain an error message (string) indicating why the request failed.
Parameters
$license_key : string

The license key to check.

$item_id : int

The download ID for the item to check.

$url : mixed
Return values
stdClass

The result object (see above).

deactivate_license()

Deactivate the specified license key.

public deactivate_license(string $license_key, int $item_id, mixed $url) : stdClass

Returns a stdClass object containing two properties:

  • success: true or false. Whether the request returned successfully.
  • response: If success is true, it will contain the JSON-decoded response (an object) from the server containing the result. If success if false, it will contain an error message (string) indicating why the request failed.
Parameters
$license_key : string

The license key to deactivate.

$item_id : int

The download ID for the item to check.

$url : mixed
Return values
stdClass

The result object (see above).

get_latest_version()

Gets the latest version information for the specified plugin.

public get_latest_version(string $license_key, int $item_id, mixed $url, string $slug[, bool $beta_testing = false ]) : stdClass

Returns a stdClass object containing two properties:

  • success: true or false. Whether the request returned successfully.
  • response: If success is true, it will contain the JSON-decoded response (an object) from the server containing the latest version information. If success if false, it will contain an error message (string) indicating why the request failed.
Parameters
$license_key : string

The license key.

$item_id : int

The download ID for the item to check.

$url : mixed
$slug : string

The plugin slug.

$beta_testing : bool = false

Whether to check for beta versions.

Return values
stdClass

The result object (see above).

instance()

public static instance() : mixed
Return values
mixed

api_request()

private api_request(mixed $params) : mixed
Parameters
$params : mixed
Return values
mixed

get_api_error_message()

private static get_api_error_message(mixed $response) : mixed
Parameters
$response : mixed
Return values
mixed

is_api_error()

private static is_api_error(mixed $response) : mixed
Parameters
$response : mixed
Return values
mixed

Search results