carddb 0.2.2 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -245,6 +245,16 @@ module CardDB
245
245
  def to_json(*args)
246
246
  data.to_json(*args)
247
247
  end
248
+
249
+ private
250
+
251
+ def parse_time(value)
252
+ return nil unless value
253
+
254
+ Time.parse(value)
255
+ rescue ArgumentError
256
+ value
257
+ end
248
258
  end
249
259
 
250
260
  # Wrapper for Publisher objects
@@ -334,6 +344,14 @@ module CardDB
334
344
  data['description']
335
345
  end
336
346
 
347
+ def metafy_game_uuid
348
+ data['metafyGameUuid']
349
+ end
350
+
351
+ def metafy_game_slug
352
+ data['metafyGameSlug']
353
+ end
354
+
337
355
  def website
338
356
  data['website']
339
357
  end
@@ -362,6 +380,10 @@ module CardDB
362
380
  data.dig('coverFile', 'url')
363
381
  end
364
382
 
383
+ def archived_at
384
+ parse_time(data['archivedAt'])
385
+ end
386
+
365
387
  def created_at
366
388
  parse_time(data['createdAt'])
367
389
  end
@@ -436,6 +458,10 @@ module CardDB
436
458
  data['purpose']
437
459
  end
438
460
 
461
+ def active_version_id
462
+ data['activeVersionId']
463
+ end
464
+
439
465
  def tcgplayer_product_id_field_key
440
466
  data['tcgplayerProductIdFieldKey']
441
467
  end
@@ -448,6 +474,22 @@ module CardDB
448
474
  data['isArchived']
449
475
  end
450
476
 
477
+ def archived_at
478
+ parse_time(data['archivedAt'])
479
+ end
480
+
481
+ def pos_x
482
+ data['posX']
483
+ end
484
+
485
+ def pos_y
486
+ data['posY']
487
+ end
488
+
489
+ def sort_order
490
+ data['sortOrder']
491
+ end
492
+
451
493
  def publisher_id
452
494
  data['publisherId']
453
495
  end
@@ -582,6 +624,10 @@ module CardDB
582
624
  @fields ||= (data['fields'] || []).map { |f| FieldInfo.new(f) }
583
625
  end
584
626
 
627
+ def field_keys
628
+ fields.map(&:key)
629
+ end
630
+
585
631
  def filterable_fields
586
632
  data['filterableFields'] || []
587
633
  end
@@ -640,10 +686,38 @@ module CardDB
640
686
  data['isIdentifier']
641
687
  end
642
688
 
689
+ def sort_order
690
+ data['sortOrder']
691
+ end
692
+
643
693
  def item_type
644
694
  data['itemType']
645
695
  end
646
696
 
697
+ def link_dataset_id
698
+ data['linkDatasetId']
699
+ end
700
+
701
+ def link_dataset_key
702
+ data['linkDatasetKey']
703
+ end
704
+
705
+ def link_dataset_name
706
+ data['linkDatasetName']
707
+ end
708
+
709
+ def link_field_key
710
+ data['linkFieldKey']
711
+ end
712
+
713
+ def link_alias
714
+ data['linkAlias']
715
+ end
716
+
717
+ def link_direction
718
+ data['linkDirection']
719
+ end
720
+
647
721
  def display_format
648
722
  data['displayFormat']
649
723
  end
@@ -652,10 +726,54 @@ module CardDB
652
726
  data['semanticType']
653
727
  end
654
728
 
729
+ def placeholder
730
+ data['placeholder']
731
+ end
732
+
733
+ def hidden?
734
+ data['isHidden']
735
+ end
736
+
737
+ def computed?
738
+ data['isComputed']
739
+ end
740
+
741
+ def system_field?
742
+ data['isSystemField']
743
+ end
744
+
745
+ def default_value
746
+ data['defaultValue']
747
+ end
748
+
655
749
  def allowed_values
656
750
  data['allowedValues']
657
751
  end
658
752
 
753
+ def min_length
754
+ data['minLength']
755
+ end
756
+
757
+ def max_length
758
+ data['maxLength']
759
+ end
760
+
761
+ def min_value
762
+ data['minValue']
763
+ end
764
+
765
+ def max_value
766
+ data['maxValue']
767
+ end
768
+
769
+ def pattern
770
+ data['pattern']
771
+ end
772
+
773
+ def unique?
774
+ data['isUnique']
775
+ end
776
+
659
777
  def nested_fields
660
778
  @nested_fields ||= (data['nestedFields'] || []).map { |f| FieldInfo.new(f) }
661
779
  end
@@ -688,6 +806,22 @@ module CardDB
688
806
  def target_dataset_id
689
807
  data['targetDatasetId']
690
808
  end
809
+
810
+ def target_field_key
811
+ data['targetFieldKey']
812
+ end
813
+
814
+ def link_alias
815
+ data['linkAlias']
816
+ end
817
+
818
+ def link_direction
819
+ data['linkDirection']
820
+ end
821
+
822
+ def array?
823
+ data['isArray']
824
+ end
691
825
  end
692
826
 
693
827
  # Wrapper for DatasetRecord objects
@@ -760,8 +894,8 @@ module CardDB
760
894
  def parse_resolved_links
761
895
  return {} unless data['resolvedLinks']
762
896
 
763
- data['resolvedLinks'].each_with_object({}) do |link, hash|
764
- hash[link['field']] = ResolvedLink.new(link, client: client)
897
+ data['resolvedLinks'].to_h do |link|
898
+ [link['field'], ResolvedLink.new(link, client: client)]
765
899
  end
