Skip to main content

A Python client for web service communication

Project description

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`)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wservice_client-1.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

wservice_client-1.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file wservice_client-1.1.1.tar.gz.

File metadata

  • Download URL: wservice_client-1.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.2

File hashes

Hashes for wservice_client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 ad185f8ed110a65e57f6dcf17b3fcd21bde7258e0d6cf2ab00d64dcfa3f272f8
MD5 158b0f2f9ccefebc55af1bc9900fd8aa
BLAKE2b-256 2d65714baff789c35245b259d5a85c56ee7dbf869fa233075e0440f90b0c660c

See more details on using hashes here.

File details

Details for the file wservice_client-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wservice_client-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 656b37933613db9db08be2c0a7eb9c7f3ba2f3999d543c983bef4278d8239f34
MD5 8a9798f433e7e91257f3806642fa46b0
BLAKE2b-256 4f27cbb65e89ce75dc6ced1dd28727ae606a960dd16937658d4ee17d9f1a6658

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page