Class: SoarHttpClient
- Inherits:
-
Object
- Object
- SoarHttpClient
- Defined in:
- lib/soar_http_client.rb,
lib/soar_http_client/version.rb
Constant Summary collapse
- VERSION =
"0.1.4"
Instance Attribute Summary collapse
-
#auditing ⇒ Object
readonly
Returns the value of attribute auditing.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#max_sleep_seconds ⇒ Object
readonly
Returns the value of attribute max_sleep_seconds.
-
#min_sleep_seconds ⇒ Object
readonly
Returns the value of attribute min_sleep_seconds.
-
#persistent_connection ⇒ Object
readonly
Returns the value of attribute persistent_connection.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
- #get(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
-
#initialize(url:, retries: 2, auditing: nil, persistent_connection: false, timeout: 5, basic_auth: nil, min_sleep_seconds: 0.5, max_sleep_seconds: 1) ⇒ SoarHttpClient
constructor
A new instance of SoarHttpClient.
- #patch(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
- #post(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
- #put(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
Constructor Details
#initialize(url:, retries: 2, auditing: nil, persistent_connection: false, timeout: 5, basic_auth: nil, min_sleep_seconds: 0.5, max_sleep_seconds: 1) ⇒ SoarHttpClient
Returns a new instance of SoarHttpClient.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/soar_http_client.rb', line 7 def initialize(url:, retries: 2, auditing: nil, persistent_connection: false, timeout: 5, basic_auth: nil, min_sleep_seconds: 0.5, max_sleep_seconds: 1) @semaphore = Mutex.new @semaphore.synchronize { @url = url @retries = retries @auditing = auditing @persistent_connection = persistent_connection @min_sleep_seconds = min_sleep_seconds @max_sleep_seconds = max_sleep_seconds @connection = Faraday.new(:url => @url) do |faraday| faraday.[:open_timeout] = timeout faraday.[:timeout] = timeout faraday.request :url_encoded faraday.adapter Faraday.default_adapter if persistent_connection == false faraday.adapter :net_http_persistent if persistent_connection == true faraday.basic_auth basic_auth[:user], basic_auth[:password] if basic_auth && (basic_auth[:user] && basic_auth[:password]) end } end |
Instance Attribute Details
#auditing ⇒ Object (readonly)
Returns the value of attribute auditing.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def auditing @auditing end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def connection @connection end |
#max_sleep_seconds ⇒ Object (readonly)
Returns the value of attribute max_sleep_seconds.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def max_sleep_seconds @max_sleep_seconds end |
#min_sleep_seconds ⇒ Object (readonly)
Returns the value of attribute min_sleep_seconds.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def min_sleep_seconds @min_sleep_seconds end |
#persistent_connection ⇒ Object (readonly)
Returns the value of attribute persistent_connection.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def persistent_connection @persistent_connection end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def retries @retries end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/soar_http_client.rb', line 5 def url @url end |
Instance Method Details
#delete(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
45 46 47 |
# File 'lib/soar_http_client.rb', line 45 def delete(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) do_request(verb: 'delete', path: path, params: params, body: body, token: token, headers: headers, flow_identifier: flow_identifier) end |
#get(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
29 30 31 |
# File 'lib/soar_http_client.rb', line 29 def get(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) do_request(verb: 'get', path: path, params: params, body: body, token: token, headers: headers, flow_identifier: flow_identifier) end |
#patch(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
41 42 43 |
# File 'lib/soar_http_client.rb', line 41 def patch(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) do_request(verb: 'patch', path: path, params: params, body: body, token: token, headers: headers, flow_identifier: flow_identifier) end |
#post(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
33 34 35 |
# File 'lib/soar_http_client.rb', line 33 def post(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) do_request(verb: 'post', path: path, params: params, body: body, token: token, headers: headers, flow_identifier: flow_identifier) end |
#put(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) ⇒ Object
37 38 39 |
# File 'lib/soar_http_client.rb', line 37 def put(path:, params: nil, body: nil, token: nil, headers: nil, flow_identifier: nil) do_request(verb: 'put', path: path, params: params, body: body, token: token, headers: headers, flow_identifier: flow_identifier) end |