Sha256: 4b93d4d0c36a3f127bc55cab01f490ace3be561b03569d72ee4a24aa986c3dd9
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
module Messenger module Bot class Request def self.post(url, data) url = URI.parse(url) http = Net::HTTP.new(url.host, 443) http.use_ssl = true begin request = Net::HTTP::Post.new(url.request_uri) request["Content-Type"] = "application/json" request.body = data.to_json response = http.request(request) body = JSON(response.body) return { ret: body["error"].nil?, body: body } rescue => e raise e end end def self.get(url, data = {}) url = URI.parse(url) http = Net::HTTP.new(url.host, 443) http.use_ssl = true begin request = Net::HTTP::Get.new(url.request_uri) request["Content-Type"] = "application/json" response = http.request(request) body = JSON(response.body) return { ret: body["error"].nil?, body: body } rescue => e raise e end end def self.delete(url, data) url = URI.parse(url) http = Net::HTTP.new(url.host, 443) http.use_ssl = true begin request = Net::HTTP::Delete.new(url.request_uri) request["Content-Type"] = "application/json" request.body = data.to_json response = http.request(request) body = JSON(response.body) return { ret: body["error"].nil?, body: body } rescue => e raise e end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
messenger-bot-1.0.3.2 | lib/messenger/bot/request.rb |
messenger-bot-1.0.3.1 | lib/messenger/bot/request.rb |
messenger-bot-1.0.3 | lib/messenger/bot/request.rb |