Module: MintsHelper
- Included in:
- Mints::Contact, Mints::Pub, Mints::User
- Defined in:
- lib/mints_helper.rb
Instance Method Summary collapse
-
#correct_json(data) ⇒ Object
Correct json.
-
#data_transform(data) ⇒ Object
Data transform.
-
#get_query_results(url, options = nil, use_post = true) ⇒ Object
Get query results.
Instance Method Details
permalink #correct_json(data) ⇒ Object
Correct json.
Receives a json data and convert it to a symbolized object.
Parameters
- data
-
(Hash) – Data to be submited.
39 40 41 42 43 44 45 |
# File 'lib/mints_helper.rb', line 39 def correct_json(data) if data.is_a? String data = JSON.parse(data) end data = data.symbolize_keys return data end |
permalink #data_transform(data) ⇒ Object
Data transform.
Transform a ‘data’ variable to a standardized ‘data’ variable.
Parameters
- data
-
(Hash) – Data to be submited.
25 26 27 28 29 30 31 |
# File 'lib/mints_helper.rb', line 25 def data_transform(data) data = correct_json(data) unless data[:data] data = {data: data} end return data.to_json end |
permalink #get_query_results(url, options = nil, use_post = true) ⇒ Object
Get query results.
Method used to give the options to make a ‘post’ or ‘get’ request.
Parameters
- url
-
(String) – Url to make the request.
- options
-
(Hash) – List of Resource collection Options shown above can be used as parameter.
- use_post
-
(Boolean) – Variable to determine if the request is by ‘post’ or ‘get’ functions.
11 12 13 14 15 16 17 |
# File 'lib/mints_helper.rb', line 11 def get_query_results(url, = nil, use_post = true) if use_post return @client.raw("post", "#{url}/query", ) else return @client.raw("get", url, ) end end |