Sha256: bb21b864fb1ae0c6b7364c72b6300c6002ffc16f20c05f56ab11a5d2930ae44c

Contents?: true

Size: 1010 Bytes

Versions: 2

Compression:

Stored size: 1010 Bytes

Contents

module Quaderno::Behavior
  module Retrieve

    def self.included(receiver)
      receiver.send :extend, ClassMethods
    end

    module ClassMethods
      include Quaderno::Helpers::Authentication

      def retrieve(gateway_id, gateway = 'stripe', options = {})
        authentication = get_authentication(options.merge(api_model: api_model))

        response = get("#{authentication[:url]}#{gateway}/#{@_retrieve_path}/#{gateway_id}.json",
          basic_auth: authentication[:basic_auth],
          headers: version_header.merge(authentication[:headers])
        )

        check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })
        hash = response.parsed_response
        hash[:authentication_data] = authentication

        object = new hash
        object.rate_limit_info = response

        object
      end
      alias_method :retrieve_customer, :retrieve

      private
      def retrieve_path(path)
        @_retrieve_path = path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quaderno-1.17.1 lib/quaderno-ruby/behavior/retrieve.rb
quaderno-1.17.0 lib/quaderno-ruby/behavior/retrieve.rb