def request(self, method, url, params=None, headers=None): params = params or self._params requestor = RequestHandler( token=self.api_token, api_base=self.api_base or constants.API_BASE, ) response = requestor.request(method, url, params, headers) return create_object(response, self.api_token, _type=self.class_name)
def __next__(self): if self.current_index >= len(self.current_list): if self.next_page: self._update() else: raise StopIteration self.current_index += 1 return create_object(self.current_list[self.current_index - 1], api_token=self.api_token, _type=self.class_name)
def load_data(self, data, api_token=None, partial=False): self.api_token = api_token or getattr(data, 'api_token', None) if partial: self._unsaved_attributes -= set(data) else: self._unsaved_attributes = set() self.clear() if data: for key, value in data.items(): super().__setitem__(key, create_object(value, api_token, _type=self.class_name)) self._previous = data