class ImageKit::ImageKitClient

ImageKit class holds each method will be used by user

Attributes

file[R]

Public Class Methods

new(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil) click to toggle source
# File lib/imagekit/imagekit.rb, line 18
def initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil)
  @private_key = private_key
  @public_key = public_key
  @url_endpoint = url_endpoint
  @transformation_position = transformation_pos
  @options = options

  @ik_req = ImageKitRequest.new(private_key, public_key, url_endpoint)
  @file = ImageKitFile.new(@ik_req)
  @url_obj = Url.new(@ik_req)

end

Public Instance Methods

bulk_file_delete(file_ids) click to toggle source
# File lib/imagekit/imagekit.rb, line 66
def bulk_file_delete(file_ids)
  # Delete file in bulks by list of file id
  @file.batch_delete(file_ids)
end
delete_file(file_id) click to toggle source
# File lib/imagekit/imagekit.rb, line 61
def delete_file(file_id)
  # Delete a file by file-id
  @file.delete(file_id)
end
get_authentication_parameters(token = nil, expire = nil) click to toggle source
# File lib/imagekit/imagekit.rb, line 102
def get_authentication_parameters(token = nil, expire = nil)
  # Get Authentication params
  get_authenticated_params(token, expire, @ik_req.private_key)
end
get_file_details(file_identifier) click to toggle source
# File lib/imagekit/imagekit.rb, line 51
def get_file_details(file_identifier)
  # Get file detail by file-id or file_url
  @file.details(file_identifier)
end
get_file_metadata(file_id) click to toggle source
# File lib/imagekit/imagekit.rb, line 71
def get_file_metadata(file_id)
  # Get metadata of a file by file-id
  @file.get_metadata(file_id)
end
get_remote_file_url_metadata(remote_file_url = "") click to toggle source
# File lib/imagekit/imagekit.rb, line 85
def get_remote_file_url_metadata(remote_file_url = "")
  @file.get_metadata_from_remote_url(remote_file_url)
end
list_files(options) click to toggle source
# File lib/imagekit/imagekit.rb, line 46
def list_files(options)
  # list all files
  @file.list(options)
end
phash_distance(first, second) click to toggle source

Get metadata from remote_file_url param remote_file_url: url string of remote file

# File lib/imagekit/imagekit.rb, line 92
def phash_distance(first, second)
  # Get hamming distance between two phash(image hash) to check
  # similarity between images

  unless first && second
    raise ArgumentError, Error::MISSING_PHASH_VALUE
  end
  hamming_distance(first, second)
end
purge_file_cache(file_url) click to toggle source
# File lib/imagekit/imagekit.rb, line 76
def purge_file_cache(file_url)
  # Purge cache from ImageKit server by file_url
  @file.purge_cache(file_url)
end
purge_file_cache_status(request_id) click to toggle source
# File lib/imagekit/imagekit.rb, line 81
def purge_file_cache_status(request_id)
  @file.purge_cache_status(request_id.to_s)
end
set_ik_request(ik_req) click to toggle source
# File lib/imagekit/imagekit.rb, line 31
def set_ik_request(ik_req)
  # setter for imagekit request mainly will be used for
  # test
  @ik_req = ik_req
end
update_file_details(file_id, options) click to toggle source
# File lib/imagekit/imagekit.rb, line 56
def update_file_details(file_id, options)
  # update file details by file id and other options payload
  @file.update_details(file_id, options)
end
upload_file(file = nil, file_name = nil, options = nil) click to toggle source
# File lib/imagekit/imagekit.rb, line 41
def upload_file(file = nil, file_name = nil, options = nil)
  # upload file to imagekit server
  @file.upload(file, file_name, options)
end
url(options) click to toggle source
# File lib/imagekit/imagekit.rb, line 37
def url(options)
  @url_obj.generate_url(options)
end