Skip to content

Commit

Permalink
Avoid possible name collisions with derived plugins. Close #290
Browse files Browse the repository at this point in the history
  • Loading branch information
ufna committed Mar 26, 2020
1 parent 989a507 commit 9c4c896
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 36 deletions.
9 changes: 6 additions & 3 deletions Config/BaseVaRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestRequestJSON",NewName="/Script/VaRest.VaRestRequestJSON")
+StructRedirects=(OldName="/Script/VaRestPlugin.VaRestCallResponse",NewName="/Script/VaRest.VaRestCallResponse")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaJson",NewName="/Script/VaRest.EVaJson")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestVerb",NewName="/Script/VaRest.ERequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestContentType",NewName="/Script/VaRest.ERequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestStatus",NewName="/Script/VaRest.ERequestStatus")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt")
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject")
Expand Down
10 changes: 7 additions & 3 deletions Config/DefaultVaRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestRequestJSON",NewName="/Script/VaRest.VaRestRequestJSON")
+StructRedirects=(OldName="/Script/VaRestPlugin.VaRestCallResponse",NewName="/Script/VaRest.VaRestCallResponse")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaJson",NewName="/Script/VaRest.EVaJson")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestVerb",NewName="/Script/VaRest.ERequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestContentType",NewName="/Script/VaRest.ERequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestStatus",NewName="/Script/VaRest.ERequestStatus")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestHttpStatusCode",NewName="/Script/VaRest.EVaRestHttpStatusCode")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt")
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject")
Expand Down
30 changes: 15 additions & 15 deletions Source/VaRest/Private/VaRestRequestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ UVaRestRequestJSON::UVaRestRequestJSON(const class FObjectInitializer& PCIP)
{
ContinueAction = nullptr;

RequestVerb = ERequestVerb::GET;
RequestContentType = ERequestContentType::x_www_form_urlencoded_url;
RequestVerb = EVaRestRequestVerb::GET;
RequestContentType = EVaRestRequestContentType::x_www_form_urlencoded_url;

ResetData();
}

void UVaRestRequestJSON::SetVerb(ERequestVerb Verb)
void UVaRestRequestJSON::SetVerb(EVaRestRequestVerb Verb)
{
RequestVerb = Verb;
}
Expand All @@ -46,7 +46,7 @@ void UVaRestRequestJSON::SetCustomVerb(FString Verb)
CustomVerb = Verb;
}

void UVaRestRequestJSON::SetContentType(ERequestContentType ContentType)
void UVaRestRequestJSON::SetContentType(EVaRestRequestContentType ContentType)
{
RequestContentType = ContentType;
}
Expand Down Expand Up @@ -171,9 +171,9 @@ FString UVaRestRequestJSON::GetURL() const
return HttpRequest->GetURL();
}

ERequestStatus UVaRestRequestJSON::GetStatus() const
EVaRestRequestStatus UVaRestRequestJSON::GetStatus() const
{
return ERequestStatus((uint8)HttpRequest->GetStatus());
return EVaRestRequestStatus((uint8)HttpRequest->GetStatus());
}

int32 UVaRestRequestJSON::GetResponseCode() const
Expand Down Expand Up @@ -278,23 +278,23 @@ void UVaRestRequestJSON::ProcessRequest()
// Set verb
switch (RequestVerb)
{
case ERequestVerb::GET:
case EVaRestRequestVerb::GET:
HttpRequest->SetVerb(TEXT("GET"));
break;

case ERequestVerb::POST:
case EVaRestRequestVerb::POST:
HttpRequest->SetVerb(TEXT("POST"));
break;

case ERequestVerb::PUT:
case EVaRestRequestVerb::PUT:
HttpRequest->SetVerb(TEXT("PUT"));
break;

case ERequestVerb::DEL:
case EVaRestRequestVerb::DEL:
HttpRequest->SetVerb(TEXT("DELETE"));
break;

case ERequestVerb::CUSTOM:
case EVaRestRequestVerb::CUSTOM:
HttpRequest->SetVerb(CustomVerb);
break;

Expand All @@ -305,7 +305,7 @@ void UVaRestRequestJSON::ProcessRequest()
// Set content-type
switch (RequestContentType)
{
case ERequestContentType::x_www_form_urlencoded_url:
case EVaRestRequestContentType::x_www_form_urlencoded_url:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded"));

Expand Down Expand Up @@ -348,7 +348,7 @@ void UVaRestRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::x_www_form_urlencoded_body:
case EVaRestRequestContentType::x_www_form_urlencoded_body:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded"));

Expand Down Expand Up @@ -385,7 +385,7 @@ void UVaRestRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::binary:
case EVaRestRequestContentType::binary:
{
HttpRequest->SetHeader(TEXT("Content-Type"), BinaryContentType);
HttpRequest->SetContent(RequestBytes);
Expand All @@ -394,7 +394,7 @@ void UVaRestRequestJSON::ProcessRequest()

break;
}
case ERequestContentType::json:
case EVaRestRequestContentType::json:
{
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));

Expand Down
4 changes: 2 additions & 2 deletions Source/VaRest/Private/VaRestSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void UVaRestSubsystem::Deinitialize()
Super::Deinitialize();
}

void UVaRestSubsystem::CallURL(const FString& URL, ERequestVerb Verb, ERequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback)
void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback)
{
UWorld* World = GetWorld();
check(World);
Expand Down Expand Up @@ -79,7 +79,7 @@ UVaRestRequestJSON* UVaRestSubsystem::ConstructVaRestRequest()
return NewObject<UVaRestRequestJSON>(this);
}