766
900
  end
767
901
 
@@ -774,12 +908,429 @@ module CardDB
774
908
  end
775
909
  end
776
910
 
911
+ class File < Resource
912
+ def id = data['id']
913
+ def key = data['key']
914
+ def filename = data['filename']
915
+ def content_type = data['contentType']
916
+ def size = data['size']
917
+ def status = data['status']
918
+ def public? = !!data['isPublic']
919
+ def entity_type = data['entityType']
920
+ def entity_id = data['entityId']
921
+ def url = data['url']
922
+ def created_at = parse_time(data['createdAt'])
923
+ def updated_at = parse_time(data['updatedAt'])
924
+ end
925
+
926
+ class PresignedUpload < Resource
927
+ def upload_url = data['uploadUrl']
928
+ def expires_at = parse_time(data['expiresAt'])
929
+
930
+ def file
931
+ @file ||= data['file'] ? File.new(data['file'], client: client) : nil
932
+ end
933
+ end
934
+
935
+ class ObjectField < Resource
936
+ def id = data['id']
937
+ def object_type_id = data['objectTypeId']
938
+ def key = data['key']
939
+ def label = data['label']
940
+ def data_type = data['dataType']
941
+ def required? = !!data['isRequired']
942
+ def filterable? = !!data['isFilterable']
943
+ def searchable? = !!data['isSearchable']
944
+ def identifier? = !!data['isIdentifier']
945
+ def sort_order = data['sortOrder']
946
+ def description = data['description']
947
+ def placeholder = data['placeholder']
948
+ def display_format = data['displayFormat']
949
+ def semantic_type = data['semanticType']
950
+ def hidden? = !!data['isHidden']
951
+ def computed? = !!data['isComputed']
952
+ def system_field? = !!data['isSystemField']
953
+ def default_value = data['defaultValue']
954
+ def allowed_values = data['allowedValues']
955
+ def min_length = data['minLength']
956
+ def max_length = data['maxLength']
957
+ def min_value = data['minValue']
958
+ def max_value = data['maxValue']
959
+ def pattern = data['pattern']
960
+ def unique? = !!data['isUnique']
961
+ def item_type = data['itemType']
962
+ def link_dataset_id = data['linkDatasetId']
963
+ def link_field_key = data['linkFieldKey']
964
+ def link_alias = data['linkAlias']
965
+ def link_direction = data['linkDirection']
966
+ def parent_field_id = data['parentFieldId']
967
+ def created_at = parse_time(data['createdAt'])
968
+ def updated_at = parse_time(data['updatedAt'])
969
+ end
970
+
971
+ class RecordValidationError < Resource
972
+ def field = data['field']
973
+ def message = data['message']
974
+ def details = data['details'] || {}
975
+ end
976
+
977
+ class BulkRecordError < Resource
978
+ def dataset_key = data['datasetKey']
979
+ def index = data['index']
980
+
981
+ def errors
982
+ @errors ||= (data['errors'] || []).map { |error| RecordValidationError.new(error, client: client) }
983
+ end
984
+ end
985
+
986
+ class ImportStats < Resource
987
+ def total = data['total']
988
+ def inserted = data['inserted']
989
+ def updated = data['updated']
990
+ def skipped = data['skipped']
991
+ def failed = data['failed']
992
+ end
993
+
994
+ class BulkImportResult < Resource
995
+ def inserted
996
+ @inserted ||= (data['inserted'] || []).map { |record| Record.new(record, client: client) }
997
+ end
998
+
999
+ def updated
1000
+ @updated ||= (data['updated'] || []).map { |record| Record.new(record, client: client) }
1001
+ end
1002
+
1003
+ def skipped = data['skipped']
1004
+
1005
+ def errors
1006
+ @errors ||= (data['errors'] || []).map { |error| BulkRecordError.new(error, client: client) }
1007
+ end
1008
+
1009
+ def created_fields
1010
+ @created_fields ||= (data['createdFields'] || []).map { |field| ObjectField.new(field, client: client) }
1011
+ end
1012
+
1013
+ def stats
1014
+ @stats ||= data['stats'] ? ImportStats.new(data['stats'], client: client) : nil
1015
+ end
1016
+ end
1017
+
1018
+ class DatasetRecordsUpsertPayload < Resource
1019
+ def job
1020
+ @job ||= data['job'] ? ImportJob.new(data['job'], client: client) : nil
1021
+ end
1022
+
1023
+ def dry_run_result
1024
+ @dry_run_result ||= data['dryRunResult'] ? BulkImportResult.new(data['dryRunResult'], client: client) : nil
1025
+ end
1026
+ end
1027
+
1028
+ class DatasetRecordDeleteJobResult < Resource
1029
+ def target = data['target']
1030
+ def record_id = data['recordId']
1031
+ def identifier = data['identifier']
1032
+ def status = data['status']
1033
+ def message = data['message']
1034
+ end
1035
+
1036
+ class DatasetRecordDeleteJob < Resource
1037
+ def id = data['id']
1038
+ def publisher_id = data['publisherId']
1039
+ def dataset_id = data['datasetId']
1040
+ def account_id = data['accountId']
1041
+ def status = data['status']
1042
+ def target_type = data['targetType']
1043
+ def dry_run? = !!data['dryRun']
1044
+ def targets = data['targets'] || []
1045
+ def progress = data['progress']
1046
+ def total_targets = data['totalTargets']
1047
+ def processed_targets = data['processedTargets']
1048
+ def matched_count = data['matchedCount']
1049
+ def deleted_count = data['deletedCount']
1050
+ def missing_count = data['missingCount']
1051
+ def blocked_count = data['blockedCount']
1052
+ def failed_count = data['failedCount']
1053
+ def error_message = data['errorMessage']
1054
+ def started_at = parse_time(data['startedAt'])
1055
+ def completed_at = parse_time(data['completedAt'])
1056
+ def created_at = parse_time(data['createdAt'])
1057
+ def updated_at = parse_time(data['updatedAt'])
1058
+ def completed? = status == 'COMPLETED'
1059
+ def failed? = status == 'FAILED'
1060
+
1061
+ def publisher
1062
+ @publisher ||= data['publisher'] ? Publisher.new(data['publisher'], client: client) : nil
1063
+ end
1064
+
1065
+ def dataset
1066
+ @dataset ||= data['dataset'] ? Dataset.new(data['dataset'], client: client) : nil
1067
+ end
1068
+
1069
+ def results
1070
+ @results ||= (data['results'] || []).map { |result| DatasetRecordDeleteJobResult.new(result, client: client) }
1071
+ end
1072
+ end
1073
+
1074
+ class ImportJobAsset < Resource
1075
+ def file_id = data['fileId']
1076
+ def filename = data['filename']
1077
+
1078
+ def file
1079
+ @file ||= data['file'] ? File.new(data['file'], client: client) : nil
1080
+ end
1081
+ end
1082
+
1083
+ class ImportJob < Resource
1084
+ def id = data['id']
1085
+ def publisher_id = data['publisherId']
1086
+ def dataset_id = data['datasetId']
1087
+ def account_id = data['accountId']
1088
+ def status = data['status']
1089
+ def mode = data['mode']
1090
+ def on_conflict = data['onConflict']
1091
+ def format = data['format']
1092
+ def file_id = data['fileId']
1093
+ def progress = data['progress']
1094
+ def total_records = data['totalRecords']
1095
+ def processed_records = data['processedRecords']
1096
+ def inserted_count = data['insertedCount']
1097
+ def updated_count = data['updatedCount']
1098
+ def skipped_count = data['skippedCount']
1099
+ def failed_count = data['failedCount']
1100
+ def error_message = data['errorMessage']
1101
+ def started_at = parse_time(data['startedAt'])
1102
+ def completed_at = parse_time(data['completedAt'])
1103
+ def created_at = parse_time(data['createdAt'])
1104
+ def updated_at = parse_time(data['updatedAt'])
1105
+ def last_checkpoint_index = data['lastCheckpointIndex']
1106
+ def resumed? = !!data['isResumed']
1107
+ def images_pending = data['imagesPending']
1108
+ def images_completed = data['imagesCompleted']
1109
+ def images_failed = data['imagesFailed']
1110
+ def completed? = status == 'COMPLETED'
1111
+ def failed? = status == 'FAILED'
1112
+
1113
+ def publisher
1114
+ @publisher ||= data['publisher'] ? Publisher.new(data['publisher'], client: client) : nil
1115
+ end
1116
+
1117
+ def dataset
1118
+ @dataset ||= data['dataset'] ? Dataset.new(data['dataset'], client: client) : nil
1119
+ end
1120
+
1121
+ def created_fields
1122
+ @created_fields ||= (data['createdFields'] || []).map { |field| ObjectField.new(field, client: client) }
1123
+ end
1124
+
1125
+ def errors
1126
+ @errors ||= (data['errors'] || []).map { |error| BulkRecordError.new(error, client: client) }
1127
+ end
1128
+
1129
+ def assets
1130
+ @assets ||= (data['assets'] || []).map { |asset| ImportJobAsset.new(asset, client: client) }
1131
+ end
1132
+ end
1133
+
1134
+ class ImportJobLog < Resource
1135
+ def id = data['id']
1136
+ def import_job_id = data['importJobId']
1137
+ def level = data['level']
1138
+ def message = data['message']
1139
+ def dataset_key = data['datasetKey']
1140
+ def record_index = data['recordIndex']
1141
+ def field_key = data['fieldKey']
1142
+ def details = data['details'] || {}
1143
+ def created_at = parse_time(data['createdAt'])
1144
+ end
1145
+
1146
+ class FieldMapping < Resource
1147
+ def source_field = data['sourceField']
1148
+ def target_field = data['targetField']
1149
+ def target_field_label = data['targetFieldLabel']
1150
+ def inferred_type = data['inferredType']
1151
+ def inferred_item_type = data['inferredItemType']
1152
+ def inferred_children = data['inferredChildren'] || []
1153
+ def inferred_link_dataset = data['inferredLinkDataset']
1154
+ def inferred_link_field_key = data['inferredLinkFieldKey']
1155
+ def inferred_link_direction = data['inferredLinkDirection']
1156
+ def target_field_type = data['targetFieldType']
1157
+ def sample_values = data['sampleValues'] || []
1158
+ def status = data['status']
1159
+ end
1160
+
1161
+ class ImportWarning < Resource
1162
+ def dataset_key = data['datasetKey']
1163
+ def field = data['field']
1164
+ def message = data['message']
1165
+ def severity = data['severity']
1166
+ end
1167
+
1168
+ class DatasetImportPreview < Resource
1169
+ def dataset_key = data['datasetKey']
1170
+ def dataset_name = data['datasetName']
1171
+ def dataset_id = data['datasetId']
1172
+ def exists? = !!data['exists']
1173
+ def record_count = data['recordCount']
1174
+ def sample_records = data['sampleRecords'] || []
1175
+
1176
+ def field_mappings
1177
+ @field_mappings ||= (data['fieldMappings'] || []).map { |mapping| FieldMapping.new(mapping, client: client) }
1178
+ end
1179
+
1180
+ def warnings
1181
+ @warnings ||= (data['warnings'] || []).map { |warning| ImportWarning.new(warning, client: client) }
1182
+ end
1183
+ end
1184
+
1185
+ class DatasetImportPreviewResult < DatasetImportPreview
1186
+ def can_proceed? = !!data['canProceed']
1187
+
1188
+ def available_datasets
1189
+ @available_datasets ||= (data['availableDatasets'] || []).map { |dataset| Dataset.new(dataset, client: client) }
1190
+ end
1191
+ end
1192
+
1193
+ class GameImportPreview < Resource
1194
+ def import_order = data['importOrder'] || []
1195
+ def can_proceed? = !!data['canProceed']
1196
+
1197
+ def datasets
1198
+ @datasets ||= (data['datasets'] || []).map { |dataset| DatasetImportPreview.new(dataset, client: client) }
1199
+ end
1200
+
1201
+ def warnings
1202
+ @warnings ||= (data['warnings'] || []).map { |warning| ImportWarning.new(warning, client: client) }
1203
+ end
1204
+ end
1205
+
1206
+ class GameImportDatasetStatus < Resource
1207
+ def dataset_key = data['datasetKey']
1208
+ def dataset_id = data['datasetId']
1209
+ def dataset_name = data['datasetName']
1210
+ def status = data['status']
1211
+ def record_count = data['recordCount']
1212
+ def inserted_count = data['insertedCount']
1213
+ def updated_count = data['updatedCount']
1214
+ def skipped_count = data['skippedCount']
1215
+ def failed_count = data['failedCount']
1216
+ def error_message = data['errorMessage']
1217
+ end
1218
+
1219
+ class GameImportJob < Resource
1220
+ def id = data['id']
1221
+ def publisher_id = data['publisherId']
1222
+ def game_id = data['gameId']
1223
+ def account_id = data['accountId']
1224
+ def status = data['status']
1225
+ def mode = data['mode']
1226
+ def on_conflict = data['onConflict']
1227
+ def file_id = data['fileId']
1228
+ def total_datasets = data['totalDatasets']
1229
+ def completed_datasets = data['completedDatasets']
1230
+ def progress = data['progress']
1231
+ def import_order = data['importOrder'] || []
1232
+ def error_message = data['errorMessage']
1233
+ def started_at = parse_time(data['startedAt'])
1234
+ def completed_at = parse_time(data['completedAt'])
1235
+ def created_at = parse_time(data['createdAt'])
1236
+ def updated_at = parse_time(data['updatedAt'])
1237
+ def completed_dataset_keys = data['completedDatasetKeys'] || []
1238
+ def current_dataset_key = data['currentDatasetKey']
1239
+ def last_checkpoint_index = data['lastCheckpointIndex']
1240
+ def resumed? = !!data['isResumed']
1241
+ def images_pending = data['imagesPending']
1242
+ def images_completed = data['imagesCompleted']
1243
+ def images_failed = data['imagesFailed']
1244
+ def phase = data['phase']
1245
+ def link_building_dataset = data['linkBuildingDataset']
1246
+ def link_building_total_datasets = data['linkBuildingTotalDatasets']
1247
+ def link_building_completed_datasets = data['linkBuildingCompletedDatasets']
1248
+ def link_building_processed_records = data['linkBuildingProcessedRecords']
1249
+ def link_building_total_records = data['linkBuildingTotalRecords']
1250
+ def completed? = status == 'COMPLETED'
1251
+ def failed? = status == 'FAILED'
1252
+
1253
+ def publisher
1254
+ @publisher ||= data['publisher'] ? Publisher.new(data['publisher'], client: client) : nil
1255
+ end
1256
+
1257
+ def game
1258
+ @game ||= data['game'] ? Game.new(data['game'], client: client) : nil
1259
+ end
1260
+
1261
+ def assets
1262
+ @assets ||= (data['assets'] || []).map { |asset| ImportJobAsset.new(asset, client: client) }
1263
+ end
1264
+
1265
+ def dataset_statuses
1266
+ @dataset_statuses ||= (data['datasetStatuses'] || []).map do |status|
1267
+ GameImportDatasetStatus.new(status, client: client)
1268
+ end
1269
+ end
1270
+ end
1271
+
1272
+ class ExportJob < Resource
1273
+ def id = data['id']
1274
+ def publisher_id = data['publisherId']
1275
+ def dataset_id = data['datasetId']
1276
+ def account_id = data['accountId']
1277
+ def status = data['status']
1278
+ def format = data['format']
1279
+ def filter = data['filter']
1280
+ def total_records = data['totalRecords']
1281
+ def processed_records = data['processedRecords']
1282
+ def progress = data['progress']
1283
+ def file_id = data['fileId']
1284
+ def download_url = data['downloadUrl']
1285
+ def download_expires_at = parse_time(data['downloadExpiresAt'])
1286
+ def error_message = data['errorMessage']
1287
+ def started_at = parse_time(data['startedAt'])
1288
+ def completed_at = parse_time(data['completedAt'])
1289
+ def created_at = parse_time(data['createdAt'])
1290
+ def updated_at = parse_time(data['updatedAt'])
1291
+ def last_checkpoint_index = data['lastCheckpointIndex']
1292
+ def completed? = status == 'COMPLETED'
1293
+ def failed? = status == 'FAILED'
1294
+
1295
+ def publisher
1296
+ @publisher ||= data['publisher'] ? Publisher.new(data['publisher'], client: client) : nil
1297
+ end
1298
+
1299
+ def dataset
1300
+ @dataset ||= data['dataset'] ? Dataset.new(data['dataset'], client: client) : nil
1301
+ end
1302
+ end
1303
+
777
1304
  # Wrapper for hosted Deck objects
