Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 56df33f

Browse files
committed
add reload
1 parent b04568e commit 56df33f

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ Example Usage:
4848
profiles[0].update()
4949
5050
51+
# working with search
52+
s = atomx.search('mini*')
53+
# s is now a dict with lists of search results for the different models
54+
# with the model id and name
55+
56+
publisher = s['publisher'][0] # get the first publisher..
57+
publisher.reload() # .. and load all the data
58+
print(publisher) # now all publisher data is there
59+
60+
61+
5162
Installation
5263
------------
5364

atomx/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ def search(self, query):
4848
r = self.session.get(self.api_endpoint + 'search', params={'q': query})
4949
if not r.ok:
5050
raise APIError(r.json()['error'])
51-
return r.json()['search']
51+
search_result = r.json()['search']
52+
# convert publisher, creative dicts etc from search result to Atomx.model
53+
for m in search_result.keys():
54+
model_name = get_model_name(m)
55+
if model_name:
56+
search_result[m] = [getattr(models, model_name)(self, **v)
57+
for v in search_result[m]]
58+
return search_result
5259

5360
def get(self, resource, **kwargs):
5461
r = self.session.get(self.api_endpoint + resource, params=kwargs)

0 commit comments

Comments
 (0)