78 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections.Generic;
 | |
| 
 | |
| namespace AdjustSdk
 | |
| {
 | |
|     public class AdjustSessionSuccess
 | |
|     {
 | |
|         public string Adid { get; set; }
 | |
|         public string Message { get; set; }
 | |
|         public string Timestamp { get; set; }
 | |
|         public Dictionary<string, object> JsonResponse { get; set; }
 | |
| 
 | |
|         public AdjustSessionSuccess() {}
 | |
| 
 | |
|         public AdjustSessionSuccess(Dictionary<string, string> sessionSuccessDataMap)
 | |
|         {
 | |
|             if (sessionSuccessDataMap == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             this.Adid = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyAdid);
 | |
|             this.Message = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyMessage);
 | |
|             this.Timestamp = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyTimestamp);
 | |
| 
 | |
|             string jsonResponseString = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyJsonResponse);
 | |
|             var jsonResponseNode = JSON.Parse(jsonResponseString);
 | |
|             if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
 | |
|             {
 | |
|                 this.JsonResponse = new Dictionary<string, object>();
 | |
|                 AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public AdjustSessionSuccess(string jsonString)
 | |
|         {
 | |
|             var jsonNode = JSON.Parse(jsonString);
 | |
|             if (jsonNode == null) 
 | |
| 			{
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             this.Adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid);
 | |
|             this.Message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage);
 | |
|             this.Timestamp = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTimestamp);
 | |
| 
 | |
|             var jsonResponseNode = jsonNode[AdjustUtils.KeyJsonResponse];
 | |
|             if (jsonResponseNode == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             if (jsonResponseNode.AsObject == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             this.JsonResponse = new Dictionary<string, object>();
 | |
|             AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse);
 | |
|         }
 | |
| 
 | |
|         public void BuildJsonResponseFromString(string jsonResponseString)
 | |
|         {
 | |
|             var jsonNode = JSON.Parse(jsonResponseString);
 | |
|             if (jsonNode == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             this.JsonResponse = new Dictionary<string, object>();
 | |
|             AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse);
 | |
|         }
 | |
| 
 | |
|         public string GetJsonResponseAsString()
 | |
|         {
 | |
|             return AdjustUtils.GetJsonResponseCompact(JsonResponse);
 | |
|         }
 | |
|     }
 | |
| }
 |