778
1305
  class Deck < Resource
779
1306
  def id
780
1307
  data['id']
781
1308
  end
782
1309
 
1310
+ def owner_type
1311
+ data['ownerType']
1312
+ end
1313
+
1314
+ def owner_account_id
1315
+ data['ownerAccountId']
1316
+ end
1317
+
1318
+ def owner_api_application_id
1319
+ data['ownerApiApplicationId']
1320
+ end
1321
+
1322
+ def environment
1323
+ data['environment']
1324
+ end
1325
+
1326
+ def created_by_account_id
1327
+ data['createdByAccountId']
1328
+ end
1329
+
1330
+ def created_by_api_application_id
1331
+ data['createdByApiApplicationId']
1332
+ end
1333
+
783
1334
  def account_id
784
1335
  data['accountId']
785
1336
  end
@@ -820,10 +1371,54 @@ module CardDB
820
1371
  data['visibility']
821
1372
  end
822
1373
 
1374
+ def access_mode
1375
+ data['accessMode']
1376
+ end
1377
+
1378
+ def discoverability
1379
+ data['discoverability']
1380
+ end
1381
+
1382
+ def state
1383
+ data['state']
1384
+ end
1385
+
1386
+ def archived?
1387
+ state == 'ARCHIVED'
1388
+ end
1389
+
1390
+ def deleted?
1391
+ state == 'DELETED'
1392
+ end
1393
+
1394
+ def archived_at
1395
+ parse_time(data['archivedAt'])
1396
+ end
1397
+
1398
+ def deleted_at
1399
+ parse_time(data['deletedAt'])
1400
+ end
1401
+
1402
+ def unpublished_at
1403
+ parse_time(data['unpublishedAt'])
1404
+ end
1405
+
1406
+ def external_ref_api_application_id
1407
+ data['externalRefApiApplicationId']
1408
+ end
1409
+
823
1410
  def external_ref
