Skip to content

Commit 82999e3

Browse files
committed
updated readme
1 parent 940ebff commit 82999e3

File tree

6 files changed

+20
-82
lines changed

6 files changed

+20
-82
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from fewsats.core import *
3838
fs = Fewsats()
3939
import os
4040
fs = Fewsats(api_key=os.getenv("FEWSATS_LOCAL_API_KEY"), base_url='http://localhost:8000')
41+
4142
fs.payment_methods().json(), fs.balance().json(), fs.me().json()
4243
```
4344

@@ -53,14 +54,14 @@ fs.payment_methods().json(), fs.balance().json(), fs.me().json()
5354
'exp_month': 12,
5455
'exp_year': 2034,
5556
'is_default': True}],
56-
[{'id': 1, 'balance': 4463, 'currency': 'usd'}],
57+
[{'id': 1, 'balance': 4421, 'currency': 'usd'}],
5758
{'name': 'Pol',
5859
'last_name': 'Alvarez Vecino',
5960
'email': 'pol@fewsats.com',
6061
'billing_info': None,
6162
'id': 1,
6263
'created_at': '2024-08-20T16:13:01.255Z',
63-
'webhook_url': 'https://example.com/asdfagasdfaasdfa'})
64+
'webhook_url': 'https://example.com'})
6465

6566
The `pay` method uses the information returned by a [L402
6667
Protocol](https://github.com/l402-protocol/l402?tab=readme-ov-file#402-response-format)
@@ -75,30 +76,27 @@ l402_offer = {
7576
"offers":[
7677
{
7778
"amount":1,
78-
"balance":1,
7979
"currency":"USD",
8080
"description":"Purchase 1 credit for API access",
8181
"offer_id":"offer_c668e0c0",
8282
"payment_methods":[
8383
"lightning"
8484
],
8585
"title":"1 Credit Package",
86-
"type":"top-up"
8786
}
8887
],
8988
"payment_context_token":"edb53dec-28f5-4cbb-924a-20e9003c20e1",
9089
"payment_request_url":"https://stock.l402.org/l402/payment-request",
91-
"terms_url":"https://link-to-terms.com",
92-
"version":"0.2.1"
90+
"version":"0.2.2"
9391
}
9492
```
9593

9694
``` python
97-
fs.pay_offer(l402_offer).json()
95+
fs.pay_offer(l402_offer['offers'][0]['offer_id'], l402_offer).json()
9896
```
9997

