Class: ImageKitIo::Client
Overview
ImageKitIo class holds each method will be used by user
Constant Summary
Utils::Calculation::DEFAULT_TIME_DIFF
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_bulk_tags(file_ids: [], tags: []) ⇒ Object
-
#bulk_job_status(job_id: nil) ⇒ Object
-
#copy_file(source_file_path: nil, destination_path: nil) ⇒ Object
-
#copy_folder(source_folder_path: nil, destination_path: nil) ⇒ Object
-
#create_custom_metadata_field(name: nil, label: nil, schema: {}) ⇒ Object
-
#create_folder(folder_name: nil, parent_folder_path: "/") ⇒ Object
-
#delete_bulk_ai_tags(file_ids: [], ai_tags: []) ⇒ Object
-
#delete_bulk_files(file_ids: []) ⇒ Object
-
#delete_bulk_tags(file_ids: [], tags: []) ⇒ Object
-
#delete_custom_metadata_field(id: nil) ⇒ Object
-
#delete_file(file_id: nil) ⇒ Object
-
#delete_folder(folder_path: nil) ⇒ Object
-
#get_authentication_parameters(token = nil, expire = nil) ⇒ Object
-
#get_custom_metadata_fields(options = {}) ⇒ Object
-
#get_file_details(file_id: nil) ⇒ Object
-
#get_file_metadata(file_id: nil) ⇒ Object
-
#get_remote_file_url_metadata(remote_file_url: "") ⇒ Object
Get metadata from remote_file_url param remote_file_url: url string of remote file.
-
#initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil) ⇒ Client
constructor
A new instance of Client.
-
#list_files(options = {}) ⇒ Object
-
#move_file(source_file_path: nil, destination_path: nil) ⇒ Object
-
#move_folder(source_folder_path: nil, destination_path: nil) ⇒ Object
-
#phash_distance(first, second) ⇒ Object
-
#purge_file_cache(file_url: nil) ⇒ Object
-
#purge_file_cache_status(request_id: nil) ⇒ Object
-
#rename_file(file_path: nil, new_file_name: nil, **options) ⇒ Object
-
#set_ik_request(ik_req) ⇒ Object
-
#stream_file(file_url: nil, &block) ⇒ Object
-
#update_custom_metadata_field(id: nil, label: nil, schema: nil) ⇒ Object
-
#update_file_details(file_id: nil, **options) ⇒ Object
-
#upload_file(file: nil, file_name: nil, **options) ⇒ Object
-
#url(options = {}) ⇒ Object
#constants, included
get_authenticated_params, hamming_distance, is_valid_hex
Constructor Details
#initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil) ⇒ Client
Returns a new instance of Client.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/imagekitio/client.rb', line 23
def initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil)
unless(private_key.is_a?(String) && private_key.to_s.strip.length != 0)
raise ArgumentError, constants.MISSING_PRIVATE_KEY
end
unless(public_key.is_a?(String) && public_key.to_s.strip.length != 0)
raise ArgumentError, constants.MISSING_PUBLIC_KEY
end
unless(url_endpoint.is_a?(String) && url_endpoint.to_s.strip.length != 0)
raise ArgumentError, constants.MISSING_URL_ENDPOINT
end
@private_key = private_key
@public_key = public_key
@url_endpoint = url_endpoint
@transformation_position = transformation_pos
@options = options
@ik_req = Request.new(private_key, public_key, url_endpoint)
@url_obj = Url.new(@ik_req)
@file_service = ApiService::File.new(@ik_req)
@custom_metadata_field_service = ApiService::CustomMetadataField.new(@ik_req)
@folder_service = ApiService::Folder.new(@ik_req)
@bulk_service = ApiService::Bulk.new(@ik_req)
end
|
Instance Attribute Details
#bulk_service ⇒ Object
Returns the value of attribute bulk_service.
21
22
23
|
# File 'lib/imagekitio/client.rb', line 21
def bulk_service
@bulk_service
end
|
Returns the value of attribute custom_metadata_field_service.
21
22
23
|
# File 'lib/imagekitio/client.rb', line 21
def custom_metadata_field_service
@custom_metadata_field_service
end
|
#file_service ⇒ Object
Returns the value of attribute file_service.
21
22
23
|
# File 'lib/imagekitio/client.rb', line 21
def file_service
@file_service
end
|
#folder_service ⇒ Object
Returns the value of attribute folder_service.
21
22
23
|
# File 'lib/imagekitio/client.rb', line 21
def folder_service
@folder_service
end
|
Instance Method Details
119
120
121
|
# File 'lib/imagekitio/client.rb', line 119
def add_bulk_tags(file_ids: [], tags: [])
@bulk_service.add_tags(file_ids: file_ids, tags: tags)
end
|
#bulk_job_status(job_id: nil) ⇒ Object
136
137
138
|
# File 'lib/imagekitio/client.rb', line 136
def bulk_job_status(job_id: nil)
@bulk_service.job_status(job_id: job_id)
end
|
#copy_file(source_file_path: nil, destination_path: nil) ⇒ Object
107
108
109
|
# File 'lib/imagekitio/client.rb', line 107
def copy_file(source_file_path: nil, destination_path: nil)
@file_service.copy(source_file_path: source_file_path, destination_path: destination_path)
end
|
#copy_folder(source_folder_path: nil, destination_path: nil) ⇒ Object
148
149
150
|
# File 'lib/imagekitio/client.rb', line 148
def copy_folder(source_folder_path: nil, destination_path: nil)
@folder_service.copy(source_folder_path: source_folder_path, destination_path: destination_path)
end
|
156
157
158
|
# File 'lib/imagekitio/client.rb', line 156
def create_custom_metadata_field(name: nil, label: nil, schema: {})
@custom_metadata_field_service.create(name: name, label: label, schema: schema)
end
|
#create_folder(folder_name: nil, parent_folder_path: "/") ⇒ Object
140
141
142
|
# File 'lib/imagekitio/client.rb', line 140
def create_folder(folder_name: nil, parent_folder_path: "/")
@folder_service.create(folder_name: folder_name, parent_folder_path: parent_folder_path)
end
|
132
133
134
|
# File 'lib/imagekitio/client.rb', line 132
def delete_bulk_ai_tags(file_ids: [], ai_tags: [])
@bulk_service.remove_ai_tags(file_ids: file_ids, ai_tags: ai_tags)
end
|
#delete_bulk_files(file_ids: []) ⇒ Object
123
124
125
126
|
# File 'lib/imagekitio/client.rb', line 123
def delete_bulk_files(file_ids: [])
@bulk_service.remove_files(file_ids: file_ids)
end
|
128
129
130
|
# File 'lib/imagekitio/client.rb', line 128
def delete_bulk_tags(file_ids: [], tags: [])
@bulk_service.remove_tags(file_ids: file_ids, tags: tags)
end
|
168
169
170
|
# File 'lib/imagekitio/client.rb', line 168
def delete_custom_metadata_field(id: nil)
@custom_metadata_field_service.delete(id: id)
end
|
#delete_file(file_id: nil) ⇒ Object
78
79
80
81
|
# File 'lib/imagekitio/client.rb', line 78
def delete_file(file_id: nil)
@file_service.delete(file_id: file_id)
end
|
#delete_folder(folder_path: nil) ⇒ Object
144
145
146
|
# File 'lib/imagekitio/client.rb', line 144
def delete_folder(folder_path: nil)
@folder_service.delete(folder_path: folder_path)
end
|
#get_authentication_parameters(token = nil, expire = nil) ⇒ Object
181
182
183
184
|
# File 'lib/imagekitio/client.rb', line 181
def get_authentication_parameters(token = nil, expire = nil)
get_authenticated_params(token, expire, @ik_req.private_key)
end
|
160
161
162
|
# File 'lib/imagekitio/client.rb', line 160
def get_custom_metadata_fields(options = {})
@custom_metadata_field_service.list(**options)
end
|
#get_file_details(file_id: nil) ⇒ Object
68
69
70
71
|
# File 'lib/imagekitio/client.rb', line 68
def get_file_details(file_id: nil)
@file_service.details(file_identifier: file_id)
end
|
83
84
85
86
|
# File 'lib/imagekitio/client.rb', line 83
def get_file_metadata(file_id: nil)
@file_service.get_metadata(file_id: file_id)
end
|
Get metadata from remote_file_url param remote_file_url: url string of remote file
99
100
101
|
# File 'lib/imagekitio/client.rb', line 99
def get_remote_file_url_metadata(remote_file_url: "")
@file_service.get_metadata_from_remote_url(remote_file_url: remote_file_url)
end
|
#list_files(options = {}) ⇒ Object
63
64
65
66
|
# File 'lib/imagekitio/client.rb', line 63
def list_files(options = {})
@file_service.list(**options)
end
|
#move_file(source_file_path: nil, destination_path: nil) ⇒ Object
111
112
113
|
# File 'lib/imagekitio/client.rb', line 111
def move_file(source_file_path: nil, destination_path: nil)
@file_service.move(source_file_path: source_file_path, destination_path: destination_path)
end
|
#move_folder(source_folder_path: nil, destination_path: nil) ⇒ Object
152
153
154
|
# File 'lib/imagekitio/client.rb', line 152
def move_folder(source_folder_path: nil, destination_path: nil)
@folder_service.move(source_folder_path: source_folder_path, destination_path: destination_path)
end
|
#phash_distance(first, second) ⇒ Object
172
173
174
175
176
177
178
179
|
# File 'lib/imagekitio/client.rb', line 172
def phash_distance(first, second)
if first.to_s.strip == "" || second.to_s.strip == ""
raise ArgumentError, constants.MISSING_PHASH_VALUE
end
hamming_distance(first, second)
end
|
#purge_file_cache(file_url: nil) ⇒ Object
88
89
90
91
|
# File 'lib/imagekitio/client.rb', line 88
def purge_file_cache(file_url: nil)
@file_service.purge_cache(file_url: file_url)
end
|
#purge_file_cache_status(request_id: nil) ⇒ Object
93
94
95
|
# File 'lib/imagekitio/client.rb', line 93
def purge_file_cache_status(request_id: nil)
@file_service.purge_cache_status(request_id: request_id.to_s)
end
|
#rename_file(file_path: nil, new_file_name: nil, **options) ⇒ Object
115
116
117
|
# File 'lib/imagekitio/client.rb', line 115
def rename_file(file_path: nil, new_file_name: nil, **options)
@file_service.rename(file_path: file_path, new_file_name: new_file_name, **options)
end
|
#set_ik_request(ik_req) ⇒ Object
48
49
50
51
52
|
# File 'lib/imagekitio/client.rb', line 48
def set_ik_request(ik_req)
@ik_req = ik_req
end
|
#stream_file(file_url: nil, &block) ⇒ Object
103
104
105
|
# File 'lib/imagekitio/client.rb', line 103
def stream_file(file_url: nil, &block)
@file_service.stream_file(remote_file_url: file_url, &block)
end
|
164
165
166
|
# File 'lib/imagekitio/client.rb', line 164
def update_custom_metadata_field(id: nil, label: nil, schema: nil)
@custom_metadata_field_service.update(id: id, label: label, schema: schema)
end
|
#update_file_details(file_id: nil, **options) ⇒ Object
73
74
75
76
|
# File 'lib/imagekitio/client.rb', line 73
def update_file_details(file_id: nil, **options)
@file_service.update_details(file_id: file_id, **options)
end
|
#upload_file(file: nil, file_name: nil, **options) ⇒ Object
58
59
60
61
|
# File 'lib/imagekitio/client.rb', line 58
def upload_file(file: nil, file_name: nil, **options)
@file_service.upload(file: file, file_name: file_name, **options)
end
|
#url(options = {}) ⇒ Object
54
55
56
|
# File 'lib/imagekitio/client.rb', line 54
def url(options = {})
@url_obj.generate_url(options)
end
|