Skip to content

Commit

Permalink
feat: add LocationAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
NFSS10 committed Sep 1, 2021
1 parent 4a8497b commit b3740a4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/examples/__init__.py
Expand Up @@ -37,6 +37,7 @@
from . import app
from . import base
from . import cart
from . import location
from . import order
from . import product

Expand Down
46 changes: 46 additions & 0 deletions src/examples/location.py
@@ -0,0 +1,46 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Hive Shopify API
# Copyright (c) 2008-2020 Hive Solutions Lda.
#
# This file is part of Hive Shopify API.
#
# Hive Shopify 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 Shopify 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 Shopify API. If not, see <http://www.apache.org/licenses/>.

__author__ = "João Magalhães <joamag@hive.pt>"
""" 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-2020 Hive Solutions Lda."
""" The copyright for the module """

__license__ = "Apache License, Version 2.0"
""" The license for the module """

from . import base

if __name__ == "__main__":
api = base.get_api()
print(api.list_locations(limit = 3))
else:
__path__ = []
2 changes: 2 additions & 0 deletions src/shopify/__init__.py
Expand Up @@ -36,6 +36,7 @@

from . import base
from . import cart
from . import location
from . import order
from . import product
from . import shop
Expand All @@ -44,6 +45,7 @@

from .base import API, OAuthAPI
from .cart import CartAPI
from .location import LocationAPI
from .order import OrderAPI
from .product import ProductAPI
from .shop import ShopAPI
Expand Down
2 changes: 2 additions & 0 deletions src/shopify/base.py
Expand Up @@ -43,6 +43,7 @@
import hashlib

from . import cart
from . import location
from . import order
from . import product
from . import shop
Expand Down Expand Up @@ -72,6 +73,7 @@ class API(
appier.API,
cart.CartAPI,
shop.ShopAPI,
location.LocationAPI,
order.OrderAPI,
product.ProductAPI,
smart_collection.SmartCollectionAPI,
Expand Down
45 changes: 45 additions & 0 deletions src/shopify/location.py
@@ -0,0 +1,45 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Hive Shopify API
# Copyright (c) 2008-2020 Hive Solutions Lda.
#
# This file is part of Hive Shopify API.
#
# Hive Shopify 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 Shopify 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 Shopify API. If not, see <http://www.apache.org/licenses/>.

__author__ = "João Magalhães <joamag@hive.pt>"
""" 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-2020 Hive Solutions Lda."
""" The copyright for the module """

__license__ = "Apache License, Version 2.0"
""" The license for the module """

class LocationAPI(object):

def list_locations(self, *args, **kwargs):
url = self.base_url + "admin/locations.json"
contents = self.get(url, **kwargs)
return contents["locations"]

0 comments on commit b3740a4

Please sign in to comment.