Skip to content

Commit 212e28c

Browse files
committed
add marketcontext, pass first test
1 parent f279e96 commit 212e28c

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

openleadr/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import logging
2020
import ssl
2121
from datetime import datetime, timedelta, timezone
22+
from dataclasses import asdict
2223
from functools import partial
2324
from http import HTTPStatus
2425

@@ -622,7 +623,8 @@ async def create_opt(self, opt_type, opt_reason, targets, vavailability=None, ev
622623
vavailability=vavailability,
623624
event_id=event_id,
624625
modification_number=modification_number,
625-
targets=targets
626+
targets=targets,
627+
market_context=market_context
626628
)
627629
self.opts.append(opt)
628630

@@ -631,7 +633,7 @@ async def create_opt(self, opt_type, opt_reason, targets, vavailability=None, ev
631633
payload = {
632634
'request_id': request_id,
633635
'ven_id': self.ven_id,
634-
**opt
636+
**asdict(opt)
635637
}
636638

637639
service = 'EiOpt'
@@ -640,7 +642,7 @@ async def create_opt(self, opt_type, opt_reason, targets, vavailability=None, ev
640642

641643
if 'opt_id' in response_payload:
642644
# VTN acknowledged the opt message
643-
return response_payload['opt-id']
645+
return response_payload['opt_id']
644646

645647
# TODO: what to do if the VTN sends an error or does not acknowledge the opt?
646648

openleadr/objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class Opt:
345345
vavailability: Vavailability = None
346346
targets: List[Target] = None
347347
targets_by_type: Dict = None
348+
market_context: str = None
348349

349350
def __post_init__(self):
350351
if self.opt_type not in enums.OPT.values:
@@ -367,7 +368,7 @@ def __post_init__(self):
367368
if self.targets is None and self.targets_by_type is None:
368369
raise ValueError(
369370
"You must supply either 'targets' or 'targets_by_type'.")
370-
elif self.targets_by_type is None:
371+
if self.targets_by_type is None:
371372
list_of_targets = [asdict(target) if is_dataclass(
372373
target) else target for target in self.targets]
373374
self.targets_by_type = utils.group_targets_by_type(list_of_targets)

0 commit comments

Comments
 (0)