%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom329039/wp-content/plugins/gravityforms/includes/external-api/
Upload File :
Create Path :
Current File : //dom329039/wp-content/plugins/gravityforms/includes/external-api/class-gf-api-response.php

<?php

namespace Gravity_Forms\Gravity_Forms\External_API;

/**
 * Class GF_API_Response
 *
 * An abstracted Response class used to standardize the responses we send back from an API Connector. Includes
 * standardized serialization and JSON methods to support saving the class to the Database.
 *
 * @since 2.5
 *
 * @package Gravity_Forms\Gravity_Forms\External_API
 */
abstract class GF_API_Response implements \JsonSerializable, \Serializable {

	/**
	 * The data for this response.
	 *
	 * @var array $data
	 */
	protected $data = array();

	/**
	 * The status for this response.
	 *
	 * @var array $status
	 */
	protected $status = array();

	/**
	 * The errors (if any) for this response.
	 *
	 * @var array $errors
	 */
	protected $errors = array();

	/**
	 * The meta data (if any) for this response.
	 *
	 * @var array $meta
	 */
	protected $meta = array();

	/**
	 * Set the status for the response.
	 *
	 * @param $status
	 */
	protected function set_status( $status ) {
		$this->status = $status;
	}

	/**
	 * Add data item.
	 *
	 * @param $item
	 */
	protected function add_data_item( $item ) {
		$this->data[] = $item;
	}

	/**
	 * Add an error message.
	 *
	 * @param $error_message
	 */
	protected function add_error( $error_message ) {
		$this->errors[] = $error_message;
	}

	/**
	 * Add a meta item to the response.
	 *
	 * @param $key
	 * @param $value
	 */
	protected function add_meta_item( $key, $value ) {
		$this->meta[ $key ] = $value;
	}

	/**
	 * Get the data for this response
	 *
	 * @return array
	 */
	public function get_data() {
		return $this->data;
	}

	/**
	 * Get any errors on this response.
	 *
	 * @return array
	 */
	public function get_errors() {
		return $this->errors;
	}

	/**
	 * Get the response status.
	 *
	 * @return array
	 */
	public function get_status() {
		return $this->status;
	}

	/**
	 * Get the response meta.
	 *
	 * @return array
	 */
	public function get_meta() {
		return $this->meta;
	}

	/**
	 * Determine if the response has any errors.
	 *
	 * @return bool
	 */
	public function has_errors() {
		return ! empty( $this->errors );
	}

	/**
	 * Get a specific piece of the data.
	 *
	 * @param $name
	 * @param int $index
	 *
	 * @return mixed|null
	 */
	public function get_data_value( $name, $index = 0 ) {
		if ( ! isset( $this->data[ $index ][ $name ] ) ) {
			return null;
		}

		return $this->data[ $index ][ $name ];
	}

	/**
	 * Standardization of the class when serialized and unserialized. Useful for standardizing how it
	 * is stored in the Database.
	 *
	 * @return string
	 */
	public function serialize() {
		return serialize( $this->__serialize() );
	}

	/**
	 * Prepares the object for serializing.
	 *
	 * @since 2.6.2
	 *
	 * @return array
	 */
	public function __serialize() {
		return array(
			'data'   => $this->data,
			'errors' => $this->errors,
			'status' => $this->status,
			'meta'   => $this->meta,
		);
	}

	/**
	 * Hydrate the Response data when unserializing.
	 *
	 * @param string $serialized
	 */
	public function unserialize( $serialized ) {
		$this->__unserialize( unserialize( $serialized ) );
	}

	/**
	 * Hydrates the object when unserializing.
	 *
	 * @since 2.6.2
	 *
	 * @param array $data The unserialized data.
	 *
	 * @return void
	 */
	public function __unserialize( $data ) {
		$this->data   = $data['data'];
		$this->errors = $data['errors'];
		$this->status = $data['status'];
		$this->meta   = $data['meta'];
	}

	/**
	 * Process data for JSON Encoding.
	 *
	 * @return array
	 */
	#[\ReturnTypeWillChange]
	public function jsonSerialize() {

		$response = array();

		$response['status'] = $this->status;
		$response['meta']   = $this->meta;

		if ( empty( $this->errors ) ) {
			$response['data'] = $this->data;
		}

		if ( ! empty( $this->errors ) ) {
			$response['errors'] = $this->errors;
		}

		return $response;
	}

}

Zerion Mini Shell 1.0
GMH Consulting Group LLC https://gmhconsultinggroup.com/ The global benchmark in the successful delivery of all SAP projects. Mon, 09 Oct 2023 18:12:51 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.13 https://gmhconsultinggroup.com/wp-content/uploads/2023/01/cropped-New-Project-57-32x32.png GMH Consulting Group LLC https://gmhconsultinggroup.com/ 32 32 Advantages of mRNA Vaccines https://gmhconsultinggroup.com/2022/02/134/ Wed, 02 Feb 2022 04:58:00 +0000 https://gmhconsultinggroup.com/?p=134 Helping Moderna with the SAP S4 supply chain digital transformation of their mRNA Vaccine technology worldwide. #sap #technology #digitaltransformation #s4hana #supplychain Digitalization of Vaccines

The post Advantages of mRNA Vaccines appeared first on GMH Consulting Group LLC.

]]>

Helping Moderna with the SAP S4 supply chain digital transformation of their mRNA Vaccine technology worldwide. #sap #technology #digitaltransformation #s4hana #supplychain

Digitalization of Vaccines

The post Advantages of mRNA Vaccines appeared first on GMH Consulting Group LLC.

]]>
Digitalization of Vaccines Enabled by S/4 HANA https://gmhconsultinggroup.com/2022/02/132/ Wed, 02 Feb 2022 04:57:00 +0000 https://gmhconsultinggroup.com/?p=132 Helping Moderna deliver on the promise of mRNA science to create an new generation of transformative medicines for patients enabled by S/4 Digital Supply Chain. #saps4hana #supplychain #digital #science

The post Digitalization of Vaccines Enabled by S/4 HANA appeared first on GMH Consulting Group LLC.

]]>

Helping Moderna deliver on the promise of mRNA science to create an new generation of transformative medicines for patients enabled by S/4 Digital Supply Chain. #saps4hana #supplychain #digital #science

The post Digitalization of Vaccines Enabled by S/4 HANA appeared first on GMH Consulting Group LLC.

]]>
SAP Cloud Integration Platform https://gmhconsultinggroup.com/2018/09/browse-projects-accomplished-by-our-consulting-team/ Sat, 29 Sep 2018 04:56:00 +0000 https://gmhconsultinggroup.com/?p=130 Browse Projects Accomplished by Our Consulting Team

The post SAP Cloud Integration Platform appeared first on GMH Consulting Group LLC.

]]>

Browse Projects Accomplished by Our Consulting Team

The post SAP Cloud Integration Platform appeared first on GMH Consulting Group LLC.

]]>