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)

Json File


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)

Cancel callback

from powerlingapi import PowerlingApi

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

  # [get a file]
  file.cancel_callback()

Get analisys

from powerlingapi import PowerlingApi

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

  # [get a file]
  file.get_analisys()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

powerling_api_sdk-0.1.6-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for powerling_api_sdk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7f75da6e2ebc4ad539ea749d62c94dac2ce8e1a0968bf4d2c5a68e5ab8ec1ffd
MD5 2e76b5162331ac7282f0896fec8e458a
BLAKE2b-256 49ad70676b1c12d93eb4348d1d0349161316c4de2bdeddb8cb84464894e8c04d

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