Class: Access::Request
- Inherits:
-
Object
- Object
- Access::Request
- Includes:
- HTTParty
- Defined in:
- lib/access/request.rb
Instance Method Summary collapse
- #delete(path, api_type, options = {}, &block) ⇒ Object
- #get(path, api_type, options = {}, &block) ⇒ Object
- #post(path, api_type, options = {}, &block) ⇒ Object
- #post_for_filter(path, api_type, filter, options = {}, &block) ⇒ Object
Instance Method Details
#delete(path, api_type, options = {}, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/access/request.rb', line 34 def delete(path, api_type, ={}, &block) url = set_base(api_type, path) results = self.class.delete(url, headers: headers([:access_token]), body: .to_json, timeout: ([:access_timeout] || Access.config.access_timeout)) if should_return_json?([:return_json]) hashify_results?([:hashify]) ? results.hashify : results else block.call results end rescue Net::ReadTimeout, Net::OpenTimeout raise Access::Error::Timeout rescue EOFError raise Access::Error::NoData end |
#get(path, api_type, options = {}, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/access/request.rb', line 5 def get(path, api_type, ={}, &block) url = set_base(api_type, path) results = self.class.get(url, headers: headers([:access_token]), query: , timeout: ([:access_timeout] || Access.config.access_timeout)) if should_return_json?([:return_json]) hashify_results?([:hashify]) ? results.hashify : results else block.call results end rescue Net::ReadTimeout, Net::OpenTimeout # block.call({"message"=>"Request Timeout Error", "status"=>408}) raise Access::Error::Timeout rescue EOFError raise Access::Error::NoData end |
#post(path, api_type, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/access/request.rb', line 20 def post(path, api_type, ={}, &block) url = set_base(api_type, path) results = self.class.post(url, headers: headers([:access_token]), body: .to_json, timeout: ([:access_timeout] || Access.config.access_timeout)) if should_return_json?([:return_json]) hashify_results?([:hashify]) ? results.hashify : results else block.call results end rescue Net::ReadTimeout, Net::OpenTimeout raise Access::Error::Timeout rescue EOFError raise Access::Error::NoData end |
#post_for_filter(path, api_type, filter, options = {}, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/access/request.rb', line 48 def post_for_filter(path, api_type, filter, ={}, &block) url = set_base(api_type, path) results = self.class.post(url, headers: headers([:access_token]), body: filter, timeout: ([:access_timeout] || Access.config.access_timeout)) if should_return_json?([:return_json]) hashify_results?([:hashify]) ? results.hashify : results else block.call results end rescue Net::ReadTimeout, Net::OpenTimeout raise Access::Error::Timeout rescue EOFError raise Access::Error::NoData end |