Module: Knowtify::Helper

Included in:
Contact, Contacts
Defined in:
lib/knowtify/helper.rb

Constant Summary collapse

AUTHENTICATION_ERROR_MESSAGE =
"Knowtify response had authentication error, check your API key.".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/knowtify/helper.rb', line 4

def errors
  @errors
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/knowtify/helper.rb', line 4

def response
  @response
end

Instance Method Details

#add_authenication_errorObject



18
19
20
21
22
# File 'lib/knowtify/helper.rb', line 18

def add_authenication_error
  Knowtify.logger.error AUTHENTICATION_ERROR_MESSAGE if Knowtify.logger
  @errors ||= []
  @errors << AUTHENTICATION_ERROR_MESSAGE
end

#blank_string?(str) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/knowtify/helper.rb', line 24

def blank_string?(str)
  str =~ /^\s*$/
end

#clientObject



9
10
11
# File 'lib/knowtify/helper.rb', line 9

def client
  @client ||= Knowtify::Client.new
end

#configObject



28
29
30
# File 'lib/knowtify/helper.rb', line 28

def config
  Knowtify.config
end

#parsed_responseObject



13
14
15
16
# File 'lib/knowtify/helper.rb', line 13

def parsed_response
  @parsed_response ||= JSON.parse(response.body) if response
  @parsed_response
end