Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion etsy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _v2 import EtsyV2 as Etsy
from _v2 import Association, EtsyV2 as Etsy
from etsy_env import EtsyEnvSandbox, EtsyEnvProduction


Expand Down
10 changes: 8 additions & 2 deletions etsy/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@ def invoke(self, *args, **kwargs):
ps[p] = kwargs[p]
del kwargs[p]

self.type_checker(self.spec, **kwargs)
return self.api._get(self.spec['http_method'], self.uri_format % ps, **kwargs)
fields = kwargs.pop('fields', None)
includes = kwargs.pop('includes', None)

self.type_checker(self.spec, **kwargs)

if fields:
kwargs['fields'] = ','.join(fields)
if includes:
kwargs['includes'] = ','.join([str(include) for include in includes])
return self.api._get(self.spec['http_method'], self.uri_format % ps, **kwargs)


class MethodTableCache(object):
Expand Down
28 changes: 28 additions & 0 deletions etsy/_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,31 @@ def _get_url(self, url, http_method, content_type, body):
if self.etsy_oauth_client is not None:
return self.etsy_oauth_client.do_oauth_request(url, http_method, content_type, body)
return API._get_url(self, url, http_method, content_type, body)


class Association(object):
class Bounds(object):
def __init__(self, limit, offset=None):
self.limit = limit
self.offset = offset

def __init__(self, name, fields=None, scope=None, bounds=None, child=None):
self.name = name
self.fields = fields
self.scope = scope
self.bounds = bounds
self.child = child

def __str__(self):
elems = [self.name]
if self.fields is not None:
elems.extend(['(', ','.join(self.fields), ')'])
if self.scope is not None:
elems.extend([':', self.scope])
if self.bounds is not None:
elems.extend([':', str(self.bounds.limit)])
if self.bounds.offset is not None:
elems.extend([':', str(self.bounds.offset)])
if self.child is not None:
elems.extend(['/', str(self.child)])
return ''.join(elems)