Welcome to ePages Client’s documentation!¶
Contents:
ePages Client¶
Python 3 client for ePages REST API.
- Free software: MIT license
- Documentation: https://epages-client.readthedocs.io.
Features¶
- TODO
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install ePages Client, run this command in your terminal:
$ pip install epages_client
This is the preferred method to install ePages Client, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for ePages Client can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/vilkasgroup/epages_client
Or download the tarball:
$ curl -OL https://github.com/vilkasgroup/epages_client/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage¶
Basic usage¶
To use ePages Client in a project:
from epages_client.client import RestClient
# Set the api url and token for your shop
api_url = "https://yourshop.vilkasstore.com/rs/shops/yourshop/"
api_token = "shop_token_goes_here"
# Get the instance of the client
client = RestClient(api_url, api_token)
# Example method: get shop info
shop_info = client.get_shop_info()
The dictionary parameter¶
Each method accepts a single dictionary parameter called params. This parameter is not mandatory for all methods.
# params can have five different keys
params = {
"data": "",
"param1": "",
"param2": "",
"query": {},
"object": "",
}
- data
- The content here is usually a dictionary, but can have a binary file, too.
- param1
- The first parameter to add to the api url.
- param2
- The second parameter to add to the api url.
- query
- A dictionary for query parameters, for example including hidden items in results.
- object
- As the name implies, this gets an object as a value. Objects are located in the dataobjects directory.
Examples¶
# Example 1
# Set category id and product id
params["data"] = {
'categoryId': "5A41E34F-BAC7-8396-336A-0A2810152BBC",
'productId': "5A497829-7619-ACCC-E487-0A281012346F"
}
# Connect category and product
response = client.connect_category_and_product(params)
# Example 2
# Set product id
# The api url will be:
# https://yourshop.vilkasstore.com/rs/shops/yourshop/products/5A497829-7619-ACCC-E487-0A281012346F
params["param1"] = "5A497829-7619-ACCC-E487-0A281012346F"
# Get product data
product = client.get_product(params)
# Example 3
# Set product id and image name
# The api url will be:
# https://yourshop.vilkasstore.com/rs/shops/yourshop/products/5A497829-7619-ACCC-E487-0A281012346F/slideshow/test.jpg
params["param1"] = "5A497829-7619-ACCC-E487-0A281012346F"
params["param2"] = "test.jpg"
# Delete image from product
response = client.delete_product_image(params)
# Example 4
# Find products where name contains the word 'laptop'
# Limit search results to have 50 items
params["query"] = {
"query": "laptop",
"limit": 50
}
# Search for the products
results = self.client.search_products(self.params)
# Example 5
# Create a customer
customer = CustomerCreate()
customer.billingAddress.firstName = "John"
customer.billingAddress.lastName = "Doe"
customer.billingAddress.emailAddress = "john.doe@mail.com"
# Add customer to params
params["object"] = customer
# Create a customer
response = client.add_customer(params)
Currency and locale¶
There are two ways to set currency and locale.
Note: If currency and locale are set using both setters and params[“query”], values of params[“query”] are used.
# Currency and locale are set using client setters
client.currency = "GBP"
client.locale = "en_US"
# Currency and locale are set using params["query"]
params["query"] = {
"currency": = "GBP",
"locale": = "en_US"
}
Methods¶
Here’s a list of available methods to use with ePages Client. Each method accepts a single dict parameter called params. The more detailed description of the param is found in the usage document. Method descriptions have a link to the ePages API, too.
Customers¶
get_customer¶
This method fetches single customer from the shop.
Required parameters: Customer id in param1
add_customer¶
This method adds a customer to the shop.
Required parameters: Instance of CustomerCreate in object
Note: When adding a customer, only the Address object must have something in some instance variable. It doesn’t matter which variable it is. The Address object is in the billingAddress instance variable of CustomerCreate.
Legal information¶
get_legal_information¶
This method gets hyperlinks of legal information for a shop.
Required parameters: none
get_contact_information¶
This method gets the contact information of a shop.
Required parameters: none
get_terms_and_conditions¶
This method gets the terms and conditions of a shop.
Required parameters: none
get_rights_of_withdrawal¶
This method gets the customer rights of withdrawal of a shop.
Required parameters: none
get_shipping_information¶
This method gets the detailed information on possible shipping types and the costs incurred.
Required parameters: none
update_contact_information¶
This method updates the contact information of a shop.
Required parameters: locale must be set
update_privacy_policy¶
This method updates the privacy policy of a shop.
Required parameters: locale must be set
update_terms_and_conditions¶
This method updates the terms and conditions of a shop.
Required parameters: locale must be set
update_rights_of_withdrawal¶
This method updates the customer rights of withdrawal of a shop.
Required parameters: locale must be set
Newsletters¶
get_newsletter_campaigns¶
This method gets the newsletter campaigns from a shop.
Required parameters: none
Orders and carts¶
get_order¶
This method gets the information of a single order.
Required parameters: Order id in param1
get_order_documents¶
This method gets finalized invoice and credit note order documents of a single order.
Required parameters: Order id in param1
add_coupon¶
This method applies a coupon code on a cart of a shop.
Required parameters: Cart id in param1, coupon code in data
delete_coupon¶
This method deletes a coupon from a cart and recalculates cart.
Required parameters: Cart id in param1, coupon line item id in param2
add_cart_line_item¶
This method adds a product line item in a cart.
Required parameters: Cart id in param1, instance of ProductLineItemCreate in object
update_cart_line_item¶
This method updates a product line item in a cart.
Required parameters: Cart id in param1, product line item id in param2, instance of ProductLineItemUpdate in object
delete_cart_line_item¶
This method deletes a product line item from a cart.
Required parameters: Cart id in param1, product line item id in param2
add_order¶
This method adds an order to a shop.
Required parameters: Cart id in param1
Note: Before creating an order, the billing address must be set in a cart. Billing address can be set after cart creation using the update_billing_address method.
update_billing_address¶
This method updates the billing address for a cart.
Required parameters: Cart id in param1
delete_billing_address¶
This method deletes the billing address from a cart.
Required parameters: Cart id in param1
update_shipping_address¶
This method updates the shipping address for a cart.
Required parameters: Cart id in param1
Products¶
get_shop_info¶
This method gets the public information of a shop, like name, slogan and logo.
Required parameters: none
get_category¶
This method gets a single product category of a shop.
Required parameters: Category id in param1
get_product¶
This method gets a single product from a shop.
Required parameters: Product id in param1
get_product_variations¶
This method gets links to product variations.
Required parameters: Product id in param1
get_product_images¶
This method gets product images with links to different sizes of the images.
Required parameters: Product id in param1
get_product_image_names¶
This method gets product image names in the order they appear in a shop.
Required parameters: Product id in param1
get_product_custom_attributes¶
This method gets the user-defined product attributes with their values.
Required parameters: Product id in param1
get_product_lowest_price¶
This method gets the lowest price of all variations of a product.
Required parameters: Product id in param1
search_products¶
This method searches products with a query.
Required parameters: Query string in query
get_shipping_method¶
This method gets a single shipping method of a shop.
Required parameters: Shipping method id in param1
get_tax_class¶
This method gets a single tax class of a shop.
Required parameters: Tax class id in param1
add_category¶
This method adds a subcategory to existing main category.
Required parameters: Main category id in param1, instance of CategoryCreate in object
update_category¶
This method updates a single category.
Required parameters: Category id in param1, instance of CategoryUpdate
Note: When updating a category, at least category id and category alias must be set. Category id must be the same that is set in param1, and alias can’t be the same than some other category has. So, alias must be set always and it must be the same it was or something else that other categories have.
get_subcategory_sequence¶
This method gets the order of subcategories for the main category.
Required parameters: Main category id in param1
update_subcategory_sequence¶
This method updates the order of subcategories.
Required parameters: Main category id in param1, instance of CategorySequenceUpdate in object
add_product¶
This method adds a new product for a shop.
Required parameters: Instance of ProductCreate
update_product¶
This method updates an existing product of a shop.
Required parameters: Product id in param1, instance of ProductUpdate
delete_product¶
This method deletes a product from a shop.
Required parameters: Product id in param1
upload_product_image¶
This method uploads an image for a product.
Required parameters: Product id in param1, image file in binary in data
Note: This doesn’t set the uploaded image in the main image of a product, even if uploaded image is the first image of the product. It must be set using update_product method.
delete_product_image¶
This method deletes a image from a product.
Required parameters: Product id in param1, image name in param2
update_product_image_sequence¶
This method updates the order of product images.
Required parameters: Product id in param1, instance of ProductSlideshowSequenceUpdate in object
get_updated_products¶
This method gets updated products by product attributes.
Required parameters: Product attribute in param1
Note: At the time of writing only stocklevel attribute works for this.
connect_category_and_product¶
This method connects categories and products.
Required parameters: Category and product id in data
Note: There can be more than one category or product id when connecting them to each other. Category id and product id values can be a list of ids, too.
disconnect_product_and_category¶
This method disconnects categories and products.
Required parameters: Category and product id in query
Note: There can be more than one category or product id when disconnecting them from each other. Category id and product id values can be a list of ids, too.
get_watched_products¶
This method lists products that are watched by customers.
Required parameters: none
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/vilkasgroup/epages_client/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
ePages Client could always use more documentation, whether as part of the official ePages Client docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/vilkasgroup/epages_client/issues.
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.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up epages_client for local development.
Fork the epages_client repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/epages_client.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv epages_client $ cd epages_client/ $ 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.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 epages_client tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 3.3, 3.4, 3.5, 3.6 and 3.7, and for PyPy. Check https://travis-ci.org/vilkasgroup/epages_client/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Pekka Piispanen <pekka@vilkas.fi>
- Tero Kotti <tero@vilkas.fi>
Contributors¶
None yet. Why not be the first?