-
Notifications
You must be signed in to change notification settings - Fork 12
/
WebAPIModels.cs
1183 lines (1000 loc) · 41.1 KB
/
WebAPIModels.cs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Security.Cryptography;
namespace SKM.V3.Models
{
/// <summary>
/// <para>
/// All the classes that are either used as a paramter for an API method or represent the
/// data that is being sent back.
/// </para>
/// </summary>
internal class NamespaceDoc
{
}
public class GetEventsModel : RequestModel
{
public int Limit { get; set; }
public int StartingAfter { get; set; }
public int ProductId { get; set; }
public string Key { get; set; }
}
public class GetWebAPILogModel : RequestModel
{
public int Limit { get; set; }
public int StartingAfter { get; set; }
public int ProductId { get; set; }
public string Key { get; set; }
public string FriendlyName { get; set; }
}
public class GetWebAPILogResult : BasicResult
{
public List<WebAPILog> Logs { get; set; }
}
public class WebAPILog
{
public long Id { get; set; }
public int ProductId { get; set; }
public string Key { get; set; }
public string IP { get; set; }
public long Time { get; set; }
public short State { get; set; }
public string MachineCode { get; set; }
public string FriendlyName { get; set; }
}
public class MachineInfo
{
public string OSName { get; set; }
public string OSVersion { get; set; }
public bool Is64Bit { get; set; }
}
public class RequestModel
{
/// <summary>
/// This field is optional and is only required if you re-route your requests
/// through a license server (https://github.com/cryptolens/license-server).
/// </summary>
public string LicenseServerUrl { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime CreationDate { get; set; }
public string Description { get; set; }
public string Password { get; set; }
public bool IsPublic { get; set; }
[DefaultValue(AlgorithmTypes.SKGL)]
public AlgorithmTypes KeyAlgorithm { get; set; }
public FeatureDefinitions FeatureDefinitions { get; set; }
public List<DataObject> DataObjects { get; set; }
}
public class FeatureDefinitions
{
public FeatureDefinition F1 { get; set; }
public FeatureDefinition F2 { get; set; }
public FeatureDefinition F3 { get; set; }
public FeatureDefinition F4 { get; set; }
public FeatureDefinition F5 { get; set; }
public FeatureDefinition F6 { get; set; }
public FeatureDefinition F7 { get; set; }
public FeatureDefinition F8 { get; set; }
public bool AllLicensesTimeLimited { get; set; }
public bool BlockExpiredLicenses { get; set; }
}
public class FeatureDefinition
{
public string Name { get; set; }
public FeatureType Type { get; set; }
}
public enum FeatureType
{
Default = 0,
TimeLimitedFeature = 1,
TrialFeature = 2
}
/// <summary>
/// Keeps track of different algorithms that are used to generate a serial key.
/// </summary>
public enum AlgorithmTypes
{
/// <summary>
/// The old one, legacy.
/// </summary>
SKGL,
/// <summary>
/// The new one, located in Key Algorithm (Helper Methods)
/// </summary>
SKM15
}
public class GetProductsResult : BasicResult
{
public List<Product> Products { get; set; }
}
public class RecordUsageModel : RequestModel
{
public int ProductId { get; set; }
public string Key { get; set; }
public int Amount { get; set; }
}
public class CreateSessionResult : BasicResult
{
public string SessionId { get; set; }
}
public class CreateSessionModel :RequestModel
{
public int PaymentFormId { get; set; }
public double Price { get; set; }
public string Currency { get; set; }
public string Heading { get; set; } // remember to set a max length.
public string ProductName { get; set; }
//[MaxLength(1000)]
public string CustomField { get; set; }
//[MaxLength(1000)]
public string Metadata { get; set; }
public long Expires { get; set; }
}
public class GetMessagesResult : BasicResult
{
public List<MessageObject> Messages { get; set; }
}
public class GetMessagesModel : RequestModel
{
/// <summary>
/// Specifies the channel, whose messages you would like to retrieve. If not set, messages from all channels will be returned.
/// </summary>
[DefaultValue("")]
public string Channel { get; set; }
/// <summary>
/// Allows you to retrieve only those messages that were created after a certain Time (strictly greater than), eg. the last time you contacted the server. The format is unix timestamp. If no time is specified, all messages will be returned.
/// </summary>
[DefaultValue(0)]
public long Time { get; set; }
}
public class RegisterEventModel : RequestModel
{
[DefaultValue(-1)]
public int ProductId { get; set; }
[DefaultValue("")]
public string Key { get; set; }
[DefaultValue("")]
public string MachineCode { get; set; }
[DefaultValue("")]
public string FeatureName { get; set; }
[DefaultValue("")]
public string EventName { get; set; }
[DefaultValue(0)]
public int Value { get; set; }
[DefaultValue("")]
public string Currency { get; set; }
[DefaultValue("")]
public string Metadata { get; set; }
}
public class RegisterEventsModel : RequestModel
{
[DefaultValue(-1)]
public int ProductId { get; set; }
[DefaultValue("")]
public string Key { get; set; }
[DefaultValue("")]
public string MachineCode { get; set; }
[DefaultValue("")]
public List<Event> Events { get; set; }
}
public class Event
{
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string FeatureName { get; set; }
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string EventName { get; set; }
[DefaultValue(0)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int Value { get; set; }
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public string Currency { get; set; }
public long Time { get; set; }
public string Metadata { get; set; }
}
public class GetCustomerLicensesModel : RequestModel
{
/// <summary>
/// The id of the customer whose licenses we want to access.
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// Specifies the amount of parameters that should be included with each license key in the LiceseKeys.
/// If true, License Key will be used. By default, Basic License Key will be used (where for instance data objects and activated devices are omitted.)
/// Please read more here: https://app.cryptolens.io/docs/api/v3/GetCustomerLicenses
/// </summary>
public bool Detailed { get; set; }
}
public class GetCustomerLicensesResult : BasicResult
{
public List<LicenseKey> LicenseKeys { get; set; }
}
public class RemoveCustomerModel : RequestModel
{
public int CustomerId { get; set; }
}
public class GetCustomersModel : RequestModel
{
/// <summary>
/// If either the Name, Company or Email contains the search string, it will be returned.
/// </summary>
public string Search { get; set; }
/// <summary>
/// Specifies how many customers will be returned. If not set, all customers will be returned.
/// </summary>
public int Limit { get; set; }
}
public class GetCustomersResult : BasicResult
{
public List<Customer> Customers { get; set; }
}
public class AddCustomerModel : RequestModel
{
/// <summary>
/// The name of the customer (at most 100 chars)
/// </summary>
public string Name { get; set; }
/// <summary>
/// The email of the customer (at most 100 chars)
/// </summary>
public string Email { get; set; }
/// <summary>
/// The company name of the company the customer belongs to (at most 100 chars)
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// If set to true, a portal link will be returned where the customer will be able to view their licenses.
/// </summary>
public bool EnableCustomerAssociation { get; set; }
}
public class AddCustomerResult : BasicResult
{
/// <summary>
/// A unique integer identifier associated with this customer.
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// A link that allows the customer to create an account where they will see their licenses (in the customer dashboard).
/// </summary>
public string PortalLink { get; set; }
}
public class DeactivateModel : KeyLockModel
{
[DefaultValue("")]
public string MachineCode { get; set; }
/// <summary>
/// When true, this will release the floating license
/// (without removing it from the list of node-locked licenses)
/// </summary>
public bool Floating { get; set; }
/// <summary>
/// Additional OS information, which will be registered as an event. If this variable is not set or set to null,
/// this variable will contain a JSON serialized version of <see cref="MachineInfo"/>, which is computed using
/// <see cref="V3.Methods.Helpers.GetOSStats"/>. If you do not want OS data to be registered, set this variable to
/// empty string. You can also send in other data by setting this variable to something else.
/// Be careful with personal identifiable information and do not send in more data than necessary. Please read more
/// at https://help.cryptolens.io/legal/DataPolicy#how-to-be-compliant-as-a-software-vendor.
/// </summary>
public string OSInfo { get; set; }
}
public class KeyInfoModel : RequestModel
{
public int ProductId { get; set; }
/// <summary>
/// The Key Id, eg. 12345.
/// </summary>
public string Key { get; set; }
public bool Sign { get; set; }
public int FieldsToReturn { get; set; }
public bool Metadata { get; set; }
}
public class CreateTrialKeyModel : RequestModel
{
/// <summary>
/// The id of the product you want to access. You can find it
/// when you are logged in on https://app.cryptolens.io/docs/api/v3/KeyLock
/// and select the product in the drop down list.
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// The machine code (a string that identifies a device) that this trial key will be locked to.
/// </summary>
public string MachineCode { get; set; }
}
public class CreateKeyModel : RequestModel
{
public int ProductId { get; set; }
public int Period { get; set; }
public bool F1 { get; set; }
public bool F2 { get; set; }
public bool F3 { get; set; }
public bool F4 { get; set; }
public bool F5 { get; set; }
public bool F6 { get; set; }
public bool F7 { get; set; }
public bool F8 { get; set; }
[DefaultValue("")]
public string Notes { get; set; }
public bool Block { get; set; }
public int CustomerId { get; set; } // maybe int instead?
public bool TrialActivation { get; set; }
public bool AutomaticActivation { get; set; }
public int MaxNoOfMachines { get; set; }
public string AllowedMachines { get; set; }
}
public class CreateKeyResult : BasicResult
{
public string Key { get; set; }
}
public class GetKeysModel : RequestModel
{
/// <summary>
/// The product id
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// If there are more than 100 keys, only 99 will be returned
/// on the first page. in order to obtain the remaining licenses,
/// increment this parameter by 1.
/// </summary>
[DefaultValue(1)]
public int Page { get; set; }
/// <summary>
/// Specifies the way to order the result. The order by field has the
/// following structure: fieldName [ascending|descending]. For example,
/// If you want to order by the feature field 1 (F1), you should use F1.
/// If you want it in descending order, please add the descending keywords
/// right after the field, eg. F1 descending. The ascending keyword is
/// the default, hence optional.
/// </summary>
public string OrderBy { get; set; }
/// <summary>
/// Sorts the result so that only the license keys that satisfy the
/// criterion will be displayed. Please see:
/// https://support.serialkeymanager.com/kb/searching-for-licenses-using-linq-queries
/// </summary>
public string SearchQuery { get; set; }
}
public class GetKeysResult : BasicResult
{
/// <summary>
/// A list of <see cref="LicenseKey"/> objects.
/// </summary>
public List<LicenseKey> LicenseKeys { get; set; }
/// <summary>
/// The number of licenses returned in the request, eg. size
/// of the returned list.
/// </summary>
public int Returned { get; set; }
/// <summary>
/// The total number of keys available that satisfy the condition.
/// For example, if search query is empty, the total is the number
/// of license keys in the entire product. Otherwise, it's the
/// number of results of that query. By default, only 99 license
/// keys will be returned in a single request. There may still
/// be more license keys, which are obtained by increasing the
/// Page parameter.
/// </summary>
public int Total { get; set; }
/// <summary>
/// Since not all keys will be returned if the number of them is
/// more than 99, you can increment the Page parameter to list
/// the remaining ones. This value is the limit of the number of
/// pages available (this makes it easier to iterate through all
/// the keys).
/// </summary>
public int PageCount { get; set; }
}
public class ActivateModel : RequestModel
{
/// <summary>
/// The product id, which can be found on the product page.
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// The Key string, eg. AAAA-BBBB-CCCC-DDDD.
/// </summary>
public string Key { get; set; }
/// <summary>
/// If true, the information inside the LiceseKey object will be signed. Note,
/// in almost all cases, you should set this to True.
/// </summary>
public bool Sign { get; set; }
/// <summary>
/// The machine code (a string that identifies a device) for activation.
/// </summary>
public string MachineCode { get; set; }
/// <summary>
/// Allows you to specify a friendy name for the activated device, for example the
/// employee's email. Friendly name does not impact the number of active machine codes / seats,
/// but it offers an easy way of linking a machine/seat with a user. For added security,
/// you can HMAC hash this value.
/// </summary>
public string FriendlyName { get; set; }
/// <summary>
/// An integer that allows you to restrict the information returned in the license key data object.
/// Please read https://app.cryptolens.io/docs/api/v3/Activate#remarks for more details.
/// </summary>
public int FieldsToReturn { get; set; }
/// <summary>
/// Includes additional information about the license key, such as number of activated devices, etc.
/// </summary>
public bool Metadata { get; set; }
/// <summary>
/// When set to something greater than zero, floating licensing will be enabled.
/// The time interval is then used to check that no more than the allowed number
/// of machine codes (specified in maximumNumberOfMachines) have been activated
/// in that time period (in seconds).
/// </summary>
public int FloatingTimeInterval { get; set; }
/// <summary>
/// When set to something greater than zero (and assuming FloatingTimeInterval is set too)
/// floating licensing will permit a license overdraft (eg. activation will succeed even if
/// maximumNumberOfMachines is reached). MaxOverdraft value specifies how much we can exceed
/// the maximumNumberOfMachines value.
/// </summary>
public int MaxOverdraft { get; set; }
public SignMethod SignMethod { get; set; }
/// <summary>
/// Additional OS information, which will be registered as an event. If this variable is not set or set to null,
/// this variable will contain a JSON serialized version of <see cref="MachineInfo"/>, which is computed using
/// <see cref="V3.Methods.Helpers.GetOSStats"/>. If you do not want OS data to be registered, set this variable to
/// empty string. You can also send in other data by setting this variable to something else.
/// Be careful with personal identifiable information and do not send in more data than necessary. Please read more
/// at https://help.cryptolens.io/legal/DataPolicy#how-to-be-compliant-as-a-software-vendor.
/// </summary>
public string OSInfo { get; set; }
}
/// <summary>
/// Result of <see cref="SKM.V3.Methods.Key.Activate(string, int, string, string, bool, int, int)"/> (new protocol).
/// </summary>
public class RawResponse : BasicResult
{
public string LicenseKey { get; set; }
public string Signature { get; set; }
/// <summary>
/// Metadata related to the license key. Note, this will not always contain value.
/// Please see remarks for more information.
/// </summary>
/// <remarks>
/// In order to access this variable, you need to set
/// <see cref="ActivateModel.Metadata"/> or <see cref="KeyInfoModel.Metadata"/> to true.
/// Keep in mind that if your access token is restricted using the 'feature lock' field
/// or if <see cref="ActivateModel.FieldsToReturn"/> or <see cref="KeyInfoModel.FieldsToReturn"/>
/// (depending on if you activated or validated the license) have a certain value, metadata may still be null.
/// </remarks>
public KeyMetadata Metadata { get; set; }
}
/// <summary>
///
/// </summary>
public class KeyInfoResult : BasicResult
{
public LicenseKey LicenseKey { get; set; }
/// <summary>
/// Metadata related to the license key. Note, this will not always contain value.
/// Please see remarks for more information.
/// </summary>
/// <remarks>
/// In order to access this variable, you need to set
/// <see cref="ActivateModel.Metadata"/> or <see cref="KeyInfoModel.Metadata"/> to true.
/// Keep in mind that if your access token is restricted using the 'feature lock' field
/// or if <see cref="ActivateModel.FieldsToReturn"/> or <see cref="KeyInfoModel.FieldsToReturn"/>
/// (depending on if you activated or validated the license) have a certain value, metadata may still be null.
/// </remarks>
public KeyMetadata Metadata { get; set; }
}
/// <summary>
/// Metadata related to the license key. Note, this will not always contain value.
/// </summary>
public class KeyMetadata
{
/// <summary>
/// The number of activated machines for this license key.
/// </summary>
public int ActivatedMachines { get; set; }
/// <summary>
/// Additional information about the license key. This variable will use the
/// 'feature definitions' (that you can define in the dashboard for a given product)
/// and the license properties to determine if the license is valid or not (eg. if it has expired).
/// </summary>
public LicenseStatus LicenseStatus { get; set; }
/// <summary>
/// The number of active floating machine codes for a specific FloatingTimeInterval.
/// Tip: If you want to find the number of unused machines, subtract this value from maxNumberOfMachines.
/// If overdraft is used, you need to add the maxOverdraft value to maxNumberOfMachines.
/// </summary>
public int UsedFloatingMachines { get; set; }
/// <summary>
/// The Signature of the metadata object.
/// </summary>
public string Signature { get; set; }
#if (NET46 || NETSTANDARD2_0 || NET47 || NET471)
/// <summary>
/// Verifies the integrity of the object (eg. it has not been changed since it was generated on the server).
/// </summary>
/// <param name="RSAPublicKey">Your public key (see this page https://app.cryptolens.io/docs/api/v3/QuickStart)</param>
/// <returns>True if the signature is correct and false otherwise.</returns>
public bool VerifySignature(string RSAPublicKey)
{
var rsa = RSA.Create();
rsa.FromXmlString(RSAPublicKey);
var res = Internal.SecurityMethods.VerifyObject(Signature, rsa);
if (res == null)
return false;
var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<KeyMetadata>(res.Object);
if (obj.ActivatedMachines != ActivatedMachines ||
!obj.LicenseStatus.Equals(LicenseStatus))
return false;
return true;
}
#endif
}
public class MachineLockLimit : KeyLockModel
{
public int NumberOfMachines { get; set; }
}
public class ChangeNotesModel : KeyLockModel
{
public string Notes { get; set; }
}
/// <summary>
/// Input parameters to KeyLock method.
/// </summary>
public class KeyLockModel : RequestModel
{
/// <summary>
/// The id of the product you want to access. You can find it
/// when you are logged in on https://app.cryptolens.io/docs/api/v3/KeyLock
/// and select the product in the drop down list.
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// The Key String, i.e. ABCDE-ABCDE-ABCDE-ABCDE.
/// </summary>
public string Key { get; set; }
}
/// <summary>
/// The result of <see cref="SKM.V3.Methods.Auth.KeyLock(string, KeyLockModel)/>
/// </summary>
public class KeyLockResult : BasicResult
{
public long KeyId { get; set; }
public string Token { get; set; }
}
public class AddDataObjectToKeyModel : KeyLockModel
{
/// <summary>
/// The name of the data object. Max 10 characters.
/// </summary>
public string Name { get; set; }
/// <summary>
/// A string value (text) to store. Max 10000 characters.
/// </summary>
public string StringValue { get; set; }
/// <summary>
/// An int value (int32) to store.
/// </summary>
public int IntValue { get; set; }
/// <summary>
/// Make sure data objects with the same name are not added.
/// </summary>
public bool CheckForDuplicates { get; set; }
}
public class ListDataObjectsToKeyModel : KeyLockModel
{
/// <summary>
/// Lists the names that contain the desired string only.
/// </summary>
[DefaultValue("")]
public string Contains { get; set; }
}
/// <summary>
/// Used to identify a data object.
/// </summary>
public class ChangeStringValueToKeyModel : KeyLockModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
/// <summary>
/// A string value (text) to store. Max 10000 characters.
/// </summary>
public string StringValue { get; set; }
}
/// <summary>
/// Used to identify a data object.
/// </summary>
public class ChangeIntValueToKeyModel : KeyLockModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
/// <summary>
/// This is either the new int value that should be assigned to the Data Object
/// when using <see cref="Data.SetIntValue(AuthDetails, ChangeIntValueModel)"/>
/// in which case it can be a signed int32, eg. 10, and -10 OR it is a the value that
/// should be added to the current IntValue of an existing Data Object, in which case
/// this value will be treated as an unsigned value, eg. 10 = -10. The latter case is
/// relevant for <see cref="Data.IncrementIntValue(AuthDetails, ChangeIntValueModel)"/>
/// and <see cref="Data.DecrementIntValue(AuthDetails, ChangeIntValueModel)"/>.
/// </summary>
public int IntValue { get; set; }
/// <summary>
/// If set to true, it will be possible to specify an upper/lower bound.
/// (for Increment Int Value) For example, if you set the Bound parameter (below) to 10, you
/// will be able to increment the int value until you reach ten (inclusive).
/// Once the upper bound is reached, an error will be thrown.
/// (for Decrement Int Value) For example, if you set the Bound parameter (below) to 0,
/// you will be able to decrement the int value until you reach zero (inclusive).
/// Once the lower bound is reached, an error will be thrown.
/// </summary>
public bool EnableBound { get; set; }
/// <summary>
/// This is the upper/lower bound that will be enforced on the increment or
/// decrement operation. It will only be enforced if EnableBound
/// is set to true. Please read the description above.
/// </summary>
public int Bound { get; set; }
}
/// <summary>
/// Used to remove a data object.
/// </summary>
public class RemoveDataObjectToKeyModel : KeyLockModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
}
internal interface IAddOrListDataObjectsModel
{
/// <summary>
/// Indicates if the data object should be added to a
/// license key, a product or the entire user account.
/// <see cref="DataObject"/>
/// </summary>
DataObjectType ReferencerType { get; set; }
/// <summary>
/// The id of the Referencer. It can either be an id to a product that
/// you have or to a license key. When ReferencerType is set to User,
/// there is no need to set this value.
/// </summary>
int ReferencerId { get; set; }
}
/// <summary>
/// Used to add a new Data Object.
/// </summary>
public class AddDataObjectModel : RequestModel, IAddOrListDataObjectsModel
{
/// <summary>
/// The name of the data object. Max 10 characters.
/// </summary>
public string Name { get; set; }
/// <summary>
/// A string value (text) to store. Max 100 characters.
/// </summary>
public string StringValue { get; set; }
/// <summary>
/// An int value (int32) to store.
/// </summary>
public int IntValue { get; set; }
/// <summary>
/// Indicates if the data object should be added to a
/// license key, a product or the entire user account.
/// <see cref="DataObject"/>
/// </summary>
public DataObjectType ReferencerType { get; set; }
/// <summary>
/// The id of the Referencer. It can either be an id to a product
/// that you have or to a license key. When ReferencerType is set
/// to User, there is no need to set this value.
/// </summary>
public int ReferencerId { get; set; }
/// <summary>
/// Make sure data objects with the same name are not added.
/// </summary>
public bool CheckForDuplicates { get; set; }
}
/// <summary>
/// Used to list Data Objects.
/// </summary>
public class ListDataObjectsModel : RequestModel, IAddOrListDataObjectsModel
{
/// <summary>
/// Indicates if the data object is associated with a license key,
/// a product or the entire user account. User = 0, Product = 1, Key = 2.
/// </summary>
public DataObjectType ReferencerType { get; set; }
/// <summary>
/// The id of the Referencer. It can either be an id to a product that
/// you have or to a license key. When ReferencerType is set to User,
/// there is no need to set this value.
/// </summary>
public int ReferencerId { get; set; }
/// <summary>
/// Shows only Data Objects where the name contains the following string.
/// </summary>
public string Contains { get; set; }
/// <summary>
/// If set to true, all data objects will be returned, that is,
/// both those associated with your entire account, a specific
/// product and a license key. In addition, each data object
/// item will include the ReferencerType and its Id. Otherwise,
/// i.e. when set to false, only the data objects associated
/// with the user, product or key will be returned, without the
/// ReferencerType and its Id.
/// </summary>
public bool ShowAll { get; set; }
}
/// <summary>
/// Used to identify a data object.
/// </summary>
internal interface IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
long Id { get; set; }
}
/// <summary>
/// Used to identify a data object.
/// </summary>
public class ChangeStringValueModel : RequestModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
/// <summary>
/// A string value (text) to store. Max 10000 characters.
/// </summary>
public string StringValue { get; set; }
}
/// <summary>
/// Used to identify a data object.
/// </summary>
public class ChangeIntValueModel : RequestModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
/// <summary>
/// This is either the new int value that should be assigned to the Data Object
/// when using <see cref="Data.SetIntValue(AuthDetails, ChangeIntValueModel)"/>
/// in which case it can be a signed int32, eg. 10, and -10 OR it is a the value that
/// should be added to the current IntValue of an existing Data Object, in which case
/// this value will be treated as an unsigned value, eg. 10 = -10. The latter case is
/// relevant for <see cref="Data.IncrementIntValue(AuthDetails, ChangeIntValueModel)"/>
/// and <see cref="Data.DecrementIntValue(AuthDetails, ChangeIntValueModel)"/>.
/// </summary>
public int IntValue { get; set; }
/// <summary>
/// If set to true, it will be possible to specify an upper/lower bound.
/// (for Increment Int Value) For example, if you set the Bound parameter (below) to 10, you
/// will be able to increment the int value until you reach ten (inclusive).
/// Once the upper bound is reached, an error will be thrown.
/// (for Decrement Int Value) For example, if you set the Bound parameter (below) to 0,
/// you will be able to decrement the int value until you reach zero (inclusive).
/// Once the lower bound is reached, an error will be thrown.
/// </summary>
public bool EnableBound { get; set; }
/// <summary>
/// This is the upper/lower bound that will be enforced on the increment or
/// decrement operation. It will only be enforced if EnableBound
/// is set to true. Please read the description above.
/// </summary>
public int Bound { get; set; }
}
/// <summary>
/// Used to remove a data object.
/// </summary>
public class RemoveDataObjectModel : RequestModel, IChangeValueModel
{
/// <summary>
/// The unique object id for the data object.
/// </summary>
public long Id { get; set; }
}
/// <summary>
/// Stores the parameters that are required by the Extend License method.
/// </summary>
public class ExtendLicenseModel : RequestModel
{
/// <summary>
/// The id of the product you want to access. You can find it
/// when you are logged in on https://serialkeymanager.com/docs/api/v3/ExtendLicense
/// and select the product in the drop down list.
/// </summary>
public int ProductId { get; set; }
/// <summary>
/// The Key String, i.e. ABCDE-ABCDE-ABCDE-ABCDE.
/// </summary>
public string Key { get; set; }
/// <summary>
/// The number of days the license should be extended.
/// </summary>
public int NoOfDays { get; set; }
}
/// <summary>
/// Stores the parameters required by AddFeature and RemoveFeature methods.
/// </summary>
public class FeatureModel : RequestModel
{
public int ProductId { get; set; }
/// <summary>
/// The Key String, i.e. ABCDE-ABCDE-ABCDE-ABCDE.
/// </summary>
public string Key { get; set; }
/// <summary>
/// From 1 to 8.
/// </summary>
public int Feature { get; set; }