|
| 1 | +# jenga |
| 2 | + |
| 3 | +A minimal Python package for interacting with selected Jenga API endpoints. |
| 4 | + |
| 5 | +Implemented endpoints: |
| 6 | + |
| 7 | +- `account-balance` |
| 8 | +- `mini-statement` |
| 9 | + |
| 10 | +Implemented features: |
| 11 | + |
| 12 | +- Reads configuration from environment variables |
| 13 | +- Generates access tokens |
| 14 | +- Signs request values with your RSA private key using `cryptography` |
| 15 | +- Provides both Python and CLI usage |
| 16 | + |
| 17 | +Pending endpoints are listed later in this document. |
| 18 | + |
| 19 | +## 1. Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +pip install jenga |
| 23 | +``` |
| 24 | + |
| 25 | +## 2. Configuration |
| 26 | + |
| 27 | +The package reads configuration from environment variables. The required variables are: |
| 28 | + |
| 29 | +```env |
| 30 | +JENGA_API_KEY= |
| 31 | +JENGA_MERCHANT_CODE= |
| 32 | +JENGA_CONSUMER_SECRET= |
| 33 | +JENGA_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nreplace-with-private-key\n-----END PRIVATE KEY-----" |
| 34 | +JENGA_LIVE_MODE=false |
| 35 | +``` |
| 36 | + |
| 37 | +> [!INFO] |
| 38 | +> - `JENGA_LIVE_MODE=true` uses `https://api.finserve.africa` white `JENGA_LIVE_MODE=false` uses `https://uat.finserve.africa` |
| 39 | +> - For PEM values, you can use either real multiline values or `\n`-escaped text in `.env` files. |
| 40 | +
|
| 41 | +If you are using a local `.env` file, load it into your shell before running commands: |
| 42 | + |
| 43 | +## 3. Usage |
| 44 | + |
| 45 | +### 3.1 Signature generation |
| 46 | + |
| 47 | +Request signing is handled internally by `JengaClient` before protected endpoint calls are made. |
| 48 | + |
| 49 | +If you need to generate a signature manually: |
| 50 | + |
| 51 | +```python |
| 52 | +from jenga import JengaClient |
| 53 | + |
| 54 | +client = JengaClient.from_env() |
| 55 | +signature = client.sign("KE", "1450160649886") |
| 56 | +``` |
| 57 | + |
| 58 | +The data is signed in the order it is passed. |
| 59 | + |
| 60 | +### 3.1 Python usage |
| 61 | + |
| 62 | +Use the package directly in your application code. |
| 63 | + |
| 64 | +```python |
| 65 | +from jenga import JengaClient |
| 66 | + |
| 67 | +client = JengaClient.from_env() |
| 68 | + |
| 69 | +balance = client.account_balance( |
| 70 | + country_code="KE", |
| 71 | + account_id="1450160649886", |
| 72 | +) |
| 73 | + |
| 74 | +statement = client.mini_statement( |
| 75 | + country_code="KE", |
| 76 | + account_id="1450160649886", |
| 77 | +) |
| 78 | +``` |
| 79 | + |
| 80 | +## 4. Endpoint Coverage |
| 81 | + |
| 82 | +### 4.1 Account Services |
| 83 | + |
| 84 | +<details> |
| 85 | + |
| 86 | +<summary><strong>4.1.1 Account Balance</strong></summary> |
| 87 | + |
| 88 | +Python: |
| 89 | + |
| 90 | +```python |
| 91 | +from jenga import JengaClient |
| 92 | + |
| 93 | +client = JengaClient.from_env() |
| 94 | +result = client.account_balance(country_code="KE", account_id="1450160649886") |
| 95 | +print(result) |
| 96 | +``` |
| 97 | + |
| 98 | +CLI: |
| 99 | + |
| 100 | +```bash |
| 101 | +PYTHONPATH=src python3 -m jenga.cli account-balance --country-code KE --account-id 1450160649886 |
| 102 | +``` |
| 103 | + |
| 104 | +</details> |
| 105 | + |
| 106 | +<details> |
| 107 | + |
| 108 | +<summary><strong>4.1.2 Account Mini Statement</strong></summary> |
| 109 | + |
| 110 | +Python: |
| 111 | + |
| 112 | +```python |
| 113 | +from jenga import JengaClient |
| 114 | + |
| 115 | +client = JengaClient.from_env() |
| 116 | +result = client.mini_statement(country_code="KE", account_id="1450160649886") |
| 117 | +print(result) |
| 118 | +``` |
| 119 | + |
| 120 | +CLI: |
| 121 | + |
| 122 | +```bash |
| 123 | +PYTHONPATH=src python3 -m jenga.cli mini-statement --country-code KE --account-id 1450160649886 |
| 124 | +``` |
| 125 | + |
| 126 | +</details> |
| 127 | + |
| 128 | +- [ ] Account Full Statement |
| 129 | +- [ ] Opening and Closing Account Balance |
| 130 | +- [ ] Account Inquiry - Bank Accounts |
| 131 | + |
| 132 | +### 4.2 Send Money |
| 133 | + |
| 134 | +- [ ] Within Equity Bank |
| 135 | +- [ ] To Mobile Wallets |
| 136 | +- [ ] RTGS |
| 137 | +- [ ] SWIFT |
| 138 | +- [ ] Pesalink - To Bank Account |
| 139 | +- [ ] Pesalink - To Mobile Number |
| 140 | + |
| 141 | +### 4.3 Send Money - IMT |
| 142 | + |
| 143 | +- [ ] IMT Within Equity Bank |
| 144 | +- [ ] IMT to Mobile Wallets |
| 145 | +- [ ] IMT Pesalink - To Bank Account |
| 146 | +- [ ] IMT Pesalink - To Bank Mobile |
| 147 | + |
| 148 | +### 4.4 Receive Money |
| 149 | + |
| 150 | +- [ ] Receive Payments - Bill Payments |
| 151 | +- [ ] Receive Payments - Merchant Payments |
| 152 | +- [ ] Bill Validation |
| 153 | + |
| 154 | +### 4.5 Receive Money Queries |
| 155 | + |
| 156 | +- [ ] Get All EazzyPay Merchants |
| 157 | +- [ ] Query Transaction Details |
| 158 | +- [ ] Get All Billers |
| 159 | + |
| 160 | +### 4.6 Airtime |
| 161 | + |
| 162 | +- [ ] Purchase Airtime |
| 163 | + |
| 164 | +### 4.7 Forex Rates |
| 165 | + |
| 166 | +- [ ] Forex Exchange Rates |
| 167 | + |
| 168 | +### 4.8 ID Search and Verification |
| 169 | + |
| 170 | +- [ ] ID Search and Verification |
| 171 | + |
| 172 | +### 4.9 MPGS Direct Integration |
| 173 | + |
| 174 | +- [ ] MPGS Validate Payment |
| 175 | +- [ ] MPGS Authenticate Payment |
| 176 | +- [ ] MPGS Authorize Payment |
| 177 | +- [ ] MPGS Query Payment |
| 178 | +- [ ] MPGS Refund Payment |
| 179 | + |
| 180 | +## 5. Testing |
| 181 | + |
| 182 | +Run the automated tests: |
| 183 | + |
| 184 | +```bash |
| 185 | +python3 -m unittest discover -s tests |
| 186 | +``` |
| 187 | + |
| 188 | +Run a real manual test with your local `.env`: |
| 189 | + |
| 190 | +```bash |
| 191 | +set -a |
| 192 | +source .env |
| 193 | +set +a |
| 194 | +PYTHONPATH=src python3 -m jenga.cli account-balance --country-code KE --account-id 1450160649886 |
| 195 | +``` |
| 196 | + |
| 197 | +## 6. Notes |
| 198 | + |
| 199 | +- This package currently focuses on a small subset of Jenga APIs. |
| 200 | +- The README only documents endpoints that are actually implemented in this repository. |
| 201 | +- Pending endpoints are listed for roadmap visibility only. |
| 202 | + |
| 203 | +## 7. License |
| 204 | +License: [MIT](./LICENSE) |
0 commit comments