Skip to content

Commit

Permalink
Refactor messaging parameters and update function names
Browse files Browse the repository at this point in the history
This commit changes the handling of messaging parameters by making certain parameters mandatory and removing setter methods. It also modifies the function name from 'get_chunk_components' to 'get_chunk_component'. These changes aim to streamline how parameters are managed and improve the readability of the function names.
  • Loading branch information
saschadoemer committed Mar 12, 2024
1 parent 7bdb307 commit 2f6c5a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
53 changes: 19 additions & 34 deletions agrirouter/messaging/parameters/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ class SendMessageParameters(MessageParameters):
def __init__(self,
*,
onboarding_response: BaseOnboardingResponse,
technical_message_type: str = None,
technical_message_type: str,
recipients: list = None,
chunk_components: ChunkComponent = None,
base64_message_content: bytes = None,
chunk_component=None,
base64_message_content: bytes,
type_url: str = None,
chunk_size: int = None,
application_message_id: str = None,
application_message_seq_no: int = None,
mode=None
application_message_id: str,
application_message_seq_no: int,
mode
):
"""
onboarding_response: Onboarding response of the sender
Expand All @@ -127,58 +127,43 @@ def __init__(self,
application_message_seq_no=application_message_seq_no,
onboarding_response=onboarding_response)

# Initialise the instance variables with the provided values. If not provided, they can be set using the
# respective SET methods.
self._technical_message_type = technical_message_type
self._recipients = recipients
self._chunk_components = chunk_components,
self._base64_message_content = base64_message_content
self._type_url = type_url
self._chunk_size = chunk_size
self._mode = mode

if recipients:
self._recipients = recipients

if chunk_component:
self._chunk_component: ChunkComponent = chunk_component,
else:
self._chunk_component = None

if chunk_size:
self._chunk_size = chunk_size

def get_technical_message_type(self):
return self._technical_message_type

def set_technical_message_type(self, technical_message_type: str):
self._technical_message_type = technical_message_type

def get_recipients(self) -> list:
return self._recipients

def set_recipients(self, recipients: list):
self._recipients = recipients

def get_chunk_components(self) -> ChunkComponent:
return self._chunk_components

def set_chunk_components(self, chunk_components: ChunkComponent):
self._chunk_components = chunk_components
def get_chunk_component(self) -> ChunkComponent:
return self._chunk_component

def get_base64_message_content(self):
return self._base64_message_content

def set_base64_message_content(self, base64_message_content):
self._base64_message_content = base64_message_content

def get_type_url(self) -> str:
return self._type_url

def set_type_url(self, type_url):
self._type_url = type_url

def get_chunk_size(self) -> int:
return self._chunk_size

def set_chunk_size(self, chunk_size):
self._chunk_size = chunk_size

def get_mode(self):
return self._mode

def set_mode(self, mode):
self._mode = mode


class ChunkedMessageParameters(MessageParameters):
"""
Expand Down
2 changes: 1 addition & 1 deletion agrirouter/messaging/services/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def encode(parameters: SendMessageParameters) -> EncodedMessage:
team_set_context_id=parameters.get_team_set_context_id(),
application_message_seq_no=parameters.get_application_message_seq_no(),
recipients=parameters.get_recipients(),
chunk_component=parameters.get_chunk_components(),
chunk_component=parameters.get_chunk_component(),
application_message_id=parameters.get_application_message_id()
)

Expand Down

0 comments on commit 2f6c5a7

Please sign in to comment.