From 344119a6786a326e632207318bf599f1258cd923 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Mon, 30 Mar 2026 13:10:51 +0200 Subject: [PATCH 1/4] revert clientify --- .../crm-library/class-crmlib-clientify.php | 400 +++++++++--------- 1 file changed, 193 insertions(+), 207 deletions(-) diff --git a/includes/crm-library/class-crmlib-clientify.php b/includes/crm-library/class-crmlib-clientify.php index 09a826e..eb932ef 100644 --- a/includes/crm-library/class-crmlib-clientify.php +++ b/includes/crm-library/class-crmlib-clientify.php @@ -2,13 +2,12 @@ /** * Clientify connect library * - * Has functions to login, list fields and create lead. - * Uses Clientify API v2: https://newapi.clientify.com/ + * Has functions to login, list fields and create lead * * @author closemarketing * @category Functions * @package Gravityforms CRM - * @version 2.0.0 + * @version 1.0.0 * * phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound */ @@ -18,24 +17,133 @@ */ class CRMLIB_Clientify { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy class name, changing would break compatibility. + /** + * Gets information from Clientify CRM + * + * @param string $url URL for module. + * @param string $apikey API Authentication. + * + * @return array + */ + private function get( $url, $apikey ) { + if ( ! $apikey ) { + return array( + 'status' => 'error', + 'data' => 'No API Key', + ); + } + $args = array( + 'headers' => array( + 'Authorization' => 'Token ' . $apikey, + ), + 'timeout' => 120, + ); + // Loop. + $next = true; + $results_value = array(); + $url = 'https://api.clientify.net/v1/' . $url; + + while ( $next ) { + $result_api = wp_remote_get( $url, $args ); + $results = json_decode( wp_remote_retrieve_body( $result_api ), true ); + $code_status = (int) wp_remote_retrieve_response_code( $result_api ); + $code = (int) round( $code_status / 100, 0 ); + + if ( 2 !== $code ) { + $message = implode( ' ', $result_api['response'] ) . ' '; + $body = json_decode( $result_api['body'], true ); + + if ( is_array( $body ) ) { + foreach ( $body as $key => $value ) { + $message_value = is_array( $value ) ? implode( '.', $value ) : $value; + $message .= $key . ': ' . $message_value; + } + } + formscrm_error_admin_message( 'ERROR', $message ); + return array( + 'status' => 'error', + 'data' => $message, + ); + } elseif ( isset( $results['results'] ) ) { + $results_value = array_merge( $results_value, $results['results'] ); + } + + if ( isset( $results['next'] ) && $results['next'] ) { + $url = $results['next']; + } else { + $next = false; + } + } + + $results['results'] = $results_value; + return array( + 'status' => 'ok', + 'data' => $results, + ); + } + /** + * Posts information from Holded CRM + * + * @param string $module URL for module. + * @param string $bodypost Params to send to API. + * @param string $apikey API Authentication. + * @param string $method Method to use. + * @return array + */ + private function request( $module, $bodypost, $apikey, $method = 'POST' ) { + $args = array( + 'headers' => array( + 'Authorization' => 'Token ' . $apikey, + 'Content-Type' => 'application/json', + ), + 'method' => $method, + 'timeout' => 120, + 'body' => wp_json_encode( $bodypost ), + ); + $url = 'https://api.clientify.net/v1/' . strtolower( $module ); + $result = wp_remote_post( $url, $args ); + $code = isset( $result['response']['code'] ) ? (int) round( $result['response']['code'] / 100, 0 ) : 0; + + if ( 2 !== $code ) { + $message = implode( ' ', $result['response'] ) . ' '; + $body = json_decode( $result['body'], true ); + if ( is_array( $body ) ) { + foreach ( $body as $key => $value ) { + $message_value = is_array( $value ) ? implode( '.', $value ) : $value; + $message .= $key . ': ' . $message_value; + } + } + formscrm_error_admin_message( 'ERROR', $message ); + return array( + 'status' => 'error', + 'data' => $message, + 'url' => $url, + 'query' => wp_json_encode( $bodypost ), + ); + } else { + $body = wp_remote_retrieve_body( $result ); + return array( + 'status' => 'ok', + 'data' => json_decode( $body, true ), + ); + } + } + /** * Logins to a CRM * * @param array $settings settings from Gravity Forms options. - * @return bool True if login succeeded, false otherwise. + * @return false or id returns false if cannot login and string if gets token */ public function login( $settings ) { - $apikey = isset( $settings['fc_crm_apipassword'] ) ? $settings['fc_crm_apipassword'] : ''; - if ( ! $apikey ) { - return false; - } + $apikey = isset( $settings['fc_crm_apipassword'] ) ? $settings['fc_crm_apipassword'] : ''; + $get_result = $this->get( 'settings/my-account/', $apikey ); - $result = $this->request( 'me/', array(), $apikey, 'GET' ); - if ( 'ok' !== $result['status'] || empty( $result['data']['id'] ) ) { + if ( $apikey && isset( $get_result['data']['count'] ) && $get_result['data']['count'] > 0 ) { + return true; + } else { return false; } - - return true; } /** @@ -272,17 +380,15 @@ private function get_fields_websites() { */ private function get_fields_email_phones() { $fields = array(); - - // Email types: 1=Work, 2=Personal, 3=Other, 4=Main. - $email_types = array( + $types = array( 1 => __( 'Work', 'formscrm' ), 2 => __( 'Personal', 'formscrm' ), 3 => __( 'Other', 'formscrm' ), - 4 => __( 'Main', 'formscrm' ), ); + // Emails. array_walk( - $email_types, + $types, function ( $type, $key ) use ( &$fields ) { $fields[] = array( 'name' => 'emails|' . $key, @@ -292,9 +398,7 @@ function ( $type, $key ) use ( &$fields ) { } ); - // Phone types from Clientify API: Main, Mobile, Work, Home, Fax, Other. - $phone_types = array( - 1 => __( 'Main', 'formscrm' ), + $types = array( 2 => __( 'Mobile', 'formscrm' ), 3 => __( 'Work', 'formscrm' ), 4 => __( 'Home', 'formscrm' ), @@ -302,8 +406,9 @@ function ( $type, $key ) use ( &$fields ) { 6 => __( 'Other', 'formscrm' ), ); + // Phones. array_walk( - $phone_types, + $types, function ( $type, $key ) use ( &$fields ) { $fields[] = array( 'name' => 'phones|' . $key, @@ -479,13 +584,6 @@ public function list_fields( $settings, $module = 'Contacts' ) { 'required' => false, ); - $fields[] = array( - 'name' => 'marketing_status', - 'label' => __( 'Marketing Status', 'formscrm' ), - 'tooltip' => __( '1=Sales Contact, 2=Marketing Contact.', 'formscrm' ), - 'required' => false, - ); - $fields[] = array( 'name' => 'birthday', 'label' => __( 'Birthday date', 'formscrm' ), @@ -628,21 +726,6 @@ public function list_fields( $settings, $module = 'Contacts' ) { $fields[] = array( 'name' => 'deal|pipeline_desc', 'label' => __( 'Pipeline Name', 'formscrm' ), - 'tooltip' => __( 'Name of the pipeline (pipeline_desc).', 'formscrm' ), - 'required' => false, - ); - - $fields[] = array( - 'name' => 'deal|pipeline_id', - 'label' => __( 'Pipeline ID', 'formscrm' ), - 'tooltip' => __( 'Numeric ID of the pipeline.', 'formscrm' ), - 'required' => false, - ); - - $fields[] = array( - 'name' => 'deal|pipeline_stage_desc', - 'label' => __( 'Pipeline Stage Name', 'formscrm' ), - 'tooltip' => __( 'Name of the pipeline stage.', 'formscrm' ), 'required' => false, ); @@ -665,35 +748,36 @@ public function list_fields( $settings, $module = 'Contacts' ) { ); } - // Fetch custom fields by object_type. - $object_types_map = array( - 'contacts' => array( 'contacts' ), - 'companies' => array( 'companies' ), - 'contacts-deals' => array( 'contacts', 'deals' ), - 'companies-deals' => array( 'companies', 'deals' ), - ); - $label_map = array( - 'contacts' => __( 'Contact', 'formscrm' ), - 'companies' => __( 'Company', 'formscrm' ), - 'deals' => __( 'Deal', 'formscrm' ), - ); - - if ( isset( $object_types_map[ $module_slug ] ) ) { - foreach ( $object_types_map[ $module_slug ] as $object_type ) { - $result_api = $this->request( 'custom-fields/?object_type=' . $object_type, array(), $apikey, 'GET' ); - if ( isset( $result_api['status'] ) && 'ok' === $result_api['status'] && isset( $result_api['data']['results'] ) ) { - foreach ( $result_api['data']['results'] as $custom_field ) { - $key = 'deals' === $object_type ? 'deal|' : ''; - $key .= 'custom_fields|' . $custom_field['name']; - - $label = isset( $label_map[ $object_type ] ) ? $label_map[ $object_type ] . ': ' : ''; - - $fields[] = array( - 'name' => $key, - 'label' => $label . $custom_field['name'], - 'required' => false, - ); - } + // Get Custom Fields. + $equivalent_module = array( + 'contacts' => array( 'contact', 'contacts | contact' ), + 'companies' => array( 'company', 'companies | company' ), + 'contacts-deals' => array( 'deal', 'contact', 'deals | deal', 'contacts | contact' ), + 'companies-deals' => array( 'deal', 'contact', 'deals | deal', 'contacts | contact' ), + ); + $label_module = array( + 'contact' => __( 'Contact', 'formscrm' ), + 'company' => __( 'Company', 'formscrm' ), + 'deal' => __( 'Deal', 'formscrm' ), + 'contacts | contact' => __( 'Contact', 'formscrm' ), + 'companies | company' => __( 'Company', 'formscrm' ), + 'deals | deal' => __( 'Deal', 'formscrm' ), + ); + + $result_api = $this->get( 'custom-fields/', $apikey ); + if ( isset( $result_api['status'] ) && 'ok' === $result_api['status'] && isset( $result_api['data']['results'] ) ) { + foreach ( $result_api['data']['results'] as $custom_field ) { + if ( isset( $equivalent_module[ $module_slug ] ) && in_array( $custom_field['content_type'], $equivalent_module[ $module_slug ], true ) ) { + $key = 'deals | deal' === $custom_field['content_type'] ? 'deal|' : ''; + $key .= 'custom_fields|' . $custom_field['name']; + + $label = isset( $label_module[ $custom_field['content_type'] ] ) ? $label_module[ $custom_field['content_type'] ] . ': ' : ''; + + $fields[] = array( + 'name' => $key, + 'label' => $label . $custom_field['name'], + 'required' => false, + ); } } } @@ -736,12 +820,12 @@ public function create_entry( $settings, $merge_vars ) { $deal_tags = $element['value']; } elseif ( 'deal|expected_closed_date_days' === $element['name'] ) { $deal['expected_closed_date'] = gmdate( 'Y-m-d', strtotime( '+' . (int) $element['value'] . ' days' ) ); - } elseif ( 'deal|pipeline_id' === $element['name'] ) { - $deal['pipeline_id'] = (int) $element['value']; - } elseif ( 'deal|pipeline_desc' === $element['name'] ) { - $deal['pipeline_desc'] = $element['value']; - } elseif ( 'deal|pipeline_stage_desc' === $element['name'] ) { - $deal['pipeline_stage_desc'] = $element['value']; + } elseif ( 'deal|pipeline_name' === $element['name'] ) { + // Pipeline URL functionality not yet implemented. + // For now, use the pipeline name directly if provided. + if ( ! empty( $element['value'] ) ) { + $deal['pipeline'] = $element['value']; + } } else { $deal_field = explode( '|', $element['name'] ); $deal[ $deal_field[1] ] = $element['value']; @@ -789,8 +873,6 @@ public function create_entry( $settings, $merge_vars ) { $contact[ $element['name'] ] = array( $element['value'] ); } elseif ( 'gdpr_accept' === $element['name'] || 'disclaimer' === $element['name'] ) { $contact[ $element['name'] ] = empty( $element['value'] ) ? false : true; - } elseif ( 'marketing_status' === $element['name'] ) { - $contact['marketing_status'] = (int) $element['value']; } elseif ( 'birthday' === $element['name'] ) { // Normalize birthday date format to YYYY-MM-DD. $normalized_date = formscrm_normalize_date_format( $element['value'] ); @@ -802,18 +884,13 @@ public function create_entry( $settings, $merge_vars ) { } } - // Default marketing status to 2 (Marketing Contact) if not set. - if ( ! isset( $contact['marketing_status'] ) ) { - $contact['marketing_status'] = 2; - } - // Clean tags blank. if ( ! empty( $contact['tags'] ) && is_array( $contact['tags'] ) ) { $contact_tags = array_map( 'trim', $contact['tags'] ); $contact['tags'] = array_values( array_filter( $contact_tags ) ); } - $result = $this->request( $module . '/', $contact, $apikey ); + $result = $this->request( $module, $contact, $apikey ); if ( 'ok' === $result['status'] ) { $contact_id = isset( $result['data']['id'] ) ? $result['data']['id'] : ''; $response_result = array( @@ -822,24 +899,30 @@ public function create_entry( $settings, $merge_vars ) { 'id' => $contact_id, ); - // Create deal linked to the contact/company. + // Crea ahora la oportunidad. if ( ! empty( $deal ) ) { + $deal_products = array(); if ( ! empty( $deal_product_skus ) ) { $res_products = $this->extract_deal_products( $deal_product_skus, $apikey ); if ( ! empty( $res_products['data'] ) ) { - $deal['products'] = $res_products['data']; - $deal['amount'] = ! empty( $res_products['total'] ) ? $res_products['total'] : 0; + $deal_products = $res_products['data']; + $deal['amount'] = ! empty( $res_products['total'] ) ? $res_products['total'] : 0; } } + // Set default values for key and slug. + $key = 'contact'; + $slug = 'contacts'; - // V2 uses ID-based references instead of URL-based. if ( 'contacts' === $module ) { - $deal['contact_id'] = (int) $contact_id; + $key = 'contact'; + $slug = 'contacts'; } elseif ( 'companies' === $module ) { - $deal['company_id'] = (int) $contact_id; + $key = 'company'; + $slug = 'companies'; } + $deal[ $key ] = "https://api.clientify.net/v1/$slug/$contact_id/"; $deal['amount'] = isset( $deal['amount'] ) ? $deal['amount'] : 0; - $result = $this->request( 'deals/', $deal, $apikey ); + $result = $this->request( 'deals', $deal, $apikey ); if ( 'ok' === $result['status'] ) { $response_result['id'] = sprintf( /* translators: %1$s: Contact ID, %2$s: Deal ID */ @@ -850,7 +933,7 @@ public function create_entry( $settings, $merge_vars ) { } // Add tags to deal. - if ( ! empty( $deal_tags ) && isset( $result['data']['id'] ) ) { + if ( ! empty( $deal_tags ) ) { $deal_tags_raw = explode( ',', $deal_tags ); $deal_id = $result['data']['id']; @@ -877,6 +960,13 @@ public function create_entry( $settings, $merge_vars ) { $response_result['message'] .= ' ' . $result_deal_tag; } } + + // Add products to deal. + if ( ! empty( $deal_products ) && isset( $res_products['data'] ) ) { + $result = $this->request( 'deals/' . $result['data']['id'] . '/products/', $res_products['data'], $apikey, 'PUT' ); + + $response_result['message'] .= ' ' . $result['message'] . '.'; + } $last_module = 'deal'; } } else { @@ -894,29 +984,26 @@ public function create_entry( $settings, $merge_vars ) { } /** - * Extracts deal products from a string of SKUs and get Clientify schema. + * Extracts deal products from a string of SKUs and get Clientify schema * * @param string $deal_product_skus The string of SKUs separated by commas. * @param string $apikey The API key. - * @return array The array of deal products in v2 format. + * @return array The array of deal products */ private function extract_deal_products( $deal_product_skus, $apikey ) { $skus = explode( ',', $deal_product_skus ); $deal_products = array(); $deal_total = 0; foreach ( $skus as $sku ) { - $sku = trim( $sku ); - $res_product = $this->request( 'products/?sku=' . $sku, array(), $apikey, 'GET' ); + $res_product = $this->get( 'products/?sku=' . $sku, $apikey ); if ( 'ok' === $res_product['status'] && isset( $res_product['data']['results'][0]['id'] ) ) { - $product = $res_product['data']['results'][0]; - $product_price = ! empty( $product['price'] ) ? (float) $product['price'] : 0; - $deal_products[] = array( - 'product_id' => $product['id'], - 'price' => $product_price, - 'quantity' => 1, + 'product' => $res_product['data']['results'][0]['id'], + 'quantity' => 1, ); - $deal_total += $product_price; + if ( ! empty( $res_product['data']['results'][0]['price'] ) ) { + $deal_total += $res_product['data']['results'][0]['price']; + } } } return array( @@ -925,105 +1012,4 @@ private function extract_deal_products( $deal_product_skus, $apikey ) { 'total' => $deal_total, ); } - - /** - * Sends a request to Clientify API (GET with optional pagination, POST, PUT, etc.). - * - * @param string $module URL path for the API endpoint (e.g. 'me/', 'contacts/'). - * @param array $params Params to send. In GET requests, are fields. - * @param string $apikey API authentication token. - * @param string $method HTTP method: GET, POST, PUT, etc. - * @return array 'status' => 'ok'|'error', 'data' => response or error message. - */ - private function request( $module, $params = array(), $apikey = '', $method = 'POST' ) { - if ( ! $apikey ) { - return array( - 'status' => 'error', - 'data' => 'No API Key', - ); - } - - $api_url = 'https://api-plus.clientify.com/v2/'; - $url = $api_url . strtolower( $module ); - $args = array( - 'headers' => array( - 'Authorization' => 'Token ' . $apikey, - ), - 'method' => $method, - 'timeout' => 120, - ); - - if ( 'GET' !== $method && ! empty( $params ) ) { - $args['headers']['Content-Type'] = 'application/json'; - $args['body'] = wp_json_encode( $params ); - } - - if ( 'GET' === $method ) { - if ( empty( $params ) ) { - $params = array( 'fields' => 'id' ); - } - $url .= '?' . http_build_query( $params ); - } - - $next = true; - $results_value = array(); - - while ( $next ) { - $result = wp_remote_request( $url, $args ); - $body_raw = wp_remote_retrieve_body( $result ); - $results = json_decode( $body_raw, true ); - $code = (int) round( (int) wp_remote_retrieve_response_code( $result ) / 100, 0 ); - - if ( 2 !== $code ) { - $message = $this->request_error_message( $result, $body_raw ); - formscrm_error_admin_message( 'ERROR', $message ); - $out = array( - 'status' => 'error', - 'data' => $message, - ); - if ( 'GET' !== $method ) { - $out['url'] = $url; - $out['query'] = wp_json_encode( $params ); - } - return $out; - } - - if ( 'GET' === $method && isset( $results['results'] ) ) { - $results_value = array_merge( $results_value, $results['results'] ); - } - - if ( 'GET' === $method && ! empty( $results['next'] ) ) { - $url = $results['next']; - } else { - $next = false; - if ( 'GET' === $method && ! empty( $results_value ) ) { - $results['results'] = $results_value; - } - } - } - - return array( - 'status' => 'ok', - 'data' => 'GET' === $method ? $results : json_decode( $body_raw, true ), - ); - } - - /** - * Builds error message string from API response. - * - * @param array|\WP_Error $result wp_remote_* result. - * @param string $body_raw Raw response body. - * @return string - */ - private function request_error_message( $result, $body_raw ) { - $message = (int) wp_remote_retrieve_response_code( $result ) . ' '; - $body = json_decode( $body_raw, true ); - if ( is_array( $body ) ) { - foreach ( $body as $key => $value ) { - $message_value = is_array( $value ) ? implode( '.', $value ) : $value; - $message .= $key . ': ' . $message_value; - } - } - return $message; - } -} +} //from Class From 976405ecf51df7223debb6167006675d854930ec Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Mon, 30 Mar 2026 13:16:02 +0200 Subject: [PATCH 2/4] version --- formscrm.php | 4 ++-- readme.txt | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/formscrm.php b/formscrm.php index b3cf479..c4c41ef 100644 --- a/formscrm.php +++ b/formscrm.php @@ -3,7 +3,7 @@ * Plugin Name: FormsCRM * Plugin URI : https://close.technology/wordpress-plugins/formscrm/ * Description: Connects Forms with CRM, ERP and Email Marketing. - * Version: 4.3.2 + * Version: 4.3.2.1 * Author: CloseTechnology * Author URI: https://close.technology * Text Domain: formscrm @@ -23,7 +23,7 @@ defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); -define( 'FORMSCRM_VERSION', '4.3.2' ); +define( 'FORMSCRM_VERSION', '4.3.2.1' ); define( 'FORMSCRM_PLUGIN', __FILE__ ); define( 'FORMSCRM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'FORMSCRM_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); diff --git a/readme.txt b/readme.txt index 40a0c93..11333aa 100644 --- a/readme.txt +++ b/readme.txt @@ -4,8 +4,8 @@ Tags: gravityforms, wpforms, crm, vtiger, odoo Donate link: https://close.marketing/go/donate/ Requires at least: 5.5 Tested up to: 7.0 -Stable tag: 4.3.2 -Version: 4.3.2 +Stable tag: 4.3.2.1 +Version: 4.3.2.1 License: GPL2 License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -244,6 +244,9 @@ WordPress installation and then activate the Plugin from Plugins page. == Changelog == += 4.3.2.1 = +* Hotfix: revert Clientify API v2 migration due to critical issues with field mapping configuration. + = 4.3.2 = * Migrated: Clientify to API v2 (api-plus.clientify.com/v2): login me/, custom fields object_type filter, deal creation with ID-based refs and inline products (v2 schema). * Added: Clientify contact marketing_status, pipeline ID/stage name, and Email Main/Phone Main field types. It defaults to Marketing Contact (2). From 97071c3ffb7d58832e0785d3a7cae2b4d6ee8640 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Mon, 30 Mar 2026 13:19:41 +0200 Subject: [PATCH 3/4] migrate tests --- tests/API/test-clientify.php | 262 +++++++---------------------------- 1 file changed, 49 insertions(+), 213 deletions(-) diff --git a/tests/API/test-clientify.php b/tests/API/test-clientify.php index d0b3f44..d2bc1d1 100644 --- a/tests/API/test-clientify.php +++ b/tests/API/test-clientify.php @@ -1,264 +1,100 @@ settings = array( - 'fc_crm_type' => 'clientify', + + $this->settings = [ + 'fc_crm_type' => 'clientify', 'fc_crm_apipassword' => 'api-password', - 'fc_crm_module' => 'Contacts', - ); + 'fc_crm_module' => 'Contacts', + ]; $this->crm_clientify = formscrm_get_api_class( 'clientify' ); + + // Mock the HTTP request to return a successful response. + add_filter( + 'pre_http_request', + function( $pre, $r, $url ) { + $body_query = ! empty( $r['body'] ) ? json_decode( $r['body'], true ) : array(); + $response_file = 'clientify-'; + + // Login. + if ( str_contains( $url, 'settings/my-account/' ) ) { + $response_file .= 'login.json'; + } + if ( str_contains( $url, 'custom-fields/' ) ) { + $response_file .= 'custom-fields.json'; + } + + $response_file = UNIT_TESTS_DATA_PLUGIN_DIR . $response_file; + if ( file_exists( $response_file ) ) { + return array( + 'body' => file_get_contents( $response_file ), + 'response' => array( 'code' => 200, 'message' => 'OK' ), + ); + } - add_filter( 'pre_http_request', array( $this, 'mock_http_requests' ), 10, 3 ); - } - - /** - * Mock HTTP requests for Clientify API v2. - * - * @param false|array $pre Pre-emptive return value. - * @param array $r Request arguments. - * @param string $url Request URL. - * @return array Mocked response. - */ - public function mock_http_requests( $pre, $r, $url ) { - $response_file = ''; - - // V2 login endpoint. - if ( str_contains( $url, '/v2/me/' ) ) { - $response_file = 'clientify-login.json'; - } - - // V2 custom fields endpoint. - if ( str_contains( $url, '/v2/custom-fields/' ) ) { - $response_file = 'clientify-custom-fields.json'; - } - - // V2 contact creation. - if ( str_contains( $url, '/v2/contacts/' ) && 'POST' === $r['method'] ) { - return array( - 'body' => wp_json_encode( - array( - 'id' => 100597402, - 'first_name' => 'Test', - 'last_name' => 'User', - 'email' => 'test@example.com', - 'status' => 'cold-lead', - ) - ), - 'response' => array( - 'code' => 201, - 'message' => 'Created', - ), - ); - } - - // V2 deal creation. - if ( str_contains( $url, '/v2/deals/' ) && 'POST' === $r['method'] ) { - return array( - 'body' => wp_json_encode( - array( - 'id' => 626, - 'name' => 'Test Deal', - 'amount' => '1000.00', - ) - ), - 'response' => array( - 'code' => 201, - 'message' => 'Created', - ), - ); - } - - if ( $response_file ) { - $response_file = UNIT_TESTS_DATA_PLUGIN_DIR . $response_file; - if ( file_exists( $response_file ) ) { return array( - 'body' => file_get_contents( $response_file ), // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - 'response' => array( - 'code' => 200, - 'message' => 'OK', - ), + 'body' => '', + 'response' => array( 'code' => 500, 'message' => 'Error API' ), ); - } - } - - return array( - 'body' => '', - 'response' => array( - 'code' => 500, - 'message' => 'Error API', - ), - ); + }, + 10, 3 ); } - /** - * Test login succeeds with valid credentials. - */ public function test_login_without_errors() { $login = $this->crm_clientify->login( $this->settings ); $this->assertTrue( $login ); } - /** - * Test login fails with empty API key. - */ public function test_login_with_errors() { $this->settings['fc_crm_apipassword'] = ''; $login = $this->crm_clientify->login( $this->settings ); $this->assertFalse( $login ); } - /** - * Test modules list returns expected structure. - */ public function test_list_modules_without_errors() { $modules = $this->crm_clientify->list_modules( $this->settings ); - $this->assertIsArray( $modules ); - $module_names = array_column( $modules, 'name' ); - $this->assertContains( 'contacts', $module_names ); - $this->assertContains( 'contacts-deals', $module_names ); - $this->assertContains( 'companies', $module_names ); - $this->assertContains( 'companies-deals', $module_names ); + $this->assertTrue( is_array( $modules ) ); } - /** - * Test fields list returns standard and custom fields. - */ public function test_list_fields_without_errors() { $fields = $this->crm_clientify->list_fields( $this->settings, 'Contacts' ); - $this->assertIsArray( $fields ); - $field_names = array_column( $fields, 'name' ); - - // Standard fields. - $this->assertContains( 'first_name', $field_names ); - $this->assertContains( 'last_name', $field_names ); - $this->assertContains( 'email', $field_names ); - $this->assertContains( 'phone', $field_names ); - $this->assertContains( 'company', $field_names ); - - // Website fields. - $this->assertContains( 'websites|corporate', $field_names ); - $this->assertContains( 'websites|personal', $field_names ); - - // Custom fields from v2 mock data. - $this->assertContains( 'custom_fields|interes2', $field_names ); - $this->assertContains( 'custom_fields|verified', $field_names ); - $this->assertContains( 'custom_fields|social_lead_1', $field_names ); - } - - /** - * Test v2 email type 4 (Main) and phone type 1 (Main) are present. - */ - public function test_list_fields_includes_v2_types() { - $fields = $this->crm_clientify->list_fields( $this->settings, 'Contacts' ); - $field_names = array_column( $fields, 'name' ); - - $this->assertContains( 'emails|4', $field_names ); - $this->assertContains( 'phones|1', $field_names ); - } - - /** - * Test deal fields are present for contacts-deals module. - */ - public function test_list_fields_deals_module() { - $fields = $this->crm_clientify->list_fields( $this->settings, 'contacts-deals' ); - $field_names = array_column( $fields, 'name' ); - - $this->assertContains( 'deal|name', $field_names ); - $this->assertContains( 'deal|amount', $field_names ); - $this->assertContains( 'deal|pipeline_desc', $field_names ); - $this->assertContains( 'deal|pipeline_id', $field_names ); - $this->assertContains( 'deal|pipeline_stage_desc', $field_names ); - $this->assertContains( 'deal|product_skus', $field_names ); - $this->assertContains( 'deal|tags', $field_names ); - } - - /** - * Test creating a contact entry. - */ - public function test_create_entry_contact() { - $merge_vars = array( - array( - 'name' => 'first_name', - 'value' => 'Test', - ), - array( - 'name' => 'last_name', - 'value' => 'User', - ), - array( - 'name' => 'email', - 'value' => 'test@example.com', - ), - array( - 'name' => 'status', - 'value' => 'cold-lead', - ), - ); - - $result = $this->crm_clientify->create_entry( $this->settings, $merge_vars ); - $this->assertEquals( 'ok', $result['status'] ); - $this->assertEquals( 100597402, $result['id'] ); - } - - /** - * Test creating a contact with deal entry. - */ - public function test_create_entry_contact_deal() { - $this->settings['fc_crm_module'] = 'contacts-deals'; - - $merge_vars = array( - array( - 'name' => 'first_name', - 'value' => 'Test', - ), - array( - 'name' => 'email', - 'value' => 'test@example.com', - ), - array( - 'name' => 'deal|name', - 'value' => 'Test Deal', - ), - array( - 'name' => 'deal|amount', - 'value' => '1000', - ), - ); - - $result = $this->crm_clientify->create_entry( $this->settings, $merge_vars ); - $this->assertEquals( 'ok', $result['status'] ); - $this->assertEquals( 'deal', $result['module'] ); + $this->assertTrue( is_array( $fields ) ); + $fields = array_column( $fields, 'name' ); + $this->assertTrue( in_array( 'first_name', $fields ) ); + $this->assertTrue( in_array( 'last_name', $fields ) ); + $this->assertTrue( in_array( 'email', $fields ) ); + $this->assertTrue( in_array( 'phone', $fields ) ); + $this->assertTrue( in_array( 'company', $fields ) ); + $this->assertTrue( in_array( 'custom_fields|interes2', $fields ) ); + $this->assertTrue( in_array( 'websites|corporate', $fields ) ); + $this->assertTrue( in_array( 'websites|personal', $fields ) ); + $this->assertTrue( in_array( 'custom_fields|verified', $fields ) ); + $this->assertTrue( in_array( 'custom_fields|social_lead_1', $fields ) ); } } From d631c12d67af7b995f214f85772ce78de75c2dbb Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Mon, 30 Mar 2026 13:22:00 +0200 Subject: [PATCH 4/4] move data for v1 and v2 --- tests/Data/clientify-custom-fields.json | 358 ++++++++++++++++++- tests/Data/clientify-login.json | 17 +- tests/Data/clientify-v2-custom-fields.json | 396 +++++++++++++++++++++ tests/Data/clientify-v2-login.json | 3 + 4 files changed, 761 insertions(+), 13 deletions(-) create mode 100644 tests/Data/clientify-v2-custom-fields.json create mode 100644 tests/Data/clientify-v2-login.json diff --git a/tests/Data/clientify-custom-fields.json b/tests/Data/clientify-custom-fields.json index 6e53fd8..0ad0ca2 100644 --- a/tests/Data/clientify-custom-fields.json +++ b/tests/Data/clientify-custom-fields.json @@ -1,62 +1,396 @@ { - "count": 5, + "count": 354, "next": null, "previous": null, "results": [ { + "url": "https://api.clientify.net/v1/custom-fields/476966/", "id": 476966, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", "name": "verified", "help_text": "", "field_type": 3, "field_type_display": "Text", "default_value": "", "dropdown_choices": [], - "visible": false, - "object_type": "contacts" + "visible": false }, { + "url": "https://api.clientify.net/v1/custom-fields/476965/", "id": 476965, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", "name": "social_lead_1", "help_text": "", "field_type": 3, "field_type_display": "Text", "default_value": "", "dropdown_choices": [], - "visible": false, - "object_type": "contacts" + "visible": false }, { + "url": "https://api.clientify.net/v1/custom-fields/476964/", + "id": 476964, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "social_lead", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476963/", + "id": 476963, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "satisfaccion_atencion_al_cliente", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476962/", + "id": 476962, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "quiero_comprar", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476961/", + "id": 476961, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "para_su_1er_inversin_cuenta_con", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476960/", + "id": 476960, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "nmero_de_telfono", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476959/", + "id": 476959, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "item", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476958/", + "id": 476958, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "interes_categoria", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476957/", "id": 476957, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", "name": "interes2", "help_text": "", "field_type": 3, "field_type_display": "Text", "default_value": "", "dropdown_choices": [], - "visible": false, - "object_type": "contacts" + "visible": false }, { + "url": "https://api.clientify.net/v1/custom-fields/476956/", "id": 476956, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", "name": "info_chat", "help_text": "", "field_type": 3, "field_type_display": "Text", "default_value": "", "dropdown_choices": [], - "visible": false, - "object_type": "contacts" + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476955/", + "id": 476955, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "have_you_or_a_loved_one_been_injured_in_an_accident", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false }, { + "url": "https://api.clientify.net/v1/custom-fields/476954/", + "id": 476954, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "formulario_satisfaccion_de_atencion_al_cliente", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476953/", + "id": 476953, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "estado_del_contacto", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476952/", + "id": 476952, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "en_una_escala_del_1_al_5___cuanto_satisfecho_esta_usted_con_nuestro_producto_servicio_", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476951/", + "id": 476951, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "documento", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476950/", "id": 476950, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", "name": "datos_de_contacto", "help_text": "", "field_type": 3, "field_type_display": "Text", "default_value": "", "dropdown_choices": [], - "visible": false, - "object_type": "contacts" + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476949/", + "id": 476949, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "cuentas_con_la_inversin_de_1000000", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476948/", + "id": 476948, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "correo_electrnico", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476947/", + "id": 476947, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "comentarios", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476946/", + "id": 476946, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "ciudad", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476923/", + "id": 476923, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "carrito_abandonado", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/473103/", + "id": 473103, + "user_company": "PRUEBA CLOSE", + "content_type": "products | product", + "name": "unidad_medida_alegra", + "help_text": "", + "field_type": 1, + "field_type_display": "Dropdown", + "default_value": "", + "dropdown_choices": [ + { + "name": "unit" + }, + { + "name": "centimeter" + }, + { + "name": "meter" + }, + { + "name": "inch" + }, + { + "name": "centimeterSquared" + }, + { + "name": "meterSquared" + }, + { + "name": "inchSquared" + }, + { + "name": "mililiter" + }, + { + "name": "liter" + }, + { + "name": "gallon" + }, + { + "name": "gram" + }, + { + "name": "kilogram" + }, + { + "name": "service" + }, + { + "name": "par" + }, + { + "name": "cubicMeterNet" + }, + { + "name": "cubicMeter" + }, + { + "name": "hour" + }, + { + "name": "MIN" + }, + { + "name": "DAY" + }, + { + "name": "box" + }, + { + "name": "drum" + } + ], + "visible": true + }, + { + "url": "https://api.clientify.net/v1/custom-fields/473102/", + "id": 473102, + "user_company": "PRUEBA CLOSE", + "content_type": "products | product", + "name": "prueba producto custom field", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/472950/", + "id": 472950, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "zoom_webinar_registration_count", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false } ] -} +} \ No newline at end of file diff --git a/tests/Data/clientify-login.json b/tests/Data/clientify-login.json index 00a4b08..8137630 100644 --- a/tests/Data/clientify-login.json +++ b/tests/Data/clientify-login.json @@ -1,3 +1,18 @@ { - "id": 57672 + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "language": "es", + "country": "ES", + "time_zone": "Europe/Madrid", + "currency": "EUR", + "currency_symbol": "€", + "currency_format": 1, + "hour_format": 1, + "date_format": 1, + "sub_brand": "" + } + ] } \ No newline at end of file diff --git a/tests/Data/clientify-v2-custom-fields.json b/tests/Data/clientify-v2-custom-fields.json new file mode 100644 index 0000000..0ad0ca2 --- /dev/null +++ b/tests/Data/clientify-v2-custom-fields.json @@ -0,0 +1,396 @@ +{ + "count": 354, + "next": null, + "previous": null, + "results": [ + { + "url": "https://api.clientify.net/v1/custom-fields/476966/", + "id": 476966, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "verified", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476965/", + "id": 476965, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "social_lead_1", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476964/", + "id": 476964, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "social_lead", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476963/", + "id": 476963, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "satisfaccion_atencion_al_cliente", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476962/", + "id": 476962, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "quiero_comprar", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476961/", + "id": 476961, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "para_su_1er_inversin_cuenta_con", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476960/", + "id": 476960, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "nmero_de_telfono", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476959/", + "id": 476959, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "item", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476958/", + "id": 476958, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "interes_categoria", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476957/", + "id": 476957, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "interes2", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476956/", + "id": 476956, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "info_chat", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476955/", + "id": 476955, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "have_you_or_a_loved_one_been_injured_in_an_accident", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476954/", + "id": 476954, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "formulario_satisfaccion_de_atencion_al_cliente", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476953/", + "id": 476953, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "estado_del_contacto", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476952/", + "id": 476952, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "en_una_escala_del_1_al_5___cuanto_satisfecho_esta_usted_con_nuestro_producto_servicio_", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476951/", + "id": 476951, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "documento", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476950/", + "id": 476950, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "datos_de_contacto", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476949/", + "id": 476949, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "cuentas_con_la_inversin_de_1000000", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476948/", + "id": 476948, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "correo_electrnico", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476947/", + "id": 476947, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "comentarios", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476946/", + "id": 476946, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "ciudad", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/476923/", + "id": 476923, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "carrito_abandonado", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/473103/", + "id": 473103, + "user_company": "PRUEBA CLOSE", + "content_type": "products | product", + "name": "unidad_medida_alegra", + "help_text": "", + "field_type": 1, + "field_type_display": "Dropdown", + "default_value": "", + "dropdown_choices": [ + { + "name": "unit" + }, + { + "name": "centimeter" + }, + { + "name": "meter" + }, + { + "name": "inch" + }, + { + "name": "centimeterSquared" + }, + { + "name": "meterSquared" + }, + { + "name": "inchSquared" + }, + { + "name": "mililiter" + }, + { + "name": "liter" + }, + { + "name": "gallon" + }, + { + "name": "gram" + }, + { + "name": "kilogram" + }, + { + "name": "service" + }, + { + "name": "par" + }, + { + "name": "cubicMeterNet" + }, + { + "name": "cubicMeter" + }, + { + "name": "hour" + }, + { + "name": "MIN" + }, + { + "name": "DAY" + }, + { + "name": "box" + }, + { + "name": "drum" + } + ], + "visible": true + }, + { + "url": "https://api.clientify.net/v1/custom-fields/473102/", + "id": 473102, + "user_company": "PRUEBA CLOSE", + "content_type": "products | product", + "name": "prueba producto custom field", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + }, + { + "url": "https://api.clientify.net/v1/custom-fields/472950/", + "id": 472950, + "user_company": "PRUEBA CLOSE", + "content_type": "contacts | contact", + "name": "zoom_webinar_registration_count", + "help_text": "", + "field_type": 3, + "field_type_display": "Text", + "default_value": "", + "dropdown_choices": [], + "visible": false + } + ] +} \ No newline at end of file diff --git a/tests/Data/clientify-v2-login.json b/tests/Data/clientify-v2-login.json new file mode 100644 index 0000000..00a4b08 --- /dev/null +++ b/tests/Data/clientify-v2-login.json @@ -0,0 +1,3 @@ +{ + "id": 57672 +} \ No newline at end of file