-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from newfold-labs/PRESS0-1202
Press0 1202
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace NewfoldLabs\WP\Module\Migration\Services; | ||
|
||
/** | ||
* Class for handling analytics events. | ||
*/ | ||
class EventService { | ||
|
||
/** | ||
* Sends a Hiive Event to the data module API. | ||
* | ||
* @param array $event The event to send. | ||
* @return WP_REST_Response|WP_Error | ||
*/ | ||
public static function send( $event ) { | ||
$event_data_request = new \WP_REST_Request( | ||
\WP_REST_Server::CREATABLE, | ||
NFD_MODULE_DATA_EVENTS_API | ||
); | ||
$event_data_request->set_body_params( $event ); | ||
|
||
$response = rest_do_request( $event_data_request ); | ||
if ( $response->is_error() ) { | ||
return $response->as_error(); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains 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