A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
VaRestSubsystem.h
Go to the documentation of this file.
1// Copyright 2014-2020 Vladimir Alyamkin. All Rights Reserved.
2
3#pragma once
4
5#include "VaRestJsonObject.h"
6#include "VaRestJsonValue.h"
7#include "VaRestRequestJSON.h"
8
9#include "Subsystems/EngineSubsystem.h"
10
11#include "VaRestSubsystem.generated.h"
12
14
15USTRUCT()
17{
18 GENERATED_USTRUCT_BODY()
19
20 UPROPERTY()
21 UVaRestRequestJSON* Request;
22
23 UPROPERTY()
24 FVaRestCallDelegate Callback;
26 FDelegateHandle CompleteDelegateHandle;
27 FDelegateHandle FailDelegateHandle;
28
30 : Request(nullptr)
31 {
32 }
33};
34
35UCLASS()
36class VAREST_API UVaRestSubsystem : public UEngineSubsystem
37{
38 GENERATED_BODY()
39
40public:
42
43 // Begin USubsystem
44 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
45 virtual void Deinitialize() override;
46 // End USubsystem
47
49 // Easy URL processing
50
51public:
53 UFUNCTION(BlueprintCallable, Category = "VaRest|Utility")
54 void CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback);
55
57 void OnCallComplete(UVaRestRequestJSON* Request);
58
59protected:
60 UPROPERTY()
61 TMap<UVaRestRequestJSON*, FVaRestCallResponse> RequestMap;
62
64 // Construction helpers
65
66public:
68 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Construct Json Request (Empty)"), Category = "VaRest|Subsystem")
69 UVaRestRequestJSON* ConstructVaRestRequest();
70
72 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Construct Json Request"), Category = "VaRest|Subsystem")
73 UVaRestRequestJSON* ConstructVaRestRequestExt(EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType);
76 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Construct Json Object"), Category = "VaRest|Subsystem")
77 UVaRestJsonObject* ConstructVaRestJsonObject();
78
80 UFUNCTION()
81 static UVaRestJsonObject* StaticConstructVaRestJsonObject();
82
85 UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json Number Value"), Category = "VaRest|Subsystem")
86 UVaRestJsonValue* ConstructJsonValueNumber(float Number);
87
89 UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json String Value"), Category = "VaRest|Subsystem")
90 UVaRestJsonValue* ConstructJsonValueString(const FString& StringValue);
91
93 UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json Bool Value"), Category = "VaRest|Subsystem")
94 UVaRestJsonValue* ConstructJsonValueBool(bool InValue);
95
97 UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json Array Value"), Category = "VaRest|Subsystem")
98 UVaRestJsonValue* ConstructJsonValueArray(const TArray<UVaRestJsonValue*>& InArray);
99
101 UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Json Object Value"), Category = "VaRest|Subsystem")
102 UVaRestJsonValue* ConstructJsonValueObject(UVaRestJsonObject* JsonObject);
103
105 UVaRestJsonValue* ConstructJsonValue(const TSharedPtr<FJsonValue>& InValue);
106
108 // Serialization
109
110public:
112 UFUNCTION(BlueprintCallable, Category = "VaRest|Subsystem")
113 UVaRestJsonValue* DecodeJsonValue(const FString& JsonString);
114
116 UFUNCTION(BlueprintCallable, Category = "VaRest|Subsystem")
117 UVaRestJsonObject* DecodeJsonObject(const FString& JsonString);
118
120 // File system integration
121
122public:
127 UFUNCTION(BlueprintCallable, Category = "VaRest|Utility")
128 UVaRestJsonObject* LoadJsonFromFile(const FString& Path, const bool bIsRelativeToContentDir = true);
129};
DECLARE_DYNAMIC_DELEGATE_OneParam(FVaRestCallDelegate, UVaRestRequestJSON *, Request)
EVaRestRequestContentType
UENUM(BlueprintType)
Definition VaRestTypes.h:31
EVaRestRequestVerb
UENUM(BlueprintType)
Definition VaRestTypes.h:15
UCLASS(BlueprintType, Blueprintable)
UCLASS(BlueprintType, Blueprintable)
UCLASS(BlueprintType, Blueprintable)
TMap< UVaRestRequestJSON *, FVaRestCallResponse > RequestMap
UPROPERTY()
FVaRestCallDelegate Callback
UPROPERTY()
FDelegateHandle CompleteDelegateHandle
UVaRestRequestJSON * Request
UPROPERTY()
FDelegateHandle FailDelegateHandle