Exemple #1
0
    def _s_patch(self, **kwargs):
        """Patch this model in SAFRS API.

        Notes
        -----
        Allow PATCH in the SAFRS API to set the password and campaign_id. Both are custom properties
        which are (apparently) not recognized by the auto-field-generating ability of SAFRS.
        """
        SAFRSBase._s_patch(self, **kwargs)

        campaign_id = kwargs.pop("campaign_id", None)

        if campaign_id:
            self.campaign_id = campaign_id

        password = kwargs.pop("password", None)

        if password:
            self.password = password
Exemple #2
0
    def to_dict(self):
        """Serialize this class into a SAFRS-compatible dictionary.

        Notes
        -----
        This is where we expose additional fields that are either 1) not in the model or 2) not
        automatically put in the model by SAFRS because it does not work with custom properties.
        """
        result = SAFRSBase.to_dict(self)
        result.update({"campaign_id": self.campaign_id, "password": None})

        return result
Exemple #3
0
    def to_dict(self):
        """Serialize this class into a SAFRS-compatible dictionary.

        Notes
        -----
        This is where we expose additional fields that are either 1) not in the model or 2) not
        automatically put in the model by SAFRS because it does not work with custom properties.
        """
        result = SAFRSBase.to_dict(self)
        result.update({
            "price": self.price,
            "sku": self.sku,
            "total": self.total
        })

        return result
Exemple #4
0
 def to_dict(self):
     result = SAFRSBase.to_dict(self)
     result["custom_field"] = "some customization"
     return result
Exemple #5
0
 def __init__(self, *args, **kwargs):
     custom_field = kwargs.pop("custom_field", None)
     SAFRSBase.__init__(self, **kwargs)