824
1411
  data['externalRef']
825
1412
  end
826
1413
 
1414
+ def external_subject_ref
1415
+ data['externalSubjectRef']
1416
+ end
1417
+
1418
+ def ruleset_id
1419
+ data['rulesetId']
1420
+ end
1421
+
827
1422
  def source_url
828
1423
  data['sourceUrl']
829
1424
  end
@@ -836,6 +1431,12 @@ module CardDB
836
1431
  @entries ||= (data['entries'] || []).map { |entry| DeckEntry.new(entry, client: client) }
837
1432
  end
838
1433
 
1434
+ def section_definitions
1435
+ @section_definitions ||= (data['sectionDefinitions'] || []).map do |definition|
1436
+ DeckSectionDefinition.new(definition, client: client)
1437
+ end
1438
+ end
1439
+
839
1440
  def latest_published_version
840
1441
  @latest_published_version ||= data['latestPublishedVersion'] ? DeckVersion.new(data['latestPublishedVersion'], client: client) : nil
841
1442
  end
@@ -844,6 +1445,22 @@ module CardDB
844
1445
  parse_time(data['publishedAt'])
845
1446
  end
846
1447
 
1448
+ def draft_revision
1449
+ data['draftRevision']
1450
+ end
1451
+
1452
+ def draft_updated_at
1453
+ parse_time(data['draftUpdatedAt'])
1454
+ end
1455
+
1456
+ def draft_updated_by_account_id
1457
+ data['draftUpdatedByAccountId']
1458
+ end
1459
+
1460
+ def draft_updated_by_api_application_id
1461
+ data['draftUpdatedByApiApplicationId']
1462
+ end
1463
+
847
1464
  def has_unpublished_changes?
