Пример #1
0
 def create(self, field):
     data = field.to_native()
     # When creating a Field in Pipedrive, the 'options' field is not a list
     # of FieldOption dictionaries, but instead a list of strings
     # representing the options' labels - so once again, we need to put a
     # square peg in a round hole
     # https://www.youtube.com/watch?v=C2YZnTL596Q
     if data['options']:
         data['options'] = json.dumps([o['label'] for o in data['options']])
     response = self._create(data=data)
     return dict_to_model(response.json()['data'], self.FIELD_CLASS)
Пример #2
0
    def to_native(self, value, context=None):
        if isinstance(value, self.model_class):
            return value

        if isinstance(value, int):
            return self.model_class({"id": value})

        if isinstance(value, dict):
            return dict_to_model(value, self.model_class)

        raise ConversionError(self.messages["value_type"] % self.model_class)
Пример #3
0
 def create(self, stage):
     response = self._create(data=stage.to_primitive())
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)
Пример #4
0
 def detail(self, resource_ids):
     response = self._detail(resource_ids)
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)
Пример #5
0
 def update(self, organization):
     response = self._update(organization.id,\
         data=organization.to_primitive())
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)
Пример #6
0
 def create(self, stage):
     response = self._create(data=stage.to_primitive())
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)
Пример #7
0
 def detail(self, resource_ids):
     response = self._detail(resource_ids)
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)
Пример #8
0
 def update(self, organization):
     response = self._update(organization.id,\
         data=organization.to_primitive())
     return dict_to_model(response.json()['data'], self.MODEL_CLASS)