add health endpoint.

This commit is contained in:
ZippyDev 2020-07-31 17:51:28 -06:00
parent 2d171a4170
commit c293181b36
6 changed files with 95 additions and 0 deletions

View File

@ -70,6 +70,10 @@ All endpoints are accessed via namespaced Api resource. Example: `client.users.c
1. `DELETE #revoke(key)`
1. `DELETE #revoke!`
#### Api Keys:
1. `GET #status`
### Request helpers
#### Api Keys:

View File

@ -7,6 +7,7 @@ module BtcPay
module Api
class Base < Client::Service
require_relative './api_keys'
require_relative './health'
require_relative './users'
end
end

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
module BtcPay
module Client
module Api
class Health < Base
PATH = '/health'
# @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Health_GetHealth
def status(**opts)
client.get(path, options: opts)
end
alias get status
alias info status
protected
def base_path
PATH
end
end
end
end
end

View File

@ -71,6 +71,10 @@ module BtcPay
@api_keys_helper ||= Helpers::ApiKeys.new(client: self)
end
def health
@health ||= Api::Health.new(client: self)
end
def users
@users ||= Api::Users.new(client: self)
end

View File

@ -0,0 +1,47 @@
---
http_interactions:
- request:
method: get
uri: http://localhost:49392/api/v1/health
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- application/json
User-Agent:
- btcpay_ruby/0.1.0
Content-Type:
- application/json
Accept-Encoding:
- deflate, gzip
Authorization:
- token 9133b8ef3ae9a4b7f2d9a6efef1d5cf738067c68
Host:
- localhost:49392
response:
status:
code: 200
message: OK
headers:
Date:
- Fri, 31 Jul 2020 23:51:09 GMT
Content-Type:
- application/json; charset=utf-8
Server:
- Kestrel
Content-Length:
- '21'
Referrer-Policy:
- same-origin
X-Xss-Protection:
- 1; mode=block
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
body:
encoding: UTF-8
string: '{"synchronized":true}'
recorded_at: Fri, 31 Jul 2020 23:51:09 GMT
recorded_with: VCR 6.0.0

View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BtcPay::Client::Api::Health, :vcr do
let(:client) { build(:client) }
subject { described_class.new(client: client) }
describe 'GET #status' do
let(:response) { subject.status }
it { expect(response).to be_success }
end
end