Files
UnrealEngineUWP/Engine/Source/Developer/SlackIntegrations/Private/SlackIncomingWebhookInterface.h
ben marsh 2b46ba7b94 Update copyright notices to 2019.
#rb none
#lockdown Nick.Penwarden

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: ben.marsh
#ROBOMERGE-SOURCE: CL 4662404 in //UE4/Main/...
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 4662413 by ben marsh in Dev-Networking branch]
2018-12-14 13:44:01 -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);
};