Skip to content

Commit

Permalink
Allow empty array to be used as param in get requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaftTrick committed Aug 8, 2016
1 parent eeb5f82 commit 7797f91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change log

## master (unreleased)
* [#34](https://github.com/ONLYOFFICE/onlyoffice_api_gem/pull/34): Allow empty array to be used as param in get requests.

## 0.6
### New features
* Support of keepConvertStatus for insert methods (from OnlyOffice > 8.9.1)
Expand Down
8 changes: 7 additions & 1 deletion lib/teamlab/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def request(type, args)
rescue Exception => e
raise e
end
fail "Error #{response.code}: #{response.error}" unless response.success
raise "Error #{response.code}: #{response.error}" unless response.success
response
end

Expand All @@ -56,6 +56,7 @@ def parse_args(args, type)
command = args.first.instance_of?(Array) ? '/' + args.shift.join('/') : args.shift.to_s
opts = {}
opts[:body] = args.last.instance_of?(Hash) ? args.pop : {}
remove_empty_array(opts, type)
opts[:headers] = Teamlab.config.headers
if opts[:body].key?(:somefile)
opts[:query] = opts.delete(:body)
Expand All @@ -64,5 +65,10 @@ def parse_args(args, type)
opts[:query] = opts.delete(:body) if type == :get
[command, opts]
end

def remove_empty_array(opts, type)
return if type == :get
opts[:body].delete_if { |_key, value| value == [] }
end
end
end

0 comments on commit 7797f91

Please sign in to comment.