Sha256: 519cf1f9608541effac4a10a97cd0005a67036822d8bd9c74687893e689f5464
Contents?: true
Size: 946 Bytes
Versions: 15
Compression:
Stored size: 946 Bytes
Contents
module ZendeskAppsTools module APIConnection FULL_URL = /https?:\/\// URL_TEMPLATE = 'https://%s.zendesk.com/' def prepare_api_auth @subdomain ||= get_cache('subdomain') || get_value_from_stdin('Enter your Zendesk subdomain or full Zendesk URL:') @username ||= get_cache('username') || get_value_from_stdin('Enter your username:') unless @password print 'Enter your password: ' @password ||= STDIN.noecho(&:gets).chomp puts set_cache 'subdomain' => @subdomain, 'username' => @username end end def get_full_url if FULL_URL =~ @subdomain @subdomain else URL_TEMPLATE % @subdomain end end def get_connection(encoding = :url_encoded) prepare_api_auth Faraday.new get_full_url do |f| f.request encoding f.adapter :net_http f.basic_auth @username, @password end end end end
Version data entries
15 entries across 15 versions & 1 rubygems