* Behoben: Falsche CRM-URL in Buchungs-Service-E-Mail
* Kontaktformular git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3300 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
ff9c159297
commit
353b758bcd
12 changed files with 741 additions and 34 deletions
|
|
@ -13,18 +13,12 @@ use AppBundle\Entity\Traveler;
|
|||
use AppBundle\Util;
|
||||
use Monolog\Logger;
|
||||
|
||||
class SternToursCrmBookingExporter
|
||||
class BookingSternToursCrmExporter extends SternToursCrmExporter
|
||||
{
|
||||
const API_URL = 'http://www.cms.stern-tours.net/api';
|
||||
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
|
||||
const API_USER_ID = 15; // 'apiuser'
|
||||
const WEBSITE_ID = 1; // 'sterntours.de'
|
||||
|
||||
private $logger;
|
||||
|
||||
public function __construct(Logger $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function process(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo)
|
||||
|
|
@ -322,30 +316,6 @@ class SternToursCrmBookingExporter
|
|||
return $resp['success'];
|
||||
}
|
||||
|
||||
private function httpGet($url)
|
||||
{
|
||||
$resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY]);
|
||||
$ret = json_decode($resp['content'], true);
|
||||
if ($ret === null)
|
||||
{
|
||||
$this->warn('Invalid server response: '. $resp['content']);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function httpPost($context, $postData = [], $isContextFullUrl = false)
|
||||
{
|
||||
$url = $isContextFullUrl ? $context : self::API_URL.'/'. $context .'.json';
|
||||
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY], true);
|
||||
return [
|
||||
'content' => json_decode($resp['content']),
|
||||
'location' => isset($resp['response_headers']['location'])
|
||||
? $resp['response_headers']['location']
|
||||
: null,
|
||||
'success' => $resp['success'] && ($resp['status_code'] == 201)
|
||||
];
|
||||
}
|
||||
|
||||
private function warn($msg, BookingRequest $bookingRequest = null, TravelDate $travelDate = null,
|
||||
$level = Logger::WARNING)
|
||||
{
|
||||
61
trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php
Normal file
61
trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
||||
* @date 02/21/2017
|
||||
*/
|
||||
|
||||
namespace AppBundle\Export;
|
||||
|
||||
|
||||
use AppBundle\Entity\ContactRequest;
|
||||
use Monolog\Logger;
|
||||
|
||||
class ContactSternToursCrmExporter extends SternToursCrmExporter
|
||||
{
|
||||
|
||||
public function __construct(Logger $logger)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function process(ContactRequest $contactRequest)
|
||||
{
|
||||
$data = ['lead' => [
|
||||
'customerForm' => [
|
||||
'salutation_id' => $contactRequest->getSalutation(),
|
||||
'name' => $contactRequest->getLastName(),
|
||||
'firstname' => $contactRequest->getFirstName(),
|
||||
'street' => $contactRequest->getStreetAddress(),
|
||||
'zip' => $contactRequest->getZipCode(),
|
||||
'city' => $contactRequest->getCity(),
|
||||
'country_id' => $contactRequest->getNation(),
|
||||
'phone' => $contactRequest->getPhone(),
|
||||
'phonemobile' => $contactRequest->getMobilePhone(),
|
||||
'email' => $contactRequest->getEmail()
|
||||
],
|
||||
'request_date' => (new \DateTime())->format('Y-m-d'),
|
||||
'sf_guard_user_id' => self::API_USER_ID,
|
||||
'status_id' => 10, // 'Angebot erstellen'
|
||||
'travelperiod_start' => $contactRequest->getStart(),
|
||||
'travelperiod_end' => $contactRequest->getEnd(),
|
||||
//'travelcategory_id'
|
||||
'is_closed' => 0,
|
||||
'website_id' => self::WEBSITE_ID,
|
||||
'initialcontacttype_id' => 1,
|
||||
'travelperiod_length' => $contactRequest->getDuration(),
|
||||
'remarks' => $contactRequest->getNotes(),
|
||||
'pax' => $contactRequest->getTravelerCount(),
|
||||
]];
|
||||
|
||||
$resp = $this->httpPost('lead', $data);
|
||||
|
||||
if (!$resp['success'])
|
||||
{
|
||||
$this->logger->error(get_class($this). ': Failed submitting contact request to CRM');
|
||||
$this->logger->error('*** Submitted data: '. json_encode($data));
|
||||
$this->logger->error('*** Server response: '. $resp['content']);
|
||||
}
|
||||
|
||||
return $resp['location'] ?? null;
|
||||
}
|
||||
}
|
||||
51
trunk/src/AppBundle/Export/SternToursCrmExporter.php
Normal file
51
trunk/src/AppBundle/Export/SternToursCrmExporter.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
||||
* @date 02/21/2017
|
||||
*/
|
||||
|
||||
namespace AppBundle\Export;
|
||||
|
||||
|
||||
use AppBundle\Util;
|
||||
use Monolog\Logger;
|
||||
|
||||
abstract class SternToursCrmExporter
|
||||
{
|
||||
const API_URL = 'http://www.cms.stern-tours.net/api';
|
||||
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
|
||||
const API_USER_ID = 15; // 'apiuser'
|
||||
const WEBSITE_ID = 1; // 'sterntours.de'
|
||||
|
||||
protected $logger;
|
||||
|
||||
public function __construct(Logger $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
protected final function httpGet($url)
|
||||
{
|
||||
$resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY]);
|
||||
$ret = json_decode($resp['content'], true);
|
||||
if ($ret === null)
|
||||
{
|
||||
$this->logger->warn(get_class($this) .': Invalid server response: '. $resp['content']);
|
||||
$this->logger->warn('*** Date: '. (new \DateTime())->format('d.m.Y'));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected final function httpPost($context, $postData = [], $isContextFullUrl = false)
|
||||
{
|
||||
$url = $isContextFullUrl ? $context : self::API_URL.'/'. $context .'.json';
|
||||
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY], true);
|
||||
return [
|
||||
'content' => json_decode($resp['content']),
|
||||
'location' => isset($resp['response_headers']['location'])
|
||||
? $resp['response_headers']['location']
|
||||
: null,
|
||||
'success' => $resp['success'] && ($resp['status_code'] == 201)
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue