Class: IronBank::Resources::Export

Inherits:
IronBank::Resource show all
Defined in:
lib/iron_bank/resources/export.rb

Overview

Export ZOQL queries.

Constant Summary collapse

DEFAULT_CREATE_OPTIONS =
{
  format: "csv",
  zip:    false
}.freeze
ENDPOINT =
"/v1/object/export"

Instance Attribute Summary

Attributes inherited from IronBank::Resource

#remote

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IronBank::Resource

#==, #id, #initialize, #inspect, object_name, #reload, #remove_instance_vars, with_cache, with_local_records

Methods included from Associations::ClassMethods

#with_many, #with_one

Methods included from Metadata

#excluded_fields, #fields, #query_custom_fields, #query_fields, #reset, #schema, #single_resource_query_fields, #with_schema

Methods included from Queryable

#all, #find, #find_each, #first, #where

Methods included from Associations

#with_memoization

Constructor Details

This class inherits a constructor from IronBank::Resource

Class Method Details

.create(query, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/iron_bank/resources/export.rb', line 17

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

Instance Method Details

#contentObject



27
28
29
30
31
# File 'lib/iron_bank/resources/export.rb', line 27

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

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