Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Bump to version 1.8.8
Browse files Browse the repository at this point in the history
1. Update to Platform CRM API v3
  • Loading branch information
aaronhuisinga committed Nov 29, 2019
1 parent 49bef97 commit 6cdc0ef
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 39 deletions.
2 changes: 1 addition & 1 deletion assets/js/platform-email-validator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 15 additions & 17 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ jQuery('document').ready(function ($) {
});

// Email Validation
if (HouseHunter.platformvaluator !== undefined && HouseHunter.platformvaluator !== '') {
$('#email').platform_email_validator({
api_key: HouseHunter.platformvaluator,
in_progress: function () {
$('#email').parent().removeClass('has-warning has-error');
$(".mailcheck-suggestion").remove();
$("[type=submit]").addClass("disabled").attr("disabled", "disabled");
},
success: function (data) {
$('#email').after(get_suggestion_str(data['is_valid'], data['did_you_mean']));
},
error: function () {
$("[type=submit]").removeClass("disabled").removeAttr("disabled");
}
});
}
// Parse Mailgun Responses
$('#email').platform_email_validator({
in_progress: function () {
$('#email').parent().removeClass('has-warning has-error');
$(".mailcheck-suggestion").remove();
$("[type=submit]").addClass("disabled").attr("disabled", "disabled");
},
success: function (data) {
$('#email').after(get_suggestion_str(data['is_valid'], data['did_you_mean']));
},
error: function () {
$("[type=submit]").removeClass("disabled").removeAttr("disabled");
}
});

// Parse email validator Responses
function get_suggestion_str(is_valid, alternate) {
if (is_valid) {
if (alternate) {
Expand Down
40 changes: 25 additions & 15 deletions classes/class-frontdesk.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FrontDesk
*
* @param int $api_version
*/
public function __construct($api_version = 2)
public function __construct($api_version = 3)
{
$this->token = 'pf_house_hunter';
$this->api_key = get_option('pf_seller_quiz_frontdesk_key');
Expand Down Expand Up @@ -54,13 +54,15 @@ public function createCampaign($title, $permalink)
if ($this->api_key != null || $this->api_key != '') {
$response = $this->guzzle->post($this->api_base . 'campaigns/', [
'form_params' => [
'key' => $this->api_key,
'title' => $title,
'description' => 'Campaign for Platform House Hunter',
'type' => 'Platform',
'total_cost' => '10000',
'source' => $permalink
]
],
'headers' => [
'Authorization' => 'Bearer ' . $this->api_key,
],
]);

add_filter('redirect_post_location', [$this, 'add_success_var'], 99);
Expand All @@ -85,10 +87,12 @@ public function updateCampaign($id, $title, $permalink)
if ($this->api_key != null || $this->api_key != '') {
$this->guzzle->patch($this->api_base . 'campaigns/' . $id, [
'form_params' => [
'key' => $this->api_key,
'title' => $title,
'source' => $permalink
]
],
'headers' => [
'Authorization' => 'Bearer ' . $this->api_key,
],
]);
}
}
Expand All @@ -105,13 +109,15 @@ public function createProspect($data)
{
try {
if ($this->api_key != null || $this->api_key != '') {
$response = $this->guzzle->post($this->api_base . 'subscribers/complete', [
$response = $this->guzzle->post($this->api_base . 'subscribers', [
'form_params' => [
'key' => $this->api_key,
'campaigns' => $data['campaign_id'],
'email' => $data['email'],
'first_name' => $data['first_name']
]
'campaigns' => $data['campaign_id'],
'email' => $data['email'],
'first_name' => $data['first_name']
],
'headers' => [
'Authorization' => 'Bearer ' . $this->api_key,
],
]);

return json_decode($response->getBody(), true)['data']['id'];
Expand All @@ -138,7 +144,6 @@ public function updateProspect($id, $data)
if ($this->api_key != null || $this->api_key != '') {
$response = $this->guzzle->patch($this->api_base . 'subscribers/' . $id, [
'form_params' => [
'key' => $this->api_key,
'email' => $data['email'],
'last_name' => $data['last_name'],
'address' => $data['address'],
Expand All @@ -147,7 +152,10 @@ public function updateProspect($id, $data)
'state' => $data['state'],
'zip_code' => $data['zip_code'],
'phone' => $data['phone']
]
],
'headers' => [
'Authorization' => 'Bearer ' . $this->api_key,
],
]);

return json_decode($response->getBody(), true)['data']['id'];
Expand All @@ -174,11 +182,13 @@ public function createNote($id, $title, $content)
if ($this->api_key != null || $this->api_key != '') {
$response = $this->guzzle->post($this->api_base . 'subscribers/notes/', [
'form_params' => [
'key' => $this->api_key,
'subscriber_id' => $id,
'title' => $title,
'content' => $content
]
],
'headers' => [
'Authorization' => 'Bearer ' . $this->api_key,
],
]);

return json_decode($response->getBody(), true)['data']['id'];
Expand Down
2 changes: 1 addition & 1 deletion classes/class-house-hunter-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function frontdesk_key_field()
$data = $option;

echo '<input id="frontdesk_key" type="text" name="' . $this->token . '_frontdesk_key" value="' . $data . '"/>
<label for="frontdesk_key"><span class="description">' . __('Enter your API key generated by Platform CRM. To access your API key, visit <a href="https://platformcrm.com/account/api" target="_blank">https://platformcrm.com/account/api</a>.', $this->token) . '</span></label>';
<label for="frontdesk_key"><span class="description">' . __('Enter your API key generated by Platform CRM. To access your API key, visit <a href="https://platformcrm.com" target="_blank">https://platformcrm.com</a>.', $this->token) . '</span></label>';

}

Expand Down
3 changes: 1 addition & 2 deletions classes/class-house-hunter.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ public function enqueue_scripts()
wp_enqueue_script('platform-email-validator');

$localize = [
'ajaxurl' => admin_url('admin-ajax.php'),
'platformvaluator' => defined('MAILGUN_PUBLIC') ? MAILGUN_PUBLIC : ''
'ajaxurl' => admin_url('admin-ajax.php'),
];
wp_localize_script($this->token . '-js', 'HouseHunter', $localize);
}
Expand Down
4 changes: 2 additions & 2 deletions house-hunter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* Plugin Name: House Hunter
* Version: 1.8.7
* Version: 1.8.8
* Plugin URI: http://www.coldturkeygroup.com/
* Description: A form for prospective home buyers to fill out to request more information from a real estate agent.
* Author: Cold Turkey Group
Expand All @@ -24,7 +24,7 @@
}

if (!defined('HOUSE_HUNTER_PLUGIN_VERSION')) {
define('HOUSE_HUNTER_PLUGIN_VERSION', '1.8.7');
define('HOUSE_HUNTER_PLUGIN_VERSION', '1.8.8');
}

require_once('classes/class-house-hunter.php');
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: Aaron Huisinga
Tags: real estate, platform, house hunter
Requires at least: 3.5
Tested up to: 5.1
Stable tag: 1.8.7
Stable tag: 1.8.8

A form for prospective home buyers to fill out to request more information from a real estate agent.

Expand Down

0 comments on commit 6cdc0ef

Please sign in to comment.