Skip to content

Commit

Permalink
deploy: b62d6c9
Browse files Browse the repository at this point in the history
  • Loading branch information
TDKorn committed Dec 9, 2023
0 parents commit 2939976
Show file tree
Hide file tree
Showing 103 changed files with 53,101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 62e00b463d5fe114d7ee1bf5d00b6e5d
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
765 changes: 765 additions & 0 deletions README.html

Large diffs are not rendered by default.

Binary file added _images/magento_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
594 changes: 594 additions & 0 deletions _modules/index.html

Large diffs are not rendered by default.

2,845 changes: 2,845 additions & 0 deletions _modules/logging.html

Large diffs are not rendered by default.

628 changes: 628 additions & 0 deletions _modules/magento.html

Large diffs are not rendered by default.

1,054 changes: 1,054 additions & 0 deletions _modules/magento/clients.html

Large diffs are not rendered by default.

668 changes: 668 additions & 0 deletions _modules/magento/exceptions.html

Large diffs are not rendered by default.

784 changes: 784 additions & 0 deletions _modules/magento/models/category.html

Large diffs are not rendered by default.

700 changes: 700 additions & 0 deletions _modules/magento/models/invoice.html

Large diffs are not rendered by default.

871 changes: 871 additions & 0 deletions _modules/magento/models/model.html

Large diffs are not rendered by default.

877 changes: 877 additions & 0 deletions _modules/magento/models/order.html

Large diffs are not rendered by default.

1,205 changes: 1,205 additions & 0 deletions _modules/magento/models/product.html

Large diffs are not rendered by default.

1,405 changes: 1,405 additions & 0 deletions _modules/magento/search.html

Large diffs are not rendered by default.

951 changes: 951 additions & 0 deletions _modules/magento/utils.html

Large diffs are not rendered by default.

639 changes: 639 additions & 0 deletions _snippets/available_endpoints.html

Large diffs are not rendered by default.

251 changes: 251 additions & 0 deletions _sources/README.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
.. Title: MyMagento
.. Description: A Python package that wraps and extends the Magento 2 REST API
.. Author: TDKorn
.. meta::
:title: MyMagento
:description: A Python package that wraps and extends the Magento 2 REST API

.. |RTD| replace:: **Explore the docs »**
.. _RTD: https://my-magento.readthedocs.io/en/latest/
.. |api_endpoint| replace:: API endpoint
.. _api_endpoint: https://adobe-commerce.redoc.ly/2.3.7-admin/


.. only:: pypi

MyMagento🛒
---------------

.. image:: https://i.imgur.com/dkCWWYn.png
:alt: Logo for MyMagento: Python Magento 2 REST API Wrapper
:align: center
:width: 200
:height: 175

.. raw:: html

<div align="center">

.. only:: html or readme

.. image:: _static/magento_orange.png
:alt: Logo for MyMagento: Python Magento 2 REST API Wrapper
:width: 15%

.. only:: html

.. raw:: html

<span class="h1">MyMagento🛒</span>

.. only:: readme

.. raw:: html

<h1>MyMagento🛒</h1>


A Python package that wraps and extends the Magento 2 REST API


|RTD|_

.. only:: pypi

|
.. image:: https://img.shields.io/pypi/v/my-magento?color=eb5202
:target: https://pypi.org/project/my-magento/
:alt: PyPI Version

.. image:: https://img.shields.io/badge/GitHub-my--magento-4f1abc
:target: https://github.com/tdkorn/my-magento
:alt: GitHub Repository

.. image:: https://static.pepy.tech/personalized-badge/my-magento?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads
:target: https://pepy.tech/project/my-magento

.. image:: https://readthedocs.org/projects/my-magento/badge/?version=latest
:target: https://my-magento.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. raw:: html

</div>

|
About MyMagento
~~~~~~~~~~~~~~~~~~~~

.. admonition:: What's MyMagento?
:class: note

