Skip to main content

Python API Wrapper for the public CodeOffer API

Project description

CodeOffer Python Package

This is a Python package that provides an API wrapper for the public CodeOffer API. The package simplifies authentication and management of in-app assets for developers who use the CodeOffer API in their applications.

Installation

To install the package, run the following command:

pip install codeoffer

Usage

Import the codeoffer class from the package:

Authentication & Sessions

Initialize a new session, but first you need to import the oauth class from codeoffer

from codeoffer import oauth

After that you can create a new session token:

token = session.create_session_token()

Now get the login link and ask the user to log in: token.get_login_link()

Right after that call the token.wait_for_confirmation() method, this method will wait until the user completed the login-process.

To return the current logged in user you need to import the user class from codeoffer

from src.codeoffer import user

Then you can return the current user by using the get_user method and passing the token as a parameter:

user = user.User.get_user(token)

And now you can get the username, email, profile picture and access to the current logged in app (if the user purchased / downloaded the app with his account)

print(f"Hey {user.username}")

Assets

You can return all the apps your app contains.

First import the app class from codeoffer

from codeoffer import app

Then you need to initialize the app with a session token.

app = app.App.by_session_token(token)

After that you can return all the assets your app contains and return properties like the name, identifier and if the user has access to that asset.

assets = app.get_asset_directory()
for asset in assets:  
	print(f"{asset.name}: {asset.access}")

Complete Example

from codeoffer import oauth
from codeoffer import app
from src.codeoffer import user

session = oauth.Session("10aa641e562bdd82d2f8449d")
token = session.create_session_token()
token.get_login_link()
token.wait_for_confirmation()
user = user.User.get_user(token)
print(f"Hey {user.username}")
app = app.App.by_session_token(token)
assets = app.get_asset_directory()
for asset in assets:
    print(f"{asset.name}: {asset.access}")

License

This package is licensed under the MIT License.

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

codeoffer-0.9.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

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

codeoffer-0.9.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file codeoffer-0.9.0.tar.gz.

File metadata

  • Download URL: codeoffer-0.9.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for codeoffer-0.9.0.tar.gz
Algorithm Hash digest
SHA256 eb9c5887b30004cf92ec1e32abcfa72d88882b0481a6d12197531cda64ee406c
MD5 84b6fa0effcf3f7256d6bbdbaa5973f7
BLAKE2b-256 24e493da3f391d1f591719302973c4a1fa1ea80af24b7d318f296c9b3ca6c34e

See more details on using hashes here.

File details

Details for the file codeoffer-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: codeoffer-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for codeoffer-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54079ba630d36e83381fc24b96d60445ee7956d2f818c13f8fce3aafe884e587
MD5 90ef4eaefdf3b608481980d3219d3862
BLAKE2b-256 b2626deb9c81f9b4959f76e42fc1c54fb4590c5ab626508cd0119a10076e3d13

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