|
| 1 | +// Copyright (c) 2021 AccelByte Inc. All Rights Reserved. |
| 2 | +// This is licensed software from AccelByte Inc, for limitations |
| 3 | +// and restrictions contact your company contract manager. |
| 4 | + |
| 5 | +#include "Blueprints/ABCatalog.h" |
| 6 | +#include "Api/AccelByteItemApi.h" |
| 7 | +#include "Api/AccelByteCategoryApi.h" |
| 8 | +#include "Core/AccelByteRegistry.h" |
| 9 | + |
| 10 | +void UABCatalog::SetApiClient(FApiClientPtr const& NewApiClientPtr) |
| 11 | +{ |
| 12 | + ApiClientPtr = NewApiClientPtr; |
| 13 | +} |
| 14 | + |
| 15 | +void UABCatalog::GetRootCategories( |
| 16 | + FString const& Language, |
| 17 | + FDArrayModelsCategoryInfoResponse OnSuccess, |
| 18 | + FDErrorHandler OnError) const |
| 19 | +{ |
| 20 | + ApiClientPtr->Category.GetRootCategories( |
| 21 | + Language, |
| 22 | + THandler<TArray<FAccelByteModelsCategoryInfo>>::CreateLambda( |
| 23 | + [OnSuccess](TArray<FAccelByteModelsCategoryInfo> const& Response) |
| 24 | + { |
| 25 | + FArrayModelsCategoryInfoResponse Result; |
| 26 | + Result.Content = Response; |
| 27 | + OnSuccess.ExecuteIfBound(Result); |
| 28 | + }), |
| 29 | + FErrorHandler::CreateLambda( |
| 30 | + [OnError](int Code, FString const& Message) |
| 31 | + { |
| 32 | + OnError.ExecuteIfBound(Code, Message); |
| 33 | + })); |
| 34 | +} |
| 35 | + |
| 36 | +void UABCatalog::GetCategory( |
| 37 | + FString const& CategoryPath, |
| 38 | + FString const& Language, |
| 39 | + FDModelsCategoryInfoResponse OnSuccess, |
| 40 | + FDErrorHandler OnError) const |
| 41 | +{ |
| 42 | + ApiClientPtr->Category.GetCategory( |
| 43 | + CategoryPath, |
| 44 | + Language, |
| 45 | + THandler<FAccelByteModelsCategoryInfo>::CreateLambda( |
| 46 | + [OnSuccess](FAccelByteModelsCategoryInfo const& Response) |
| 47 | + { |
| 48 | + OnSuccess.ExecuteIfBound(Response); |
| 49 | + }), |
| 50 | + FErrorHandler::CreateLambda( |
| 51 | + [OnError](int Code, FString const& Message) |
| 52 | + { |
| 53 | + OnError.ExecuteIfBound(Code, Message); |
| 54 | + })); |
| 55 | +} |
| 56 | + |
| 57 | +void UABCatalog::GetChildCategories( |
| 58 | + FString const& CategoryPath, |
| 59 | + FString const& Language, |
| 60 | + FDArrayModelsCategoryInfoResponse OnSuccess, |
| 61 | + FDErrorHandler OnError) const |
| 62 | +{ |
| 63 | + ApiClientPtr->Category.GetChildCategories( |
| 64 | + Language, |
| 65 | + CategoryPath, |
| 66 | + THandler<TArray<FAccelByteModelsCategoryInfo>>::CreateLambda( |
| 67 | + [OnSuccess](TArray<FAccelByteModelsCategoryInfo> const& Response) |
| 68 | + { |
| 69 | + FArrayModelsCategoryInfoResponse Result; |
| 70 | + Result.Content = Response; |
| 71 | + OnSuccess.ExecuteIfBound(Result); |
| 72 | + }), |
| 73 | + FErrorHandler::CreateLambda( |
| 74 | + [OnError](int Code, FString const& Message) |
| 75 | + { |
| 76 | + OnError.ExecuteIfBound(Code, Message); |
| 77 | + })); |
| 78 | +} |
| 79 | + |
| 80 | +void UABCatalog::GetDescendantCategories( |
| 81 | + FString const& CategoryPath, |
| 82 | + FString const& Language, |
| 83 | + FDArrayModelsCategoryInfoResponse OnSuccess, |
| 84 | + FDErrorHandler OnError) const |
| 85 | +{ |
| 86 | + ApiClientPtr->Category.GetDescendantCategories( |
| 87 | + Language, |
| 88 | + CategoryPath, |
| 89 | + THandler<TArray<FAccelByteModelsCategoryInfo>>::CreateLambda( |
| 90 | + [OnSuccess](TArray<FAccelByteModelsCategoryInfo> const& Response) |
| 91 | + { |
| 92 | + FArrayModelsCategoryInfoResponse Result; |
| 93 | + Result.Content = Response; |
| 94 | + OnSuccess.ExecuteIfBound(Result); |
| 95 | + }), |
| 96 | + FErrorHandler::CreateLambda( |
| 97 | + [OnError](int Code, FString const& Message) |
| 98 | + { |
| 99 | + OnError.ExecuteIfBound(Code, Message); |
| 100 | + })); |
| 101 | +} |
| 102 | + |
| 103 | +void UABCatalog::GetItemById( |
| 104 | + FString const& ItemId, |
| 105 | + FString const& Language, |
| 106 | + FString const& Region, |
| 107 | + FDModelsPopulatedItemInfoResponse OnSuccess, |
| 108 | + FDErrorHandler OnError) const |
| 109 | +{ |
| 110 | + ApiClientPtr->Item.GetItemById( |
| 111 | + ItemId, |
| 112 | + Language, |
| 113 | + Region, |
| 114 | + THandler<FAccelByteModelsPopulatedItemInfo>::CreateLambda( |
| 115 | + [OnSuccess](FAccelByteModelsPopulatedItemInfo const& Response) |
| 116 | + { |
| 117 | + OnSuccess.ExecuteIfBound(Response); |
| 118 | + }), |
| 119 | + FErrorHandler::CreateLambda( |
| 120 | + [OnError](int Code, FString const& Message) |
| 121 | + { |
| 122 | + OnError.ExecuteIfBound(Code, Message); |
| 123 | + })); |
| 124 | +} |
| 125 | + |
| 126 | +void UABCatalog::GetItemByAppId( |
| 127 | + FString const& AppId, |
| 128 | + FString const& Language, |
| 129 | + FString const& Region, |
| 130 | + FDModelsItemInfoResponse OnSuccess, |
| 131 | + FDErrorHandler OnError) const |
| 132 | +{ |
| 133 | + ApiClientPtr->Item.GetItemByAppId( |
| 134 | + AppId, |
| 135 | + Language, |
| 136 | + Region, |
| 137 | + THandler<FAccelByteModelsItemInfo>::CreateLambda( |
| 138 | + [OnSuccess](FAccelByteModelsItemInfo const& Response) |
| 139 | + { |
| 140 | + OnSuccess.ExecuteIfBound(Response); |
| 141 | + }), |
| 142 | + FErrorHandler::CreateLambda( |
| 143 | + [OnError](int Code, FString const& Message) |
| 144 | + { |
| 145 | + OnError.ExecuteIfBound(Code, Message); |
| 146 | + })); |
| 147 | +} |
| 148 | + |
| 149 | +void UABCatalog::GetItemsByCriteria( |
| 150 | + FAccelByteModelsItemCriteria const& ItemCriteria, |
| 151 | + int32 const& Offset, |
| 152 | + int32 const& Limit, |
| 153 | + FDModelsItemPagingSlicedResultResponse OnSuccess, |
| 154 | + FDErrorHandler OnError) const |
| 155 | +{ |
| 156 | + ApiClientPtr->Item.GetItemsByCriteria( |
| 157 | + ItemCriteria, |
| 158 | + Offset, |
| 159 | + Limit, |
| 160 | + THandler<FAccelByteModelsItemPagingSlicedResult>::CreateLambda( |
| 161 | + [OnSuccess](FAccelByteModelsItemPagingSlicedResult const& Response) |
| 162 | + { |
| 163 | + OnSuccess.ExecuteIfBound(Response); |
| 164 | + }), |
| 165 | + FErrorHandler::CreateLambda( |
| 166 | + [OnError](int Code, FString const& Message) |
| 167 | + { |
| 168 | + OnError.ExecuteIfBound(Code, Message); |
| 169 | + })); |
| 170 | +} |
| 171 | + |
| 172 | +void UABCatalog::SearchItem( |
| 173 | + FString const& Language, |
| 174 | + FString const& Keyword, |
| 175 | + int32 const& Offset, |
| 176 | + int32 const& Limit, |
| 177 | + FString const& Region, |
| 178 | + FDModelsItemPagingSlicedResultResponse OnSuccess, |
| 179 | + FDErrorHandler OnError) const |
| 180 | +{ |
| 181 | + ApiClientPtr->Item.SearchItem( |
| 182 | + Language, |
| 183 | + Keyword, |
| 184 | + Offset, |
| 185 | + Limit, |
| 186 | + Region, |
| 187 | + THandler<FAccelByteModelsItemPagingSlicedResult>::CreateLambda( |
| 188 | + [OnSuccess](FAccelByteModelsItemPagingSlicedResult const& Response) |
| 189 | + { |
| 190 | + OnSuccess.ExecuteIfBound(Response); |
| 191 | + }), |
| 192 | + FErrorHandler::CreateLambda( |
| 193 | + [OnError](int Code, FString const& Message) |
| 194 | + { |
| 195 | + OnError.ExecuteIfBound(Code, Message); |
| 196 | + })); |
| 197 | +} |
0 commit comments