848
1465
  !!data['hasUnpublishedChanges']
849
1466
  end
@@ -929,6 +1546,40 @@ module CardDB
929
1546
  data['computedDiff'] || {}
930
1547
  end
931
1548
 
1549
+ def ruleset_id
1550
+ data['rulesetId']
1551
+ end
1552
+
1553
+ def ruleset_version_id
1554
+ data['rulesetVersionId']
1555
+ end
1556
+
1557
+ def card_dataset_id
1558
+ data['cardDatasetId']
1559
+ end
1560
+
1561
+ def card_dataset_version_id
1562
+ data['cardDatasetVersionId']
1563
+ end
1564
+
1565
+ def validated_at
1566
+ parse_time(data['validatedAt'])
1567
+ end
1568
+
1569
+ def validation_summary
1570
+ data['validationSummary'] || {}
1571
+ end
1572
+
1573
+ def validated_against
1574
+ @validated_against ||= data['validatedAgainst'] ? DeckValidatedAgainst.new(data['validatedAgainst'], client: client) : nil
1575
+ end
1576
+
1577
+ def section_definitions
1578
+ @section_definitions ||= (data['sectionDefinitions'] || []).map do |definition|
1579
+ DeckSectionDefinition.new(definition, client: client)
1580
+ end
1581
+ end
1582
+
932
1583
  def published_by_account_id
