Sha256: 18e99d9092956c5ae710ceaa3210f5a0a4a96a28142d070a207594c74b384152

Contents?: true

Size: 487 Bytes

Versions: 2

Compression:

Stored size: 487 Bytes

Contents

module SantanderChile
  module ApiClient
    class Collection
      include Enumerable
      attr_reader :data

      def initialize(data:)
        @data = data
      end

      def self.from_response(response, dig_keys:, type:)
        body = response.body
        new(
          data: body.dig(*dig_keys).map {
            |attrs|
            type.new(attrs)
          },
        )
      end

      def each(*args, &block)
        @data.each(*args, &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
santander_chile-api_client-1.1.1 lib/santander_chile/api_client/collection.rb
santander_chile-api_client-1.1.0 lib/santander_chile/api_client/collection.rb