lib/yookassa.rb in yookassa-0.1.0 vs lib/yookassa.rb in yookassa-0.2.0

- old
+ new

@@ -1,13 +1,31 @@ # frozen_string_literal: true -require 'evil/client' +require "dry-struct" +require "forwardable" +require "yookassa/version" +require "yookassa/config" +require "yookassa/client" -require 'yookassa/version' -require 'yookassa/payment' -require 'yookassa/refund' -require 'yookassa/response' -require 'yookassa/callable' -require 'yookassa/optional' -require 'yookassa/entity/payment' -require 'yookassa/entity/refund' -require 'yookassa/error' +module Yookassa + ConfigError = Class.new(StandardError) + + 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