|
3 | 3 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
4 | 4 | from ..helpers import prefix, clean_empty, REMOVED
|
5 | 5 | from ..schema import (
|
6 |
| - LabelInput, |
7 | 6 | Address,
|
8 |
| - LabelOutput, |
9 | 7 | Auth,
|
10 |
| - Service, |
| 8 | + Label, |
| 9 | + LabelInput, |
| 10 | + LabelOutput, |
11 | 11 | Parcel,
|
12 | 12 | ParcelLabel,
|
13 |
| - Label, |
| 13 | + PickupSite, |
| 14 | + PickupSiteInput, |
| 15 | + PickupSiteOutput, |
| 16 | + PickupSiteSearch, |
| 17 | + Service, |
14 | 18 | )
|
15 | 19 | from .constants import SORTED_KEYS
|
16 | 20 | from hashlib import md5
|
@@ -154,6 +158,48 @@ def soap(self):
|
154 | 158 | )
|
155 | 159 |
|
156 | 160 |
|
| 161 | +class MondialRelayPickupSiteSearch(PickupSiteSearch): |
| 162 | + id: int | None = None |
| 163 | + weight: float | None = None |
| 164 | + action: str | None = None |
| 165 | + delay: int | None = None |
| 166 | + searchRadius: int | None = None |
| 167 | + actionType: str | None = None |
| 168 | + resultsCount: int | None = None |
| 169 | + |
| 170 | + def soap(self): |
| 171 | + return clean_empty( |
| 172 | + { |
| 173 | + "Pays": self.country, |
| 174 | + "NumPointRelais": self.id, |
| 175 | + "CP": self.zip, |
| 176 | + "Latitude": self.lat, |
| 177 | + "Longitude": self.lng, |
| 178 | + "Poids": self.weight, |
| 179 | + "Action": self.action, |
| 180 | + "DelaiEnvoi": self.delay, |
| 181 | + "RayonRecherche": self.searchRadius, |
| 182 | + "TypeActivite": self.actionType, |
| 183 | + "NombreResultats": self.resultsCount, |
| 184 | + } |
| 185 | + ) |
| 186 | + |
| 187 | + |
| 188 | +class MondialRelayPickupSiteInput(PickupSiteInput): |
| 189 | + auth: MondialRelayAuth |
| 190 | + search: MondialRelayPickupSiteSearch |
| 191 | + |
| 192 | + def soap(self): |
| 193 | + return self.auth.sign( |
| 194 | + clean_empty( |
| 195 | + { |
| 196 | + **self.auth.soap(), |
| 197 | + **self.search.soap(), |
| 198 | + } |
| 199 | + ) |
| 200 | + ) |
| 201 | + |
| 202 | + |
157 | 203 | class MondialRelayLabel(Label):
|
158 | 204 | @classmethod
|
159 | 205 | def from_soap(cls, result):
|
@@ -181,3 +227,52 @@ class MondialRelayLabelOutput(LabelOutput):
|
181 | 227 | @classmethod
|
182 | 228 | def from_soap(cls, result):
|
183 | 229 | return cls.model_construct(parcels=[MondialRelayParcelLabel.from_soap(result)])
|
| 230 | + |
| 231 | + |
| 232 | +class MondialRelayPickupSite(PickupSite): |
| 233 | + actionType: str |
| 234 | + hours: dict |
| 235 | + url_pic: str |
| 236 | + url_map: str |
| 237 | + |
| 238 | + @classmethod |
| 239 | + def from_soap(cls, result): |
| 240 | + return cls.model_construct( |
| 241 | + id=result["Num"], |
| 242 | + name="\n".join( |
| 243 | + [part for part in [result["LgAdr1"], result["LgAdr2"]] if part] |
| 244 | + ), |
| 245 | + street="\n".join( |
| 246 | + [part for part in [result["LgAdr3"], result["LgAdr4"]] if part] |
| 247 | + ), |
| 248 | + zip=result["CP"], |
| 249 | + city=result["Ville"], |
| 250 | + country=result["Pays"], |
| 251 | + lat=result["Latitude"], |
| 252 | + lng=result["Longitude"], |
| 253 | + actionType=result["TypeActivite"], |
| 254 | + hours={ |
| 255 | + "monday": result["Horaires_Lundi"], |
| 256 | + "tuesday": result["Horaires_Mardi"], |
| 257 | + "wednesday": result["Horaires_Mercredi"], |
| 258 | + "thursday": result["Horaires_Jeudi"], |
| 259 | + "friday": result["Horaires_Vendredi"], |
| 260 | + "saturday": result["Horaires_Samedi"], |
| 261 | + "sunday": result["Horaires_Dimanche"], |
| 262 | + }, |
| 263 | + url_pic=result["URL_Photo"], |
| 264 | + url_map=result["URL_Plan"], |
| 265 | + ) |
| 266 | + |
| 267 | + |
| 268 | +class MondialRelayPickupSiteOutput(PickupSiteOutput): |
| 269 | + sites: list[MondialRelayPickupSite] |
| 270 | + |
| 271 | + @classmethod |
| 272 | + def from_soap(cls, result): |
| 273 | + return cls.model_construct( |
| 274 | + sites=[ |
| 275 | + MondialRelayPickupSite.from_soap(site) |
| 276 | + for site in result["PointsRelais"]["PointRelais_Details"] |
| 277 | + ] |
| 278 | + ) |
0 commit comments