Skip to content

Commit

Permalink
client for the 2.0 API + unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Macedo committed Sep 21, 2010
1 parent a3f84ae commit e1d4053
Show file tree
Hide file tree
Showing 9 changed files with 736 additions and 344 deletions.
2 changes: 1 addition & 1 deletion LICENCE
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2008 3scale networks S.L.
Copyright (c) 2010 3scale networks S.L.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: ThreeScale
Version: 1.0
Metadata-Version: 2.0
Name: ThreeScalePY
Version: 2.0
Summary: Plugin to 3scale API in Python
Home-page: http://www.3scale.net/
Author: http://www.3scale.net/
Expand Down
44 changes: 11 additions & 33 deletions README
@@ -1,53 +1,31 @@
Please note: This version of the library targets the new API, which is currently in beta phase. Please contact 3scale support at support@3scale.net before you use it. You can also use older version (1.0.0) targeting the old API: http://github.com/3scale/3scale_ws_api_for_python/tree/v1.0.0


Installation:

Standard distutils installation: unpack ThreeScale-1.0.tar.gz, and from ThreeScale-1.0 directory run
Standard distutils installation: unpack ThreeScale-2.0.tar.gz, and from ThreeScale-2.0 directory run

sudo python setup.py install

or you may put ThreeScale.py to the same directory as your program
or you may put ThreeScalePY.py to the same directory as your program

Usage:

In short:

import ThreeScale

# 3scale SERVER
# You can find the server hostname on http://www.3scale.net/support/api
hostname = "XXX.XXXX.XXX"

# KEYS PROVIDED BY 3scale (when you create contracts)
provider_verification_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
provider_auth_key = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"

# KEY PROVIDED BY 3scale to your customer
# your customer (or user) will send you this key, you must send it
# back to 3scale for the transaction to start
user_key = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
import ThreeScalePY

# USAGE:

# Create a new transaction:
interface = ThreeScale.Interface(hostname, provider_auth_key)
transaction = interface.start(user_key, hits = 1)
# Should be check for
# provider_verification_key == transaction['provider_verification_key']:

# If the transaction was successful, you can go ahead with your service,
# After your services is done, you must either confirm it or cancel it

result = interface.confirm(transaction['id'])
# Result can be either true or exception

transaction = interface.start(user_key, hits = 2)
result = interface.cancel(transaction['id'])
# Result can be either true or True or exception
# Authorize a transaction:

ThreeScalePY.ThreeScaleAuthorize("provider key", "app id", "app key").authorize()

For more documentation see `pydoc ThreeScale` or comments in the module
# Report a transaction:

ThreeScalePY.ThreeScaleReport("provider key").report([{"app_id":"app id", "usage":{"hits":1, "max_value":5}}]

Legal:

Copyright (c) 2008 3scale networks S.L., released under the MIT license.
Copyright (c) 2010 3scale networks S.L., released under the MIT license.

306 changes: 0 additions & 306 deletions ThreeScale.py

This file was deleted.

0 comments on commit e1d4053

Please sign in to comment.