Class: Cloudxls::ReadRequest
- Inherits:
-
Object
- Object
- Cloudxls::ReadRequest
- Includes:
- BaseRequest
- Defined in:
- lib/cloudxls.rb
Constant Summary collapse
- DATA_PARAMETERS =
%w[excel file]
Instance Attribute Summary collapse
-
#client_options ⇒ Object
readonly
Returns the value of attribute client_options.
-
#file_format ⇒ Object
Returns the value of attribute file_format.
-
#post_data ⇒ Object
readonly
post_data is an array of key,value arrays.
Instance Method Summary collapse
- #add_data(params) ⇒ Object
-
#as_csv ⇒ Object
Set request to CSV.
-
#as_json ⇒ Object
Set request to JSON.
Methods included from BaseRequest
#api_base, #api_key, #build_request, #each, #initialize, #path_to, #start, #test_key?, #user_agent
Instance Attribute Details
#client_options ⇒ Object (readonly)
Returns the value of attribute client_options.
228 229 230 |
# File 'lib/cloudxls.rb', line 228 def @client_options end |
#file_format ⇒ Object
Returns the value of attribute file_format.
229 230 231 |
# File 'lib/cloudxls.rb', line 229 def file_format @file_format end |
#post_data ⇒ Object (readonly)
post_data is an array of key,value arrays. Reason:
-
A key can appear multiple times (for multiple sheets)
-
Parameters need to be in the right order: template - config - data
Example: [[“separator”, “,”], [“csv”, “hello,world”]]
227 228 229 |
# File 'lib/cloudxls.rb', line 227 def post_data @post_data end |
Instance Method Details
#add_data(params) ⇒ Object
233 234 235 236 237 238 239 240 241 242 |
# File 'lib/cloudxls.rb', line 233 def add_data(params) params.map do |key,value| key = key.to_s if DATA_PARAMETERS.include?(key) value = UploadIO.new(value, "text/csv", "data.csv") end @post_data << [key, value] end self end |
#as_csv ⇒ Object
Set request to CSV
257 258 259 260 |
# File 'lib/cloudxls.rb', line 257 def as_csv self.file_format = "csv" ReadResponse.new(self) end |
#as_json ⇒ Object
Set request to JSON
248 249 250 251 |
# File 'lib/cloudxls.rb', line 248 def as_json self.file_format = "json" ReadResponse.new(self) end |