-
Notifications
You must be signed in to change notification settings - Fork 1
/
xAPIAgentComponent.cpp
56 lines (37 loc) · 1.24 KB
/
xAPIAgentComponent.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "xAPIIntegration.h"
#include "xAPIAgentComponent.h"
DEFINE_LOG_CATEGORY(xAPILog);
UxAPIAgentComponent::UxAPIAgentComponent(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP), ifi_type(EAgentIFIType::MBOX)
{
}
const TSharedPtr<FJsonObject> UxAPIAgentComponent::toAgent() const
{
// initialize the object we'll be returning
TSharedPtr<FJsonObject> agent(new FJsonObject());
// specify that the return object is an Agent
agent->SetStringField(TEXT("objectType"), TEXT("Agent"));
// add the general-purpose name if specified
if (!Name.IsEmpty()){
agent->SetStringField(TEXT("name"), Name);
}
// add the IFI specified by ifi_type
switch (ifi_type){
case EAgentIFIType::MBOX:
agent->SetStringField(TEXT("mbox"), Mbox);
break;
case EAgentIFIType::MBOX_SHA1SUM:
agent->SetStringField(TEXT("mbox_sha1sum"), MboxSha1Sum);
break;
case EAgentIFIType::OPENID:
agent->SetStringField(TEXT("openid"), OpenID);
break;
case EAgentIFIType::ACCOUNT:
TSharedPtr<FJsonObject> accountObj(new FJsonObject());
accountObj->SetStringField(TEXT("homePage"), Account.Homepage);
accountObj->SetStringField(TEXT("name"), Account.Name);
agent->SetObjectField(TEXT("account"), accountObj);
break;
}
return agent;
}