933
1584
  data['publishedByAccountId']
934
1585
  end
@@ -993,6 +1644,49 @@ module CardDB
993
1644
  end
994
1645
  end
995
1646
 
1647
+ class DeckOwnershipTransferPayload < Resource
1648
+ def deck
1649
+ @deck ||= Deck.new(data['deck'], client: client)
1650
+ end
1651
+
1652
+ def retained_app_access? = !!data['retainedAppAccess']
1653
+ end
1654
+
1655
+ class DeckCopyPayload < DeckOwnershipTransferPayload
1656
+ def copied_from_deck_id = data['copiedFromDeckId']
1657
+ end
1658
+
1659
+ class DeckAccessApplication < Resource
1660
+ def id = data['id']
1661
+ def name = data['name']
1662
+ def description = data['description']
1663
+ def revoked_at = parse_time(data['revokedAt'])
1664
+ end
1665
+
1666
+ class DeckAPIApplicationAccess < Resource
1667
+ def id = data['id']
1668
+ def deck_id = data['deckId']
1669
+
1670
+ def deck
1671
+ @deck ||= data['deck'] ? Deck.new(data['deck'], client: client) : nil
1672
+ end
1673
+
1674
+ def api_application_id = data['apiApplicationId']
1675
+
1676
+ def api_application
1677
+ @api_application ||= data['apiApplication'] ? DeckAccessApplication.new(data['apiApplication'], client: client) : nil
1678
+ end
1679
+
1680
+ def role = data['role']
1681
+ def grant_source = data['grantSource']
1682
+ def external_ref = data['externalRef']
1683
+ def created_by_account_id = data['createdByAccountId']
1684
+ def created_by_api_application_id = data['createdByApiApplicationId']
1685
+ def revoked_at = parse_time(data['revokedAt'])
1686
+ def created_at = parse_time(data['createdAt'])
1687
+ def updated_at = parse_time(data['updatedAt'])
1688
+ end
1689
+
996
1690
  # Wrapper for deck preview token metadata
997
1691
  class DeckPreviewToken < Resource
998
1692
  def id
@@ -1049,6 +1743,329 @@ module CardDB
1049
1743
  end
1050
1744
  end
1051
1745
 