``MyMagento`` is a highly interconnected package that wraps and extends the Magento 2 REST API,
providing a more intuitive and user-friendly interface to access and update your store.


.. rubric:: MyMagento simplifies interaction with the Magento 2 REST API

If you've worked with the Magento 2 API, you'll know that not all endpoints are created equally.

``MyMagento`` aims to streamline your workflow by simplifying a
variety of commonly needed API operations.

.. only:: readme

...

Main Components
==================================

.. admonition:: The :class:`~.Client`
:class: client

* Handles all API interactions
* Supports multiple store views
* Provides access to all other package components

.. admonition:: The :class:`~.SearchQuery` and Subclasses
:class: search

* :meth:`~.execute` a search query on any endpoint
* Intuitive interface for :ref:`Custom Queries`
* All predefined methods retrieve data using only 1-2 API requests

.. admonition:: The :class:`~.Model` Subclasses
:class: hint

* Wrap all API responses in the package
* Provide additional endpoint-specific methods to retrieve and update data

.. only:: readme

...

Available Endpoints
======================

``MyMagento`` is compatible with every |api_endpoint|_

Endpoints are wrapped with a :class:`~.Model` and :class:`~.SearchQuery` subclass as follows:

.. include:: _snippets/available_endpoints.rst
:start-line: 6


...

⚙ Installing MyMagento
~~~~~~~~~~~~~~~~~~~~~~~~~~


To install using ``pip``::

pip install my-magento

Please note that ``MyMagento`` requires ``Python >= 3.10``

...

.. only:: readme or pypi

📚 Documentation
~~~~~~~~~~~~~~~~~~

Full documentation can be found on `ReadTheDocs <https://my-magento.readthedocs.io/en/latest/>`_

|
QuickStart: Login with MyMagento
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``MyMagento`` uses the :class:`~.Client` class to handle all interactions with the API.

.. tip:: See :ref:`logging-in` for full details on generating an access token


Setting the Login Credentials
===================================

To generate an :attr:`~.ACCESS_TOKEN` you'll need to :meth:`~.authenticate` your :attr:`~.USER_CREDENTIALS`.

Creating a :class:`~.Client` requires a ``domain``, ``username``, and ``password`` at minimum.


.. code-block:: python
>>> domain = 'website.com'
>>> username ='username'
>>> password = 'password'
If you're using a local installation of Magento you'll need to set ``local=True``. Your domain should look like this:

.. code-block:: python
>>> domain = '127.0.0.1/path/to/magento'
...

Getting a :class:`~.Client`
=================================

Option 1: Initialize a :class:`~.Client` Directly
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python
from magento import Client
>>> api = Client(domain, username, password, **kwargs)
Option 2: Call :func:`~.get_api`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python
import magento
>>> api = magento.get_api(**kwargs)
:func:`.get_api` takes the same keyword arguments as the :class:`~.Client`

* If the ``domain``, ``username``, or ``password`` are missing,
it will attempt to use the following environment variables:


.. code-block:: python
import os
os.environ['MAGENTO_DOMAIN'] = domain
os.environ['MAGENTO_USERNAME']= username
os.environ['MAGENTO_PASSWORD']= password
...

Getting an :attr:`~.ACCESS_TOKEN`
=======================================

Unless you specify ``login=False``, the :class:`~.Client` will automatically call :meth:`~.authenticate` once initialized:


.. code-block:: python
>> api.authenticate()
|[ MyMagento | website_username ]|: Authenticating username on website.com...
|[ MyMagento | website_username ]|: Logged in to username
.. only:: readme or pypi

|
.. include:: interact-with-api.rst
:start-line: 11
17 changes: 17 additions & 0 deletions _sources/_snippets/available_endpoints.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. _available_endpoints:

Available Endpoints
~~~~~~~~~~~~~~~~~~~~~~~

The following endpoints are currently wrapped with a :class:`~.Model` and :class:`~.SearchQuery` subclass

