Class: Sheetsu::Client
- Inherits:
-
Object
- Object
- Sheetsu::Client
- Defined in:
- lib/sheetsu.rb
Instance Method Summary collapse
- #create(data, sheet = nil) ⇒ Object
- #delete(column, value, sheet = nil) ⇒ Object
-
#initialize(api_url, auth_credentials = {}) ⇒ Client
constructor
A new instance of Client.
- #read(options = {}) ⇒ Object
- #update(column, value, data, update_whole = false, sheet = nil) ⇒ Object
Constructor Details
#initialize(api_url, auth_credentials = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/sheetsu.rb', line 10 def initialize(api_url, auth_credentials={}) @api_url = Sheetsu::Util.parse_api_url(api_url) @http_basic_auth = auth_credentials end |
Instance Method Details
#create(data, sheet = nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/sheetsu.rb', line 15 def create(data, sheet=nil) if data.is_a?(Hash) Sheetsu::Create.new(@api_url, @http_basic_auth).row(data, { sheet: sheet }) elsif data.is_a?(Array) Sheetsu::Create.new(@api_url, @http_basic_auth).rows(data, { sheet: sheet }) end end |
#delete(column, value, sheet = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/sheetsu.rb', line 37 def delete(column, value, sheet=nil) = { column: column, value: value, sheet: sheet } Sheetsu::Delete.new(@api_url, @http_basic_auth).rows() end |
#read(options = {}) ⇒ Object
23 24 25 |
# File 'lib/sheetsu.rb', line 23 def read(={}) Sheetsu::Read.new(@api_url, @http_basic_auth).rows() end |
#update(column, value, data, update_whole = false, sheet = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/sheetsu.rb', line 27 def update(column, value, data, update_whole=false, sheet=nil) = { column: column, value: value, data: data, update_whole: update_whole, sheet: sheet } if update_whole Sheetsu::Update.new(@api_url, @http_basic_auth).put() else Sheetsu::Update.new(@api_url, @http_basic_auth).patch() end end |