Class: BtcPay::Client::Base
- Inherits:
-
Object
- Object
- BtcPay::Client::Base
- Defined in:
- lib/btcpay/client/base.rb
Constant Summary collapse
- API_PATH =
'/api/v1'
- DEFAULT_TIMEOUT =
10
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #api_keys ⇒ Object
- #api_keys_helper ⇒ Object
-
#delete(uri, options: {}, headers: {}) ⇒ Result
DELETE request.
-
#get(uri, options: {}, headers: {}, **kwargs) ⇒ Result
GET request.
- #health ⇒ Object
-
#initialize(config:, logger: Logger.new(STDOUT), timeout: DEFAULT_TIMEOUT, **_kwargs) ⇒ Base
constructor
A new instance of Base.
- #lightning ⇒ Object
-
#post(uri, payload: {}, options: {}, headers: {}) ⇒ Result
POST request.
- #pull_payments ⇒ Object (also: #payments)
-
#put(uri, payload:, options: {}, headers: {}) ⇒ Result
PUT request.
- #server ⇒ Object
- #store ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(config:, logger: Logger.new(STDOUT), timeout: DEFAULT_TIMEOUT, **_kwargs) ⇒ Base
Returns a new instance of Base.
28 29 30 31 32 |
# File 'lib/btcpay/client/base.rb', line 28 def initialize(config:, logger: Logger.new(STDOUT), timeout: DEFAULT_TIMEOUT, **_kwargs) @config = config @logger = logger @timeout = timeout end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
23 24 25 |
# File 'lib/btcpay/client/base.rb', line 23 def logger @logger end |
Instance Method Details
#api_keys ⇒ Object
78 79 80 |
# File 'lib/btcpay/client/base.rb', line 78 def api_keys @api_keys ||= Api::ApiKeys.new(client: self) end |
#api_keys_helper ⇒ Object
82 83 84 |
# File 'lib/btcpay/client/base.rb', line 82 def api_keys_helper @api_keys_helper ||= Helpers::ApiKeys.new(client: self) end |
#delete(uri, options: {}, headers: {}) ⇒ Result
DELETE request
74 75 76 |
# File 'lib/btcpay/client/base.rb', line 74 def delete(uri, options: {}, headers: {}) request(uri, method: :delete, options: , headers: headers) end |
#get(uri, options: {}, headers: {}, **kwargs) ⇒ Result
GET request
40 41 42 |
# File 'lib/btcpay/client/base.rb', line 40 def get(uri, options: {}, headers: {}, **kwargs) request(uri, method: :get, options: , headers: headers, **kwargs) end |
#health ⇒ Object
86 87 88 |
# File 'lib/btcpay/client/base.rb', line 86 def health @health ||= Api::Health.new(client: self) end |
#lightning ⇒ Object
90 91 92 |
# File 'lib/btcpay/client/base.rb', line 90 def lightning @lightning ||= OpenStruct.new(node: Api::LightningNode.new(client: self)) end |
#post(uri, payload: {}, options: {}, headers: {}) ⇒ Result
POST request
51 52 53 54 |
# File 'lib/btcpay/client/base.rb', line 51 def post(uri, payload: {}, options: {}, headers: {}) data = payload.is_a?(Hash) ? payload.to_json : payload request(uri, method: :post, payload: data, options: , headers: headers) end |
#pull_payments ⇒ Object Also known as: payments
94 95 96 |
# File 'lib/btcpay/client/base.rb', line 94 def pull_payments @pull_payments ||= Api::PullPayments.new(client: self) end |
#put(uri, payload:, options: {}, headers: {}) ⇒ Result
PUT request
63 64 65 66 |
# File 'lib/btcpay/client/base.rb', line 63 def put(uri, payload:, options: {}, headers: {}) data = payload.is_a?(Hash) ? payload.to_json : payload request(uri, method: :put, payload: data, options: , headers: headers) end |
#server ⇒ Object
100 101 102 |
# File 'lib/btcpay/client/base.rb', line 100 def server @server ||= Api::Server.new(client: self) end |