lib/hello_sign/client.rb in hellosign-ruby-sdk-3.7.0 vs lib/hello_sign/client.rb in hellosign-ruby-sdk-3.7.1
- old
+ new
@@ -30,11 +30,10 @@
require 'hello_sign/resource'
require 'hello_sign/api'
require 'logger'
module HelloSign
-
#
# You'll need the HelloSign::Client to do just about everything, from creating
# signatures to updating account information.
#
# @example
@@ -67,65 +66,65 @@
502 => Error::BadGateway,
503 => Error::ServiceUnavailable
}
#
- # Creates a new HelloSign Client
+ # Initiates a new HelloSign Client
- # @option opts [String] email_address email address
- # @option opts [String] password password
- # @option opts [String] api_key Api key
+ # @option opts [String] email_address The account's email address. (optional)
+ # @option opts [String] password The account's password, if authenticating with an email_address. (optional)
+ # @option opts [String] api_key The account's API key.
# @return [HelloSign::Client] a new HelloSign::Client
def initialize(opts={})
options = HelloSign.options.merge(opts)
HelloSign::Configuration::VALID_OPTIONS_KEYS.each do |key|
self.send("#{key}=", options[key])
end
end
#
- # Make a http get request
- # @param path [String] relative path of the request
- # @option options [Hash] params params of the url
+ # Makes an HTTP GET request
+ # @param path [String] Relative path of the request.
+ # @option options [Hash] params Params of the URL.
#
def get(path, options={})
response = request(path, :get, options)
validate response
parsed_response = parse response
data = { headers: response.headers, body: parsed_response }
end
#
- # Make a http post request
- # @param path [String] relative path of the request
- # @option options [Hash] params params of the url
- # @option options [Hash] body request body
+ # Makes an HTTP POST request
+ # @param path [String] Relative path of the request.
+ # @option options [Hash] params Params of the URL.
+ # @option options [Hash] body Body of the request.
#
def post(path, options={})
response = request(path, :post, options)
validate response
parsed_response = parse response
data = { headers: response.headers, body: parsed_response }
end
#
- # Make a http put request
- # @param path [String] relative path of the request
- # @option options [Hash] params params of the url
- # @option options [Hash] body request body
+ # Makes an HTTP PUT request
+ # @param path [String] Relative path of the request.
+ # @option options [Hash] params Params of the URL.
+ # @option options [Hash] body Body of the request.
#
def put(path, options={})
response = request(path, :put, options)
validate response
responsed_response = parse response
data = { headers: response.headers, body: parsed_response }
end
#
- # Make a http delete request
- # @param path [String] relative path of the request
- # @option options [Hash] params params of the url
+ # Make an HTTP DELETE request
+ # @param path [String] Relative path of the request.
+ # @option options [Hash] Params of the URL.
#
def delete(path, options={})
response = request(path, :delete, options)
validate response
parsed_response = parse response
@@ -158,10 +157,11 @@
faraday.request :url_encoded
faraday.response :logger, logger if @logging
faraday.adapter :net_http
faraday.options[:timeout] = timeout if timeout
end
+
if options[:no_auth]
elsif auth_token
connection.authorization :Bearer, auth_token
elsif api_key
connection.basic_auth api_key, ''
@@ -181,13 +181,10 @@
def validate(response)
if response.status >= 400
error_class = ERRORS[response.status] || HelloSign::Error::UnknownError
error = error_class.new(response.status, response.body, response.to_hash[:url].to_s)
- # error.response_status = response.status
- # error.response_body = response.body
- # error.request_uri = response.to_hash[:url].to_s
raise error
end
end
def parse(response)
@@ -202,11 +199,11 @@
end
end
def MIMEfromName(name)
parts = name.split('.')
- #default to pdf if no extension
+ # defaults to pdf if no extension provided
if parts.length < 2
return 'application/pdf'
end
extension = parts[-1]
types = MIME::Types.type_for(extension)
@@ -297,24 +294,24 @@
def prepare_form_fields(opts)
if (opts[:form_fields_per_document] and opts[:form_fields_per_document].is_a? Array)
opts[:form_fields_per_document] = MultiJson.dump(opts[:form_fields_per_document])
end
- #ignore if it's already a string, or not present
+ # ignore if it's already a string, or not present
end
def prepare_custom_fields(opts)
if (opts[:custom_fields] and opts[:custom_fields].is_a? Array)
opts[:custom_fields] = MultiJson.dump(opts[:custom_fields])
end
- #ignore if it's already a string, or not present
+ # ignore if it's already a string, or not present
end
def prepare_merge_fields(opts)
if (opts[:merge_fields] and opts[:merge_fields].is_a? Array)
opts[:merge_fields] = MultiJson.dump(opts[:merge_fields])
end
- #ignore if it's already a string, or not present
+ # ignore if it's already a string, or not present
end
def prepare(opts, key)
return unless opts[key]
opts[key].each_with_index do |value, index|