From 5049f674c45ae1a4b41dd04f93c1f4f14f892835 Mon Sep 17 00:00:00 2001 From: Tiago Silva Date: Fri, 1 Apr 2016 13:31:25 +0100 Subject: [PATCH] added collection api --- src/budy/__init__.py | 2 ++ src/budy/base.py | 2 ++ src/budy/collection.py | 49 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/budy/collection.py diff --git a/src/budy/__init__.py b/src/budy/__init__.py index caa19af..672514e 100644 --- a/src/budy/__init__.py +++ b/src/budy/__init__.py @@ -39,6 +39,7 @@ from . import bag from . import base from . import category +from . import collection from . import color from . import country from . import order @@ -49,6 +50,7 @@ from .bag import BagApi from .base import Api from .category import CategoryApi +from .collection import CollectionApi from .color import ColorApi from .country import CountryApi from .order import OrderApi diff --git a/src/budy/base.py b/src/budy/base.py index a639c2e..9afcf1a 100644 --- a/src/budy/base.py +++ b/src/budy/base.py @@ -47,6 +47,7 @@ from . import country from . import product from . import category +from . import collection from . import subscription BASE_URL = "http://localhost:8080/api/" @@ -63,6 +64,7 @@ class Api( country.CountryApi, product.ProductApi, category.CategoryApi, + collection.CollectionApi, subscription.SubscriptionApi ): diff --git a/src/budy/collection.py b/src/budy/collection.py new file mode 100644 index 0000000..5c80e3b --- /dev/null +++ b/src/budy/collection.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Hive Budy API +# Copyright (c) 2008-2016 Hive Solutions Lda. +# +# This file is part of Hive Budy API. +# +# Hive Budy API is free software: you can redistribute it and/or modify +# it under the terms of the Apache License as published by the Apache +# Foundation, either version 2.0 of the License, or (at your option) any +# later version. +# +# Hive Budy API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Apache License for more details. +# +# You should have received a copy of the Apache License along with +# Hive Budy API. If not, see . + +__author__ = "João Magalhães " +""" The author(s) of the module """ + +__version__ = "1.0.0" +""" The version of the module """ + +__revision__ = "$LastChangedRevision$" +""" The revision number of the module """ + +__date__ = "$LastChangedDate$" +""" The last change date of the module """ + +__copyright__ = "Copyright (c) 2008-2016 Hive Solutions Lda." +""" The copyright for the module """ + +__license__ = "Apache License, Version 2.0" +""" The license for the module """ + +class CollectionApi(object): + + def list_collections(self, *args, **kwargs): + url = self.base_url + "collections" + contents = self.get( + url, + auth = False, + **kwargs + ) + return contents