Update a channel with information from the response of watch(). When a request is sent to watch() a resource, the response returned from the watch() request is a dictionary with updated channel information, such as the resource_id, which is needed when stopping a subscriptio
(self, resp)
| 233 | return result |
| 234 | |
| 235 | def update(self, resp): |
| 236 | """Update a channel with information from the response of watch(). |
| 237 | |
| 238 | When a request is sent to watch() a resource, the response returned |
| 239 | from the watch() request is a dictionary with updated channel information, |
| 240 | such as the resource_id, which is needed when stopping a subscription. |
| 241 | |
| 242 | Args: |
| 243 | resp: dict, The response from a watch() method. |
| 244 | """ |
| 245 | for json_name, param_name in CHANNEL_PARAMS.items(): |
| 246 | value = resp.get(json_name) |
| 247 | if value is not None: |
| 248 | setattr(self, param_name, value) |
| 249 | |
| 250 | |
| 251 | def notification_from_headers(channel, headers): |