Skip to main content

WServiceClient

WServiceClient is a Python package designed for easy communication with web services. It allows you to send data, ping servers, perform HTTP requests, and extract IP addresses from URLs.

Features

  • Send JSON data to a web service
  • Perform GET requests for specific web service endpoints
  • Ping servers to check their availability
  • Extract IP addresses from URLs
  • Handle HTTP errors, timeouts, and connection errors gracefully

Installation

You can install wservice_client directly from PyPI:

pip install wservice-client

Alternatively, if you want to install it from the source, clone the repository and install it locally:

git clone git@github.com:mnedev-cell/wservice_client.git
cd wservice_client
pip install .

Usage

Here’s how to use the WServiceClient in your project:

Initialize the Client You can initialize the WServiceClient with the URL of the web service you want to communicate with:

from wservice_client import WServiceClient

# Initialize the client with the base URL of the web service
ws_client = WServiceClient("http://example.com/webservice")

Send Data to the Web Service

You can send JSON data to the web service using the send_data method:

data = {"key": "value"}
response = ws_client.send_data(data)
print("Response:", response)

Ping a Server

You can check if a server is online by using the ping method:

is_online = ws_client.ping("example.com")
print("Server online:", is_online)

Extract IP Address from URL

You can extract the IP address from a URL using the extract_ip method:

ip_address = ws_client.extract_ip()
print("Extracted IP:", ip_address)

Perform a GET Request with MAJ_PASSAGE_TICKET

You can use the MAJ_PASSAGE_TICKET method to perform a GET request to update ticket status with custom parameters

response, status = ws_client.MAJ_PASSAGE_TICKET(
    cb="codebarre", 
    mode_prg="N", 
    user_agent="Agent", 
    sBadge_Ticket_Type="BILLET", 
    stypeCRTL="SAL"
)
print("Response:", response, "Status:", status)

Running Tests

To ensure everything works properly, run the unit tests provided in the tests folder:

python -m unittest discover tests

This will execute all test cases for the WServiceClient class.

Contributing

Contributions are welcome! If you find any bugs or have any suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.

Fork the repository Create your feature branch (git checkout -b feature/AmazingFeature) Commit your changes (git commit -m 'Add some AmazingFeature') Push to the branch (git push origin feature/AmazingFeature) Open a pull request License This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This package uses the requests library to handle HTTP requests. For more information about requests, check out the documentation.Usage Here’s how to use the WServiceClient in your project:

Breakdown of the Sections:

  1. Features: Lists the main capabilities of the WServiceClient.
  2. Installation: Instructions for installing the package from PyPI or from source via GitHub.
  3. Usage: Sample code to help users quickly understand how to use the client.
  4. Running Tests: Instructions on how to run unit tests.
  5. Contributing: Guidelines for contributing to the project.
  6. License: Information about the project's licensing.

This README.md is comprehensive and serves as both your PyPI project description and GitHub repository guide.

wservice_client/              # Project root directory
│
├── wservice_client/          # Main package folder
│   └── __init__.py           # Initialize the package
│   └── wservice_client.py    # The WServiceClient class (your main module)
├── tests/                    # Unit tests
│   └── test_wservice_client.py
├── README.md                 # Project README with instructions and usage
├── setup.py                  # Setup script for PyPI
└── requirements.txt          # Dependencies (like `requests`)

Metadata

Release files for wservice-client 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wservice-client 1.1.1
File Size Uploaded
wservice_client-1.1.1.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wservice-client 1.1.1
File Interpreter ABI Platform
wservice_client-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / wservice_client-1.1.1.tar.gz

Download URL wservice_client-1.1.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ad185f8ed110a65e57f6dcf17b3fcd21bde7258e0d6cf2ab00d64dcfa3f272f8
BLAKE2b-256 checksum
How to use checksums
2d65714baff789c35245b259d5a85c56ee7dbf869fa233075e0440f90b0c660c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.2

Release files / wservice_client-1.1.1-py3-none-any.whl

Download URL wservice_client-1.1.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
656b37933613db9db08be2c0a7eb9c7f3ba2f3999d543c983bef4278d8239f34
BLAKE2b-256 checksum
How to use checksums
4f27cbb65e89ce75dc6ced1dd28727ae606a960dd16937658d4ee17d9f1a6658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page