From 63e5ea028dc21ce9b0032fc123a02cdad44fcf0c Mon Sep 17 00:00:00 2001 From: "v.alyamkin" Date: Fri, 22 Jan 2016 17:13:38 +0300 Subject: [PATCH 1/7] Fix compilation issues on Mac for UE 4.11 --- Source/VaRestEditorPlugin/Private/VaRest_BreakJson.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/VaRestEditorPlugin/Private/VaRest_BreakJson.cpp b/Source/VaRestEditorPlugin/Private/VaRest_BreakJson.cpp index 317a4a95..66cfeaaf 100644 --- a/Source/VaRestEditorPlugin/Private/VaRest_BreakJson.cpp +++ b/Source/VaRestEditorPlugin/Private/VaRest_BreakJson.cpp @@ -274,3 +274,5 @@ FText UVaRest_BreakJson::GetNodeTitle(ENodeTitleType::Type TitleType) const { return LOCTEXT("VaRest_Break_Json.NodeTitle", "Break Json"); } + +#undef LOCTEXT_NAMESPACE From afd8d66212539a4d80780aa8a74490a0135d91f2 Mon Sep 17 00:00:00 2001 From: Vladimir Alyamkin Date: Sun, 24 Jan 2016 14:53:19 +0300 Subject: [PATCH 2/7] Custom Verb support --- .../Classes/Json/VaRestRequestJSON.h | 12 ++++++++- .../Private/Json/VaRestRequestJSON.cpp | 25 +++++++++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Source/VaRestPlugin/Classes/Json/VaRestRequestJSON.h b/Source/VaRestPlugin/Classes/Json/VaRestRequestJSON.h index 84c03549..faf5047a 100644 --- a/Source/VaRestPlugin/Classes/Json/VaRestRequestJSON.h +++ b/Source/VaRestPlugin/Classes/Json/VaRestRequestJSON.h @@ -69,7 +69,9 @@ namespace ERequestVerb GET, POST, PUT, - DEL UMETA(DisplayName="DELETE") + DEL UMETA(DisplayName="DELETE"), + /** Set CUSTOM verb by SetCustomVerb() function */ + CUSTOM }; } @@ -114,6 +116,10 @@ class VARESTPLUGIN_API UVaRestRequestJSON : public UObject UFUNCTION(BlueprintCallable, Category = "VaRest|Request") void SetVerb(ERequestVerb::Type Verb); + /** Set custom verb to the request */ + UFUNCTION(BlueprintCallable, Category = "VaRest|Request") + void SetCustomVerb(FString Verb); + /** 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") @@ -268,4 +274,8 @@ class VARESTPLUGIN_API UVaRestRequestJSON : public UObject /** Http Response code */ int32 ResponseCode; + + /** Custom verb that will be used with RequestContentType == CUSTOM */ + FString CustomVerb; + }; diff --git a/Source/VaRestPlugin/Private/Json/VaRestRequestJSON.cpp b/Source/VaRestPlugin/Private/Json/VaRestRequestJSON.cpp index be4cc09c..bbb57866 100644 --- a/Source/VaRestPlugin/Private/Json/VaRestRequestJSON.cpp +++ b/Source/VaRestPlugin/Private/Json/VaRestRequestJSON.cpp @@ -45,6 +45,11 @@ void UVaRestRequestJSON::SetVerb(ERequestVerb::Type Verb) RequestVerb = Verb; } +void UVaRestRequestJSON::SetCustomVerb(FString Verb) +{ + CustomVerb = Verb; +} + void UVaRestRequestJSON::SetContentType(ERequestContentType::Type ContentType) { RequestContentType = ContentType; @@ -239,19 +244,23 @@ void UVaRestRequestJSON::ProcessRequest(TSharedRef HttpRequest) switch (RequestVerb) { case ERequestVerb::GET: - HttpRequest->SetVerb("GET"); + HttpRequest->SetVerb(TEXT("GET")); break; case ERequestVerb::POST: - HttpRequest->SetVerb("POST"); + HttpRequest->SetVerb(TEXT("POST")); break; case ERequestVerb::PUT: - HttpRequest->SetVerb("PUT"); + HttpRequest->SetVerb(TEXT("PUT")); break; case ERequestVerb::DEL: - HttpRequest->SetVerb("DELETE"); + HttpRequest->SetVerb(TEXT("DELETE")); + break; + + case ERequestVerb::CUSTOM: + HttpRequest->SetVerb(CustomVerb); break; default: @@ -263,7 +272,7 @@ void UVaRestRequestJSON::ProcessRequest(TSharedRef HttpRequest) { case ERequestContentType::x_www_form_urlencoded_url: { - HttpRequest->SetHeader("Content-Type", "application/x-www-form-urlencoded"); + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded")); FString UrlParams = ""; uint16 ParamIdx = 0; @@ -290,7 +299,7 @@ void UVaRestRequestJSON::ProcessRequest(TSharedRef HttpRequest) } case ERequestContentType::x_www_form_urlencoded_body: { - HttpRequest->SetHeader("Content-Type", "application/x-www-form-urlencoded"); + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded")); FString UrlParams = ""; uint16 ParamIdx = 0; @@ -317,14 +326,14 @@ void UVaRestRequestJSON::ProcessRequest(TSharedRef HttpRequest) } case ERequestContentType::binary: { - HttpRequest->SetHeader("Content-Type", BinaryContentType); + HttpRequest->SetHeader(TEXT("Content-Type"), BinaryContentType); HttpRequest->SetContent(RequestBytes); break; } case ERequestContentType::json: { - HttpRequest->SetHeader("Content-Type", "application/json"); + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json")); // Serialize data to json string FString OutputString; From 0b8dfd5944c229765b27a7874e7b86b8fd70755e Mon Sep 17 00:00:00 2001 From: Vladimir Alyamkin Date: Sun, 21 Feb 2016 13:30:51 +0300 Subject: [PATCH 3/7] Add marketplace markets --- VaRestPlugin.uplugin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VaRestPlugin.uplugin b/VaRestPlugin.uplugin index 00d908cc..af9dcb1f 100644 --- a/VaRestPlugin.uplugin +++ b/VaRestPlugin.uplugin @@ -6,9 +6,10 @@ "VersionName" : "1.1-r12", "CreatedBy" : "Vladimir Alyamkin", "CreatedByURL" : "http://alyamkin.com", - "EngineVersion" : 1579795, + "EngineVersion" : "4.10.0", "Description" : "Plugin that makes REST (JSON) server communication easy to use. Parse API helpers included.", "Category" : "Network", + "MarketplaceURL" : "com.epicgames.launcher://ue/marketplace/offers/e47be161e7a24e928560290abd5dcc4f", "Modules" : [ From f0057ab668a7e9c6063e6e15e01d7d21089059c0 Mon Sep 17 00:00:00 2001 From: Vladimir Alyamkin Date: Sun, 21 Feb 2016 14:51:49 +0300 Subject: [PATCH 4/7] Minor refactoring --- VaRestPlugin.uplugin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VaRestPlugin.uplugin b/VaRestPlugin.uplugin index af9dcb1f..e1af443f 100644 --- a/VaRestPlugin.uplugin +++ b/VaRestPlugin.uplugin @@ -1,5 +1,5 @@ { - "FileVersion" : 3, + "FileVersion" : 3, "FriendlyName" : "VaRest", "Version" : 12, @@ -11,12 +11,12 @@ "Category" : "Network", "MarketplaceURL" : "com.epicgames.launcher://ue/marketplace/offers/e47be161e7a24e928560290abd5dcc4f", - "Modules" : + "Modules" : [ { "Name" : "VaRestPlugin", "Type" : "Runtime", - "LoadingPhase": "PreDefault" + "LoadingPhase": "PreDefault" }, { "Name": "VaRestEditorPlugin", From fabf34317884bf65dbeb64ebf4cde4ba493965a9 Mon Sep 17 00:00:00 2001 From: "v.alyamkin" Date: Fri, 1 Apr 2016 09:35:01 +0300 Subject: [PATCH 5/7] Remove deprecated stuff --- Source/VaRestPlugin/VaRestPlugin.Build.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Source/VaRestPlugin/VaRestPlugin.Build.cs b/Source/VaRestPlugin/VaRestPlugin.Build.cs index e37d64cd..affc6b47 100644 --- a/Source/VaRestPlugin/VaRestPlugin.Build.cs +++ b/Source/VaRestPlugin/VaRestPlugin.Build.cs @@ -6,16 +6,6 @@ namespace UnrealBuildTool.Rules { public class VaRestPlugin : ModuleRules { - private string ModulePath - { - get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); } - } - - private string ThirdPartyPath - { - get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); } - } - public VaRestPlugin(TargetInfo Target) { PrivateIncludePaths.AddRange( From fa1afdbd9a227861b8cbcd435bb804fa17cbf745 Mon Sep 17 00:00:00 2001 From: "v.alyamkin" Date: Tue, 3 May 2016 19:00:36 +0300 Subject: [PATCH 6/7] Remove Parse API managers from plugin (I decided to keep just core API here) --- .../Classes/Parse/VaRestParseManager.h | 77 ---------- .../Private/Parse/VaRestParseManager.cpp | 138 ------------------ Source/VaRestPlugin/Private/VaRestPlugin.cpp | 1 - 3 files changed, 216 deletions(-) delete mode 100644 Source/VaRestPlugin/Classes/Parse/VaRestParseManager.h delete mode 100644 Source/VaRestPlugin/Private/Parse/VaRestParseManager.cpp diff --git a/Source/VaRestPlugin/Classes/Parse/VaRestParseManager.h b/Source/VaRestPlugin/Classes/Parse/VaRestParseManager.h deleted file mode 100644 index 50a53bef..00000000 --- a/Source/VaRestPlugin/Classes/Parse/VaRestParseManager.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 Vladimir Alyamkin. All Rights Reserved. - -#pragma once - -#include "VaRestParseManager.generated.h" - -/** - * Helper class to make Parse communication easier - */ -UCLASS(BlueprintType, Blueprintable) -class UVaRestParseManager : public UVaRestRequestJSON -{ - GENERATED_UCLASS_BODY() - - /** Creates new Parse request with defined verb and content type */ - UFUNCTION(BlueprintPure, meta = (DisplayName = "Construct Parse Request", HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"), Category = "VaRest|Parse") - static UVaRestParseManager* ConstructParseRequest(UObject* WorldContextObject, ERequestVerb::Type Verb, ERequestContentType::Type ContentType); - - /** Open the Parse URL (Attn.!! App Id and Api Key should be set before) */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - void ProcessParseURL(const FString& ParseModule = TEXT("classes"), const FString& ParseClass = TEXT("GameScore"), const FString& ParseObjectId = "", const FString& ParseSessionToken = ""); - - /** Set Parse authenication data */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - static void SetParseAuthData(FString AppId, FString ApiKey); - - - ////////////////////////////////////////////////////////////////////////// - // Quering helpers - - /** Create Json string that contains Pointer to the Parse Object */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - static FString ConstructPointer(const FString& ClassName, const FString& ObjectId); - - /** Create Json object that contains Pointer to the Parse Object */ - UFUNCTION(BlueprintPure, Category = "VaRest|Parse") - static UVaRestJsonObject* ConstructPointerObject(const FString& ClassName, const FString& ObjectId); - - /** Create Json object that contains a date */ - UFUNCTION(BlueprintPure, Category = "VaRest|Parse") - static UVaRestJsonObject* ConstructDateObject(const FDateTime& Date); - - /** Create Json object that instructs Parse to delete whatever field it is set to */ - UFUNCTION(BlueprintPure, Category = "VaRest|Parse") - static UVaRestJsonObject* ConstructDeleteOperation(); - - /** Create Json object that contains Facebook auth data */ - UFUNCTION(BlueprintPure, Category = "VaRest|Parse") - static UVaRestJsonObject* ConstructFacebookAuthDataObject(FString UserId, FString AccessToken, FString ExpirationDate); - - /** Construct simple WHERE query that contains only one condition. - * Attn!! String Values should containt quotes! */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - static FString ConstructWhereQuerySimple(const FString& Key, const FString& Value); - - /** Construct WHERE query based on conditions defined as Json */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - static FString ConstructWhereQuery(UVaRestJsonObject* JsonObject); - - /** A bit more happiness for our beautiful world */ - UFUNCTION(BlueprintCallable, Category = "VaRest|Parse") - static FString GetHappyMessage(); - - - ////////////////////////////////////////////////////////////////////////// - // Internal data -private: - /** Parse App Id */ - static FString ParseAppId; - - /** Parse Api Key */ - static FString ParseApiKey; - - /** Parse URL */ - static FString ParseURL; - -}; diff --git a/Source/VaRestPlugin/Private/Parse/VaRestParseManager.cpp b/Source/VaRestPlugin/Private/Parse/VaRestParseManager.cpp deleted file mode 100644 index 8d706c06..00000000 --- a/Source/VaRestPlugin/Private/Parse/VaRestParseManager.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2014 Vladimir Alyamkin. All Rights Reserved. - -#include "VaRestPluginPrivatePCH.h" - -FString UVaRestParseManager::ParseURL(TEXT("https://api.parse.com/1/")); -FString UVaRestParseManager::ParseAppId(TEXT("")); -FString UVaRestParseManager::ParseApiKey(TEXT("")); - -UVaRestParseManager::UVaRestParseManager(const class FObjectInitializer& PCIP) - : Super(PCIP) -{ - -} - -UVaRestParseManager* UVaRestParseManager::ConstructParseRequest( - UObject* WorldContextObject, - ERequestVerb::Type Verb, - ERequestContentType::Type ContentType) -{ - return (UVaRestParseManager*)ConstructRequestExt(WorldContextObject, Verb, ContentType); -} - -void UVaRestParseManager::ProcessParseURL( - const FString& ParseModule, - const FString& ParseClass, - const FString& ParseObjectId, - const FString& ParseSessionToken) -{ - FString RequestUrl = ParseURL; - - // Build the full request url - if (!ParseModule.IsEmpty()) - { - RequestUrl += ParseModule; - - if (!ParseClass.IsEmpty()) - { - RequestUrl += "/" + ParseClass; - } - - if (!ParseObjectId.IsEmpty()) - { - RequestUrl += "/" + ParseObjectId; - } - } - - TSharedRef HttpRequest = FHttpModule::Get().CreateRequest(); - HttpRequest->SetURL(RequestUrl); - - HttpRequest->SetHeader("X-Parse-Application-Id", ParseAppId); - HttpRequest->SetHeader("X-Parse-REST-API-Key", ParseApiKey); - - if (!ParseSessionToken.IsEmpty()) - { - HttpRequest->SetHeader("X-Parse-Session-Token", ParseSessionToken); - } - - ProcessRequest(HttpRequest); -} - -void UVaRestParseManager::SetParseAuthData(FString AppId, FString ApiKey) -{ - ParseAppId = AppId; - ParseApiKey = ApiKey; -} - -////////////////////////////////////////////////////////////////////////// -// Quering helpers - -FString UVaRestParseManager::ConstructPointer(const FString& ClassName, const FString& ObjectId) -{ - return FString::Printf(TEXT("{\"__type\":\"Pointer\",\"className\":\"%s\",\"objectId\":\"%s\"}"), *ClassName, *ObjectId); -} - -UVaRestJsonObject* UVaRestParseManager::ConstructPointerObject(const FString& ClassName, const FString& ObjectId) -{ - UVaRestJsonObject* OutRestJsonObj = NewObject(); - - OutRestJsonObj->SetStringField(TEXT("__type"), TEXT("Pointer")); - OutRestJsonObj->SetStringField(TEXT("className"), ClassName); - OutRestJsonObj->SetStringField(TEXT("objectId"), ObjectId); - - return OutRestJsonObj; -} - -UVaRestJsonObject* UVaRestParseManager::ConstructDateObject(const FDateTime& Date) -{ - UVaRestJsonObject* OutRestJsonObj = NewObject(); - - OutRestJsonObj->SetStringField(TEXT("__type"), TEXT("Date")); - OutRestJsonObj->SetStringField(TEXT("iso"), Date.ToIso8601()); - - return OutRestJsonObj; -} - -UVaRestJsonObject* UVaRestParseManager::ConstructDeleteOperation() -{ - UVaRestJsonObject* OutRestJsonObj = NewObject(); - - OutRestJsonObj->SetStringField(TEXT("__op"), TEXT("Delete")); - - return OutRestJsonObj; -} - -UVaRestJsonObject* UVaRestParseManager::ConstructFacebookAuthDataObject(FString UserId, FString AccessToken, FString ExpirationDate) -{ - UVaRestJsonObject* OutRestJsonObj = NewObject(); - - UVaRestJsonObject* FacebookJsonObj = NewObject(); - - FacebookJsonObj->SetStringField(TEXT("id"), UserId); - FacebookJsonObj->SetStringField(TEXT("access_token"), AccessToken); - FacebookJsonObj->SetStringField(TEXT("expiration_date"), ExpirationDate); - - OutRestJsonObj->SetObjectField(TEXT("facebook"), FacebookJsonObj); - - return OutRestJsonObj; -} - -FString UVaRestParseManager::ConstructWhereQuerySimple(const FString& Key, const FString& Value) -{ - return FString::Printf(TEXT("where={\"%s\":%s}"), *Key, *Value); -} - -FString UVaRestParseManager::ConstructWhereQuery(UVaRestJsonObject* JsonObject) -{ - // Serialize json data to string - FString OutputString; - TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString); - FJsonSerializer::Serialize(JsonObject->GetRootObject().ToSharedRef(), Writer); - - return TEXT("where=") + OutputString; -} - -FString UVaRestParseManager::GetHappyMessage() -{ - return FString("Happy New Year!"); -} diff --git a/Source/VaRestPlugin/Private/VaRestPlugin.cpp b/Source/VaRestPlugin/Private/VaRestPlugin.cpp index dedaed4f..3f22758f 100644 --- a/Source/VaRestPlugin/Private/VaRestPlugin.cpp +++ b/Source/VaRestPlugin/Private/VaRestPlugin.cpp @@ -11,7 +11,6 @@ class FVaRestPlugin : public IVaRestPlugin UVaRestJsonObject::StaticClass(); UVaRestJsonValue::StaticClass(); UVaRestRequestJSON::StaticClass(); - UVaRestParseManager::StaticClass(); } virtual void ShutdownModule() override From d63ac049a68b127b2181ac77eac39f572a58b24c Mon Sep 17 00:00:00 2001 From: "v.alyamkin" Date: Tue, 3 May 2016 19:04:03 +0300 Subject: [PATCH 7/7] Update version to release: 1.1 R 13 --- README.md | 3 +-- VaRestPlugin.uplugin | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c05eab9d..46b3b0a8 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,10 @@ Key features: * Blueprintable FJsonObject wrapper with almost full support of Json features: different types of values, **arrays**, **binary data** content, both ways serializarion to FString, etc. * Blueprintable FJsonValue wrapper - **full Json features made for blueprints!** * Both bindable events and **latent functions** are provided to control the asynchronous requests -* [Parse](https://parse.com) REST API manager to start working with Parse out of the box! Check the [Wiki](https://github.com/ufna/VaRest/wiki) tab for plugin usage examples and installation notes. -Current version: **1.1 R 12** (UE 4.8-4.10) +Current version: **1.1 R 13** (UE 4.11) ![SCREENSHOT](SCREENSHOT.jpg) diff --git a/VaRestPlugin.uplugin b/VaRestPlugin.uplugin index e1af443f..bce225b7 100644 --- a/VaRestPlugin.uplugin +++ b/VaRestPlugin.uplugin @@ -2,12 +2,12 @@ "FileVersion" : 3, "FriendlyName" : "VaRest", - "Version" : 12, - "VersionName" : "1.1-r12", + "Version" : 13, + "VersionName" : "1.1-r13", "CreatedBy" : "Vladimir Alyamkin", "CreatedByURL" : "http://alyamkin.com", - "EngineVersion" : "4.10.0", - "Description" : "Plugin that makes REST (JSON) server communication easy to use. Parse API helpers included.", + "EngineVersion" : "4.11.0", + "Description" : "Plugin that makes REST (JSON) server communication easy to use", "Category" : "Network", "MarketplaceURL" : "com.epicgames.launcher://ue/marketplace/offers/e47be161e7a24e928560290abd5dcc4f",