Class: NeetoCommonsBackend::Helpers::AuthServerApi
- Inherits:
-
Object
- Object
- NeetoCommonsBackend::Helpers::AuthServerApi
- Defined in:
- lib/neeto_commons_backend/helpers/auth_server_api.rb
Constant Summary collapse
- MAX_RETRIES =
5
- REQUEST_CLASSES =
{ get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }
Instance Attribute Summary collapse
-
#custom_headers ⇒ Object
readonly
Returns the value of attribute custom_headers.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#request_body ⇒ Object
readonly
Returns the value of attribute request_body.
-
#request_class ⇒ Object
readonly
Returns the value of attribute request_class.
-
#request_params ⇒ Object
readonly
Returns the value of attribute request_params.
Instance Method Summary collapse
- #delete(**args) ⇒ Object
- #get(**args) ⇒ Object
-
#initialize(custom_headers: {}) ⇒ AuthServerApi
constructor
A new instance of AuthServerApi.
- #post(**args) ⇒ Object
- #put(**args) ⇒ Object
- #request(type:, **args) ⇒ Object
Constructor Details
#initialize(custom_headers: {}) ⇒ AuthServerApi
Returns a new instance of AuthServerApi.
15 16 17 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 15 def initialize(custom_headers: {}) @custom_headers = custom_headers end |
Instance Attribute Details
#custom_headers ⇒ Object (readonly)
Returns the value of attribute custom_headers.
13 14 15 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 13 def custom_headers @custom_headers end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
13 14 15 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 13 def endpoint @endpoint end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
13 14 15 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 13 def request_body @request_body end |
#request_class ⇒ Object (readonly)
Returns the value of attribute request_class.
13 14 15 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 13 def request_class @request_class end |
#request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
13 14 15 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 13 def request_params @request_params end |
Instance Method Details
#delete(**args) ⇒ Object
31 32 33 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 31 def delete(**args) request(type: :delete, **args) end |
#get(**args) ⇒ Object
19 20 21 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 19 def get(**args) request(type: :get, **args) end |
#post(**args) ⇒ Object
27 28 29 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 27 def post(**args) request(type: :post, **args) end |
#put(**args) ⇒ Object
23 24 25 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 23 def put(**args) request(type: :put, **args) end |
#request(type:, **args) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/neeto_commons_backend/helpers/auth_server_api.rb', line 35 def request(type:, **args) return if Rails.env.heroku? @request_class = REQUEST_CLASSES[type] process(**args) end |