def remove_domain_or_email_to_suppression_list(self, body): """Does a DELETE request to /suppression. Use this API to remove an email address or a recipient domain from the suppression list. You can remove multiple email addresses and recipient domains together by passing them as values & separating them using commas as shown below. Args: body (RemoveEmailOrDomainToSuppressionList): remove email or domain to suppression list 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 = '/suppression' _query_builder = Configuration.base_uri _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'content-type': 'application/json; charset=utf-8'} # Prepare and execute request _request = self.http_client.delete( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) 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 add_domain_or_email_to_suppression_list(self, body): """Does a POST request to /suppression. This API allows you to suppress an email address and block any future email delivery attempts on this email address. Args: body (AddEmailOrDomainToSuppressionList): add email or domain to suppression list 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 = '/suppression' _query_builder = Configuration.base_uri _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'content-type': 'application/json; charset=utf-8'} # Prepare and execute request _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) 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 delete_domain(self, body): """Does a DELETE request to /domain/delete. This endpoint allows you to delete a domain from your Pepipost account. Args: body (DeleteDomain): delete domain 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/delete' _query_builder = Configuration.base_uri _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request _request = self.http_client.delete(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) 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 create_subaccounts_create_subaccount_post(self, body): """Does a POST request to /subaccounts/createSubaccount. Subaccount is the same as any regular Pepipost account however the credits are managed by the master account. Args: body (CreateSubaccount): create sub account 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 = '/subaccounts/createSubaccount' _query_builder = Configuration.base_uri _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'content-type': 'application/json; charset=utf-8' } # Prepare and execute request _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) 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 create_generatethemailsendrequest(self, body): """Does a POST request to /mail/send. The endpoint send is used to generate the request to pepipost server for sending an email to recipients. Args: body (Send): New mail request will be generated 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 = '/mail/send' _query_builder = Configuration.base_uri _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'content-type': 'application/json; charset=utf-8'} # Prepare and execute request _request = self.http_client.post( _query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) 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