Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add inventory item API #14

Merged
merged 1 commit into from Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

*
* Inventory Item API

### Changed

Expand Down
2 changes: 2 additions & 0 deletions src/shopify/__init__.py
Expand Up @@ -36,6 +36,7 @@

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

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

from . import cart
from . import inventory_item
from . import shop
from . import order
from . import product
Expand Down Expand Up @@ -73,6 +74,7 @@
class API(
appier.API,
cart.CartAPI,
inventory_item.InventoryItemAPI,
shop.ShopAPI,
order.OrderAPI,
product.ProductAPI,
Expand Down
55 changes: 55 additions & 0 deletions src/shopify/inventory_item.py
@@ -0,0 +1,55 @@
#!/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 InventoryItemAPI(object):

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

def get_inventory_item(self, id):
url = self.base_url + "admin/inventory_items/%d.json" % id
contents = self.get(url)
return contents["inventory_item"]

def update_inventory_item(self, id, inventory_item):
url = self.base_url + "admin/inventory_items/%d.json" % id
contents = self.put(url, data_j = dict(inventory_item = inventory_item))
return contents["inventory_item"]