Sha256: ceb97e91098a2c0cc597cacf027f67ac22f949ee3b1cde621966152ac1d4c4f8

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

module Bs2Api
  module Payment
    class Detail < Base
      attr_reader :success

      def initialize(
        payment_id,
        client_id: Bs2Api.configuration.client_id,
        client_secret: Bs2Api.configuration.client_secret,
        proxy: nil
      )
        @payment_id = payment_id
        @client_id = client_id
        @client_secret = client_secret
        @proxy = proxy
      end

      def call
        response = detail_request
        raise Bs2Api::Errors::BadRequest, ::Util::Response.parse_error(response) unless response.ok?

        Bs2Api::Entities::Payment.from_response(response)
      end

      private

      def url
        "#{Bs2Api.endpoint}/pix/direto/forintegration/v1/pagamentos/#{@payment_id}"
      end

      def detail_request
        HTTParty.get(url, headers: headers)
      end

      def bearer_token
        Bs2Api::Request::Auth.token(
          client_id: @client_id,
          client_secret: @client_secret
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bs2_api-1.6.0 lib/bs2_api/payment/detail.rb