1+ #nullable enable
2+
13using System ;
24using System . Collections . Generic ;
35
@@ -31,9 +33,9 @@ public class Progression : IEvent
3133 // Required.
3234 public ProgressionStatus Status { get ; set ; }
3335 // Optional.
34- public string World { get ; set ; }
35- public string Level { get ; set ; }
36- public string Stage { get ; set ; }
36+ public string ? World { get ; set ; }
37+ public string ? Level { get ; set ; }
38+ public string ? Stage { get ; set ; }
3739 public int ? Score { get ; set ; }
3840 public float ? DurationSec { get ; set ; }
3941
@@ -81,16 +83,19 @@ public class Resource : IEvent
8183 {
8284 // Required.
8385 public ResourceFlow Flow { get ; set ; }
84- public string Currency { get ; set ; }
86+ public string ? Currency { get ; set ; }
8587 public float Amount { get ; set ; }
8688 // Optional.
87- public string ItemType { get ; set ; }
88- public string ItemId { get ; set ; }
89+ public string ? ItemType { get ; set ; }
90+ public string ? ItemId { get ; set ; }
8991
9092 public string EventName => "resource" ;
9193
9294 public Dictionary < string , object > ToProperties ( )
9395 {
96+ if ( string . IsNullOrEmpty ( Currency ) )
97+ throw new ArgumentException ( "Resource.Currency must not be null or empty" ) ;
98+
9499 var props = new Dictionary < string , object >
95100 {
96101 [ "flow" ] = Flow . ToLowercaseString ( ) ,
@@ -109,21 +114,21 @@ public Dictionary<string, object> ToProperties()
109114 public class Purchase : IEvent
110115 {
111116 // Required. ISO 4217 three-letter uppercase currency code.
112- public string Currency { get ; set ; }
117+ public string ? Currency { get ; set ; }
113118 // Required.
114119 public decimal Value { get ; set ; }
115120 // Optional.
116- public string ItemId { get ; set ; }
117- public string ItemName { get ; set ; }
121+ public string ? ItemId { get ; set ; }
122+ public string ? ItemName { get ; set ; }
118123 public int ? Quantity { get ; set ; }
119- public string TransactionId { get ; set ; }
124+ public string ? TransactionId { get ; set ; }
120125
121126 public string EventName => "purchase" ;
122127
123128 // Hand-rolled to avoid pulling System.Text.RegularExpressions into the IL2CPP build.
124129 private static bool IsIso4217 ( string s )
125130 {
126- if ( s == null || s . Length != 3 ) return false ;
131+ if ( s . Length != 3 ) return false ;
127132 for ( var i = 0 ; i < 3 ; i ++ )
128133 {
129134 var c = s [ i ] ;
@@ -134,7 +139,7 @@ private static bool IsIso4217(string s)
134139
135140 public Dictionary < string , object > ToProperties ( )
136141 {
137- if ( ! IsIso4217 ( Currency ) )
142+ if ( Currency == null || ! IsIso4217 ( Currency ) )
138143 throw new ArgumentException (
139144 $ "Purchase.Currency '{ Currency } ' must be a three-letter uppercase ISO 4217 code") ;
140145
@@ -157,7 +162,7 @@ public Dictionary<string, object> ToProperties()
157162 public class MilestoneReached : IEvent
158163 {
159164 // Required.
160- public string Name { get ; set ; }
165+ public string ? Name { get ; set ; }
161166
162167 public string EventName => "milestone_reached" ;
163168
0 commit comments