#
# API Docs: https://docs.btcpayserver.org/API/Greenfield/v1/
#
class BtcpayManagerService < ApplicationService
  attr_reader :base_url, :store_id, :auth_token

  def initialize
    @base_url   = Setting.btcpay_api_url
    @store_id   = Setting.btcpay_store_id
    @auth_token = Setting.btcpay_auth_token
  end

  private

    def get(endpoint)
      res = Faraday.get("#{base_url}/#{endpoint}", {}, {
        "Content-Type" => "application/json",
        "Accept" => "application/json",
        "Authorization" => "token #{auth_token}"
      })

      JSON.parse(res.body)
    end
end
