Skip to content

#3 add sell() to convert ZLD to BTC#64

Open
edmoffo wants to merge 1 commit into
zold-io:masterfrom
edmoffo:3-sell-method
Open

#3 add sell() to convert ZLD to BTC#64
edmoffo wants to merge 1 commit into
zold-io:masterfrom
edmoffo:3-sell-method

Conversation

@edmoffo

@edmoffo edmoffo commented Jun 11, 2026

Copy link
Copy Markdown

Issue #3 asks for a sell() method on the WTS gateway so callers of the SDK can convert their ZLD balance to BTC without driving the website. The repository already exposes the symmetric pay() method against https://wts.zold.io/do-pay and the WTS server defines the corresponding sell endpoint at POST /do-zld-to-btc taking keygap, btc, and amount and returning the job id through the X-Zold-Job header (see front/front_btc.rb in zold-io/wts.zold.io).

This change adds Zold::WTS#sell(keygap, btc, amount) mirroring pay() end to end: it posts the three parameters to /do-zld-to-btc, runs the response through the same clean and job_of helpers, and returns the job id so the caller can pass it to wait(). A matching no-op Zold::WTS::Fake#sell(_keygap, _btc, _amount) keeps the fake gateway usable in downstream tests. Two new minitest cases stub the endpoint with webmock and exercise both the real and the fake implementations offline.

Locally on Ruby 3.3 with the gem Gemfile.lock: bundle exec rake test runs 10 tests with 0 failures, 0 errors, and 90.72% line coverage. bundle exec rubocop lib/zold/wts.rb test/zold/test_wts.rb reports the same pre-existing offences master carries minus one I autocorrected in the new hunk. The CI checks markdown-lint, typos, yamllint, and the rubocop step of test are red on master at 7c79029 for reasons unrelated to this diff (README badges, criterias typo in lib/zold/wts.rb:140, yamllint config, rubocop-rspec_rails inject_defaults!), so this branch does not introduce new red checks.

Closes #3

Wire Zold::WTS#sell to POST /do-zld-to-btc on wts.zold.io with
keygap, btc, and amount, returning the job id from the X-Zold-Job
header so callers can pass it to wait(). Mirror the method on
Zold::WTS::Fake for tests, and stub the endpoint with webmock to
keep the suite offline.

Closes zold-io#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sell()

1 participant