ImagingTools Core SDK
CClientRequestManagerCompBase.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// ACF includes
6#include <ibase/IApplicationInfo.h>
7
8// ImtCore includes
9#include <imtauth/IAccessTokenProvider.h>
10#include <imtclientgql/TClientRequestManagerCompWrap.h>
11#include <imtgql/CGqlRequest.h>
12#include <imtgql/CGqlContext.h>
13#include <imtgql/CGqlRequestContextManager.h>
14
15
16namespace imtauthgql
17{
18
19
20class CClientRequestManagerCompBase:
21 public imtclientgql::CClientRequestManagerCompBase
22{
23public:
24 typedef imtclientgql::CClientRequestManagerCompBase BaseClass;
25
26 I_BEGIN_COMPONENT(CClientRequestManagerCompBase)
27 I_ASSIGN(m_applicationInfoCompPtr, "ApplicationInfo", "Application info", true, "ApplicationInfo");
28 I_END_COMPONENT;
29
30protected:
31 QByteArrayList GetElementIds(const QByteArray& collectionId) const;
32 bool RemoveElements(const QByteArray& collectionId, const QByteArrayList& elementIds) const;
33
34 template<class Arguments, class Payload, class SdlRequest>
35 bool SendModelRequestInternal(Arguments arguments, Payload& payload) const
36 {
37 imtgql::CGqlRequest gqlRequest;
38
39 imtgql::IGqlContext* gqlContextPtr = imtgql::CGqlRequestContextManager::GetContext();
40 if (gqlContextPtr != nullptr){
41 istd::IChangeableUniquePtr clonedPtr = gqlContextPtr->CloneMe();
42 imtgql::IGqlContextUniquePtr castedPtr;
43 castedPtr.MoveCastedPtr(std::move(clonedPtr));
44 gqlRequest.SetGqlContext(imtgql::IGqlContextSharedPtr::CreateFromUnique(castedPtr));
45 }
46
47 if (!SdlRequest::SetupGqlRequest(gqlRequest, arguments)){
48 return false;
49 }
50
51 QString errorMessage;
52 payload = SendModelRequest<Payload>(gqlRequest, errorMessage);
53 if (!errorMessage.isEmpty()){
54 return false;
55 }
56
57 if (!payload.Version_1_0.HasValue()){
58 return false;
59 }
60
61 return true;
62 }
63
64protected:
65 I_REF(ibase::IApplicationInfo, m_applicationInfoCompPtr);
66};
67
68
69} // namespace imtauthgql
70
71
Authentication GraphQL API Layer Module.