Skip to content

Commit

Permalink
WIPWIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnes committed Jul 31, 2019
1 parent 91be6d5 commit e031d95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions appnexus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ def base_url(self):


services_list = ["AccountRecovery", "AdProfile", "AdQualityRule", "Adserver",
"Advertiser", "AugmentedLineItem", "BatchSegment", "Brand", "Broker", "Browser",
"BudgetSplitter", "Campaign", "Carrier", "Category",
"Advertiser", "AugmentedLineItem", "BatchSegment", "Brand",
"Broker", "Browser", "Campaign", "Carrier", "Category",
"ChangeLog", "ChangeLogDetail", "City", "ContentCategory",
"Country", "Creative", "CreativeFormat", "Currency",
"CustomModel", "CustomModelHash", "CustomModelLogit",
Expand Down
40 changes: 18 additions & 22 deletions appnexus/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,12 @@ def find(cls, **kwargs):
return super().find(**kwargs)


class BudgetSplitter(Model):

@classmethod
def find(cls, **kwargs):
raise NotImplementedError("Can't get multiple objects on '{}' service"
.format(cls.service_name))

@classmethod
def find_one(cls, id, **kwargs):
representation = (kwargs.pop("representation", None)
or cls.client.representation
or cls.constructor)
kwargs.update({
"uri_parameters_template": "/{}/splits".format(id)
})
response = cls.client.get(cls.service_name, **kwargs)
if representation:
return representation(cls.client, cls.service_name, response)
return response
class AugmentedLineItem(Model):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._splits = []

class AugmentedLineItem(Model):

@classmethod
def find(cls, **kwargs):
kwargs["line_item_type"] = "standard_v2"
Expand All @@ -167,7 +150,20 @@ def service_name(cls):

@property
def splits(self):
return BudgetSplitter.find_one(id=self.id) # noqa: F821
if not self._splits:
uri = "budget-splitter/{}/splits".format(id)
self._splits = self.client.get(uri, raw=True)
return self._splits

@splits.setter(self)
def splits(self, value):
self._splits = value

def save(self, **kwargs):
splits = self.__dict__.pop("_splits", None)
super().save(**kwargs)
if splits:
self.client.post("...", splits)


class Report(Model):
Expand Down

0 comments on commit e031d95

Please sign in to comment.