def add_query_parameter(self, name, value): """ Add a query parameter to the HttpRequest. Args: name (string): The name of the query parameter. value (string): The value of the query parameter. """ self.query_url = APIHelper.append_url_with_query_parameters(self.query_url, {name:value}) self.query_url = APIHelper.clean_url(self.query_url)
def get_domain_status_get(self, status=None, domain=None): """Does a GET request to /domain/getDomains. Lets you fetch status for the domain within pepipost account created by you Args: status (string, optional): TODO: type description here. Example: domain (string, optional): TODO: type description here. Example: Returns: object: Response from the API. API Response Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/domain/getDomains' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = { 'status': status, 'domain': domain } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare and execute request _request = self.http_client.get(_query_url) CustomHeaderAuth.apply(_request) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise APIException('API Response', _context) elif _context.response.status_code == 401: raise APIException('API Response', _context) elif _context.response.status_code == 403: raise APIException('API Response', _context) elif _context.response.status_code == 405: raise APIException('Invalid input', _context) self.validate_response(_context) # Return appropriate type return _context.response.raw_body
def get_template_get(self, template_id): """Does a GET request to /template. Let's you fetch template data using template_id for your pepipost account. Args: template_id (int): TODO: type description here. Example: Returns: object: Response from the API. API Response Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/template' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = {'template_id': template_id} _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare and execute request _request = self.http_client.get(_query_url) CustomHeaderAuth.apply(_request) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise APIException('API Response', _context) elif _context.response.status_code == 401: raise APIException('API Response', _context) elif _context.response.status_code == 403: raise APIException('API Response', _context) elif _context.response.status_code == 405: raise APIException('Invalid input', _context) self.validate_response(_context) # Return appropriate type return _context.response.raw_body
def get_stats_get(self, startdate, enddate=None, aggregated_by=None, offset=1, limit=100): """Does a GET request to /stats. Lets you fetch all the subaccounts created by you Args: startdate (date): The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD. enddate (date, optional): The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD. aggregated_by (AggregatedByEnum, optional): TODO: type description here. Example: offset (int, optional): TODO: type description here. Example: 1 limit (int, optional): TODO: type description here. Example: 100 Returns: object: Response from the API. API Response Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/stats' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = { 'startdate': startdate, 'enddate': enddate, 'aggregated_by': aggregated_by, 'offset': offset, 'limit': limit } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare and execute request _request = self.http_client.get(_query_url) CustomHeaderAuth.apply(_request) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise APIException('API Response', _context) elif _context.response.status_code == 401: raise APIException('API Response', _context) elif _context.response.status_code == 403: raise APIException('API Response', _context) elif _context.response.status_code == 405: raise APIException('Invalid input', _context) self.validate_response(_context) # Return appropriate type return _context.response.raw_body
def get_events_get(self, startdate, events=None, sort=None, enddate=None, offset=0, limit=10, subject=None, xapiheader=None, fromaddress=None, email=None): """Does a GET request to /events. Lets you to retrieve the email transaction logs. Args: startdate (date): The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD. events (EventsEnum, optional): Filter based on different email events. If not passed, all events will be fetched. Multiple comma separated events are allowed sort (SortEnum, optional): Sort based on email sent time enddate (date, optional): The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD offset (int, optional): The point in the list to begin retrieving results. limit (int, optional): The number of results to return. subject (string, optional): Filter logs based on subject xapiheader (string, optional): Filter logs based on recipient's email fromaddress (string, optional): Filter logs based on fromaddress email (string, optional): Filter logs based on recipient's email Returns: object: Response from the API. API Response Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/events' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = { 'startdate': startdate, 'events': events, 'sort': sort, 'enddate': enddate, 'offset': offset, 'limit': limit, 'subject': subject, 'xapiheader': xapiheader, 'fromaddress': fromaddress, 'email': email } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare and execute request _request = self.http_client.get(_query_url) CustomHeaderAuth.apply(_request) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise APIException('API Response', _context) elif _context.response.status_code == 401: raise APIException('API Response', _context) elif _context.response.status_code == 403: raise APIException('API Response', _context) elif _context.response.status_code == 405: raise APIException('Invalid input', _context) self.validate_response(_context) # Return appropriate type return _context.response.raw_body