Sha256: 088e3e57ccc4a5302ea13bca7291761c85e7716a3c5d41c488216657e9c9536a

Contents?: true

Size: 951 Bytes

Versions: 6

Compression:

Stored size: 951 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
      )
        @client_id = client_id
        @client_secret = client_secret
        @payment_id = payment_id
      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

6 entries across 6 versions & 1 rubygems

Version Path
bs2_api-1.5.1 lib/bs2_api/payment/detail.rb
bs2_api-1.5.0 lib/bs2_api/payment/detail.rb
bs2_api-1.4.3 lib/bs2_api/payment/detail.rb
bs2_api-1.4.2 lib/bs2_api/payment/detail.rb
bs2_api-1.4.1 lib/bs2_api/payment/detail.rb
bs2_api-1.4.0 lib/bs2_api/payment/detail.rb