busGal_api module
- class Trip(origin, destination, date, operator=None, equivalents=True)
Bases:
object
Trip class. Used for getting results as Expedition objects
- Parameters
origin (_Stop) – Origin stop
destination (_Stop) – Destination stop
date (datetime.datetime) – The date the trip will take place. Just the day matters
operator (_Operator) – The operator that you would like to own the buses
equivalent (bool) – Wether or not to get equivalent trips. Fixes stops which are the same one in the real world but are different ones in the API.
- _get_equivalent_expeditions_from_api(origin, destination, date, operator)
Calls _get_expeditions_from_api for every equivalent combination of stops and returns a list with all the expeditions merged. Called on creation if equivalents==true.
- Returns
List of avaliable expeditions
- Return type
- _get_expeditions_from_api(origin, destination, date, operator)
Obtains all the expeditions from the app API. Called on creation
- Returns
List of avaliable expeditions
- Return type
- expeditions
List of avaliable expeditions
- Type
- class _Expedition(data, date, operator=None)
Bases:
object
Represents any of the expeditions of a Trip. Get’s it’s own data from dictionary of the json response of api
- Parameters
data (dict) – Dictionary corresponding to the expedition in the json response of the API
date (datetime.datetime) – Date when the expedition takes place. Just the day matters
operator (_Operator) – Operator object to make sure the operator property has the right type. If not given will use “operator” type
- arrival
Arrival time
- Type
- departure
Deaparture time
- Type
- operator
Operator object. Note that if no operator argument was given the type of this will default to “operator”
- Type
- class _Stop(id, name, type, type_id, bus_stop_id=None)
Bases:
object
Class that represents a bus stop
- bus_stop_id
Id the API gives just in expedition details. Idk what it is. It’s used to obtain _Expedition.url
- Type
- get_operators()
Gets all the existing operators
- search_operator(name)
Searchs for operators with the specified name, using the app’s search api
- search_stop(name)
Searchs for stops with the specified name, using the app’s search api
- class Account(email=None, password=None, token=None, user_id=None)
Bases:
object
Class that represents a user account. Either email and password or token and user_id (not really necessary) must be specified
- Parameters
email (str) – Email address to login with
password (str) – Password to log in with
token (str) – Auth token to use for the requests. It will be auto-obtained if email and password are specified
user_id (int) – The user account’s id. Not really needed for anything unless you are doing weird shit with the JWTs
- _make_get_request(url)
Calls make_get_request using the object’s token, which is updated after every request. Not intended to be used by clients
- _make_post_request(url, data)
Calls make_post_request using the object’s token, which is updated after every request. Not intended to be used by clients
- add_card(number, alias)
Add a card to the user with the specified number and alias
- delete_card(number)
Delete the card with the specified number
- Parameters
number (str) – Number of the card
- get_card(number)
Get the object for the user’s card with the specified number
- get_cards()
Get all the user cards
- login(email, password)
Logins with the given email and password and returns a token, which is also set to self.token
- refresh_data()
Obtains the user’s details and sets them to the object
- rename_card(number, alias)
Change the alias of a card with the specified number
- class _Card(account, number)
Bases:
object
Class that represents a card. If an object of this class is deleted, so will be the card, it’s in the destructor (__del__)
- pending
Amount of money pending of return from the Xunta (cantos cartos débeche o pirolas)
- Type
- refresh_data()
Obtains the card’s details and sets them to the object
- recover_password(email)
Recover an account’s password (sends an email with a new temporal one)
- Parameters
email (str) – Email address
- register_account(email, password, name, last_name, identity_type, identity_number, phone_number)
Register an user account
- Parameters
email (str) – Email address
password – Password (Must be at least 6 character length, including a digit and an upper case letter)
name (str) – First name
last_name (str) – Last name
identity_type (str) – Identity type: “DNI” or “other”
identity_number (str) – Identity number e.g. your DNI
phone_number (str) – Phone number