Skip to main content

SDK for Powerling API

Project description

Powerling API SDK

Installation

From sources

git clone <url> power-api-sdk
cd power-api-sdk
pip install .

From test pypi

pip install -i https://test.pypi.org/simple/ powerling-api-sdk-package-powerling

Usage

Initialization

from powerlingapi import PowerlingApi
from powerlingapi import exceptions

def main():
  api = PowerlingApi()

  try:
    api.authorize("YOUR-ACCESS-TOKEN")

  except exceptions.api.InvalidCredentials as error:
    print(error)

Account

from powerlingapi import PowerlingApi
from powerlingapi import exceptions
from powerlingapi import Form

def main():
  # [initialization...]

  api.account()

Supported languages

from powerlingapi import PowerlingApi
from powerlingapi import exceptions
from powerlingapi import Form

def main():
  # [initialization...]

  api.supported_langs()

Order

Create

from powerlingapi import PowerlingApi
from powerlingapi import exceptions
from powerlingapi import Form

def main():
  # [initialization...]

  new_order = Form.Order("New order")

  try:
    order = api.create_order(new_order)

  except exceptions.order.ErrorOnCreation as error_on_creation:
    print(error_on_creation)

  except Exception as error:
    print(error)

Get

from powerlingapi import PowerlingApi
from powerlingapi import exceptions

def main():
  # [initialization...]

  try:
    order = api.get_order_by_id(123)

  except exceptions.order.NotFound as error_not_found:
    print(error_not_found)

  except Exception as error:
    print(error)

Submit

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get an order with id or create new one]
  order.submit()

Add callback

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  url = "https://exemple.com/callback"

  # [get an order with id or create new one]
  order.add_callback(url)

Get analysis

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get an order with id or create new one]
  order.get_analysis()

Add binary file

from powerlingapi import PowerlingApi
from powerlingapi import exceptions
from powerlingapi import Form

def main():
  # [initialization...]

  try:
    form_file = Form.FileBinary('fr_FR', 'de_DE', 'file.xlf')

    # [get an order with id or create new one]
    file_id = order.add_bin_file(form_file)

  except exceptions.form.InvalidFormFileBinary as invalid_form:
    print(invalid_form)

  except exceptions.file.ErrorOnUpload as error_on_upload:
    print(error_on_upload)

  except Exception as error:
    print(error)

Add url file

from powerlingapi import PowerlingApi
from powerlingapi import exceptions
from powerlingapi import Form

def main():
  # [initialization...]

  try:
    form_file = Form.FileUrl('fr_FR', 'de_DE', 'https://exemple.com/file.xlf')

    # [get an order with id or create new one]
    file_id = order.add_url_file(form_file)

  except exceptions.form.InvalidFormFileUrl as invalid_form:
    print(invalid_form)

  except exceptions.file.ErrorOnUpload as error_on_upload:
    print(error_on_upload)

  except Exception as error:
    print(error)

File

Get

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get an order with id or create new one]
  files = order.get_files() # Get all files attached to the order

  the_file = order.get_file_by_id(123) # Get specific file from the order

  completed_files = order.get_files_by_status("completed") # Get all files with specific status

Status

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get a file]
  file.status()

Download

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get a file]
  file.download()

Add callback

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  url = "https://exemple.com/callback"

  # [get a file]
  file.add_callback(url)

Get analysis

from powerlingapi import PowerlingApi

def main():
  # [initialization...]

  # [get a file]
  file.get_analysis()

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

powerling-api-sdk-0.1.4.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

powerling_api_sdk-0.1.4-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file powerling-api-sdk-0.1.4.tar.gz.

File metadata

  • Download URL: powerling-api-sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for powerling-api-sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3556ec51abbfb413131e5ef5d6e98c6997942e8474c2bae0441f81a2b08073ac
MD5 416a6485e35ff098a5370bda1cbac50f
BLAKE2b-256 e2fd283f083ca18212c2a2c9b7b5130a6259361c25a14ae69eaea22c12b47de2

See more details on using hashes here.

File details

Details for the file powerling_api_sdk-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for powerling_api_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 15626f2dafb31fac918e0af4f743c3fe17e519d2aeeaf34101977e19785e4b56
MD5 7ed1cf5da7f0eb2240818b9e17265bd9
BLAKE2b-256 47b99b462087cf4397a2e724a689e9b469170f3ae3d2a1d1e34f237926d00af6

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