1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-09-03 09:46:16 +03:00
Этот коммит содержится в:
Andrey Paderin
2019-06-11 15:23:40 +03:00
родитель 4531663e10
Коммит 2f03d852d1
3 изменённых файлов: 29 добавлений и 34 удалений

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

@@ -1 +1,15 @@
# frozen_string_literal: true
require_relative './amount'
module YandexCheckout
module Entity
class Refund < YandexCheckout::Response
option :payment_id
option :created_at, proc(&:to_s)
option :amount, Entity::Amount
option :receipt_registration, proc(&:to_s), optional: true
option :description, proc(&:to_s), optional: true
end
end
end

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

@@ -2,52 +2,34 @@
module YandexCheckout
class Refund < Evil::Client
option :shop_id, proc(&:to_s)
option :api_key, proc(&:to_s)
path { 'https://payment.yandex.net/api/v3/refunds' }
security { basic_auth shop_id, api_key }
operation :get_refund_info do
option :payment_id, proc(&:to_s)
http_method :get
path { "payments/#{payment_id}" }
path { "/#{payment_id}" }
response 200 do |_status, _headers, body|
p JSON.parse(*body)
end
# Parses json response, wraps it into model with [#error] and raises
# an exception where [ResponseError#response] contains the model instance
response(400, 422) do |(status, *)|
raise "#{status}: Record invalid"
end
response(404) do |(_status, *)|
p 'Record Not Found'
# raise "#{status}: Record not found"
end
response(200) { |*res| Entity::Refund.build(*res) }
response(400, 404) { |*res| Error.build(*res) }
end
operation :create do
option :payment
option :idempotency_key, optional: true
option :payload
option :idempotency_key, proc(&:to_s)
http_method :post
path { 'payments' }
# query { { params: params } }
format 'json'
headers 'Idempotence-Key' => '244afbdc-000f-5000-a000-12526186ce10'
body { payment }
headers { { 'Idempotence-Key' => idempotency_key } }
body { payload }
response 200 do |_status, _headers, body|
p JSON.parse(*body)
end
# Parses json response, wraps it into model with [#error] and raises
# an exception where [ResponseError#response] contains the model instance
response(400, 422) do |(status, *)|
raise "#{status}: Record invalid"
end
response(200) { |*res| Entity::Refund.build(*res) }
response(400, 404) { |*res| Error.build(*res) }
end
end
end

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

@@ -5,7 +5,6 @@ module YandexCheckout
extend Dry::Initializer
option :id, proc(&:to_s)
option :status, proc(&:to_s), default: proc { nil }
option :test
class << self
def build(*res)