UVaRestRequestJSON* UVaRestSubsystem::ConstructVaRestRequestExt(ERequestVerb Verb, ERequestContentType ContentType)
UVaRestRequestJSON* UVaRestSubsystem::ConstructVaRestRequestExt(EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType)
{
UVaRestRequestJSON* Request = ConstructVaRestRequest();

Expand Down
2 changes: 1 addition & 1 deletion Source/VaRest/Public/VaRestLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ class VAREST_API UVaRestLibrary : public UBlueprintFunctionLibrary
* Helper method to convert a status code from HTTP to an enum for easier readability
*/
UFUNCTION(BlueprintPure, Category = "VaRest|Utility", meta = (DisplayName = "HTTP Status Int To Enum"))
static FORCEINLINE EHttpStatusCode::Type HTTPStatusIntToEnum(int32 StatusCode) { return (EHttpStatusCode::Type)StatusCode; }
static FORCEINLINE EVaRestHttpStatusCode::Type HTTPStatusIntToEnum(int32 StatusCode) { return (EVaRestHttpStatusCode::Type)StatusCode; }
};
10 changes: 5 additions & 5 deletions Source/VaRest/Public/VaRestRequestJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class VAREST_API UVaRestRequestJSON : public UObject

/** Set verb to the request */
UFUNCTION(BlueprintCallable, Category = "VaRest|Request")
void SetVerb(ERequestVerb Verb);
void SetVerb(EVaRestRequestVerb Verb);

/** Set custom verb to the request */
UFUNCTION(BlueprintCallable, Category = "VaRest|Request")
Expand All @@ -98,7 +98,7 @@ class VAREST_API UVaRestRequestJSON : public UObject
/** Set content type to the request. If you're using the x-www-form-urlencoded,
* params/constaints should be defined as key=ValueString pairs from Json data */
UFUNCTION(BlueprintCallable, Category = "VaRest|Request")
void SetContentType(ERequestContentType ContentType);
void SetContentType(EVaRestRequestContentType ContentType);

/** Set content type of the request for binary post data */
UFUNCTION(BlueprintCallable, Category = "VaRest|Request")
Expand Down Expand Up @@ -163,7 +163,7 @@ class VAREST_API UVaRestRequestJSON : public UObject

/** Get status of http request */
UFUNCTION(BlueprintCallable, Category = "VaRest|Request")
ERequestStatus GetStatus() const;
EVaRestRequestStatus GetStatus() const;

/** Get the response code of the last query */
UFUNCTION(BlueprintCallable, Category = "VaRest|Response")
Expand Down Expand Up @@ -295,10 +295,10 @@ class VAREST_API UVaRestRequestJSON : public UObject
UVaRestJsonObject* ResponseJsonObj;

/** Verb for making request (GET,POST,etc) */
ERequestVerb RequestVerb;
EVaRestRequestVerb RequestVerb;

/** Content type to be applied for request */
ERequestContentType RequestContentType;
EVaRestRequestContentType RequestContentType;

/** Mapping of header section to values. Used to generate final header string for request */
TMap<FString, FString> RequestHeaders;
Expand Down
4 changes: 2 additions & 2 deletions Source/VaRest/Public/VaRestSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class VAREST_API UVaRestSubsystem : public UGameInstanceSubsystem
public:
/** Easy way to process http requests */
UFUNCTION(BlueprintCallable, Category = "VaRest|Utility")
void CallURL(const FString& URL, ERequestVerb Verb, ERequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback);
void CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback);

/** Called when URL is processed (one for both success/unsuccess events)*/
void OnCallComplete(UVaRestRequestJSON* Request);
Expand All @@ -71,7 +71,7 @@ class VAREST_API UVaRestSubsystem : public UGameInstanceSubsystem

/** Creates new request with defined verb and content type */
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Construct Json Request"), Category = "VaRest|Subsystem")
UVaRestRequestJSON* ConstructVaRestRequestExt(ERequestVerb Verb, ERequestContentType ContentType);
UVaRestRequestJSON* ConstructVaRestRequestExt(EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType);

/** Create new Json object */
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Construct Json Object"), Category = "VaRest|Subsystem")
Expand Down
10 changes: 5 additions & 5 deletions Source/VaRest/Public/VaRestTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/** Verb (GET, PUT, POST) used by the request */
UENUM(BlueprintType)
enum class ERequestVerb : uint8
enum class EVaRestRequestVerb : uint8
{
GET,
POST,
Expand All @@ -17,7 +17,7 @@ enum class ERequestVerb : uint8
// clang-format off
/** Content type (json, urlencoded, etc.) used by the request */
UENUM(BlueprintType)
enum class ERequestContentType : uint8
enum class EVaRestRequestContentType : uint8
{
x_www_form_urlencoded_url UMETA(DisplayName = "x-www-form-urlencoded (URL)"),
x_www_form_urlencoded_body UMETA(DisplayName = "x-www-form-urlencoded (Request Body)"),
Expand All @@ -28,7 +28,7 @@ enum class ERequestContentType : uint8

/** Enumerates the current state of an Http request */
UENUM(BlueprintType)
enum class ERequestStatus : uint8
enum class EVaRestRequestStatus : uint8
{
/** Has not been started via ProcessRequest() */
NotStarted,
Expand All @@ -44,7 +44,7 @@ enum class ERequestStatus : uint8

// Taken from Interfaces/IHttpResponse.h (had to make BlueprintType :/)
UENUM(BlueprintType)
namespace EHttpStatusCode
namespace EVaRestHttpStatusCode
{
/**
* Response codes that can come back from an Http request
Expand Down Expand Up @@ -134,4 +134,4 @@ enum Type
// the server does not support, or refuses to support, the http protocol version that was used in the request message.
VersionNotSup = 505 UMETA(DisplayName = "VersionNotSup = 505")
};
} // namespace EHttpStatusCode
} // namespace EVaRestHttpStatusCode

0 comments on commit 9c4c896

Please sign in to comment.