Hubspot_Helpers::add_contact_to_list( $list, mixed $email, $action_data )
add_contact_to_list
Contents
Parameters Parameters
-
(Required)
Return Return
(void)
Source Source
File: src/integrations/hubspot/helpers/hubspot-helpers.php
public function add_contact_to_list( $list, $email, $action_data ) { if ( empty( $email ) ) { throw new \Exception( __( 'Email is missing', 'uncanny-automator' ) ); } if ( empty( $list ) ) { throw new \Exception( __( 'List is missing', 'uncanny-automator' ) ); } $params = array( 'action' => 'add_contact_to_list', 'email' => $email, 'list' => $list, ); $response = $this->api_request( $params, $action_data ); // If the email was already in the list if ( ! empty( $response['data']['discarded'] ) ) { throw new \Exception( __( 'Contact with such email address was already in the list', 'uncanny-automator' ) ); } // If the email was not found in contacts if ( ! empty( $response['data']['invalidEmails'] ) ) { throw new \Exception( __( 'Contact with such email address was not found', 'uncanny-automator' ) ); } return $response; }
Expand full source code Collapse full source code View on Github