def create_new_person(self, person): """ Create a new person :param person: is the new person that the client wants to crete """ #Validate input self._validate_subscriber_id(person.surrogate_id) #Create new person dao = NWS_DAO() url = "/notification/v1/person" headers = {"Content-Type": "application/json"} if self.override_user is not None: headers['X_UW_ACT_AS'] = self.override_user post_response = dao.postURL(url, headers, Serializer().serialize(person)) #HTTP Status Code 201 Created: The request has been fulfilled and resulted #in a new resource being created if post_response.status != 201: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status
def execute_job(self, job): url = "/notification/v1/job" data = Serializer().serialize(job) dao = NWS_DAO() post_response = dao.postURL(url, {"Content-Type": "application/json"}, data) if post_response.status != 201: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status
def resend_sms_endpoint_verification(self, endpoint_id): """ Calls NWS function to resend verification message to endpoint's phone number """ #Validate input self._validate_uuid(endpoint_id) url = "/notification/v1/endpoint/%s/verification" % (endpoint_id) dao = NWS_DAO() post_response = dao.postURL(url, None, None) if post_response.status != 202: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status
def create_new_channel(self, channel): """ Create a new channel :param channel: is the new channel that the client wants to create """ #Create new channel dao = NWS_DAO() url = "/notification/v1/channel" post_response = dao.postURL(url, {"Content-Type": "application/json"}, Serializer().serialize(channel)) #HTTP Status Code 201 Created: The request has been fulfilled and resulted #in a new resource being created if post_response.status != 201: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status
def create_new_message(self, dispatch): """ Create a new dispatch :param dispatch: is the new dispatch that the client wants to create """ #Create new dispatch dao = NWS_DAO() url = "/notification/v1/dispatch" data = Serializer().serialize(dispatch) post_response = dao.postURL(url, {"Content-Type": "application/json"}, data) if post_response.status != 200: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status
def create_new_subscription(self, subscription): """ Create a new subscription :param subscription: is the new subscription that the client wants to create """ #Validate input if subscription.get_subscription_id() is not None: self._validate_uuid(subscription.get_subscription_id()) if subscription.get_endpoint() is not None: if subscription.get_endpoint().user: self._validate_subscriber_id(subscription.endpoint.user) if subscription.get_endpoint().get_endpoint_id() is not None: self._validate_uuid(subscription.endpoint.get_endpoint_id()) if subscription.get_channel() is not None: self._validate_uuid(subscription.channel.get_channel_id()) #Create new subscription dao = NWS_DAO() url = "/notification/v1/subscription" headers = {"Content-Type": "application/json"} if self.override_user is not None: headers['X_UW_ACT_AS'] = self.override_user post_response = dao.postURL(url, headers, Serializer().serialize(subscription)) #HTTP Status Code 201 Created: The request has been fulfilled and resulted #in a new resource being created if post_response.status != 201: raise DataFailureException(url, post_response.status, post_response.data) return post_response.status