100-
{'id': 121,
101-
'created_at': '2025-02-10T11:04:48.083Z',
98+
{'id': 164,
99+
'created_at': '2025-03-10T14:53:03.282Z',
102100
'status': 'success',
103101
'payment_method': 'lightning'}
104102

fewsats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.13"
1+
__version__ = "0.0.14"

fewsats/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ def pay_offer(self:Fewsats,
185185
support custom classes as parameters like Claudette does.
186186
187187
Returns payment status response"""
188+
if isinstance(l402_offer, dict): l402_offer = L402Offers.from_dict(l402_offer)
188189
offer_dict = l402_offer.as_dict()
189190
data = {"offer_id": offer_id, **offer_dict}
190191
return self._request("POST", "v0/l402/purchases/from-offer", json=data)
191192

192193

193-
# %% ../nbs/00_core.ipynb 50
194+
# %% ../nbs/00_core.ipynb 49
194195
@patch
195196
def pay_offer_str(self:Fewsats,
196197
offer_id : str, # the offer id to pay for
@@ -227,14 +228,14 @@ def pay_offer_str(self:Fewsats,
227228

228229
return self._request("POST", "v0/l402/purchases/from-offer", timeout=20, json=data)
229230

230-
# %% ../nbs/00_core.ipynb 54
231+
# %% ../nbs/00_core.ipynb 53
231232
@patch
232233
def payment_info(self:Fewsats,
233234
pid:str): # purchase id
234235
"Retrieve the details of a payment."
235236
return self._request("GET", f"v0/l402/outgoing-payments/{pid}")
236237

237-
# %% ../nbs/00_core.ipynb 57
238+
# %% ../nbs/00_core.ipynb 56
238239
@patch
239240
def as_tools(self:Fewsats):
240241
"Return list of available tools for AI agents"

nbs/00_core.ipynb

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@
803803
" support custom classes as parameters like Claudette does.\n",
804804
"\n",
805805
" Returns payment status response\"\"\"\n",
806+
" if isinstance(l402_offer, dict): l402_offer = L402Offers.from_dict(l402_offer)\n",
806807
" offer_dict = l402_offer.as_dict()\n",
807808
" data = {\"offer_id\": offer_id, **offer_dict}\n",
808809
" return self._request(\"POST\", \"v0/l402/purchases/from-offer\", json=data)\n"
@@ -818,65 +819,6 @@
818819
"result = fs.pay_offer(offer_id, l402)"
819820
]
820821
},
821-
{
822-
"cell_type": "code",
823-
"execution_count": null,
824-
"metadata": {},
825-
"outputs": [
826-
{
827-
"data": {
828-
"text/plain": [
829-
"{'name': 'pay_offer',\n",
830-
" 'description': 'Pays an offer_id from the l402_offers. This tools requires the LLM caller to \\n support custom classes as parameters like Claudette does.\\n\\n Returns payment status response\\n\\nReturns:\\n- type: object',\n",
831-
" 'input_schema': {'type': 'object',\n",
832-
" 'properties': {'offer_id': {'type': 'string',\n",
833-
" 'description': 'the offer id to pay for'},\n",
834-
" 'l402_offer': {'type': 'object',\n",
835-
" 'description': 'a dictionary containing L402 offers',\n",
836-
" '$ref': '#/$defs/L402Offers'}},\n",
837-
" 'title': None,\n",
838-
" 'required': ['offer_id', 'l402_offer'],\n",
839-
" '$defs': {'L402Offers': {'type': 'object',\n",
840-
" 'properties': {'offers': {'type': 'array',\n",
841-
" 'description': '',\n",
842-
" 'items': {'$ref': '#/$defs/Offer'}},\n",
843-
" 'payment_context_token': {'type': 'string', 'description': ''},\n",
844-
" 'payment_request_url': {'type': 'string', 'description': ''},\n",
845-
" 'version': {'type': 'string', 'description': ''}},\n",
846-
" 'title': 'L402Offers',\n",
847-
" 'required': ['offers',\n",
848-
" 'payment_context_token',\n",
849-
" 'payment_request_url',\n",
850-
" 'version'],\n",
851-
" '$defs': {'Offer': {'type': 'object',\n",
852-
" 'properties': {'offer_id': {'type': 'string', 'description': ''},\n",
853-
" 'amount': {'type': 'integer', 'description': ''},\n",
854-
" 'currency': {'type': 'string', 'description': ''},\n",
855-
" 'description': {'type': 'string', 'description': ''},\n",
856-
" 'title': {'type': 'string', 'description': ''},\n",
857-
" 'payment_methods': {'type': 'array',\n",
858-
" 'description': '',\n",
859-
" 'items': {'type': 'string'},\n",
860-
" 'default': None},\n",
861-
" 'type': {'type': 'string', 'description': '', 'default': 'one-off'}},\n",
862-
" 'title': 'Offer',\n",
863-
" 'required': ['offer_id',\n",
864-
" 'amount',\n",
865-
" 'currency',\n",
866-
" 'description',\n",
867-
" 'title']}}}}}}"
868-
]
869-
},
870-
"execution_count": null,
871-
"metadata": {},
872-
"output_type": "execute_result"
873-
}
874-
],
875-
"source": [
876-
"from toolslm.funccall import get_schema\n",
877-
"get_schema(fs.pay_offer)"
878-
]
879-
},
880822
{
881823
"cell_type": "markdown",
882824
"metadata": {},

nbs/index.ipynb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@
103103
" 'exp_month': 12,\n",
104104
" 'exp_year': 2034,\n",
105105
" 'is_default': True}],\n",
106-
" [{'id': 1, 'balance': 4463, 'currency': 'usd'}],\n",
106+
" [{'id': 1, 'balance': 4421, 'currency': 'usd'}],\n",
107107
" {'name': 'Pol',\n",
108108
" 'last_name': 'Alvarez Vecino',\n",
109109
" 'email': 'pol@fewsats.com',\n",
110110
" 'billing_info': None,\n",
111111
" 'id': 1,\n",
112112
" 'created_at': '2024-08-20T16:13:01.255Z',\n",
113-
" 'webhook_url': 'https://example.com/asdfagasdfaasdfa'})"
113+
" 'webhook_url': 'https://example.com'})"
114114
]
115115
},
116116
"execution_count": null,
@@ -144,21 +144,18 @@
144144
" \"offers\":[\n",
145145
" {\n",
146146
" \"amount\":1,\n",
147-
" \"balance\":1,\n",
148147
" \"currency\":\"USD\",\n",
149148
" \"description\":\"Purchase 1 credit for API access\",\n",
150149
" \"offer_id\":\"offer_c668e0c0\",\n",
151150
" \"payment_methods\":[\n",
152151
" \"lightning\"\n",
153152
" ],\n",
154153
" \"title\":\"1 Credit Package\",\n",
155-
" \"type\":\"top-up\"\n",
156154
" }\n",
157155
" ],\n",
158156
" \"payment_context_token\":\"edb53dec-28f5-4cbb-924a-20e9003c20e1\",\n",
159157
" \"payment_request_url\":\"https://stock.l402.org/l402/payment-request\",\n",
160-
" \"terms_url\":\"https://link-to-terms.com\",\n",
161-
" \"version\":\"0.2.1\"\n",
158+
" \"version\":\"0.2.2\"\n",
162159
"}"
163160
]
164161
},
@@ -170,8 +167,8 @@
170167
{
171168
"data": {
172169
"text/plain": [
173-
"{'id': 121,\n",
174-
" 'created_at': '2025-02-10T11:04:48.083Z',\n",
170+
"{'id': 164,\n",
171+
" 'created_at': '2025-03-10T14:53:03.282Z',\n",
175172
" 'status': 'success',\n",
176173
" 'payment_method': 'lightning'}"
177174
]
@@ -182,7 +179,7 @@
182179
}
183180
],
184181
"source": [
185-
"fs.pay_offer(l402_offer).json()"
182+
"fs.pay_offer(l402_offer['offers'][0]['offer_id'], l402_offer).json()"
186183
]
187184
},
188185
{

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22
repo = fewsats-python
33
lib_name = fewsats
4-
version = 0.0.13
4+
version = 0.0.14
55
min_python = 3.7
66
license = apache2
77
black_formatting = False

0 commit comments

Comments
 (0)