def save(self, force_create=False, fields=None):
values = {}<EOL>fields = fields or self.fields<EOL>for field_name in fields:<EOL><INDENT>value = getattr(self, field_name)<EOL>if isinstance(value, Resource):<EOL><INDENT>value = value.get_id()<EOL><DEDENT>if isinstance(value, list):<EOL><INDENT>if len(value) > <NUM_LIT:0> and isinstance(value[<NUM_LIT:0>], Resource):<EOL><INDENT>value = None<EOL><DEDENT>else:<EOL><INDENT>final_value_list = []<EOL>for item in value:<EOL><INDENT>final_value_list.append(item.isoformat() if isinstance(item, datetime) else item)<EOL><DEDENT>value = final_value_list<EOL><DEDENT><DEDENT>if isinstance(value, datetime):<EOL><INDENT>value = value.isoformat()<EOL><DEDENT>if value is not None:<EOL><INDENT>values[field_name] = value<EOL><DEDENT><DEDENT>http_headers = {'<STR_LIT>': '<STR_LIT:application/json>'} if self.Meta.json_data is True else None<EOL>json = values if self.Meta.json_data is True else None<EOL>data = values if self.Meta.json_data is False else None<EOL>if self.get_resource_endpoint() is not None and force_create is False:<EOL><INDENT>return self.send(self.get_resource_endpoint(), "<STR_LIT>", headers=http_headers, json=json, data=data)<EOL><DEDENT>else:<EOL><INDENT>return self.send(self.get_collection_endpoint(), "<STR_LIT>", headers=http_headers, json=json, data=data)<EOL><DEDENT>
Saves (creates or updates) resource on the server
:param force_create: If True, forces resource creation even if it already has an Id.
:param fields: List of fields to be saved. If None, all fields will be saved.
:return: