This SDK is used to connect to the Onelya and use it methods(Railway and Aeroexpress) for a 3-d party API.
pip3 install onelya_sdk
To start you will need to have credentials for the Onelya.
Example of api initializing
from onelya_sdk import API
api = API('username', 'password', 'pos')
After that, include the wrappers for requests to Railway Reservation
from onelya_sdk.railway import *
Now you can use all the methods of the Onelya Railway.
If field type in docs represented as datetime, then you need to pass it as datetime object, not str
For example:
E.g Railway/Search for route pricing:
from datetime import datetime
date = datetime.now()
route_pricing = api.railway_search.route_pricing('2000000', '2078750', date)
Now the result will be an instance of RoutePricing
product_request = ProductRequest('AccidentAndLuggageLossAndDamage')
service_add_upsale_request = ServiceAddUpsaleRequest('Igs', [1389, 1390], product_request)
add_upsale = api.railway_reservation.add_upsale(51978, 52919, service_add_upsale_request)
All methods, except the railway_reservation.return_amount
, return instance of class that contains all fields as a class variables and json_data variable with response json
api = API(self.username, self.password, self.pos)
balances = api.partner_balances()
balances.account_balances #array of AgentAccount
balances.account_balances[0].current_balance # 1 902 157,38
balances.account_balances[0].account_name # ???? ???? (??????????????)1
balances.account_balances[1].current_balance # 17 991 136,47
balances.account_balances[1].account_name # ?? ???? (????????)2
balances.json_data
{
"AccountBalances": [
{
"CurrentBalance": "1 902 157,38",
"AccountName": "???? ???? (??????????????)1"
},
{
"CurrentBalance": "17 991 136,47",
"AccountName": "?? ???? (????????)2"
}
]
}
Every method returns an objects with result or raise an error fo OnelyaAPIError
Onelya contains all data about error as in docs
Additionally returns docs url for method which raised an error
E.g.
blank_as_html = api.railway_search.route_pricing(-1, -1, None)
OnelyaAPIError output
onelya_railway_sdk.exceptions.OnelyaAPIError: Code: 43
Message: ???????????? ???????? ?????????(??) 'DepartureDate'
MessageParams: {'DepartureDate': None}
Docs: https://test.onelya.ru/ApiDocs/Api?apiId=Railway-V1-Search-RoutePricing
To use any of methods, you have to create an instance of Onelya. Described here
Currently available methods:
If you have any issues or questions regarding the API or the SDK it self, you are welcome to create an issue, or
You can write an Email to artyom.slobodyan@gmail.com
or roquie0@gmail.com
SDK is released under the MIT License.