Welcome to mijnahlib’s documentation!¶
Contents:
mijnahlib¶
a library to interact with albert heijn’s on line store
- Documentation: http://mijnahlib.readthedocs.io/en/latest
Features¶
- TODO
Installation¶
At the command line:
$ pip install mijnahlib
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv mijnahlib
$ pip install mijnahlib
Usage¶
To use mijnahlib in a project:
from mijnahlib import Server as AH
ah=AH(AH_USERNAME, AH_PASSWORD)
# add items to shopping cart by id
ah.shopping_cart.add_item_by_id('wi382975')
# add items to shopping cart by description
ah.shopping_cart.add_item_by_description('milk')
# show shopping cart contents.
print(ah.shopping_cart.contents)
# There are two types of items. Products and UnspecifiedProducts.
# UnspecifiedProducts have much less attributes exposed since they are
# generic. If accessed, those attributes return None and log a warning so
# they can be used like the Product items.
# show internal attributes of items in the cart
for item in ah.shopping_cart.contents:
print(item.description)
print(item.measurement_unit)
print(item.price)
print(item.quantity)
print(item.has_discount)
print(item.brand)
print(item.category)
print(item.price_previously)
print(item.id)
# get a list of items with discount
discounted_items = ah.shopping_cart.get_items_with_discount()
# get info over the stores
for store in ah.stores:
print(store.address)
print(store.telephone)
print(store.id)
print(store.latitude)
print(store.longtitude)
print(store.opening_times_today)
print(store.opens_sunday)
print(store.opens_evenings)
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Submit Feedback¶
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
Get Started!¶
Ready to contribute? Here’s how to set up mijnahlib for local development.
Clone your fork locally:
$ git clone https://github.com/costastf/mijnahlib.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your clone for local development:
$ mkvirtualenv mijnahlib $ cd mijnahlib/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
Commit your changes and push your branch to the server:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a merge request
mijnahlib¶
mijnahlib package¶
Submodules¶
mijnahlib.mijnahlib module¶
Main module file
Put your classes here
-
class
mijnahlib.mijnahlib.
Item
(ah_instance, info)[source]¶ Bases:
object
Generic class of the products objects
Handles all the common parts
-
quantity
¶ The quantity of the items in the shopping cart
Returns: The quantity of the items
-
url
¶ The url of the item
Returns: The url of the item
-
-
class
mijnahlib.mijnahlib.
ItemFactory
[source]¶ Bases:
object
A factory that instantiates the appropriate object based on type
-
class
mijnahlib.mijnahlib.
Product
(ah_instance, info)[source]¶ Bases:
mijnahlib.mijnahlib.Item
An object to model the products.
-
brand
¶ The brand of the product
-
category
¶ The category of the product
-
description
¶ The description of the object
-
has_discount
¶ Whether the object is a discounted one
-
id
¶ The internal id of the item
-
is_orderable
¶ Whether the object is orderable on not
Returns: A boolean of the state
-
measurement_unit
¶ The measurement unit of the product according to AH
-
price
¶ The price of the product
-
price_previously
¶ The previous price of the product if on discount.
-
-
class
mijnahlib.mijnahlib.
Server
(username, password)[source]¶ Bases:
object
Object modeling the server connection.
Handles the authentication and exposes all the internal parts as attributes.
-
stores
¶
-
-
class
mijnahlib.mijnahlib.
ShoppingCart
(ah_instance)[source]¶ Bases:
object
Object modeling the shopping cart.
It is able to add items to the cart, by id or description. It exposes item objects through the content attribute
-
add_item_by_description
(description, quantity=1)[source]¶ Adds items to the shopping cart by the internal id representation
Parameters: - description – The description of the item
- quantity – The quantity as an integer
Returns: True on success False otherwise.
-
add_item_by_id
(item_id, quantity=1)[source]¶ Adds items to the shopping cart by the internal id representation
Parameters: - item_id – The internal representation of the item
- quantity – The quantity as an integer
Returns: True on success False otherwise.
-
contents
¶ The contents of the shopping cart
Returns: A list of items according to their type
-
-
class
mijnahlib.mijnahlib.
Store
(info)[source]¶ Bases:
object
-
address
¶
-
city
¶
-
id
¶
-
latitude
¶
-
longtitude
¶
-
opening_times_today
¶
-
opens_evenings
¶
-
opens_sunday
¶
-
street
¶
-
street_number
¶
-
telephone
¶
-
zip_code
¶
-
-
class
mijnahlib.mijnahlib.
UnspecifiedProduct
(ah_instance, info)[source]¶ Bases:
mijnahlib.mijnahlib.Item
An object to model the unspecified products
-
description
¶ The description of the product
-
Credits¶
Development Lead¶
- Costas Tyfoxylos <costas.tyf@gmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.1 (10-05-2017)¶
- First release