@@ -83,18 +83,27 @@ def call_get(url):
8383 r = requests .get (url , headers = self .access_headers , timeout = self .timeout )
8484 r .raise_for_status ()
8585 return r
86+ def call_post (url , data ):
87+ r = requests .post (url , headers = {** self .access_headers , ** self .json_content }, data = json .dumps (data ), timeout = self .timeout )
88+ r .raise_for_status ()
89+ return r
8690
8791 self .refresh_auth ()
8892 url = '%s/%s' % (self .api , cmd )
8993 if method == 'DELETE' :
90- return call_delete (url )
94+ res = call_delete (url )
95+ if res .status_code == 204 :
96+ return None
97+ return res .json ()
9198 elif method == 'PUT' and data :
9299 res = call_put (url , data )
93100 if res .status_code == 204 :
94101 return None
95102 return res .json ()
96103 elif method == 'GET' :
97104 return call_get (url ).json ()
105+ elif method == 'POST' :
106+ return call_post (url , data ).json ()
98107
99108 def _api_acme_call (self , cmd , data = False , method = 'GET' ):
100109 """Perform an API call."""
@@ -616,6 +625,105 @@ def get_invitations(self):
616625 data = self ._api_call ('homes/%i/invitations' % self .id )
617626 return data
618627
628+ def set_invitation (self , email ):
629+ """
630+ Send an invitation to a user.
631+
632+ Parameters:
633+ email (str): The email of the user to invite.
634+
635+ Returns:
636+ (dict): The invitation information.
637+
638+ ??? info "Result example"
639+ ```json
640+ {
641+ "token": "44483e1d07qf439&8b786fc0372ec315",
642+ "email": "SOME_EMAIL",
643+ "firstSent": "2024-03-19T12:54:38.591Z",
644+ "lastSent": "2024-03-19T12:54:38.591Z",
645+ "inviter": {
646+ "name": "SOME_NAME",
647+ "email": "SOME_EMAIL",
648+ "username": "SOME_MAIL",
649+ "enabled": true,
650+ "id": "5c22a9b6d5018000088dba4a",
651+ "homeId": 123456,
652+ "locale": "fr",
653+ "type": "WEB_USER"
654+ },
655+ "home": {
656+ "id": 123456,
657+ "name": "Domicile",
658+ "dateTimeZone": "Europe/Paris",
659+ "dateCreated": "2018-12-25T20:58:28.674Z",
660+ "temperatureUnit": "CELSIUS",
661+ "partner": null,
662+ "simpleSmartScheduleEnabled": true,
663+ "awayRadiusInMeters": 1999.68,
664+ "installationCompleted": true,
665+ "incidentDetection": {
666+ "supported": true,
667+ "enabled": true
668+ },
669+ "generation": "PRE_LINE_X",
670+ "zonesCount": 4,
671+ "skills": [
672+ "AUTO_ASSIST"
673+ ],
674+ "christmasModeEnabled": true,
675+ "showAutoAssistReminders": true,
676+ "contactDetails": {
677+ "name": "SOME_NAME",
678+ "email": "SOME_EMAIL",
679+ "phone": "SOME_PHONE_NUMBER"
680+ },
681+ "address": {
682+ "addressLine1": "SOME_POSTAL_ADDRESS",
683+ "addressLine2": null,
684+ "zipCode": "SOME_POSTCODE",
685+ "city": "SOME_CITY",
686+ "state": null,
687+ "country": "FRA"
688+ },
689+ "geolocation": {
690+ "latitude": 12.3456789,
691+ "longitude": 1.23456
692+ },
693+ "consentGrantSkippable": true,
694+ "enabledFeatures": [
695+ "CLIMATE_REPORT_AS_WEBVIEW",
696+ "EIQ_SETTINGS_AS_WEBVIEW",
697+ "ENERGY_IQ_V2_ONBOARDING",
698+ "HIDE_BOILER_REPAIR_SERVICE",
699+ "KEEP_WEBAPP_UPDATED",
700+ "OWD_SETTINGS_AS_WEBVIEW",
701+ "SMART_SCHEDULE_AS_WEBVIEW"
702+ ],
703+ "isAirComfortEligible": true,
704+ "isBalanceAcEligible": false,
705+ "isEnergyIqEligible": true,
706+ "isHeatSourceInstalled": false,
707+ "isBalanceHpEligible": false
708+ }
709+ }
710+ ```
711+ """
712+ payload = { 'email' : email }
713+ return self ._api_call ('homes/%i/invitations' % (self .id ), data = payload , method = 'POST' )
714+
715+ def delete_invitation (self , token ):
716+ """
717+ Delete an invitation.
718+
719+ Parameters:
720+ token (str): The token of the invitation to delete.
721+
722+ Returns:
723+ (None): None.
724+ """
725+ return self ._api_call ('homes/%i/invitations/%s' % (self .id , token ), method = 'DELETE' )
726+
619727 def get_me (self ):
620728 """
621729 Get information about the current user.
0 commit comments