Class: I28s::Cli::Pull
- Inherits:
-
Object
- Object
- I28s::Cli::Pull
- Defined in:
- lib/i28s/cli/pull.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(locale_identifier, inplace: false, force_update: false, branch: "main") ⇒ Pull
constructor
A new instance of Pull.
Constructor Details
#initialize(locale_identifier, inplace: false, force_update: false, branch: "main") ⇒ Pull
Returns a new instance of Pull.
13 14 15 16 17 18 |
# File 'lib/i28s/cli/pull.rb', line 13 def initialize(locale_identifier, inplace: false, force_update: false, branch: "main") @locale_identifier = locale_identifier @inplace = inplace @force_update = force_update @branch = branch end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/i28s/cli/pull.rb', line 20 def call response = Faraday.get( "#{I28s::Cli.configuration.base_url}/projects/#{I28s::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/export", {}, { "Authorization": "Bearer #{I28s::Cli.configuration.api_key}" } ) translations = JSON.parse(response.body) if @inplace replace_inplace(translations) else dump_translations(translations) end end |