Exemple #1
0
 def page(cls, datatable, **options):
     params = {'id': str(datatable.code)}
     path = Util.constructed_path(datatable.default_path(), params)
     r = Connection.request('get', path, **options)
     response_data = r.json()
     Util.convert_to_dates(response_data)
     resource = cls.create_datatable_list_from_response(response_data)
     return resource
Exemple #2
0
 def page(cls, datatable, **options):
     params = {'id': str(datatable.code)}
     path = Util.constructed_path(datatable.default_path(), params)
     r = Connection.request('get', path, **options)
     response_data = r.json()
     Util.convert_to_dates(response_data)
     resource = cls.create_datatable_list_from_response(response_data)
     return resource
 def all(cls, **options):
     if 'params' not in options:
         options['params'] = {}
     path = Util.constructed_path(cls.list_path(), options['params'])
     r = Connection.request('get', path, **options)
     response_data = r.json()
     Util.convert_to_dates(response_data)
     resource = cls.create_list_from_response(response_data)
     return resource
Exemple #4
0
 def all(cls, **options):
     if 'params' not in options:
         options['params'] = {}
     path = Util.constructed_path(cls.list_path(), options['params'])
     r = Connection.request('get', path, **options)
     response_data = r.json()
     Util.convert_to_dates(response_data)
     resource = cls.create_list_from_response(response_data)
     return resource
Exemple #5
0
    def __get_raw_data__(self):
        if self._raw_data:
            return self._raw_data

        cls = self.__class__
        params = {'id': str(self.code)}
        options = Util.merge_options('params', params, **self.options)

        path = Util.constructed_path(cls.get_path(), options['params'])

        r = Connection.request('get', path, **options)
        response_data = r.json()
        Util.convert_to_dates(response_data)
        self._raw_data = response_data[singularize(cls.lookup_key())]
        return self._raw_data
 def test_constructed_path(self):
     path = '/hello/:foo/world/:id'
     params = {'foo': 'bar', 'id': 1, 'another': 'a'}
     result = Util.constructed_path(path, params)
     self.assertEqual(result, '/hello/bar/world/1')
     self.assertDictEqual(params, {'another': 'a'})
Exemple #7
0
 def _download_request_path(self):
     url = self.default_path()
     url = Util.constructed_path(url, {'id': self.code})
     url += '.json'
     return url
Exemple #8
0
 def _download_request_path(self):
     url = self.default_path()
     url = Util.constructed_path(url, {'id': self.code})
     url += '.json'
     return url
 def _bulk_download_path(self):
     url = self.default_path() + '/data'
     url = Util.constructed_path(url, {'id': self.code})
     return url
Exemple #10
0
 def _bulk_download_path(self):
     url = self.default_path() + '/data'
     url = Util.constructed_path(url, {'id': self.code})
     return url
Exemple #11
0
 def test_constructed_path(self):
     path = '/hello/:foo/world/:id'
     params = {'foo': 'bar', 'id': 1, 'another': 'a'}
     result = Util.constructed_path(path, params)
     self.assertEqual(result, '/hello/bar/world/1')
     self.assertDictEqual(params, {'another': 'a'})