API Documentation¶
pykayacim.api¶
This module is for communicating with im.kayac.com.
-
class
pykayacim.api.
KayacIMAPI
(username, method='none', key=None)[source]¶ Class for accessing im.kayac.com API.
Parameters: - username (str (on Python 3) or unicode (on Python 2)) – The username for your account.
- method (str (on Python 3) or unicode (on Python 2)) – (optional) The authorization method. Choose
from
pykayacim.constants.KAYACIM_METHODS
. - key (str (on Python 3) or unicode (on Python 2)) – (optional) The password or secret key.
Raises pykayacim.exceptions.PyKayacIMMethodError: if an unavailable method is specified or the provided information is insufficient
-
key
= None¶ The password or secret key.
-
method
= None¶ The authorization method im.kayac.com accepts.
-
post_params
= None¶ The parameters for a POST request.
-
post_request
= None¶ The object representing the request sent to im.kayac.com.
-
post_response
= None¶ The dictionary representing the response from im.kayac.com.
-
post_url
= None¶ The URL where POST requests should be sent.
-
prepare_parameters
(message, handler=None)[source]¶ Creates a dictionary representing the provided parameters.
This method is called by
pykayacim.api.KayacIMAPI.send()
, and does not need to be called directly.Parameters: - message (str (on Python 3) or unicode (on Python 2)) – The message which should be sent.
- handler – (optional) The URI scheme for iPhone applications, which starts with “mailto:” for example.
-
resend
()[source]¶ Resend the previous message.
Raises: - pykayacim.exceptions.PyKayacIMAPIError – if im.kayac.com reports an error
- pykayacim.exceptions.PyKayacIMCommunicationError – if connection with im.kayac.com fails
- pykayacim.exceptions.PyKayacIMMessageError – if no message was sent previously
-
send
(message, handler=None)[source]¶ Send a push notification via im.kayac.com.
Parameters: - message (str (on Python 3) or unicode (on Python 2)) – The message which should be sent.
- handler (str (on Python 3) or unicode (on Python 2)) – (optional) The URI scheme for iPhone applications, which starts with “mailto:” for example.
Raises: - pykayacim.exceptions.PyKayacIMAPIError – if im.kayac.com reports an error
- pykayacim.exceptions.PyKayacIMCommunicationError – if connection with im.kayac.com fails
-
username
= None¶ The username for your im.kayac.com account.
-
pykayacim.api.
api_logger
= <logging.Logger object at 0x0000000004CE8278>¶ The logger for this module.
-
pykayacim.api.
create_post_request
(url, params, encoding='utf-8')[source]¶ URL-encode the parameters and create a POST request.
Parameters: - url (str (on Python 3) or unicode (on Python 2)) – The URL where a POST request should be sent.
- params (dict) – The dictionary representing the parameters, whose values should be str (on Python 3) or unicode (on Python 2).
- encoding (str (on Python 3) or unicode (on Python 2)) – The encoding should be used.
Returns: an HTTP POST request
Return type: urllib.request.Request
(on Python 3) orfuture.backports.urllib.request.Request
(on Python 2)
-
pykayacim.api.
generate_signature
(data, encoding='utf-8')[source]¶ Generate the SHA-1 digest of the given string.
Parameters: data (str (on Python 3) or unicode (on Python 2)) – The string should be processed. Returns: the SHA-1 digest Return type: str (on Python 3) or future.types.newstr.newstr
(on Python 2)
Note
As above, pykayacim.api
uses the logging
system of
Python. From your application you can access the logger defined in
pykayacim.api
to process the log.
pykayacim.constants¶
This module contains constants for PyKayacIM.
-
pykayacim.constants.
KAYACIM_ENCODING
= 'utf-8'¶ Encoding im.kayac.com accepts.
-
pykayacim.constants.
KAYACIM_METHODS
= ['none', 'password', 'secret']¶ The authorization methods im.kayac.com accepts.
- “none”
- No authorization.
- “password”
- Use authorization with a password.
- “secret”
- Use secret key cryptosystem.
-
pykayacim.constants.
KAYACIM_URL
= 'http://im.kayac.com/api/post/'¶ The URL of the API endpoint.
pykayacim.exceptions¶
This module contains exceptions of PyKayacIM.
-
exception
pykayacim.exceptions.
PyKayacIMAPIError
(errmsg)[source]¶ Raised when im.kayac.com reports an error.
Parameters: errmsg (str (on Python 3) or unicode (on Python 2)) – The detailed information about the error.
-
exception
pykayacim.exceptions.
PyKayacIMCommunicationError
(reason)[source]¶ Raised when communication with im.kayac.com fails.
This exception will be raised when this module cannot establish connection with im.kayac.com, or an HTTP error occurs.
Parameters: reason (str (on Python 3) or unicode (on Python 2)) – The reason why the communication failed.
-
exception
pykayacim.exceptions.
PyKayacIMError
[source]¶ This is the base class for the exceptions in this module.