Skip to content

Latest commit

 

History

History
1217 lines (608 loc) · 28.1 KB

class.WebserviceRequestCore.md

File metadata and controls

1217 lines (608 loc) · 28.1 KB

Class WebserviceRequestCore

Contents

Constants

Properties

Methods

Constants

HTTP_GET

const HTTP_GET = 1

HTTP_POST

const HTTP_POST = 2

HTTP_PUT

const HTTP_PUT = 4

Properties

$_authenticated

protected boolean $_authenticated = false

Set if the authentication key was checked

$_available_languages

protected mixed $_available_languages = null

$_docUrl

protected string $_docUrl = 'http://doc.prestashop.com/display/PS16/Using+the+PrestaShop+Web+Service'

PrestaShop Webservice Documentation URL

$_inputXml

protected string $_inputXml

If we are in PUT or POST case, we use this attribute to store the xml string value during process

$_instance

protected \WebserviceRequest $_instance

Object instance for singleton

$_key

protected string $_key

Key used for authentication

$_object

protected \ObjectModel $_object

The current object to support, it extends the PrestaShop ObjectModel

$_outputEnabled

protected boolean $_outputEnabled = true

Set if return should display content or not

$_startTime

protected integer $_startTime

The time in microseconds of the start of the execution of the web service request

$depth

public integer $depth

This is used to have a deeper tree diagram.

$errors

public array $errors = array()

Errors triggered at execution

$fieldsToDisplay

public string $fieldsToDisplay = 'minimum'

The fields to display. These fields will be displayed when retrieving objects

$keyPermissions

public array $keyPermissions

The permissions for the current key

$method

public string $method

HTTP Method to support

$objOutput

protected \WebserviceOutputBuilder $objOutput

The object to build the output.

$objectSpecificManagement

protected \WebserviceSpecificManagementImages $objectSpecificManagement = false

Set if the management is specific or if it is classic (entity management)

$objects

public array $objects

The list of objects to display

$outputFormat

protected string $outputFormat = 'xml'

Name of the output format

$resourceConfiguration

public array $resourceConfiguration

The configuration parameters of the current resource

$resourceList

public array $resourceList

The list of each resources manageable via web service

$schemaToDisplay

public string $schemaToDisplay

The schema to display.

If null, no schema have to be displayed and normal management has to be performed

$shopIDs

public mixed $shopIDs

$specificOutput

protected string $specificOutput = ''

The XML string to display if web service call succeed

$urlFragments

public array $urlFragments = array()

The segment list of the URL after the "api" segment

$urlSegment

public array $urlSegment = array()

The segment of the URL

$wsUrl

public string $wsUrl

Base PrestaShop webservice URL

$ws_current_classname

public string $ws_current_classname

Save the class name for override used in getInstance()

Methods

authenticate

boolean WebserviceRequestCore::authenticate()

Check request authentication

checkHTTPMethod

boolean WebserviceRequestCore::checkHTTPMethod()

Check HTTP method

checkResource

boolean WebserviceRequestCore::checkResource()

Check resource validity

executeEntityDelete

boolean WebserviceRequestCore::executeEntityDelete()

Execute DELETE method on a PrestaShop entity

executeEntityGetAndHead

boolean WebserviceRequestCore::executeEntityGetAndHead()

Execute GET and HEAD requests

Build filter Build fields display Build sort Build limit

executeEntityPost

boolean WebserviceRequestCore::executeEntityPost()

Execute POST method on a PrestaShop entity

executeEntityPut

boolean WebserviceRequestCore::executeEntityPut()

Execute PUT method on a PrestaShop entity

fetch

array WebserviceRequestCore::fetch(string $key, string $method, string $url, string $params, $bad_class_name, string $inputXml)

Start Webservice request Check webservice activation Check autentication Check resource Check HTTP Method Execute the action Display the result

Arguments

  • $key string
  • $method string
  • $url string
  • $params string
  • $bad_class_name mixed
  • $inputXml string

filterLanguage

mixed WebserviceRequestCore::filterLanguage()

getClosest

string WebserviceRequestCore::getClosest(string $input, array $words)

Return the nearest value picked in the values list

