add DEBUG_JSON env

master
radex 2024-01-30 15:02:50 +01:00
parent 43d123f956
commit 8a45d727af
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
2 changed files with 11 additions and 1 deletions

View File

@ -12,3 +12,9 @@ GET http://localhost:4567/api/1/preview/:label.pdf
POST http://localhost:4567/api/1/print/:label
where :label is a `spejstore` label.id or item.short_id
to test without spejstore running locally, pass:
```sh
DEBUG_JSON='{"short_id":"abcdef","name":"Some long test item","owner":"testowner"}' bundle exec ruby main.rb
```

View File

@ -41,7 +41,11 @@ BACKEND_URL = 'https://inventory.hackerspace.pl/api/1/'
CODE_PREFIX = "https://inventory.hackerspace.pl/"
def api(uri)
Excon.get(BACKEND_URL + uri + "/").json!
if ENV["DEBUG_JSON"]
JSON.parse(ENV["DEBUG_JSON"])
else
Excon.get(BACKEND_URL + uri + "/").json!
end
end
def render_identicode(data, id, extent)