def update_preference(self, notification, frequency, **kwargs): """ Update the preference for the given notification for the given communication channel. :calls: `PUT /api/v1/users/:u_id/communication_channels/:communication_channel_id/ \ notification_preferences/:notification \ <https://canvas.instructure.com/doc/api/notification_preferences.html#method.notification_preferences.update>`_ :param notification: The name of the notification. :type notification: str :param frequency: The desired frequency for this notification. :type frequency: str Can be 'immediately', 'daily', 'weekly', or 'never' :rtype: :class:`canvasapi.notification_preference.NotificationPreference` """ kwargs['notification_preferences[frequency]'] = frequency response = self._requester.request( 'PUT', 'users/self/communication_channels/{}/notification_preferences/{}'. format(self.id, notification), _kwargs=combine_kwargs(**kwargs)) data = response.json()['notification_preferences'][0] return NotificationPreference(self._requester, data)
def get_preference(self, notification): """ Fetch the preference for the given notification for the given communication channel. :calls: `GET /api/v1/users/:u_id/communication_channels/:co_id/notification_preferences/:notif \ <https://canvas.instructure.com/doc/api/notification_preferences.html#method.notification_preferences.show>`_ :param notification: The name of the notification. :type notification: str :rtype: :class:`canvasapi.notification_preference.NotificationPreference` """ response = self._requester.request( 'GET', 'users/%s/communication_channels/%s/notification_preferences/%s' % (self.user_id, self.id, notification)) data = response.json()['notification_preferences'][0] return NotificationPreference(self._requester, data)
def get_preference(self, notification, **kwargs): """ Fetch the preference for the given notification for the given communication channel. :calls: `GET /api/v1/users/:user_id/communication_channels/ \ :communication_channel_id/notification_preferences/:notification \ <https://canvas.instructure.com/doc/api/notification_preferences.html#method.notification_preferences.show>`_ :param notification: The name of the notification. :type notification: str :rtype: :class:`canvasapi.notification_preference.NotificationPreference` """ response = self._requester.request( "GET", "users/{}/communication_channels/{}/notification_preferences/{}". format(self.user_id, self.id, notification), _kwargs=combine_kwargs(**kwargs), ) data = response.json()["notification_preferences"][0] return NotificationPreference(self._requester, data)