Skip to content

Commit 17e5239

Browse files
authored
Merge pull request #76 from JaviCerveraIngram/CPS-59-accept-null
Cps 59 accept null
2 parents e4e91f0 + da6c373 commit 17e5239

File tree

4 files changed

+124
-88
lines changed

4 files changed

+124
-88
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Connect SDK Changes History
22

3+
## v17.3
4+
5+
* HTTP timeout request to Connect platform should be not less than 300 seconds.
6+
* Accept Usage File is sending wrong parameter in post request.
7+
* Usage processor filter "product__id" is not filtering by product id.
8+
* All fields accept null to avoid parsing errors.
9+
10+
## v17.2
11+
12+
* external_id is sometimes returned as an integer by Connect API, which breaks Python SDK parsing.
13+
14+
## v17.1
15+
16+
* Add custom loggers to the automation classes, that automatically add relevant info of the request being processed. Legacy global logger still working in order to have a context-independent logger.
17+
* Get product templates and configuration params.
18+
* Put each model in its own Python file, to reduce the chance of having circular references on imports.
19+
* Tier requests are not filtering by product id by default.
20+
* Fulfillment assignee not receiving the right type.
21+
322
## v17.0
423

524
* Fixed bugs when listing and working with usage files.

connect/models/asset.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .configuration import Configuration
1010
from .connection import Connection
1111
from .contract import Contract
12+
from .events import Events
1213
from .item import Item
1314
from .marketplace import Marketplace
1415
from .param import Param
@@ -57,6 +58,9 @@ class Asset(BaseModel):
5758
- suspended: Asset becomes suspended once 'suspend' request type is fulfilled.
5859
"""
5960

61+
events = None # type: Events
62+
""" (:py:class:`.Events`) Events occurred on this asset. """
63+
6064
external_id = None # type: str
6165
""" (str) Identification for asset object on eCommerce. """
6266

connect/models/schemas.py

Lines changed: 86 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
class BaseSchema(Schema):
1111
id = fields.Str()
1212

13+
# Set allow_none to True in all fields
14+
def on_bind_field(self, field_name, field_obj):
15+
super(BaseSchema, self).on_bind_field(field_name, field_obj)
16+
field_obj.allow_none = True
17+
1318
@post_load
1419
def make_object(self, data):
1520
from connect.models import BaseModel
1621
return BaseModel(**data)
1722

1823

1924
class ActivationSchema(BaseSchema):
20-
link = fields.Str(allow_none=True)
25+
link = fields.Str()
2126
message = fields.Str()
22-
date = fields.DateTime(allow_none=True)
27+
date = fields.DateTime()
2328

2429
@post_load
2530
def make_object(self, data):
@@ -28,7 +33,7 @@ def make_object(self, data):
2833

2934

3035
class AgreementStatsSchema(BaseSchema):
31-
contracts = fields.Int(allow_none=True)
36+
contracts = fields.Int()
3237
versions = fields.Int()
3338

3439
@post_load
@@ -47,10 +52,10 @@ def make_object(self, data):
4752

4853

4954
class PhoneNumberSchema(BaseSchema):
50-
country_code = fields.Str(allow_none=True)
51-
area_code = fields.Str(allow_none=True)
52-
phone_number = fields.Str(allow_none=True)
53-
extension = fields.Str(allow_none=True)
55+
country_code = fields.Str()
56+
area_code = fields.Str()
57+
phone_number = fields.Str()
58+
extension = fields.Str()
5459

5560
@post_load
5661
def make_object(self, data):
@@ -60,8 +65,8 @@ def make_object(self, data):
6065

6166
class ContactSchema(BaseSchema):
6267
email = fields.Str()
63-
first_name = fields.Str(allow_none=True)
64-
last_name = fields.Str(allow_none=True)
68+
first_name = fields.Str()
69+
last_name = fields.Str()
6570
phone_number = fields.Nested(PhoneNumberSchema)
6671

6772
@post_load
@@ -72,12 +77,12 @@ def make_object(self, data):
7277

7378
class ContactInfoSchema(BaseSchema):
7479
address_line1 = fields.Str()
75-
address_line2 = fields.Str(allow_none=True)
80+
address_line2 = fields.Str()
7681
city = fields.Str()
7782
contact = fields.Nested(ContactSchema)
7883
country = fields.Str()
7984
postal_code = fields.Str()
80-
state = fields.Str(allow_none=True)
85+
state = fields.Str()
8186

8287
@post_load
8388
def make_object(self, data):
@@ -130,7 +135,7 @@ def make_object(self, data):
130135

131136
class UserSchema(BaseSchema):
132137
name = fields.Str()
133-
email = fields.Str(allow_none=True)
138+
email = fields.Str()
134139

135140
@post_load
136141
def make_object(self, data):
@@ -139,8 +144,8 @@ def make_object(self, data):
139144

140145

141146
class EventSchema(BaseSchema):
142-
at = fields.DateTime(allow_none=True)
143-
by = fields.Nested(UserSchema, allow_none=True)
147+
at = fields.DateTime()
148+
by = fields.Nested(UserSchema)
144149

145150
@post_load
146151
def make_object(self, data):
@@ -189,7 +194,7 @@ def make_object(self, data):
189194
class HubSchema(BaseSchema):
190195
name = fields.Str()
191196
company = fields.Nested(CompanySchema)
192-
description = fields.Str(allow_none=True)
197+
description = fields.Str()
193198
instance = fields.Nested(HubInstanceSchema)
194199
events = fields.Nested(EventsSchema)
195200
stats = fields.Nested(HubStatsSchema)
@@ -282,19 +287,19 @@ class ParamSchema(BaseSchema):
282287
name = fields.Str()
283288
description = fields.Str()
284289
type = fields.Str()
285-
value = fields.Str(allow_none=True)
286-
value_error = fields.Str(allow_none=True)
287-
value_choice = fields.Str(many=True, allow_none=True)
290+
value = fields.Str()
291+
value_error = fields.Str()
292+
value_choice = fields.Str(many=True)
288293

289294
# Undocumented fields (they appear in PHP SDK)
290-
title = fields.Str(allow_none=True)
291-
scope = fields.Str(allow_none=True)
292-
constraints = fields.Nested(ConstraintsSchema, allow_none=True)
293-
value_choices = fields.Nested(ValueChoiceSchema, many=True, allow_none=True)
294-
phase = fields.Str(allow_none=True)
295-
events = fields.Nested(EventsSchema, allow_none=True)
296-
marketplace = fields.Nested(MarketplaceSchema, allow_none=True)
297-
countries = fields.Nested(CountrySchema, many=True, allow_none=True)
295+
title = fields.Str()
296+
scope = fields.Str()
297+
constraints = fields.Nested(ConstraintsSchema)
298+
value_choices = fields.Nested(ValueChoiceSchema, many=True)
299+
phase = fields.Str()
300+
events = fields.Nested(EventsSchema)
301+
marketplace = fields.Nested(MarketplaceSchema)
302+
countries = fields.Nested(CountrySchema, many=True)
298303

299304
@post_load
300305
def make_object(self, data):
@@ -305,15 +310,15 @@ def make_object(self, data):
305310
class ItemSchema(BaseSchema):
306311
mpn = fields.Str()
307312
quantity = QuantityField()
308-
old_quantity = QuantityField(allow_none=True)
309-
renewal = fields.Nested(RenewalSchema, allow_none=True)
310-
params = fields.Nested(ParamSchema, many=True, allow_none=True)
311-
display_name = fields.Str(allow_none=True)
312-
global_id = fields.Str(allow_none=True)
313-
item_type = fields.Str(allow_none=True)
314-
period = fields.Str(allow_none=True)
315-
type = fields.Str(allow_none=True)
316-
name = fields.Str(allow_none=True)
313+
old_quantity = QuantityField()
314+
renewal = fields.Nested(RenewalSchema)
315+
params = fields.Nested(ParamSchema, many=True)
316+
display_name = fields.Str()
317+
global_id = fields.Str()
318+
item_type = fields.Str()
319+
period = fields.Str()
320+
type = fields.Str()
321+
name = fields.Str()
317322

318323
@post_load
319324
def make_object(self, data):
@@ -328,17 +333,17 @@ class AgreementSchema(BaseSchema):
328333
created = fields.DateTime()
329334
updated = fields.DateTime()
330335
owner = fields.Nested(CompanySchema)
331-
stats = fields.Nested(AgreementStatsSchema, allow_none=True)
332-
author = fields.Nested(UserSchema, allow_none=True)
336+
stats = fields.Nested(AgreementStatsSchema)
337+
author = fields.Nested(UserSchema)
333338
version = fields.Int()
334339
active = fields.Bool()
335340
link = fields.Str()
336341
version_created = fields.DateTime()
337342
version_contracts = fields.Int()
338343
agreements = fields.Nested('AgreementSchema', many=True)
339-
parent = fields.Nested('AgreementSchema', only=('id', 'name'), allow_none=True)
340-
marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name'), allow_none=True)
341-
name = fields.Str(allow_none=True)
344+
parent = fields.Nested('AgreementSchema', only=('id', 'name'))
345+
marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name'))
346+
name = fields.Str()
342347

343348
@post_load
344349
def make_object(self, data):
@@ -352,15 +357,15 @@ class ContractSchema(BaseSchema):
352357
type = fields.Str()
353358
status = fields.Str()
354359
agreement = fields.Nested(AgreementSchema, only=('id', 'name'))
355-
marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name'), allow_none=True)
356-
owner = fields.Nested(CompanySchema, only=('id', 'name'), allow_none=True)
360+
marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name'))
361+
owner = fields.Nested(CompanySchema, only=('id', 'name'))
357362
creator = fields.Nested(UserSchema, only=('id', 'name'))
358363
created = fields.DateTime()
359364
updated = fields.DateTime()
360-
enrolled = fields.DateTime(allow_none=True)
365+
enrolled = fields.DateTime()
361366
version_created = fields.DateTime()
362367
activation = fields.Nested(ActivationSchema)
363-
signee = fields.Nested(UserSchema, only=('id', 'name'), allow_none=True)
368+
signee = fields.Nested(UserSchema, only=('id', 'name'))
364369

365370
@post_load
366371
def make_object(self, data):
@@ -401,9 +406,9 @@ def make_object(self, data):
401406

402407
class ProductCategorySchema(BaseSchema):
403408
name = fields.Str()
404-
parent = fields.Nested('ProductCategorySchema', allow_none=True)
405-
children = fields.Nested('ProductCategorySchema', many=True, allow_none=True)
406-
family = fields.Nested(ProductFamilySchema, allow_none=True)
409+
parent = fields.Nested('ProductCategorySchema')
410+
children = fields.Nested('ProductCategorySchema', many=True)
411+
family = fields.Nested(ProductFamilySchema)
407412

408413
@post_load
409414
def make_object(self, data):
@@ -433,12 +438,12 @@ def make_object(self, data):
433438

434439

435440
class ProductConfigurationParameterSchema(BaseSchema):
436-
value = fields.Str(allow_none=True)
441+
value = fields.Str()
437442
parameter = fields.Nested(ParamSchema)
438-
marketplace = fields.Nested(MarketplaceSchema, allow_none=True)
439-
item = fields.Nested(ItemSchema, allow_none=True)
443+
marketplace = fields.Nested(MarketplaceSchema)
444+
item = fields.Nested(ItemSchema)
440445
events = fields.Nested(EventsSchema)
441-
constraints = fields.Nested(ConstraintsSchema, allow_none=True)
446+
constraints = fields.Nested(ConstraintsSchema)
442447

443448
@post_load
444449
def make_object(self, data):
@@ -452,13 +457,13 @@ class ProductSchema(BaseSchema):
452457
short_description = fields.Str()
453458
detailed_description = fields.Str()
454459
version = fields.Int()
455-
published_at = fields.DateTime(allow_none=True)
460+
published_at = fields.DateTime()
456461
configurations = fields.Nested(ProductConfigurationSchema)
457462
customer_ui_settings = fields.Nested(CustomerUiSettingsSchema)
458-
category = fields.Nested(ProductCategorySchema, allow_none=True)
459-
owner = fields.Nested(CompanySchema, allow_none=True)
460-
latest = fields.Bool(allow_none=True)
461-
stats = fields.Nested(ProductStatsSchema, allow_none=True)
463+
category = fields.Nested(ProductCategorySchema)
464+
owner = fields.Nested(CompanySchema)
465+
latest = fields.Bool()
466+
stats = fields.Nested(ProductStatsSchema)
462467

463468
@post_load
464469
def make_object(self, data):
@@ -468,8 +473,8 @@ def make_object(self, data):
468473

469474
class ServerErrorResponseSchema(Schema):
470475
error_code = fields.Str()
471-
params = fields.Dict(allow_none=True)
472-
errors = fields.List(fields.Str())
476+
params = fields.Dict()
477+
errors = fields.Str(many=True)
473478

474479
@post_load
475480
def make_object(self, data):
@@ -511,8 +516,8 @@ def make_object(self, data):
511516

512517
class TierAccountsSchema(Schema):
513518
customer = fields.Nested(TierAccountSchema)
514-
tier1 = fields.Nested(TierAccountSchema, allow_none=True)
515-
tier2 = fields.Nested(TierAccountSchema, allow_none=True)
519+
tier1 = fields.Nested(TierAccountSchema)
520+
tier2 = fields.Nested(TierAccountSchema)
516521

517522
@post_load
518523
def make_object(self, data):
@@ -536,18 +541,19 @@ def make_object(self, data):
536541
class AssetSchema(BaseSchema):
537542
status = fields.Str()
538543
external_id = ExternalIdField()
539-
external_uid = fields.Str(allow_none=True)
540-
external_name = fields.Str(allow_none=True)
544+
events = fields.Nested(EventsSchema)
545+
external_uid = fields.Str()
546+
external_name = fields.Str()
541547
product = fields.Nested(ProductSchema, only=('id', 'name'))
542548
connection = fields.Nested(
543-
ConnectionSchema, only=('id', 'type', 'provider', 'vendor'),
549+
ConnectionSchema, only=('id', 'type', 'provider', 'vendor')
544550
)
545-
contract = fields.Nested(ContractSchema, allow_none=True)
546-
marketplace = fields.Nested(MarketplaceSchema, allow_none=True)
551+
contract = fields.Nested(ContractSchema)
552+
marketplace = fields.Nested(MarketplaceSchema)
547553
params = fields.Nested(ParamSchema, many=True)
548554
tiers = fields.Nested(TierAccountsSchema)
549555
items = fields.Nested(ItemSchema, many=True)
550-
configuration = fields.Nested(ConfigurationSchema, allow_none=True)
556+
configuration = fields.Nested(ConfigurationSchema)
551557

552558
@post_load
553559
def make_object(self, data):
@@ -576,7 +582,7 @@ class FulfillmentSchema(BaseSchema):
576582
asset = fields.Nested(AssetSchema)
577583
contract = fields.Nested(ContractSchema, only=('id', 'name'))
578584
marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name'))
579-
assignee = AssigneeField(allow_none=True)
585+
assignee = AssigneeField()
580586

581587
@post_load
582588
def make_object(self, data):
@@ -591,13 +597,13 @@ class TierConfigSchema(BaseSchema):
591597
tier_level = fields.Int()
592598
params = fields.Nested(ParamSchema, many=True)
593599
connection = fields.Nested(ConnectionSchema)
594-
open_request = fields.Nested(BaseSchema, allow_none=True)
600+
open_request = fields.Nested(BaseSchema)
595601
template = fields.Nested(TemplateSchema)
596602
contract = fields.Nested(ContractSchema)
597603
marketplace = fields.Nested(MarketplaceSchema)
598-
configuration = fields.Nested(ConfigurationSchema, allow_none=True)
599-
events = fields.Nested(EventsSchema, allow_none=True)
600-
status = fields.Str(allow_none=True)
604+
configuration = fields.Nested(ConfigurationSchema)
605+
events = fields.Nested(EventsSchema)
606+
status = fields.Str()
601607

602608
@post_load
603609
def make_object(self, data):
@@ -615,15 +621,15 @@ class TierConfigRequestSchema(BaseSchema):
615621
tier_level = fields.Int()
616622
params = fields.Nested(ParamSchema, many=True)
617623
environment = fields.Str()
618-
assignee = fields.Nested(UserSchema, allow_none=True)
619-
template = fields.Nested(TemplateSchema, allow_none=True)
620-
reason = fields.Str(allow_none=True)
621-
activation = fields.Nested(ActivationSchema, allow_none=True)
622-
notes = fields.Str(allow_none=True)
623-
events = fields.Nested(EventsSchema, allow_none=True)
624-
tiers = fields.Nested(TierAccountsSchema, allow_none=True)
625-
marketplace = fields.Nested(MarketplaceSchema, allow_none=True)
626-
contract = fields.Nested(ContractSchema, allow_none=True)
624+
assignee = fields.Nested(UserSchema)
625+
template = fields.Nested(TemplateSchema)
626+
reason = fields.Str()
627+
activation = fields.Nested(ActivationSchema)
628+
notes = fields.Str()
629+
events = fields.Nested(EventsSchema)
630+
tiers = fields.Nested(TierAccountsSchema)
631+
marketplace = fields.Nested(MarketplaceSchema)
632+
contract = fields.Nested(ContractSchema)
627633

628634
@post_load
629635
def make_object(self, data):

0 commit comments

Comments
 (0)