Metadata-Version: 2.1
Name: kra-etims
Version: 1.0.1
Summary: A Python wrapper for the KRA eTIMS REST API
Home-page: https://github.com/ingenious-dev/kra-etims-api-python
Author: Joseph Suhudu @ ingenious.or.ke
Author-email: suhudu+joseph@gmail.com
License: MIT License
Project-URL: Source, https://github.com/ingenious-dev/kra-etims-api-python
Project-URL: Tracker, https://github.com/ingenious-dev/kra-etims-api-python/issues
Keywords: kra etims rest api
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
License-File: LICENSE.txt
Requires-Dist: requests

KRA eTIMS API - Python Client
===============================

A Python wrapper for the KRA eTIMS REST API. Easily interact with the KRA eTIMS REST API using this library.

Installation
------------

.. code-block:: bash

    pip install kra-etims

Setup
-----

.. code-block:: python

    from kra_etims import API

    etimsapi = API(
        url="http://localhost:8088",
        pin="A123456789Z",
    )

Options
~~~~~~~

+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+
|         Option        |     Type    | Required |                                              Description                                              |
+=======================+=============+==========+=======================================================================================================+
| ``url``               | ``string``  | yes      | Your Server URL, example: http://localhost:8088/                                                      |
+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+
| ``pin``               | ``string``  | yes      | Your PIN                                                                                              |
+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+
| ``timeout``           | ``integer`` | no       | Connection timeout, default is ``5``                                                                  |
+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+
| ``verify_ssl``        | ``bool``    | no       | Verify SSL when connect, use this option as ``False`` when need to test with self-signed certificates |
+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+
| ``user_agent``        | ``string``  | no       | Set a custom User-Agent, default is ``KRA-eTIMS-Python-REST-API/1.0.1``                               |
+-----------------------+-------------+----------+-------------------------------------------------------------------------------------------------------+

Methods
-------

+--------------+----------------+------------------------------------------------------------------+
|    Params    |      Type      |                           Description                            |
+==============+================+==================================================================+
| ``endpoint`` | ``string``     | KRA eTIMS API endpoint, example: ``customers`` or ``order/12``   |
+--------------+----------------+------------------------------------------------------------------+
| ``data``     | ``dictionary`` | Data that will be converted to JSON                              |
+--------------+----------------+------------------------------------------------------------------+
| ``**kwargs`` | ``dictionary`` | Accepts ``params``, also other Requests arguments                |
+--------------+----------------+------------------------------------------------------------------+

POST
~~~~

- ``.post(endpoint, data, **kwargs)``

Response
--------

All methods will return `Response <http://docs.python-requests.org/en/latest/api/#requests.Response>`_ object.

Example of returned data:

.. code-block:: bash

    >>> r = etimsapi.post("/items/selectItems", {
            "bhfId":"00",
            "lastReqDt":"20160523000000"
        })
    >>> r.status_code
    200
    >>> r.headers['content-type']
    'application/json; charset=UTF-8'
    >>> r.encoding
    'UTF-8'
    >>> r.text
    u'{"resultCd": "000","resultMsg": "Successful","resultDt": "20240816201351","data": {"itemList": [{"tin": "P052350422M",...' // Json text
    >>> r.json()
    {u'resultCd': u'000',u'resultMsg': u'Successful',u'resultDt': u'20240816201351',u'data': {u'itemList': [{u'tin': u'P052350422M',... // Dictionary data

Changelog
---------

See `CHANGELOG.md <https://github.com/ingenious-dev/kra-etims-api-python/blob/trunk/CHANGELOG.md>`_.
