Files
UnrealEngineUWP/Engine/Source/Developer/SlackIntegrations/Private/SlackIncomingWebhookInterface.h
Ryan Vance 7c51ff94af Merging //UE4/Dev-Main to Dev-VR (//UE4/Dev-VR)
CL 1 of 8
#rb integration

[CL 4748712 by Ryan Vance in Dev-VR branch]
2019-01-17 18:54:05 -05:00

50 lines
1.8 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Containers/UnrealString.h"
#include "Interfaces/IHttpRequest.h"
#include "ISlackIncomingWebhookInterface.h"
class IHttpRequest;
struct FSlackIncomingWebhook;
struct FSlackMessage;
/**
* Concrete implementation of ISlackIncomingWebhookInterface in module's private code.
* Sends Incoming Webhook messages to Slack.
*/
class FSlackIncomingWebhookInterface : public ISlackIncomingWebhookInterface
{
public:
/** Empty virtual destructor because class has virtual methods */
virtual ~FSlackIncomingWebhookInterface() {}
/**
* Send an incoming webhook message to Slack
* @param InWebhook Webhook parameters sets where and how to send the message
* @param InMessage The message to send to Slack
* @return True if the http request was send successfully, otherwise false.
*/
virtual bool SendMessage(const FSlackIncomingWebhook& InWebhook, const FSlackMessage& InMessage) const override;
private:
/** Helper used to make http requests by SendMessage() */
TSharedRef<IHttpRequest> CreateHttpRequest() const;
/**
* Callback from HTTP library when a request has completed
* @param HttpRequest The request object
* @param HttpResponse The response from the server
* @param bSucceeded Whether a response was successfully received
*/
void OnProcessRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded) const;
/** Builds the json payload bytes to send in the http request to Slack */
static void GetPayload(const FSlackIncomingWebhook& InWebhook, const FSlackMessage& InMessage, TArray<uint8>& OutPayload);
/** Helper that escapes characters in the payload to make valid json */
static FString JsonEncode(const FString& InString);
};