Arguments

  • $input string
  • $words array

getFilteredObjectDetails

mixed WebserviceRequestCore::getFilteredObjectDetails()

getFilteredObjectList

mixed WebserviceRequestCore::getFilteredObjectList()

getInstance

object WebserviceRequestCore::getInstance()

Get WebserviceRequest object instance (Singleton)

getOutputEnabled

mixed WebserviceRequestCore::getOutputEnabled()

getOutputObject

mixed WebserviceRequestCore::getOutputObject($type)

Arguments

  • $type mixed

getPriceForProduct

array WebserviceRequestCore::getPriceForProduct($field, $entity_object, $ws_params)

This method is used for calculate the price for products on the output details

Arguments

  • $field mixed
  • $entity_object mixed
  • $ws_params mixed

getResources

mixed WebserviceRequestCore::getResources()

getSQLRetrieveFilter

string WebserviceRequestCore::getSQLRetrieveFilter(string $sqlId, string $filterValue, string $tableAlias)

get SQL retrieve Filter

Arguments

  • $sqlId string
  • $filterValue string
  • $tableAlias string - = 'main.'

getallheaders

mixed WebserviceRequestCore::getallheaders()

groupShopExists

mixed WebserviceRequestCore::groupShopExists($params)

Arguments

  • $params mixed

hasErrors

boolean WebserviceRequestCore::hasErrors()

Check if there is one or more error

isActivated

boolean WebserviceRequestCore::isActivated()

Check webservice activation

manageFilters

mixed WebserviceRequestCore::manageFilters()

parseDisplayFields

mixed WebserviceRequestCore::parseDisplayFields($str)

Arguments

  • $str mixed

returnOutput

array WebserviceRequestCore::returnOutput()

Thanks to the (WebserviceOutputBuilder) WebserviceKey::objOutput Method build the output depend on the WebserviceRequest::outputFormat and set HTTP header parameters.

saveEntityFromXml

boolean WebserviceRequestCore::saveEntityFromXml(integer $successReturnCode)

save Entity Object from XML

Arguments

  • $successReturnCode integer

setError

void WebserviceRequestCore::setError(integer $status, string $label, integer $code)

Set a webservice error

Arguments

  • $status integer
  • $label string
  • $code integer

setErrorDidYouMean

void WebserviceRequestCore::setErrorDidYouMean(integer $num, string $label, array $value, $available_values, integer $code)

Set a webservice error and propose a new value near from the available values

Arguments

  • $num integer
  • $label string
  • $value array
  • $available_values mixed
  • $code integer

setFieldsToDisplay

mixed WebserviceRequestCore::setFieldsToDisplay()

setObjects

mixed WebserviceRequestCore::setObjects()

setOutputEnabled

mixed WebserviceRequestCore::setOutputEnabled($bool)

Arguments

  • $bool mixed

shopExists

mixed WebserviceRequestCore::shopExists($params)

Arguments

  • $params mixed

shopHasRight

mixed WebserviceRequestCore::shopHasRight($key)

Arguments

  • $key mixed

specificPriceCalculation

mixed WebserviceRequestCore::specificPriceCalculation($parameters)

Arguments

  • $parameters mixed

specificPriceForCombination

array WebserviceRequestCore::specificPriceForCombination($entity_object, array $parameters)

This method is used for calculate the price for products on a virtual fields

Arguments

  • $entity_object mixed
  • $parameters array

specificPriceForProduct

array WebserviceRequestCore::specificPriceForProduct($entity_object, array $parameters)

This method is used for calculate the price for products on a virtual fields

Arguments

  • $entity_object mixed
  • $parameters array

webserviceChecks

mixed WebserviceRequestCore::webserviceChecks()

webserviceErrorHandler

boolean WebserviceRequestCore::webserviceErrorHandler(string $errno, array $errstr, array $errfile, array $errline)

Used to replace the default PHP error handler, in order to display PHP errors in a XML format

Arguments

  • $errno string - contains the level of the error raised, as an integer
  • $errstr array - contains the error message, as a string
  • $errfile array - errfile, which contains the filename that the error was raised in, as a string
  • $errline array - errline, which contains the line number the error was raised at, as an integer