class Transifex::Request
Constants
- API_PATH
- OPTIONS
Public Class Methods
new(username, password)
click to toggle source
# File lib/transifex/request.rb, line 16 def initialize(username, password) @username = username @password = password end
Public Instance Methods
connection()
click to toggle source
# File lib/transifex/request.rb, line 30 def connection @connection ||= make_connection end
get(path, params = {})
click to toggle source
# File lib/transifex/request.rb, line 21 def get(path, params = {}) connection.get(build_path(path), params).body end
put(path, file_path)
click to toggle source
# File lib/transifex/request.rb, line 25 def put(path, file_path) payload = { content: Faraday::UploadIO.new(file_path, 'text/yaml') } connection.put(build_path(path), payload) end
Private Instance Methods
build_path(path)
click to toggle source
# File lib/transifex/request.rb, line 36 def build_path(path) "#{API_PATH}/#{path}" end
make_connection()
click to toggle source
# File lib/transifex/request.rb, line 40 def make_connection Faraday.new(OPTIONS) do |builder| builder.use FaradayMiddleware::Mashify builder.use Faraday::Response::ParseJson, :content_type => /\bjson$/ # Authentiation builder.basic_auth(@username, @password) # Request Middleware # builder.use Faraday::Request::Multipart builder.request :multipart builder.request :url_encoded builder.adapter :net_http end end