Skip to content

Commit ed5a452

Browse files
author
James Dalessio
committed
Add raw query response to resource iterable.
1 parent 4013b8e commit ed5a452

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ device = exp.create_device({ 'subtype': 'scala:device:player' })
243243

244244
**`exp.find_devices(params=None)`**
245245

246-
Returns an iterable of devices matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
246+
Returns an iterable of devices matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
247247

248248
**`device.get_location()`**
249249

@@ -276,7 +276,7 @@ thing = exp.create_thing({ 'subtype': 'scala:thing:rfid', 'id': '[rfid]', 'name'
276276

277277
**`exp.find_things(params=None)`**
278278

279-
Returns an iterable of things matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
279+
Returns an iterable of things matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
280280

281281
**`thing.get_location()`**
282282

@@ -309,11 +309,11 @@ Returns an experience created based on the supplied document.
309309

310310
**`exp.find_experiences(params=None)`**
311311

312-
Returns an iterable of experiences matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
312+
Returns an iterable of experiences matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
313313

314314
**`experience.get_devices(params=None)`**
315315

316-
Returns an iterable of [devices](#devices) that are part of this experience. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
316+
Returns an iterable of [devices](#devices) that are part of this experience. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
317317

318318

319319
## Locations
@@ -333,16 +333,16 @@ Returns a location created based on the supplied document.
333333

334334
**`exp.find_locations(params=None)`**
335335

336-
Returns an iterable of locations matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
336+
Returns an iterable of locations matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
337337

338338

339339
**`location.get_devices(params=None)`**
340340

341-
Returns an iterable of [devices](#devices) that are part of this location. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
341+
Returns an iterable of [devices](#devices) that are part of this location. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
342342

343343
**`location.get_things(params=None)`**
344344

345-
Returns an iterable of [things](#things) that are part of this location. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
345+
Returns an iterable of [things](#things) that are part of this location. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
346346

347347
**`location.get_zones()`**
348348

@@ -398,7 +398,7 @@ feed = exp.create_feed({ 'subtype': 'scala:feed:weather', 'searchValue': '16902'
398398

399399
**`exp.find_feeds(params=None)`**
400400

401-
Returns an iterable of feeds matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
401+
Returns an iterable of feeds matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
402402

403403
```python
404404
feeds = exp.find_feeds({ 'subtype': 'scala:feed:facebook' })
@@ -436,7 +436,7 @@ data = exp.create_data('cats', 'fluffy', { 'color': 'brown'})
436436

437437
**`exp.find_data(params=None)`**
438438

439-
Returns an iterable of data items matching the given query parameters. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
439+
Returns an iterable of data items matching the given query parameters. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
440440

441441
```python
442442
items = exp.find_data({ 'group': 'cats' })
@@ -484,7 +484,7 @@ Returns the delivery url for a variant of this content item.
484484

485485
**`content.get_children(params)`**
486486

487-
Returns an iterable of the content items children. `params` is a dictionary of query parameters. Iterable has attribute total which is the total number of matching results.
487+
Returns an iterable of the content items children. `params` is a dictionary of query parameters. Iterable also has attributes matching the raw API response document properties (i.e. `total` and `results`).
488488

489489
## Resources
490490

exp_sdk/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class Collection (list):
4545

4646
def __init__(self, Resource, document, sdk):
4747
list.__init__(self, [Resource(doc, sdk) for doc in document['results']])
48-
self.total = document['total']
49-
48+
for key, value in document.iteritems():
49+
self.__dict__[key] = value
5050

5151
class CommonResource (Resource):
5252

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name='exp-sdk',
55
packages= ['exp_sdk'],
6-
version='1.0.5',
6+
version='1.0.6',
77
description='EXP Python SDK',
88
author='Scala',
99
author_email='[email protected]',

tests/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def test_find (self):
9898
if not collection.total:
9999
raise Exception
100100
resources = self.find({ 'name': resource.name })
101+
if not resources.results[0] == resources[0].document:
102+
raise Exception
103+
if not resources.total and resources.total != 0:
104+
raise Exception
101105
if not resources:
102106
raise Exception
103107
self.assert_isinstance(resources[0])

0 commit comments

Comments
 (0)