Class: Yatapp::YataApiCaller
- Inherits:
-
Object
- Object
- Yatapp::YataApiCaller
- Defined in:
- lib/yatapp/yata_api_caller.rb
Constant Summary collapse
- API_VERSION =
'v1'
- API_END_POINT_URL =
"/api/:api_version/project/:project_id/:lang/:format"
- API_BASE_URL =
"https://run.yatapp.net"
Instance Method Summary collapse
- #download_translations_and_store ⇒ Object
- #get_translations ⇒ Object
-
#initialize ⇒ YataApiCaller
constructor
A new instance of YataApiCaller.
Constructor Details
#initialize ⇒ YataApiCaller
Returns a new instance of YataApiCaller.
11 12 13 14 15 16 17 18 |
# File 'lib/yatapp/yata_api_caller.rb', line 11 def initialize initialize_configuration @translation_format ||= 'json' @save_to_path ||= "" @root ||= false @languages ||= ['en'] @strip_empty ||= false end |
Instance Method Details
#download_translations_and_store ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yatapp/yata_api_caller.rb', line 30 def download_translations_and_store languages.each do |lang| puts "Getting translation for #{lang}" api_url = download_url_websocket(lang) puts api_url api_response = HTTParty.get(api_url) next if !should_save_the_translation?(api_response) Store.store_translations(lang, JSON.parse(api_response.body)) end end |
#get_translations ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/yatapp/yata_api_caller.rb', line 20 def get_translations languages.each do |lang| puts "Getting translation for #{lang}" api_url = download_url(lang) api_response = HTTParty.get(api_url) next if !should_save_the_translation?(api_response) save_translation(lang, api_response) end end |