Hubspot_Helpers::get_fields( $exclude = array() )

get_fields


Return Return

(void)


Source Source

File: src/integrations/hubspot/helpers/hubspot-helpers.php

	public function get_fields( $exclude = array() ) {

		$fields = array();

		$request_params = array(
			'action' => 'get_fields',
		);

		try {
			$response = $this->api_request( $request_params );

			$fields[] = array(
						'value' => '',
						'text'  => __( 'Select a field', 'uncanny-automator' ),
			);

			foreach ( $response['data'] as $field ) {

				if ( in_array( $field['name'], $exclude, true ) ) {
					continue;
				}

				if ( $field['readOnlyValue'] ) {
					continue;
				}

				$fields[] = array(
					'value' => $field['name'],
					'text'  => $field['label'],
				);
			}

		} catch ( \Exception $e ) {
			$fields[] = array(
				'value' => '',
				'text'  => $e->getMessage(),
			);
		}

		return $fields;
	}