-
Prereqs:
- protobuf
- go get github.com/twitchtv/twirp/protoc-gen-twirp_python
- npm install protobufjs
-
Run
extract_protos.js
in inspector on invoice page -
Then copy the new div to
./squareup.json
-
node ./node_modules/protobufjs/cli/bin/pbjs -t proto2 squareup.json > squareup.proto
-
Move the
service
definitions in squareup.proto to the bottom of the file; these aren't allowed inside messages -
Add
option allow_alias = true;
inside the CatalogObjectType enum above DO_NOT_USE. -
protoc --plugin=`which protoc-gen-twirp_python` --python_out=. --twirp_python_out=. -I. squareup.proto
-
Modify
__service_name
insquareup_pb2_twirp.py
to include the full package names. -
Change
/twirp
to/services
-
Change the
headers=
dict in_make_request
toContent-type: application/x-protobuf
Accept: application/x-protobuf
-
Now from python you can:
req = _sym_db.GetSymbol("squareup.invoice.frontend.GetInvoiceRequest")() req.invoice_token = 'EzNe6oF5dAHLt9FsRAjbQg' client = InvoiceFrontendServiceClient('https://squareup.com') res = client.get_invoice(req) print(res)
-
Notifications
You must be signed in to change notification settings - Fork 0
financica/python-proto-square-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published