Module: Telapi::Network
Overview
Internal object for network operations; wraps HTTParty
Class Method Summary collapse
-
.api_uri(path_components = []) ⇒ Object
path_components is an array of uri fragments, e.g [‘Calls’, ‘1234abc’].
- .default_options ⇒ Object
- .delete(path_components = []) ⇒ Object
- .get(path_components = [], query = nil) ⇒ Object
- .post(path_components = [], body) ⇒ Object
- .response_format ⇒ Object
Class Method Details
.api_uri(path_components = []) ⇒ Object
path_components is an array of uri fragments, e.g [‘Calls’, ‘1234abc’]
24 25 26 |
# File 'lib/telapi/network.rb', line 24 def api_uri(path_components=[]) [ Telapi.config.base_uri, 'Accounts', Telapi.config.account_sid, path_components ].flatten.join('/') + response_format end |
.default_options ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/telapi/network.rb', line 32 def { :basic_auth => { :username => (Telapi.config.account_sid || raise(InvalidConfiguration, 'account_sid')), :password => (Telapi.config.auth_token || raise(InvalidConfiguration, 'auth_token')) }, :ssl_ca_path => Telapi.config.ssl_ca_path } end |
.delete(path_components = []) ⇒ Object
19 20 21 |
# File 'lib/telapi/network.rb', line 19 def delete(path_components=[]) handle_response(HTTParty.delete api_uri(path_components), ) end |
.get(path_components = [], query = nil) ⇒ Object
9 10 11 12 |
# File 'lib/telapi/network.rb', line 9 def get(path_components=[], query=nil) = .merge(:query => query) handle_response(HTTParty.get api_uri(path_components), ) end |
.post(path_components = [], body) ⇒ Object
14 15 16 17 |
# File 'lib/telapi/network.rb', line 14 def post(path_components=[], body) = .merge(:body => body) handle_response(HTTParty.post api_uri(path_components), ) end |
.response_format ⇒ Object
28 29 30 |
# File 'lib/telapi/network.rb', line 28 def response_format @api_format ||= '.json' end |