Documentation

PimService
in package

Table of Contents

Properties

$baseUri  : string
$client  : Client|null
$sslDisabled  : bool

Methods

fetchAllPages()  : array<string|int, mixed>
Fetches all pages of data from the specified PIM endpoint URL.
fetchSinglePage()  : array<string|int, mixed>
Fetches a single page of data from the specified PIM endpoint URL.
get()  : mixed
getClient()  : Client
post()  : mixed
request()  : mixed

Properties

$baseUri

private static string $baseUri = WSC_PIM_API_HOST . '/' . WSC_PIM_API_VERSION

$sslDisabled

private static bool $sslDisabled = true

Methods

fetchAllPages()

Fetches all pages of data from the specified PIM endpoint URL.

public static fetchAllPages(string $requestUrl[, bool $logProgress = true ][, null|mixed $lang = null ]) : array<string|int, mixed>

This method performs a paginated request to the given endpoint, appending a page number to the URL for each subsequent request. It continues fetching data until all pages are retrieved. During the process, it logs the progress at every 10 pages and when the fetching is complete, including the total number of pages and items fetched, and the duration of the operation.

Parameters
$requestUrl : string

The base URL of the PIM endpoint with necessary query parameters (excluding the page number).

$logProgress : bool = true

true if precess will write log about process progress.

$lang : null|mixed = null
Return values
array<string|int, mixed>

An array containing all fetched items combined from all pages.

fetchSinglePage()

Fetches a single page of data from the specified PIM endpoint URL.

public static fetchSinglePage(string $requestUrl[, int $page = 1 ][, null|mixed $lang = null ]) : array<string|int, mixed>

This function appends the page number to the base request URL, performs the request, and returns the results along with the next page number if available, or false if there are no more pages.

Parameters
$requestUrl : string

The base URL of the PIM endpoint with necessary query parameters (excluding the page number).

$page : int = 1

The page number to fetch.

$lang : null|mixed = null
Return values
array<string|int, mixed>

An array with the keys 'results' containing the fetched items and 'next_page' as the next page number or false.

get()

public static get(mixed $endpoint[, null|mixed $lang = null ]) : mixed
Parameters
$endpoint : mixed
$lang : null|mixed = null
Tags
throws
GuzzleException

post()

public static post(mixed $endpoint[, null|mixed $lang = null ]) : mixed
Parameters
$endpoint : mixed
$lang : null|mixed = null
Tags
throws
GuzzleException

request()

private static request(mixed $method, mixed $endpoint[, null|mixed $lang = null ][, mixed $timeout = 30.0 ]) : mixed
Parameters
$method : mixed
$endpoint : mixed
$lang : null|mixed = null
$timeout : mixed = 30.0
Tags
throws
GuzzleException

        
On this page

Search results