Created
March 24, 2020 16:40
-
-
Save kuzmany/1635e2684b4728cabb26e0689b3dbf5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ExampleSmsCallback implements CallbackInterface | |
{ | |
/** | |
* @return string | |
*/ | |
public function getTransportName() | |
{ | |
return 'example'; | |
} | |
/** | |
* @param Request $request | |
* | |
* @return ArrayCollection | |
*/ | |
public function getContacts(Request $request) | |
{ | |
$contact = $this->getContactFromRequest($request); | |
$contacts = new ArrayCollection(); | |
$contacts->set($contact->getId(), $contact); | |
return $contacts; | |
} | |
/** | |
* @param Request $request | |
* | |
* @return \Mautic\SmsBundle\Event\DeliveryEvent | |
*/ | |
public function getEvent(Request $request) | |
{ | |
$details = $this->getRequestDetails(); | |
$deliveryEvent = new DeliveryEvent(); | |
$deliveryEvent->setTrackingHash($details['trackingHash']); | |
if($details['eventType'] === 'delivered'){ | |
$deliveryEvent->setIsDelivered(true); | |
}elseif(if($details['eventType'] === 'failed'){ | |
$deliveryEvent->setIsFailed(true); | |
} | |
return $deliveryEvent; | |
} | |
private function getRequestDetails(Request $request){ | |
// process requests | |
return $details; | |
} | |
private function getContactFromRequest(Request $request){ | |
// process requests | |
return $contact; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment