PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.3.0
JetFormBuilder — Dynamic Blocks Form Builder v3.3.0
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 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / integrations / getresponse-handler.php
jetformbuilder / includes / integrations Last commit date
getresponse-handler.php 2 years ago integration-base.php 2 years ago mailchimp-handler.php 2 years ago
getresponse-handler.php
99 lines
1 <?php
2
3 namespace Jet_Form_Builder\Integrations;
4
5 // If this file is called directly, abort.
6 if ( ! defined( 'WPINC' ) ) {
7 die;
8 }
9
10 /**
11 * Define Getresponse_Handler class
12 */
13 class Getresponse_Handler extends Integration_Base {
14
15 protected $api_base_url = 'https://api.getresponse.com/v3/';
16
17 /**
18 * Constructor for the class
19 *
20 * @param $api_key
21 */
22 public function __construct( $api_key ) {
23 parent::__construct( $api_key );
24
25 if ( empty( $api_key ) ) {
26 // phpcs:ignore Universal.CodeAnalysis.ConstructorDestructorReturn.ReturnValueFound
27 return new \WP_Error( 'invalid_api_key' );
28 }
29
30 $this->api_key = $api_key;
31 $this->api_request_args = array(
32 'headers' => array(
33 'X-Auth-Token' => 'api-key ' . $api_key,
34 'Content-Type' => 'application/json',
35 ),
36 );
37 }
38
39
40 public function get_all_data() {
41 $lists = $this->get_lists();
42 $fields = $this->get_fields();
43
44 return ( empty( $lists ) && empty( $fields ) ) ? array() : array(
45 'lists' => $lists,
46 'fields' => $fields,
47 );
48 }
49
50 public function get_lists() {
51 $result = array();
52 $lists = $this->request( 'campaigns' );
53
54 if ( ! empty( $lists ) ) {
55 foreach ( $lists as $list ) {
56 if ( ! is_array( $list ) ) {
57 continue;
58 }
59 if ( ! isset( $list['campaignId'] ) ) {
60 return array();
61 }
62
63 $result[ $list['campaignId'] ] = $list['name'];
64 }
65 }
66
67 return $result;
68 }
69
70 public function get_fields() {
71 $result = array(
72 'email' => array(
73 'label' => esc_html__( 'Email', 'jet-form-builder' ),
74 'required' => true,
75 ),
76 'name' => array(
77 'label' => esc_html__( 'Name', 'jet-form-builder' ),
78 'required' => false,
79 ),
80 );
81
82 $custom_fields = $this->request( 'custom-fields' );
83
84 if ( ! empty( $custom_fields ) ) {
85 foreach ( $custom_fields as $field ) {
86 if ( ! isset( $field['customFieldId'] ) ) {
87 return array();
88 }
89 $result[ $field['customFieldId'] ] = array(
90 'label' => $field['name'],
91 'required' => false,
92 );
93 }
94 }
95
96 return $result;
97 }
98 }
99