1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-09-06 19:05:51 +03:00

Rewriting Client and changing interface

Этот коммит содержится в:
Ivan Shamatov
2021-11-01 23:12:07 +03:00
родитель ddcc7a3e6b
Коммит f3ff78fee1
13 изменённых файлов: 175 добавлений и 134 удалений

Просмотреть файл

@@ -1,22 +1,31 @@
# frozen_string_literal: true
require "http"
require "dry-struct"
require "forwardable"
require "yookassa/version"
require "yookassa/payment"
require "yookassa/refund"
require "yookassa/entity/payment"
require "yookassa/entity/refund"
require "yookassa/entity/error"
require "yookassa/config"
require "yookassa/http_helpers"
require "yookassa/client"
module Yookassa
def self.configure
yield(config)
end
ConfigError = Class.new(StandardError)
def self.config
@config ||= Config.new
class << self
extend Forwardable
def configure
yield(config)
end
def config
@config ||= Config.new
end
def client
raise ConfigError, "Specify `shop_id` and `api_key` settins in a `.configure` block" if @config.nil?
@client ||= Client.new(shop_id: @config.shop_id, api_key: @config.api_key)
end
def_delegators :client, :payments, :refunds
end
end