Rival Regions API wrapper
Project description
Rival-Regions-Wrapper
This library will functions as an authenticator an API wrapper for interaction with Rival Regions. Use at your own risk.
Install
The following steps can be used to install the package with pip:
pip install rival_regions_wrapper
The package should be available globally.
Testing
This appplication supports unit tests, these are located in rival_regions_wrapper/tests/
.
Intall required dependancies using pipenv install --dev
.
After installing you should be able to test the python package with pytest.
Requests are cached for quick testing using VCR.py located at rival_regions_wrapper/tests/cassettes/
.
If you run in problems with testing you are advised to them run again after removing the cassettes directory.
The tests read login credentials from the following environment variables:
LOGIN_METHOD
, USERNAME
, PASSWORD
.
You can set those by creating an file named .env
with te following:
LOGIN_METHOD=PLACEHOLDER
USERNAME=PLACEHOLDER
PASSWORD=PLACEHOLDER
Replace PLACEHOLDER
with your credentials.
Also must have the chromedriver which can be found here https://sites.google.com/a/chromium.org/chromedriver/home
Add this to the system PATH
environmental variable.
Login methods
Currently the only working login method is Google. If you can help me out and make the other login methods working it would be appreciated.
login methods:
- vk
Middleware
The API wrapper uses middleware to decide where how to send the request. Middlewares can also be used to write direct requests to Rival Regions.
Current middleware
LocalAuthentication
Use username, password, and login method to log in local instance of the authenticator.
RemoteAuthentication
Connect through a remote API using URL and authentication key.
Examples
Create local authentication middleware and log in with environ variables
import os
from rival_regions_wrapper import LocalAuthentication
authentication = LocalAuthentication(
os.environ["USERNAME"],
os.environ["PASSWORD"],
os.environ["LOGIN_METHOD"]
)
request region page from Rival Regions
region = authentication.get('listed/upgrades/{}'.format(region_id))
Example of API wrapper to get oil current available resources from a state
from rival_regions_wrapper import apiWrapper
from rival_regions_wrapper.api_wrapper import ResourceState
api_wrapper = ApiWrapper(authentication)
state = 3382
resource = 'oil'
response = ResourceState(api_wrapper, state).info(resource)
For more examples look at the unit tests.
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rival_regions_wrapper-1.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d398575600cd09a285c38dfd18c3d867fd2cf1f66cac7324201ada4ed3d18c1 |
|
MD5 | 035b1b3f736458b03476fd97ec6ac32f |
|
BLAKE2b-256 | c1d8946ba8b604b1387be633894dc4464dfcb2efd7b22c81cb3fe14923ac0855 |
Hashes for rival_regions_wrapper-1.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89329986f158e6a17aa300ef947e1841b910f9a63ca51e3f1c9f45cc44a6c5e7 |
|
MD5 | be421d69599dce618bed00711f70d77c |
|
BLAKE2b-256 | 6eb90899aaa7bc0e8ce20c89d784ea64c7121f71115ce6d3dd9c1ce08a978b54 |