Class: Musoni::Fetch
- Inherits:
-
Object
- Object
- Musoni::Fetch
- Includes:
- HTTParty
- Defined in:
- lib/musoni_ruby/fetch.rb
Class Method Summary collapse
- .date_parameters(options) ⇒ Object
- .headers ⇒ Object
- .load_json? ⇒ Boolean
- .save_json(response) ⇒ Object
Class Method Details
.date_parameters(options) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/musoni_ruby/fetch.rb', line 42 def date_parameters() # bp if .map{|k,v| k.to_s }.grep(/Date/).any? {dateFormat:"dd-MM-yyyy", locale:"en_GB"} else {} end end |
.headers ⇒ Object
11 12 13 |
# File 'lib/musoni_ruby/fetch.rb', line 11 def headers Musoni.configuration.header.merge!(super) end |
.load_json? ⇒ Boolean
37 38 39 40 |
# File 'lib/musoni_ruby/fetch.rb', line 37 def load_json? # load JSON if WebMock is off while testing and only in local env with load musoni turned on defined?(WebMock).nil? and ENV['CI_TEST'].nil? and defined?(Minitest) and ENV['LOAD_MUSONI'] == "true" end |
.save_json(response) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/musoni_ruby/fetch.rb', line 29 def save_json(response) request_method = response.request.http_method.name.split('::').last.upcase file_path = response.request.path.to_s slash,model,*file_name = file_path.split('?')[0].split(/\/|\?/) file_location = "lib/musoni_ruby/support/fake_musoni/#{model}/#{request_method}_#{file_name.join('_')}.json" File.write(file_location, response.body) end |