module Transifex::CrudRequests::Update::InstanceMethods

Public Instance Methods

update(params = {}, options = {}) click to toggle source
# File lib/transifex/crud_requests.rb, line 65
def update(params = {}, options = {})
  if params.is_a?(Hash) && params[:i18n_type]
    if options[:trad_from_file]
      case params[:i18n_type]
      when "YML"
        params[:content] = YAML::load_file(params[:content]).to_yaml
      else
        file = File.open(params[:content], "rb")
        params[:content] = file.read
        file.close
      end
    end

    if params[:i18n_type] == "KEYVALUEJSON"
      params[:content] = params[:content].to_json
    end

    # Deal with accents
    params[:content] = params[:content].force_encoding("UTF-8")
  end

  url = CrudRequests.generate_url(self)

  Transifex.query_api(:put, url, params)
end