@@ -16,6 +16,17 @@ class ImageKitClient
1616 attr_reader :file
1717
1818 def initialize ( private_key , public_key , url_endpoint , transformation_pos = nil , options = nil )
19+
20+ unless ( private_key . is_a? ( String ) && private_key . to_s . strip . length != 0 )
21+ raise ArgumentError , MISSING_PRIVATE_KEY
22+ end
23+ unless ( public_key . is_a? ( String ) && public_key . to_s . strip . length != 0 )
24+ raise ArgumentError , MISSING_PUBLIC_KEY
25+ end
26+ unless ( url_endpoint . is_a? ( String ) && url_endpoint . to_s . strip . length != 0 )
27+ raise ArgumentError , MISSING_URL_ENDPOINT
28+ end
29+
1930 @private_key = private_key
2031 @public_key = public_key
2132 @url_endpoint = url_endpoint
@@ -92,8 +103,7 @@ def get_remote_file_url_metadata(remote_file_url = "")
92103 def phash_distance ( first , second )
93104 # Get hamming distance between two phash(image hash) to check
94105 # similarity between images
95-
96- unless first && second
106+ if first . to_s . strip == "" || second . to_s . strip == ""
97107 raise ArgumentError , Error ::MISSING_PHASH_VALUE
98108 end
99109 hamming_distance ( first , second )
@@ -104,5 +114,4 @@ def get_authentication_parameters(token = nil, expire = nil)
104114 get_authenticated_params ( token , expire , @ik_req . private_key )
105115 end
106116 end
107- end
108-
117+ end
0 commit comments