Class: FatZebra::Batch
- Inherits:
-
APIResource
- Object
- FatZebraObject
- APIResource
- FatZebra::Batch
- Defined in:
- lib/fat_zebra/batch.rb
Overview
FatZebra Batch
Manage Batch for the API
-
create
-
search
-
find
-
result
Constant Summary
Constants included from APIOperation::Search
APIOperation::Search::DEFAULT_PARAMS
Instance Attribute Summary
Attributes inherited from FatZebraObject
Attributes included from ObjectHelper
Class Method Summary collapse
-
.create(params, options = {}) ⇒ FatZebra::Batch
Upload a batch file.
Instance Method Summary collapse
-
#result(params = {}, options = {}) ⇒ String
Return result from the batch.
Methods included from APIOperation::Delete
Methods included from APIOperation::Save
Methods included from APIOperation::Find
Methods included from APIOperation::Search
Methods inherited from APIResource
Methods included from APIHelper
included, #request, #resource_name, #resource_path
Methods inherited from FatZebraObject
initialize_from, #load_response_api, #update_from
Methods included from Validation
#errors, #valid!, #valid?, #validates
Methods included from ObjectHelper
#[], #[]=, #add_accessor, #add_accessors, #add_data, #initialize, #inspect, #keys, #method_missing, #remove_accessor, #to_hash, #to_json, #update_attributes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FatZebra::ObjectHelper
Class Method Details
.create(params, options = {}) ⇒ FatZebra::Batch
Upload a batch file
35 36 37 38 39 40 41 42 43 |
# File 'lib/fat_zebra/batch.rb', line 35 def create(params, = {}) params[:multipart] = true params[:content_type] = 'text/csv' params[:file] = File.new(params.delete(:path)) if params.key?(:path) @resource_name = "batches/#{params[:filename]}" super(params, ) ensure @resource_name = 'batches' end |
Instance Method Details
#result(params = {}, options = {}) ⇒ String
Return result from the batch
54 55 56 57 58 59 60 |
# File 'lib/fat_zebra/batch.rb', line 54 def result(params = {}, = {}) request(:get, "#{resource_path}/#{id}/result.csv", params, ) rescue FatZebra::RequestError => e return e.http_body if e.http_status == 422 raise end |