SHEET_UPDATERECORD::get_response_status( $response )

Get the response status from Google API response.

Contents


Return Return

(array) The status.


Source Source

File: src/integrations/google-sheet/actions/sheet-updaterecord.php

	public function get_response_status( $response ) {

		$response_status = json_decode( $response );

		// Google returned a valid response but there was a valid error.
		if ( isset( $response_status->error ) && ! empty( $response_status->error ) ) {
			$error_message = sprintf(
				/* translators: The error code, type, and description */
				esc_html__( 'Error: %1$s | %2$s | %3$s', 'uncanny-automator' ),
				$response_status->statusCode, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
				$response_status->error->type,
				$response_status->error->description
			);
			return array(
				'error'   => true,
				'message' => $error_message,
			);
		}

		return array(
			'error'   => false,
			'message' => null,
		);

	}