Skip to content

Commit

Permalink
Feat: Reduce number of public methods of Blink API
Browse files Browse the repository at this point in the history
  • Loading branch information
mpedreira committed Oct 8, 2024
1 parent e54091e commit 43aece1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/classes/adapters/blink_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# pylint: disable=C0301,R0904
# pylint: disable=C0301
# -*- coding: utf-8 -*-
"""Module for using Blink Cameras through API"""

Expand Down Expand Up @@ -44,7 +44,7 @@ def __set_token__(self):
self.set_token_auth(self.config.session['TOKEN_AUTH'])
self.set_client_id(self.config.session['CLIENT_ID'])

def get_basics(self):
def __get_basics__(self):
"""
Gets the basic information of the blink account
"""
Expand Down Expand Up @@ -183,9 +183,9 @@ def arm_network(self, network_id):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def get_response_to_request(self, http_instance):
def __get_response_to_request__(self, http_instance):
"""
Args:
http_instance (class): this is the class used for the http request
Expand Down Expand Up @@ -244,9 +244,9 @@ def get_video_events(self, since="2024-07-31T09%3A58%3A14%2B0000", page="1"):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.get_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def get_newtwork_id_from_camera(self, camera_id):
def __get_newtwork_id_from_camera__(self, camera_id):
"""
Gets the network ID from the camera ID
Expand Down Expand Up @@ -280,7 +280,7 @@ def get_camera_clip(self, camera_id):
Returns:
_type_: _description_
"""
network_id = self.get_newtwork_id_from_camera(camera_id)
network_id = self.__get_newtwork_id_from_camera__(camera_id)
payload = self.__prepare_http_request__()
payload['headers']['token-auth'] = self.token_auth
endpoint = {}
Expand All @@ -289,7 +289,7 @@ def get_camera_clip(self, camera_id):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def disarm_network(self, network_id):
"""
Expand All @@ -310,7 +310,7 @@ def disarm_network(self, network_id):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def get_server(self):
"""
Expand Down Expand Up @@ -341,7 +341,7 @@ def get_login(self):
})
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def get_networks(self):
"""
Expand Down Expand Up @@ -403,7 +403,7 @@ def get_home_screen_info(self):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.get_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def set_thumbnail(self, camera_id):
"""
Expand All @@ -416,7 +416,7 @@ def set_thumbnail(self, camera_id):
dict : This responses a json with the status_code,
the response of the server(blank if has no json format) and if is_success
"""
network_id = self.get_newtwork_id_from_camera(camera_id)
network_id = self.__get_newtwork_id_from_camera__(camera_id)
payload = self.__prepare_http_request__()
payload['headers']['token-auth'] = self.token_auth
endpoint = {}
Expand All @@ -425,7 +425,7 @@ def set_thumbnail(self, camera_id):
endpoint['certificate'] = False
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def set_owl_thumbnail(self, owl_id):
"""
Expand All @@ -438,7 +438,7 @@ def set_owl_thumbnail(self, owl_id):
dict : This responses a json with the status_code,
the response of the server(blank if has no json format) and if is_success
"""
network_id = self.get_newtwork_id_from_camera(owl_id)
network_id = self.__get_newtwork_id_from_camera__(owl_id)
payload = self.__prepare_http_request__()
payload['headers']['token-auth'] = self.token_auth
endpoint = {}
Expand All @@ -448,7 +448,7 @@ def set_owl_thumbnail(self, owl_id):
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
print(http_instance.response.text)
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

def send_2fa(self, pin):
"""
Expand All @@ -472,4 +472,4 @@ def send_2fa(self, pin):
print(endpoint)
http_instance = HttpRequestStandard(endpoint, payload)
http_instance.post_request()
return self.get_response_to_request(http_instance)
return self.__get_response_to_request__(http_instance)

0 comments on commit 43aece1

Please sign in to comment.