Sha256: 5710c89b7c5372b51ae92960ed16987530513ea4bffa35b6384a9bb78f6c37bc
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require_relative 'api_routes' require_relative 'http_client' module ApiClient include ApiRoutes def create_session(hostname, params = {}) uri = session_uri(hostname) response = Uffizzi::HttpClient.make_request(uri, :post, false, params) build_response(response) end def fetch_projects(hostname) uri = projects_uri(hostname) response = Uffizzi::HttpClient.make_request(uri, :get, true) build_response(response) end def print_errors(errors) puts errors.keys.reduce([]) { |acc, key| acc.push(errors[key]) } end private def build_response(response) { body: response_body(response), headers: response_cookie(response), code: response.class, } end def response_body(response) return nil if response.body.nil? JSON.parse(response.body, symbolize_names: true) end def response_cookie(response) cookies = response.to_hash['set-cookie'] return nil if cookies.nil? cookie_content = cookies.first cookie = cookie_content.split(';').first Uffizzi::ConfigFile.rewrite_cookie(cookie) if Uffizzi::ConfigFile.exists? cookie end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uffizzi-cli-0.1.2 | lib/uffizzi/clients/api/api_client.rb |
uffizzi-cli-0.1.0 | lib/uffizzi/clients/api/api_client.rb |