yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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
Quintiq file version 2.0
#parent: #root
Method GetLoginToken () as String
{
  TextBody:
  [*
    value := '';
    
    path := '/iam/login?action=get_auth_params';
    nvtrequest := LibInt_MessageAccessor::CreateEmptyMessage();
    LibInt_MessageAccessor::SetHeaderProperty( nvtrequest, '_QI.ContentType', 'RAW' );
    LibInt_MessageAccessor::SetHeaderProperty( nvtrequest, 'HttpEndpointMethod', 'GET' );
    LibInt_MessageAccessor::SetHeaderProperty( nvtrequest, 'HttpEndpointPath', path );
    LibInt_MessageAccessor::SetHeaderProperty( nvtrequest, 'HTTPHeader.Accept', 'application/json' );
    
    nvtresponse := LibInt_IntegratorProxy::SyncNvtRequest( 'ThreeDPassport', 'ThreeDPassport', nvtrequest );
    code := LibInt_MessageAccessor::GetHeaderPropertyAsNumber( nvtresponse, 'HTTPResponseCode' );
    response := LibInt_MessageAccessor::GetBodyValueAsString( nvtresponse );
    
    if( code = 200 and response.StartsWith( '{' ) )
    {
      jsonresponse := JSON::Parse( response );
      lt := jsonresponse.Get( 'lt' );
      if( not isnull( lt ) )
      {
        value := lt.GetString();
      }
    }
    
    return value;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}