|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +This file is part of the Ingram Micro Cloud Blue Connect SDK. |
| 5 | +Copyright (c) 2019 Ingram Micro. All Rights Reserved. |
| 6 | +""" |
| 7 | +from marshmallow import fields, post_load |
| 8 | + |
| 9 | +from connect.models.base import BaseModel, BaseSchema |
| 10 | +from connect.models.company import Company, CompanySchema |
| 11 | +from connect.models.marketplace import Contract, Marketplace, ContractSchema, MarketplaceSchema |
| 12 | +from connect.models.product import Product, ProductSchema |
| 13 | + |
| 14 | + |
| 15 | +class Records(BaseModel): |
| 16 | + valid = None # type: int |
| 17 | + invalid = None # type: int |
| 18 | + |
| 19 | + |
| 20 | +class File(BaseModel): |
| 21 | + name = None # type: str |
| 22 | + description = None # type: str |
| 23 | + note = None # type: str |
| 24 | + status = None # type: str |
| 25 | + created_by = None # type: str |
| 26 | + created_at = None # type: str |
| 27 | + product = None # type: Product |
| 28 | + contract = None # type: Contract |
| 29 | + marketplace = None # type: Marketplace |
| 30 | + vendor = None # type: Company |
| 31 | + provider = None # type: Company |
| 32 | + upload_file_uri = None # type: str |
| 33 | + processed_file_uri = None # type: str |
| 34 | + acceptance_note = None # type: str |
| 35 | + rejection_note = None # type: str |
| 36 | + error_detail = None # type: str |
| 37 | + records = None # type: Records |
| 38 | + uploaded_by = None # type: str |
| 39 | + uploaded_at = None # type: str |
| 40 | + submitted_by = None # type: str |
| 41 | + submitted_at = None # type: str |
| 42 | + accepted_by = None # type: str |
| 43 | + accepted_at = None # type: str |
| 44 | + rejected_by = None # type: str |
| 45 | + rejected_at = None # type: str |
| 46 | + closed_by = None # type: str |
| 47 | + closed_at = None # type: str |
| 48 | + |
| 49 | + |
| 50 | +class Listing(BaseModel): |
| 51 | + status = None # type: str |
| 52 | + contract = None # type: Contract |
| 53 | + product = None # type: Product |
| 54 | + created = None # type: str |
| 55 | + |
| 56 | + # Undocumented fields (they appear in PHP SDK) |
| 57 | + vendor = None # type: Company |
| 58 | + provider = None # type: Company |
| 59 | + |
| 60 | + |
| 61 | +class FileUsageRecord(BaseModel): |
| 62 | + record_id = None # type: str |
| 63 | + item_search_criteria = None # type: str |
| 64 | + item_search_value = None # type: str |
| 65 | + quantity = None # type: int |
| 66 | + start_time_utc = None # type: str |
| 67 | + end_time_utc = None # type: str |
| 68 | + asset_search_criteria = None # type: str |
| 69 | + asset_search_value = None # type: str |
| 70 | + |
| 71 | + |
| 72 | +class RecordsSchema(BaseSchema): |
| 73 | + valid = fields.Int() |
| 74 | + invalid = fields.Int() |
| 75 | + |
| 76 | + @post_load |
| 77 | + def make_object(self, data): |
| 78 | + return Records(**data) |
| 79 | + |
| 80 | + |
| 81 | +class FileSchema(BaseSchema): |
| 82 | + name = fields.Str() |
| 83 | + description = fields.Str() |
| 84 | + note = fields.Str() |
| 85 | + status = fields.Str() |
| 86 | + created_by = fields.Str() |
| 87 | + created_at = fields.Str() |
| 88 | + product = fields.Nested(ProductSchema) |
| 89 | + contract = fields.Nested(ContractSchema) |
| 90 | + marketplace = fields.Nested(MarketplaceSchema) |
| 91 | + vendor = fields.Nested(CompanySchema) |
| 92 | + provider = fields.Nested(CompanySchema) |
| 93 | + upload_file_uri = fields.Str() |
| 94 | + processed_file_uri = fields.Str() |
| 95 | + acceptance_note = fields.Str() |
| 96 | + rejection_note = fields.Str() |
| 97 | + error_detail = fields.Str() |
| 98 | + records = fields.Nested(RecordsSchema) |
| 99 | + uploaded_by = fields.Str() |
| 100 | + uploaded_at = fields.Str() |
| 101 | + submitted_by = fields.Str() |
| 102 | + submitted_at = fields.Str() |
| 103 | + accepted_by = fields.Str() |
| 104 | + accepted_at = fields.Str() |
| 105 | + rejected_by = fields.Str() |
| 106 | + rejected_at = fields.Str() |
| 107 | + closed_by = fields.Str() |
| 108 | + closed_at = fields.Str() |
| 109 | + |
| 110 | + @post_load |
| 111 | + def make_object(self, data): |
| 112 | + return File(**data) |
| 113 | + |
| 114 | + |
| 115 | +class ListingSchema(BaseSchema): |
| 116 | + status = fields.Str() |
| 117 | + contract = fields.Nested(ContractSchema) |
| 118 | + product = fields.Nested(ProductSchema) |
| 119 | + created = fields.Str() |
| 120 | + |
| 121 | + # Undocumented fields (they appear in PHP SDK) |
| 122 | + vendor = fields.Nested(CompanySchema) |
| 123 | + provider = fields.Nested(CompanySchema) |
| 124 | + |
| 125 | + @post_load |
| 126 | + def make_object(self, data): |
| 127 | + return Listing(**data) |
| 128 | + |
| 129 | + |
| 130 | +class FileUsageRecordSchema(BaseSchema): |
| 131 | + record_id = fields.Str() |
| 132 | + item_search_criteria = fields.Str() |
| 133 | + item_search_value = fields.Str() |
| 134 | + quantity = fields.Int() |
| 135 | + start_time_utc = fields.Str() |
| 136 | + end_time_utc = fields.Str() |
| 137 | + asset_search_criteria = fields.Str() |
| 138 | + asset_search_value = fields.Str() |
| 139 | + |
| 140 | + @post_load |
| 141 | + def make_object(self, data): |
| 142 | + return FileUsageRecord(**data) |
0 commit comments