module SEPOMEX_HCKDRK::JsonApi::ClassMethods
Public Instance Methods
api_get(url:, headers: {})
click to toggle source
# File lib/sepomex_hckdrk/client/json_api.rb, line 12 def api_get(url:, headers: {}) custom_headers = headers.merge(default_headers) response = HTTParty.get(SEPOMEX_HCKDRK.api_base + url, headers: custom_headers) JSON.parse(response.body, symbolize_names: true) end
api_post(url:, body: {}, headers: {})
click to toggle source
# File lib/sepomex_hckdrk/client/json_api.rb, line 19 def api_post(url:, body: {}, headers: {}) custom_headers = headers.merge(default_headers) response = HTTParty.post( SEPOMEX_HCKDRK.api_base + url, body: body.to_json, headers: custom_headers ) JSON.parse(response.body, symbolize_names: true) end
api_post_multipart(url:, body: {}, headers: {})
click to toggle source
# File lib/sepomex_hckdrk/client/json_api.rb, line 31 def api_post_multipart(url:, body: {}, headers: {}) custom_headers = headers.merge(default_headers) response = HTTParty.post( SEPOMEX_HCKDRK.api_base + url, multipart: true, body: body, headers: custom_headers ) response.body end
default_headers()
click to toggle source
# File lib/sepomex_hckdrk/client/json_api.rb, line 6 def default_headers { 'Content-type' => 'application/json' } end