Class: Todoist::Request
- Inherits:
-
Object
- Object
- Todoist::Request
- Defined in:
- lib/todoist/request.rb
Constant Summary collapse
- SUCCES_STATUS_CODE =
200
Instance Attribute Summary collapse
-
#net_http_method ⇒ Object
Returns the value of attribute net_http_method.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(base_url) ⇒ Object
- #http(uri) ⇒ Object
-
#initialize(path, net_http_method) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(path, net_http_method) ⇒ Request
Returns a new instance of Request.
9 10 11 12 |
# File 'lib/todoist/request.rb', line 9 def initialize(path, net_http_method) self.path = path self.net_http_method = net_http_method end |
Instance Attribute Details
#net_http_method ⇒ Object
Returns the value of attribute net_http_method.
7 8 9 |
# File 'lib/todoist/request.rb', line 7 def net_http_method @net_http_method end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/todoist/request.rb', line 7 def path @path end |
Class Method Details
.post(path, form_data, request_class = Net::HTTP::Post) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/todoist/request.rb', line 14 def self.post(path, form_data, request_class = Net::HTTP::Post) request = request_class.new(path) request.set_form_data(form_data) new(path, request) end |
Instance Method Details
#execute(base_url) ⇒ Object
21 22 23 24 25 |
# File 'lib/todoist/request.rb', line 21 def execute(base_url) uri = URI.parse("#{base_url}#{path}") response = http(uri).request(net_http_method) end |
#http(uri) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/todoist/request.rb', line 28 def http(uri) net = Net::HTTP.new(uri.host, uri.port) net.use_ssl = true net.verify_mode = OpenSSL::SSL::VERIFY_NONE net.read_timeout = 90 net.open_timeout = 30 net end |