add server endpoint with specs.
This commit is contained in:
parent
9a4192a2b8
commit
ddc0619c34
|
@ -29,10 +29,15 @@ Or install it yourself as:
|
|||
At least one of the following auth tokens are required. Auth tokens can be created via the following:
|
||||
|
||||
1. `auth_token`
|
||||
|
||||
- Scoped Api Tokens can be created via `/Manage/APIKeys`
|
||||
|
||||
- `BTCPAY_AUTH_TOKEN` environment variable can also be used
|
||||
|
||||
1. `basic_auth_token`
|
||||
|
||||
- Legacy Api Key can be created per store via `/stores/{store-id}/Tokens`
|
||||
|
||||
- `BTCPAY_BASIC_AUTH_TOKEN` environment variable can also be used
|
||||
|
||||
##### Base Url
|
||||
|
@ -79,6 +84,10 @@ All endpoints are accessed via namespaced Api resource. Example: `client.users.c
|
|||
1. `GET #payouts`
|
||||
1. `POST #create_payout(pull_payment_id, payload)`
|
||||
|
||||
#### Server:
|
||||
|
||||
1. `GET #info`
|
||||
|
||||
#### Store:
|
||||
|
||||
- ##### Payment Requests:
|
||||
|
|
|
@ -10,6 +10,7 @@ module BtcPay
|
|||
require_relative './health'
|
||||
require_relative './lightning_node'
|
||||
require_relative './pull_payments'
|
||||
require_relative './server'
|
||||
require_relative './store_payment_requests'
|
||||
require_relative './store_payouts'
|
||||
require_relative './store_pull_payments'
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module BtcPay
|
||||
module Client
|
||||
module Api
|
||||
class Server < Base
|
||||
PATH = '/server'
|
||||
|
||||
# @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Health_GetHealth
|
||||
def info(**opts)
|
||||
client.get(path('info'), options: opts)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_base_path
|
||||
@base_path = PATH
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -97,6 +97,10 @@ module BtcPay
|
|||
|
||||
alias payments pull_payments
|
||||
|
||||
def server
|
||||
@server ||= Api::Server.new(client: self)
|
||||
end
|
||||
|
||||
def store
|
||||
@store ||= OpenStruct.new(
|
||||
payment_requests: Api::StorePaymentRequests.new(client: self),
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: get
|
||||
uri: http://localhost:49392/api/v1/server/info
|
||||
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:
|
||||
- Tue, 04 Aug 2020 01:12:06 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '253'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"version":"1.0.5.2","onion":null,"supportedPaymentMethods":["BTC","BTC_LightningLike"],"fullySynched":true,"syncStatus":[{"cryptoCode":"BTC","chainHeight":201,"syncHeight":201,"nodeInformation":{"headers":201,"blocks":201,"verificationProgress":1.0}}]}'
|
||||
recorded_at: Tue, 04 Aug 2020 01:12:06 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe BtcPay::Client::Api::Server, :vcr do
|
||||
let(:client) { build(:client) }
|
||||
subject { described_class.new(client: client) }
|
||||
|
||||
describe 'GET #info' do
|
||||
let(:response) { subject.info }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
|
@ -12,6 +12,7 @@ RSpec.describe BtcPay::Client::Base do
|
|||
it { expect(subject.health).to be_a(BtcPay::Client::Api::Health) }
|
||||
it { expect(subject.lightning.node).to be_a(BtcPay::Client::Api::LightningNode) }
|
||||
it { expect(subject.pull_payments).to be_a(BtcPay::Client::Api::PullPayments) }
|
||||
it { expect(subject.server).to be_a(BtcPay::Client::Api::Server) }
|
||||
it { expect(subject.store.payment_requests).to be_a(BtcPay::Client::Api::StorePaymentRequests) }
|
||||
it { expect(subject.store.payouts).to be_a(BtcPay::Client::Api::StorePayouts) }
|
||||
it { expect(subject.store.pull_payments).to be_a(BtcPay::Client::Api::StorePullPayments) }
|
||||
|
|
Loading…
Reference in New Issue