1746
+ class DeckEmbedToken < Resource
1747
+ def id = data['id']
1748
+ def deck_id = data['deckId']
1749
+ def api_application_id = data['apiApplicationId']
1750
+ def label = data['label']
1751
+ def read_mode = data['readMode']
1752
+ def allowed_origins = data['allowedOrigins'] || []
1753
+ def external_subject = data['externalSubject']
1754
+ def expires_at = parse_time(data['expiresAt'])
1755
+ def revoked_at = parse_time(data['revokedAt'])
1756
+ def last_used_at = parse_time(data['lastUsedAt'])
1757
+ def created_at = parse_time(data['createdAt'])
1758
+ def updated_at = parse_time(data['updatedAt'])
1759
+ end
1760
+
1761
+ class DeckEmbedTokenCreatePayload < Resource
1762
+ def token = data['token']
1763
+
1764
+ def embed_token
1765
+ @embed_token ||= data['embedToken'] ? DeckEmbedToken.new(data['embedToken'], client: client) : nil
1766
+ end
1767
+ end
1768
+
1769
+ class DeckAccessTokenIssuer < Resource
1770
+ def id = data['id']
1771
+ def deck_id = data['deckId']
1772
+ def api_application_id = data['apiApplicationId']
1773
+ def label = data['label']
1774
+ def read_modes = data['readModes'] || []
1775
+ def max_token_lifetime_seconds = data['maxTokenLifetimeSeconds']
1776
+ def direct_signing_alg = data['directSigningAlg']
1777
+ def direct_signing_key_id = data['directSigningKeyId']
1778
+ def direct_signing_public_key = data['directSigningPublicKey']
1779
+ def direct_signing_key_revoked_at = parse_time(data['directSigningKeyRevokedAt'])
1780
+ def revoked_at = parse_time(data['revokedAt'])
1781
+ def created_at = parse_time(data['createdAt'])
1782
+ def updated_at = parse_time(data['updatedAt'])
1783
+ end
1784
+
1785
+ class DeckAccessToken < Resource
1786
+ def id = data['id']
1787
+ def deck_id = data['deckId']
1788
+ def api_application_id = data['apiApplicationId']
1789
+ def issuer_id = data['issuerId']
1790
+ def read_mode = data['readMode']
1791
+ def external_subject = data['externalSubject']
1792
+ def expires_at = parse_time(data['expiresAt'])
1793
+ def revoked_at = parse_time(data['revokedAt'])
1794
+ def last_used_at = parse_time(data['lastUsedAt'])
1795
+ def created_at = parse_time(data['createdAt'])
1796
+ def updated_at = parse_time(data['updatedAt'])
1797
+ end
1798
+
1799
+ class DeckAccessTokenExchangePayload < Resource
1800
+ def token = data['token']
1801
+
1802
+ def access_token
1803
+ @access_token ||= data['accessToken'] ? DeckAccessToken.new(data['accessToken'], client: client) : nil
1804
+ end
1805
+ end
1806
+
1807
+ class DeckSectionDefinition < Resource
1808
+ def key = data['key']
1809
+ def label = data['label']
1810
+ def description = data['description']
1811
+ def order = data['order']
1812
+ def default? = !!data['default']
1813
+ def aliases = data['aliases'] || []
1814
+ def min_cards = data['minCards']
1815
+ def max_cards = data['maxCards']
1816
+ def excluded_from_deck_size? = !!data['excludedFromDeckSize']
1817
+ def legal_card_types = data['legalCardTypes'] || []
1818
+ def metadata = data['metadata'] || {}
1819
+ end
1820
+
1821
+ class DeckValidatedAgainst < Resource
1822
+ def ruleset_id = data['rulesetId']
1823
+ def ruleset_version_id = data['rulesetVersionId']
1824
+ def ruleset_version_label = data['rulesetVersionLabel']
1825
+ def card_dataset_id = data['cardDatasetId']
1826
+ def card_dataset_version_id = data['cardDatasetVersionId']
1827
+ def validated_at = parse_time(data['validatedAt'])
1828
+ def validation_result_summary = data['validationResultSummary'] || {}
1829
+ end
1830
+
1831
+ class DeckValidationIssue < Resource
1832
+ def code = data['code']
1833
+ def severity = data['severity']
1834
+ def message = data['message']
1835
+ def entry_ids = data['entryIds'] || []
1836
+ def section = data['section']
1837
+ def dataset_id = data['datasetId']
1838
+ def identifier = data['identifier']
1839
+ def metadata = data['metadata'] || {}
1840
+ end
1841
+
1842
+ class DeckValidationAffectedEntry < Resource
1843
+ def entry_id = data['entryId']
1844
+ def dataset_id = data['datasetId']
1845
+ def record_id = data['recordId']
1846
+ def identifier = data['identifier']
1847
+ def section = data['section']
1848
+ def quantity = data['quantity']
1849
+ end
1850
+
1851
+ class DeckValidation < Resource
1852
+ def deck_id = data['deckId']
1853
+ def valid? = !!data['valid']
1854
+ def checked_at = parse_time(data['checkedAt'])
1855
+
1856
+ def blockers
1857
+ @blockers ||= (data['blockers'] || []).map { |issue| DeckValidationIssue.new(issue, client: client) }
1858
+ end
1859
+
1860
+ def warnings
1861
+ @warnings ||= (data['warnings'] || []).map { |issue| DeckValidationIssue.new(issue, client: client) }
1862
+ end
1863
+
1864
+ def affected_entries
1865
+ @affected_entries ||= (data['affectedEntries'] || []).map do |entry|
1866
+ DeckValidationAffectedEntry.new(entry, client: client)
1867
+ end
1868
+ end
1869
+
1870
+ def validated_against
1871
+ @validated_against ||= DeckValidatedAgainst.new(data['validatedAgainst'], client: client)
1872
+ end
1873
+ end
1874
+
1875
+ class DeckDiff < Resource
1876
+ def deck_id = data['deckId']
1877
+ def from_version_id = data['fromVersionId']
1878
+ def to_version_id = data['toVersionId']
1879
+ def to_draft_revision = data['toDraftRevision']
1880
+ def changes? = !!data['hasChanges']
1881
+ def diff = data['diff'] || {}
1882
+ end
1883
+
1884
+ class DeckPublishPayload < Resource
1885
+ def deck
1886
+ @deck ||= Deck.new(data['deck'], client: client)
1887
+ end
1888
+
1889
+ def version
1890
+ @version ||= data['version'] ? DeckVersion.new(data['version'], client: client) : nil
1891
+ end
1892
+
1893
+ def validation
1894
+ @validation ||= DeckValidation.new(data['validation'], client: client)
1895
+ end
1896
+
1897
+ def blockers
1898
+ @blockers ||= (data['blockers'] || []).map { |issue| DeckValidationIssue.new(issue, client: client) }
1899
+ end
1900
+
1901
+ def warnings
1902
+ @warnings ||= (data['warnings'] || []).map { |issue| DeckValidationIssue.new(issue, client: client) }
1903
+ end
1904
+ end
1905
+
1906
+ class DeckEntryMutationPayload < Resource
1907
+ def deck
1908
+ @deck ||= Deck.new(data['deck'], client: client)
1909
+ end
1910
+
1911
+ def entry
1912
+ @entry ||= data['entry'] ? DeckEntry.new(data['entry'], client: client) : nil
1913
+ end
1914
+ end
1915
+
1916
+ class DeckEntryReorderPayload < Resource
1917
+ def deck
1918
+ @deck ||= Deck.new(data['deck'], client: client)
1919
+ end
1920
+
1921
+ def entries
1922
+ @entries ||= (data['entries'] || []).map { |entry| DeckEntry.new(entry, client: client) }
1923
+ end
1924
+ end
1925
+
1926
+ class DeckEntriesReplacePayload < DeckEntryReorderPayload; end
1927
+
1928
+ class DeckUpsertByExternalRefPayload < Resource
1929
+ def deck
1930
+ @deck ||= Deck.new(data['deck'], client: client)
1931
+ end
1932
+
1933
+ def created? = !!data['created']
1934
+ def idempotent_replay? = !!data['idempotentReplay']
1935
+ end
1936
+
1937
+ class DeckImportEntry < Resource
1938
+ def line_number = data['lineNumber']
1939
+ def raw = data['raw']
1940
+ def dataset_key = data['datasetKey']
1941
+ def dataset_id = data['datasetId']
1942
+ def record_id = data['recordId']
1943
+ def identifier = data['identifier']
1944
+ def quantity = data['quantity']
1945
+ def section = data['section']
1946
+ def sort_order = data['sortOrder']
1947
+ def display = data['display'] || {}
1948
+
1949
+ def record
1950
+ @record ||= data['record'] ? Record.new(data['record'], client: client) : nil
1951
+ end
1952
+ end
1953
+
1954
+ class DeckImportIssue < Resource
1955
+ def line_number = data['lineNumber']
1956
+ def raw = data['raw']
1957
+ def code = data['code']
1958
+ def message = data['message']
1959
+ end
1960
+
1961
+ class DeckImportUnmatchedEntry < DeckImportIssue
1962
+ def dataset_key = data['datasetKey']
1963
+ def identifier = data['identifier']
1964
+ def quantity = data['quantity']
1965
+ def section = data['section']
1966
+ end
1967
+
1968
+ class DeckImportCandidate < Resource
1969
+ def record_id = data['recordId']
1970
+ def identifier = data['identifier']
1971
+ def display = data['display'] || {}
1972
+ end
1973
+
1974
+ class DeckImportAmbiguousEntry < Resource
1975
+ def line_number = data['lineNumber']
1976
+ def raw = data['raw']
1977
+ def dataset_key = data['datasetKey']
1978
+ def identifier = data['identifier']
1979
+ def quantity = data['quantity']
1980
+ def section = data['section']
1981
+
1982
+ def candidates
1983
+ @candidates ||= (data['candidates'] || []).map { |candidate| DeckImportCandidate.new(candidate, client: client) }
1984
+ end
1985
+ end
1986
+
1987
+ class DeckImportFormatDefinition < Resource
1988
+ def id = data['id']
1989
+ def game_id = data['gameId']
1990
+ def key = data['key']
1991
+ def name = data['name']
1992
+ def description = data['description']
1993
+ def enabled? = !!data['enabled']
1994
+ def priority = data['priority']
1995
+ def dataset_key = data['datasetKey']
1996
+ def config = data['config'] || {}
1997
+ def archived_at = parse_time(data['archivedAt'])
1998
+ def archived? = !!data['isArchived']
1999
+ def created_at = parse_time(data['createdAt'])
2000
+ def updated_at = parse_time(data['updatedAt'])
2001
+ end
2002
+
2003
+ class DeckImportFormatDetection < Resource
2004
+ def format_id = data['formatId']
2005
+ def key = data['key']
2006
+ def name = data['name']
2007
+ def confidence = data['confidence']
2008
+ def reason = data['reason']
2009
+ end
2010
+
2011
+ class DeckHydrateEntriesPayload < Resource
2012
+ def entries
2013
+ @entries ||= (data['entries'] || []).map { |entry| DeckImportEntry.new(entry, client: client) }
2014
+ end
2015
+
2016
+ def unmatched
2017
+ @unmatched ||= (data['unmatched'] || []).map { |entry| DeckImportUnmatchedEntry.new(entry, client: client) }
2018
+ end
2019
+
2020
+ def ambiguous
2021
+ @ambiguous ||= (data['ambiguous'] || []).map { |entry| DeckImportAmbiguousEntry.new(entry, client: client) }
2022
+ end
2023
+ end
2024
+
2025
+ class DeckImportFormatTestPayload < DeckHydrateEntriesPayload
2026
+ def detection
2027
+ @detection ||= data['detection'] ? DeckImportFormatDetection.new(data['detection'], client: client) : nil
2028
+ end
2029
+
2030
+ def parse_errors
2031
+ @parse_errors ||= (data['parseErrors'] || []).map { |issue| DeckImportIssue.new(issue, client: client) }
2032
+ end
2033
+ end
2034
+
2035
+ class DeckImportPayload < DeckHydrateEntriesPayload
2036
+ def deck
2037
+ @deck ||= data['deck'] ? Deck.new(data['deck'], client: client) : nil
2038
+ end
2039
+
2040
+ def applied? = !!data['applied']
2041
+ def dry_run? = !!data['dryRun']
2042
+ def replace? = !!data['replace']
2043
+ def format = data['format']
2044
+
2045
+ def import_format
2046
+ @import_format ||= data['importFormat'] ? DeckImportFormatDefinition.new(data['importFormat'], client: client) : nil
2047
+ end
2048
+
2049
+ def detection
2050
+ @detection ||= data['detection'] ? DeckImportFormatDetection.new(data['detection'], client: client) : nil
2051
+ end
2052
+
2053
+ def parse_errors
2054
+ @parse_errors ||= (data['parseErrors'] || []).map { |issue| DeckImportIssue.new(issue, client: client) }
2055
+ end
2056
+
2057
+ def validation
2058
+ @validation ||= data['validation'] ? DeckValidation.new(data['validation'], client: client) : nil
2059
+ end
2060
+ end
2061
+
2062
+ class DeckExportPayload < Resource
2063
+ def deck_id = data['deckId']
2064
+ def format = data['format']
2065
+ def text = data['text']
2066
+ def entry_count = data['entryCount']
2067
+ end
2068
+
1052
2069
  # Wrapper for hosted DeckEntry objects
1053
2070
  class DeckEntry < Resource
1054
2071
  def id
@@ -1083,6 +2100,10 @@ module CardDB
1083
2100
  data['annotations'] || {}
1084
2101
  end
1085
2102
 
2103
+ def display
2104
+ data['display'] || {}
2105
+ end
2106
+
1086
2107
  def record
1087
2108
  @record ||= data['record'] ? Record.new(data['record'], client: client) : nil
1088
2109
  end