module DocxManagerClient::Connection

Public Class Methods

docx_manager_api_key() click to toggle source
# File lib/docx_manager_client/connection.rb, line 52
def self.docx_manager_api_key
  exist = ENV['DOCX_MANAGER_API_KEY'] || Rails.application.secrets[:docx_manager_api_key]
  raise ConfigMissing.new("ENV['DOCX_MANAGER_API_KEY'] or Rails.application.secrets[:docx_manager_api_key] not exist") if exist.blank?

  exist.to_s
end
docx_manager_server_path() click to toggle source
# File lib/docx_manager_client/connection.rb, line 45
def self.docx_manager_server_path
  exist = ENV['DOCX_MANAGER_SERVER_PATH'] || Rails.application.secrets[:docx_manager_server_path]
  raise ConfigMissing.new("ENV['DOCX_MANAGER_SERVER_PATH'] or Rails.application.secrets[:docx_manager_server_path] not exist") if exist.blank?

  exist.to_s
end
docx_manager_token() click to toggle source
# File lib/docx_manager_client/connection.rb, line 59
def self.docx_manager_token
  exist = ENV['DOCX_MANAGER_TOKEN'] || Rails.application.secrets[:docx_manager_token]
  raise ConfigMissing.new("ENV['DOCX_MANAGER_TOKEN'] or Rails.application.secrets[:docx_manager_token] not exist") if exist.blank?

  exist.to_s
end
docx_server_api(method, path, body = {}) click to toggle source
# File lib/docx_manager_client/connection.rb, line 8
def self.docx_server_api(method, path, body = {})
  response = docx_server_json.send(method, path, body)
  [response.status, Hashie::Mash.new(response.body)]
end
docx_server_api_multipart(method, path, payload) click to toggle source
# File lib/docx_manager_client/connection.rb, line 13
def self.docx_server_api_multipart(method, path, payload)
  response = docx_server_multipart.send(method, path, payload)
  [response.status, Hashie::Mash.new(response.body)]
end
docx_server_headers() click to toggle source
# File lib/docx_manager_client/connection.rb, line 18
def self.docx_server_headers
  {
    'client'        => docx_manager_api_key,
    'Authorization' => docx_manager_token,
    'User-Agent'    => "DocxManagerClient #{DocxManagerClient::VERSION}"
  }
end
docx_server_json() click to toggle source
# File lib/docx_manager_client/connection.rb, line 26
def self.docx_server_json
  @docx_server_json ||= Faraday.new(url: "#{docx_manager_server_path}/api/v1", headers: docx_server_headers) do |f|
    f.request   :json
    f.use       :instrumentation
    f.response  :json
    f.adapter   :net_http
  end
end
docx_server_multipart() click to toggle source
# File lib/docx_manager_client/connection.rb, line 35
def self.docx_server_multipart
  @docx_server_multipart ||= Faraday.new(url: "#{docx_manager_server_path}/api/v1", headers: docx_server_headers) do |f|
    f.request   :multipart
    f.request   :url_encoded
    f.use       :instrumentation
    f.response  :json
    f.adapter   :net_http
  end
end