code: def _to_dict(self, serialize=False):
          
          copy_dict = self.__dict__.copy()
          for key, value in vars(self).items():
              # We want to send all ids to Zendesk always
              if serialize and key == 'id':
                  continue
  
              # If this is a Zenpy object, convert it to a dict.
              if not serialize and isinstance(value, BaseObject):
                  copy_dict[key] = copy_dict.pop(key).to_dict()
  
              # This object has a flag indicating it has been dirtied, so we want to send it off.
              elif serialize and getattr(value, '_dirty', False):
                  continue
  
              # Here we have an attribute that should always be sent to Zendesk.
              elif serialize and key in self._always_dirty:
                  continue
  
              # These are for internal tracking, so just delete.
              elif key in ('api', '_dirty_attributes', '_always_dirty', '_dirty_callback', '_dirty'):
                  del copy_dict[key]
  
              # If the attribute has not been modified, do not send it.
              elif serialize and key not in self._dirty_attributes:
                  del copy_dict[key]
  
              # Some reserved words are prefixed with an underscore, remove it here.
              elif key.startswith('_'):
                  copy_dict[key[1:]] = copy_dict[key]
                  del copy_dict[key]
          return copy_dict
docs: This method works by copying self.__dict__, and removing everything that should not be serialized.