Esempio n. 1
0
    def _update(self, partial=False):
        request = APIRequestor(self._client, self)

        data = self.to_dict()
        if partial:
            # .items isn't effecient in Python 2
            data = {k: v for k, v in data.items() if self._raw_data.get(k) != v}

        return request.update(self.id, json.dumps(data), partial=partial)
Esempio n. 2
0
File: base.py Progetto: wmak/gapipy
    def _update(self, partial=False):
        request = APIRequestor(self._client, self)

        data = self.to_dict()
        if partial:
            # .items isn't effecient in Python 2
            data = {
                k: v
                for k, v in data.items() if self._raw_data.get(k) != v
            }

        return request.update(self.id, json.dumps(data), partial=partial)
Esempio n. 3
0
    def _update(self, partial=False):
        request = APIRequestor(self._client, self)

        # payload to send
        data = self.to_dict()

        # when making a partial (PATCH) request, ensure we only include values
        # changed on self compared to the initial raw response received from
        # the G API.
        #
        # Added (2.35.0): If the change computed results in an empty data
        #                 dictionary we'll raise a EmptyPartialUpdateError
        if partial:
            data = {
                k: v
                for k, v in data.items() if self._raw_data.get(k) != v
            }
            if not data:
                raise EmptyPartialUpdateError

        return request.update(self.id, json.dumps(data), partial=partial)