Class: CronosChain::Request
- Inherits:
-
Object
- Object
- CronosChain::Request
- Defined in:
- lib/cronos_chain/request.rb
Class Method Summary collapse
Class Method Details
.connect ⇒ Object
26 27 28 29 30 31 |
# File 'lib/cronos_chain/request.rb', line 26 def connect Faraday.new(url: CronosChain.domain) do |faraday| faraday.request :json faraday.adapter Faraday.default_adapter end end |
.get(hash) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/cronos_chain/request.rb', line 7 def get(hash) res = connect.get do |req| req.url params(hash) req.headers['Content-Type'] = 'application/json' end.body Oj.load(res) end |
.params(hash) ⇒ Object
33 34 35 36 |
# File 'lib/cronos_chain/request.rb', line 33 def params(hash) puts URI.encode_www_form(hash) '?' + URI.encode_www_form(hash) end |
.post(hash) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/cronos_chain/request.rb', line 16 def post(hash) res = connect.post do |req, params| req.url params(hash) req.headers['Content-Type'] = 'application/json' req.params params end.body Oj.load(res) end |