.. csv-table::
:header: "**Endpoint**", "**Client Shortcut**", ":class:`~.SearchQuery` **Subclass**", ":class:`~.Model` **Subclass**"

"``orders``", ":attr:`.Client.orders`", ":class:`~.OrderSearch`", ":class:`~.Order`"
"``orders/items``", ":attr:`.Client.order_items`", ":class:`~.OrderItemSearch`", ":class:`~.OrderItem`"
"``invoices``", ":attr:`.Client.invoices`", ":class:`~.InvoiceSearch`", ":class:`~.Invoice`"
"``products``", ":attr:`.Client.products`", ":class:`~.ProductSearch`", ":class:`~.Product`"
"``products/attributes``", ":attr:`.Client.product_attributes`", ":class:`~.ProductAttributeSearch`", ":class:`~.ProductAttribute`"
"``categories``", ":attr:`.Client.categories`", ":class:`~.CategorySearch`", ":class:`~.Category`"
"``endpoint``", "``Client.search('endpoint')``", ":class:`~.SearchQuery`", ":class:`~.APIResponse`"
7 changes: 7 additions & 0 deletions _sources/category.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The ``category`` module
--------------------------

.. automodule:: magento.models.category
:members:
:undoc-members:
:show-inheritance:
88 changes: 88 additions & 0 deletions _sources/changelog.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Changelog
----------

v2.1.0
~~~~~~~

* Added :meth:`~.get_api` to login using credentials stored in environment variables

- The environment variables ``MAGENTO_USERNAME``, ``MAGENTO_PASSWORD``, ``MAGENTO_DOMAIN`` will be used if the ``domain``, ``username`` or ``password`` kwargs are missing


.. code-block:: python
import magento
>>> magento.get_api()
2023-02-08 03:34:20 INFO |[ MyMagento | 127_user ]|: Authenticating user on 127.0.0.1/path/to/magento
2023-02-08 03:34:23 INFO |[ MyMagento | 127_user ]|: Logged in to user
<magento.clients.Client object at 0x000001CA83E1A200>
...

* Added ``local`` kwarg to ``Client`` to support locally hosted Magento stores and test environments

- By default, ``local=False``

.. code-block:: python
from magento import Client
>>> api = Client("127.0.0.1/path/to/magento", "username", "password", local=True)
...

* Add :meth:`~.since` and :meth:`~.until` method to :class:`~.SearchQuery` classes, which search the ``created_at`` field

- They can be chained together and also with :meth:`~.add_criteria`

.. admonition:: Example
:class: example

.. code-block:: python
# Retrieve orders from the first 7 days of 2023
>>> api.orders.since("2023-01-01").until("2023-01-07").execute()
[<Magento Order: #000000012 placed on 2023-01-02 05:19:55>, ]
.. admonition:: Example
:class: example
.. code-block:: python
# Retrieve orders over $50 placed since 2022
>>> api.orders.add_criteria(
... field="grand_total",
... value="50",
... condition="gteq"
... ).since("2022-01-01").execute()
[<Magento Order: #000000003 placed on 2022-12-21 08:09:33>, ...]
...
* Changed :meth:`~.add_criteria` to auto-increment the filter group by default if no group is specified (ie. ``AND`` condition)
.. code-block:: python
# Retrieving products that are over $10 AND in the category with id 15
#
# Before v2.1.0
>>> api.products.add_criteria('category_id','15').add_criteria('price','10','gteq', group=1)
# v2.1.0+
>>> api.products.add_criteria('category_id','15').add_criteria('price','10','gteq')
...
* Changed the :attr:`.Client.BASE_URL` to not include ``"www."`` at the start (see `#8 <https://github.com/tdkorn/my-magento/issues/8>`_)
* Added unit tests for :meth:`~.url_for`
* Added Jupyter notebook examples
7 changes: 7 additions & 0 deletions _sources/clients.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The ``clients`` module
----------------------

.. automodule:: magento.clients
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit 2939976

Please sign in to comment.