Coverage for src/integrify/lsim/bulk/handlers.py: 90%
31 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-09-01 02:22 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-09-01 02:22 +0000
1from integrify.api import APIPayloadHandler
2from integrify.lsim.bulk.schemas.request import (
3 GetBalanceRequestSchema,
4 GetBulkSMSDeatiledReportRequestSchema,
5 GetBulkSMSDeatiledWithDateReportRequestSchema,
6 GetBulkSMSReportRequestSchema,
7 SendBulkSMSDifferentMessagesRequestSchema,
8 SendBulkSMSOneMessageRequestSchema,
9)
10from integrify.lsim.bulk.schemas.response import (
11 GetBalanceResponseSchema,
12 GetBulkSMSDetailedReportResponseSchema,
13 GetBulkSMSReportResponseSchema,
14 SendBulkSMSResponseSchema,
15)
18class HeadOnlyPayloadHandler(APIPayloadHandler):
19 def post_handle_payload(self, data: dict):
20 return {'request': {'head': data}}
23class SendBulkSMSOneMessagePayloadHandler(APIPayloadHandler):
24 def __init__(self):
25 super().__init__(SendBulkSMSOneMessageRequestSchema, SendBulkSMSResponseSchema)
27 def post_handle_payload(self, data: dict):
28 msisdns = data.pop('msisdns')
30 return {'request': {'head': data, 'body': [{'msisdn': msisdn} for msisdn in msisdns]}}
33class SendBulkSMSDifferentMessagesPayloadHandler(APIPayloadHandler):
34 def __init__(self):
35 super().__init__(SendBulkSMSDifferentMessagesRequestSchema, SendBulkSMSResponseSchema)
37 def post_handle_payload(self, data: dict):
38 msisdns = data.pop('msisdns')
39 messages = data.pop('messages')
41 return {
42 'request': {
43 'head': data,
44 'body': [
45 {'msisdn': msisdn, 'message': message}
46 for msisdn, message in zip(msisdns, messages)
47 ],
48 }
49 }
52class GetBulkSMSReportPayloadHandler(HeadOnlyPayloadHandler):
53 def __init__(self):
54 super().__init__(GetBulkSMSReportRequestSchema, GetBulkSMSReportResponseSchema)
57class GetBulkSMSDeatiledReportPayloadHandler(HeadOnlyPayloadHandler):
58 def __init__(self):
59 super().__init__(
60 GetBulkSMSDeatiledReportRequestSchema,
61 GetBulkSMSDetailedReportResponseSchema,
62 )
65class GetBulkSMSDeatiledWithDateReportPayloadHandler(HeadOnlyPayloadHandler):
66 def __init__(self):
67 super().__init__(
68 GetBulkSMSDeatiledWithDateReportRequestSchema,
69 GetBulkSMSDetailedReportResponseSchema,
70 )
73class GetBalancePayloadHandler(HeadOnlyPayloadHandler):
74 def __init__(self):
75 super().__init__(GetBalanceRequestSchema, GetBalanceResponseSchema)