Skip to main content

Brainstorming package, manage http request.

Project description

pybraads Readme 📜

Brainstorming package, manage http request.

Installation ⚡

Opérating system : Windows, MacOS & Linux :

Available function/class 📑

THttpType

A collection of authentication types.
BasicUsrPws = 0 #Basic user/password
Token = 1 #Token
Tokenpermanent = 2 #Tokenpermanent
ApiKey = 3 #API Keypy install get enum
OAuth2 = 4 #OAuth2

THttpMethode

A collection af available methodes.
GET = 0 #Get
POST = 1 #Post
PUT = 2 #Put

Http(aAuthType)

To create an http connection.
aAuthType, the authentication type for the connection.    

request(aHttpMethode : THttpMethode, aUrl : str, aBody : dict = {})

To request an url.
aHttpMethode, and http methode.
aUrl, the url to communicate. 
aBody : a dict with the body to send to the url.
return a dict with the full answer.
retValue ={
        'statusCode' : statusCode,
        'reason' : reason,
        'content' : value,
        'headers' : response.headers
        }

userName

To get or set the authentication user.

passWord

To get or set the authentication password.

authType

To get the authentication type.

headers

To get or set the http header.

error

To get the last error.

url

To get or set the url.

Howto use 📰

import pybrahttp

try:
    http = pybrahttp.Http(pybrahttp.THttpType.BasicUsrPws)
    http.userName = aUser
    http.passWord = aPws
    headers ={
        'User-Agent' : 'Brainstorming 1.0', 
        'content-type' : 'application/json',
        'Accept' : '*/*',
        'Accept-Encoding' : 'gzip, deflate, br',
        'Connection' : 'keep-alive'
        }
    http.headers = headers
    url = aurl
    #Exemple of XML body 
    body ={
        'Name' : 'Timesheet(s) ' + str(aParams[3]) + '- ' + str(aParams[0]),
        'Initiator' : aParams[1],
        "AutomaticReminder": {
            "IsSendAutomaticRemindersEnabled": True,
            "DaysBeforeFirstReminder": DaysBeforeFirstReminder,
            "IsRepeatRemindersEnabled": True,
            "RepeatReminders":RepeatReminders
            }
        }
    
    re = http.request(pybrahttp.THttpMethode.POST, url, body)
    if (re['statusCode'] >= 200) and (re['statusCode'] <= 250):
        #Do code if no error
    else:
        #Print the returned error
        print(str(re['content']))
        return False

Meta 💬

Brainstorming – Support.erp@brainstorming.eu

Distributed under the MIT license. See LICENSE for more information.

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

pybrahttp-0.1.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybrahttp-0.1.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pybrahttp-0.1.3.tar.gz.

File metadata

  • Download URL: pybrahttp-0.1.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for pybrahttp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3a1826dec1fbec98a0c0f28f96821024a7b63315cd1bb3f2ab7704c357208086
MD5 b5f774c24b27ba634611537dd29b4afc
BLAKE2b-256 1989f9b606fa4485e5e8df325b5f398241bef322f9b2408e6c29a3a8b7b422c4

See more details on using hashes here.

File details

Details for the file pybrahttp-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pybrahttp-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for pybrahttp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d5f206f11cd81f3a578daa4db21947f45d54fbbfc4b756662f11b1faf84acc12
MD5 591951888cfcf077b6c31101d71a45fe
BLAKE2b-256 477c9be47efe731889756fac3035a3cdd4e83434110139b2fa933a6d4980b0c2

See more details on using hashes here.

Supported by

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