Sha256: c1f2ced49d79b7ed3634beaa99198d7a72778db18ea150186d97844a97678506

Contents?: true

Size: 777 Bytes

Versions: 36

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module IronBank
  module Resources
    # Export ZOQL queries.
    #
    class Export < Resource
      with_schema

      DEFAULT_CREATE_OPTIONS = {
        format: "csv",
        zip:    false
      }.freeze

      ENDPOINT = "/v1/object/export"

      def self.create(query, options = {})
        payload = IronBank::Object.new(
          DEFAULT_CREATE_OPTIONS.merge(query: query, **options)
        ).deep_camelize

        response = IronBank.client.connection.post(ENDPOINT, payload)

        new(IronBank::Object.new(response.body).deep_underscore)
      end

      def content
        return unless status&.casecmp?("Completed")

        @content ||= IronBank.client.connection.get("/v1/files/#{file_id}").body
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
iron_bank-5.4.1 lib/iron_bank/resources/export.rb
iron_bank-5.4.0 lib/iron_bank/resources/export.rb
iron_bank-5.3.2 lib/iron_bank/resources/export.rb
iron_bank-5.3.0 lib/iron_bank/resources/export.rb
iron_bank-5.2.6 lib/iron_bank/resources/export.rb
iron_bank-5.2.4 lib/iron_bank/resources/export.rb
iron_bank-5.2.3 lib/iron_bank/resources/export.rb
iron_bank-5.2.0 lib/iron_bank/resources/export.rb
iron_bank-5.1.1 lib/iron_bank/resources/export.rb
iron_bank-5.1.0 lib/iron_bank/resources/export.rb
iron_bank-4.4.3 lib/iron_bank/resources/export.rb
iron_bank-5.0.1 lib/iron_bank/resources/export.rb
iron_bank-5.0.0 lib/iron_bank/resources/export.rb
iron_bank-4.4.1 lib/iron_bank/resources/export.rb
iron_bank-4.4.0 lib/iron_bank/resources/export.rb
iron_bank-4.3.1 lib/iron_bank/resources/export.rb
iron_bank-4.3.0 lib/iron_bank/resources/export.rb
iron_bank-4.2.0 lib/iron_bank/resources/export.rb
iron_bank-4.1.1 lib/iron_bank/resources/export.rb
iron_bank-4.1.0 lib/iron_bank/resources/export.rb