Class: REQUESTER
- Inherits:
-
Object
- Object
- REQUESTER
- Defined in:
- lib/SWGOH/API/CLIENT/requester.rb
Overview
Makes requests for the client
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
- #auth_request(username, password) ⇒ JSON || nil
-
#initialize ⇒ REQUESTER
constructor
A new instance of REQUESTER.
- #request(access_token, path, data) ⇒ JSON || nil
Constructor Details
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
11 12 13 |
# File 'lib/SWGOH/API/CLIENT/requester.rb', line 11 def log @log end |
Instance Method Details
#auth_request(username, password) ⇒ JSON || nil
20 21 22 23 24 25 |
# File 'lib/SWGOH/API/CLIENT/requester.rb', line 20 def auth_request(username, password) response = Net::HTTP.post_form(uri(SWGOH::API::PATH::AUTH_SIGNIN), auth_request_form(username, password)) return @log.error(response) unless response.is_a?(Net::HTTPSuccess) JSON.parse(response.body) end |
#request(access_token, path, data) ⇒ JSON || nil
31 32 33 34 35 36 |
# File 'lib/SWGOH/API/CLIENT/requester.rb', line 31 def request(access_token, path, data) response = Net::HTTP.post(uri(path), default_data.merge(data).to_json, request_headers(access_token)) return @log.error(response) unless response.is_a?(Net::HTTPSuccess) JSON.parse(response.body) end |