diff --git a/.gitignore b/.gitignore index 536c4f0..dfbfd2e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ # rspec failure tracking .rspec_status +.tool-versions diff --git a/Gemfile b/Gemfile index b4bf2ee..25f9d3e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,12 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in yookassa.gemspec gemspec +group :documentation do + gem "rack" + gem "webrick" + gem "yard" +end + group :development, :test do gem "pry" gem "pry-byebug", "~> 3.8.0" diff --git a/Gemfile.lock b/Gemfile.lock index 2a7ca4a..f1995a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,6 +70,7 @@ GEM byebug (~> 11.0) pry (~> 0.10) public_suffix (4.0.6) + rack (2.2.3) rainbow (3.0.0) rake (13.0.6) regexp_parser (2.1.1) @@ -117,6 +118,8 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.7.0) + yard (0.9.26) PLATFORMS ruby @@ -124,6 +127,7 @@ PLATFORMS DEPENDENCIES pry pry-byebug (~> 3.8.0) + rack rake (~> 13.0) rspec (~> 3.5) rubocop (~> 1.22) @@ -131,6 +135,8 @@ DEPENDENCIES rubocop-rspec (~> 2.5) simplecov (~> 0.16) webmock (~> 3.14) + webrick + yard yookassa! BUNDLED WITH diff --git a/bin/yard b/bin/yard new file mode 100755 index 0000000..39d4665 --- /dev/null +++ b/bin/yard @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'yard' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("yard", "yard") diff --git a/lib/yookassa/entity/refund.rb b/lib/yookassa/entity/refund.rb index 920547b..5a81ec9 100644 --- a/lib/yookassa/entity/refund.rb +++ b/lib/yookassa/entity/refund.rb @@ -2,18 +2,45 @@ require_relative "./types" require_relative "./amount" +require_relative "./source" module Yookassa module Entity class Refund < Dry::Struct - attribute :id, Types::String attribute? :idempotency_key, Types::String - attribute :status, Types::String + # id [string, required] + # Refund's ID in YooMoney + attribute :id, Types::String + + # payment_id [string, required] + # Payment ID in YooMoney attribute :payment_id, Types::String + + # status [string, required] + # Refund status. Possible values: canceled, succeeded + attribute :status, Types::String.enum("canceled", "succeeded") + + # receipt_registration [string, optional] + # Delivery status of receipt data to online sales register (pending, succeeded, or canceled). + # For those who use the solution for 54-FZ + attribute? :receipt_registration, Types::String.enum("pending", "succeeded", "canceled") + + # created_at [string, required] + # Time to refund creation, based on UTC and specified in the ISO 8601 format, for example, 2017-11-03T11:52:31.827Z attribute :created_at, Types::String + + # amount [object, required] + # Amount refunded to the user. attribute :amount, Entity::Amount - attribute? :receipt_registration, Types::String + + # description [string, optional] + # Reason behind the refund. attribute :description, Types::String + + # sources [array, optional] + # Information about money held for refunds: the amount to be held and the stores getting the refunds. + # Specified if you use the YooMoney solution for marketplaces + attribute? :sources, Types::Array.of(Entity::Source) end end end diff --git a/lib/yookassa/entity/source.rb b/lib/yookassa/entity/source.rb new file mode 100644 index 0000000..99c36a4 --- /dev/null +++ b/lib/yookassa/entity/source.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require_relative "./types" +require_relative "./amount" + +module Yookassa + module Entity + class Source < Dry::Struct + # account_id [string, required] + # ID of the store in favor of which you're accepting the receipt. Provided by YooMoney, displayed in the Sellers section + # of your Merchant Profile (shopId column). + attribute :account_id, Types::String + + # amount [object, required] + # Refund amount + attribute :amount, Entity::Amount + + # platform_fee_amount [object, optional] + # Commission for sold products or services charged in your favor. + attribute? :platform_fee_amount, Entity::Amount + end + end +end