Class BlueVia
source code
- Known Subclasses:
-
The BlueVia base class. All other BlueVia classes are inherited from
this class BlueVia.
Mainly Stores consumer and access_token, provides the generic
_signAndSend(...) a debug() method
HOWTO USE
oAuth routines
>>> o = bluevia.BlueViaOauth('<secret>', '<key>')
>>> o.fetch_request_token()
Returns the oAuth URL for user authorization
Successful authorization returns an oAuth verifier
>>> o.fetch_access_token("<verifier>")
>>> o.saveAccessToken("newtok.pkl")
SMS outbound routines
>>> s = bluevia.BlueViaOutboundSms()
>>> s.loadAccessToken("newtok.pkl")
>>> s.sendSMS([myMobileNumber], "Hallo Welt")
Returns the delivery URL
>>> s.deliveryStatus("<deliveryURL>")
SMS receive routines
For Sandbox testing use an app that can both send SMS and receive
SMS with keyword "BlueViaRocks"
1) Send a fake SMS
>>> s = bluevia.BlueViaOutboundSms()
>>> s.loadAccessToken("smsmo.pkl")
>>> s.sendSMS(["445480605"], "SANDBlueViaRocks so much!")
2) Receive SMS with App
>>> i = bluevia.BlueViaInboundSMS()
>>> i.loadAccessToken("smsmo.pkl")
>>> i.receiveSMS("445480605")
For live testing use a mobile from the developer (e.g. the one
owning the application)
1) Send "TESTBlueViaRocks so much live!" to
445480605
2) Retrieve from Test System
>>> i = bluevia.BlueViaInboundSMS("")
>>> i.loadAccessToken("smsmo.pkl")
>>> i.receiveSMS("445480605")
Location routines
>>> l = bluevia.BlueViaLocation()
>>> l.loadAccessToken("newtok.pkl")
>>> l.locateTerminal():
User context routines
>>> u = bluevia.BlueViaUserContext()
>>> u.loadAccessToken("newtok.pkl")
>>> u.getInfo():
Advertising routines
>>> a = bluevia.BlueViaAds("<adspace Id>")
>>> a.loadAccessToken("newtok.pkl")
>>> a.getAd_3l(keywordList = ["sport"])
Payment routines
>>> p = bluevia.BlueViaPayment('<secret>', '<key>')
>>> p.fetch_request_token(<amount>, <currency>, <serviceId>, <serviceName>)
>>> p.fetch_access_token(<verifier>)
>>> p.savePaymentInfo("payment.pkl")
>>> p.loadPaymentInfo("payment.pkl")
>>> p.issuePayment()
>>> p.checkPayment(<transactionId>)
|
_signAndSend(self,
requestUrl,
method,
token,
parameters={ } ,
body='
' ,
extraHeaders={ } ,
is_form_encoded=False)
Generic method to call an oAuth authorized API in BlueVia including
oAuth signature. |
source code
|
|
|
|
|
|
|
|
|
hasCredentials(self)
Check availability of access token |
source code
|
|
|
|
|
_debug(self,
requestUrl,
query,
headers,
body,
token,
req)
Prints aut anything relevant for oAuth debugging: URL, method, body,
headers, signature base string, ... |
source code
|
|
|
access_token = None
|
|
consumer = None
|
|
realm = None
|
|
environment = '
'
|
|
version = None
|
|
debugFlag = False
|
|
http = httplib2.Http()
|
_signAndSend(self,
requestUrl,
method,
token,
parameters={ } ,
body='
' ,
extraHeaders={ } ,
is_form_encoded=False)
| source code
|
Generic method to call an oAuth authorized API in BlueVia including
oAuth signature.
- Parameters:
requestUrl - (string): The BlueVia URL
method - (string): HTTP method, "GET" or
"POST"
token - (oauth.Token): Usually the Access Token. During oAuth Dance
None or Request Token
parameters - (dict): Necessary call paramters, e.g. version, alt.
Default: None
body - (string): Body of the HTTP call. Default:
""
extraHeaders - (dict): Some calls need extra headers, e.g.
{"Content-Type":"application/json"}. Default:
None
is_form_encoded - (boolean): If True parameters are send as form encoded HTTP body.
DEFAULT: False
- Returns:
- (tuple): (HTTP response, HTTP response data)
|
Load Consumer Credentials and Access Token from disk (pickle
file).
- Parameters:
path - (string): Path to pickle file
- Returns:
- (boolean): True if successfully loaded
Note:
Unencrypted storage. Use only for testing!
|
Set the Consumer credentials.
- Parameters:
consumer - (oauth.Token): The consumer credentials as provided by getCosumer
in class BlueViaOauth
|
Set the Access Token.
- Parameters:
access_token - (oauth.Token): The oAuth access token as provided by
getAccessToken in class BlueViaOauth
|
Set or unset the debug flag
- Parameters:
dbgFlag - (boolean): If True debug information will be printed to stdout
|
_debug(self,
requestUrl,
query,
headers,
body,
token,
req)
| source code
|
Prints aut anything relevant for oAuth debugging: URL, method, body,
headers, signature base string, ...
|