PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / modules / active-campaign / methods / list-contact-property.php

list-contact-property.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at modules/active-campaign/methods/list-contact-property.php

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Active_Campaign\Methods;
5
6 use Jet_Form_Builder\Actions\Methods\Abstract_Modifier;
7 use Jet_Form_Builder\Actions\Methods\Base_Object_Property;
8 use Jet_Form_Builder\Exceptions\Action_Exception;
9 use Jet_Form_Builder\Exceptions\Gateway_Exception;
10 use Jet_Form_Builder\Exceptions\Silence_Exception;
11 use JFB_Modules\Active_Campaign\Api\Update_List_Status;
12
13 // If this file is called directly, abort.
14 if ( ! defined( 'WPINC' ) ) {
15 die;
16 }
17
18 class List_Contact_Property extends Base_Object_Property {
19
20 // It can be empty
21 // in action we use dynamic fetching properties
22 public function get_label(): string {
23 return '';
24 }
25
26 public function get_id(): string {
27 return '#list';
28 }
29
30 /**
31 * @param Abstract_Modifier|Contact_Modifier $modifier
32 *
33 * @throws Action_Exception
34 */
35 public function do_after( Abstract_Modifier $modifier ) {
36 if ( ! is_numeric( $this->value ) ) {
37 return;
38 }
39 /** @var Sync_Contact_Action $action */
40 $action = $modifier->get_action();
41
42 /** @var Update_List_Status $api */
43 $api = ( new Update_List_Status() )
44 ->set_token( $modifier->token )
45 ->set_base( $modifier->url );
46
47 $api->set_list( (int) $this->value )
48 ->set_contact( $action->contact_id );
49
50 try {
51 $api->send_request();
52 } catch ( Gateway_Exception $exception ) {
53 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
54 throw new Action_Exception( 'internal_error', $api->get_request_args() );
55 }
56 }
57
58 public function get_value( Abstract_Modifier $modifier ) {
59 throw new Silence_Exception();
60 }
61 }
62