Skip to content

Commit 59b760d

Browse files
committed
chore: constants added
1 parent ebf853e commit 59b760d

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

lib/imagekit/constants/defaults.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Enum for defaults
4+
5+
class Default
6+
TRANSFORMATION_POSITION = "path"
7+
QUERY_TRANSFORMATION_POSITION = "query"
8+
VALID_TRANSFORMATION_POSITION = [TRANSFORMATION_POSITION,
9+
QUERY_TRANSFORMATION_POSITION,].freeze
10+
DEFAULT_TIMESTAMP = "9999999999"
11+
TRANSFORMATION_PARAMETER = "tr"
12+
CHAIN_TRANSFORM_DELIMITER = ":"
13+
TRANSFORM_DELIMITER = ","
14+
TRANSFORM_KEY_VALUE_DELIMITER = "-"
15+
16+
SIGNATURE_PARAMETER = "ik-s"
17+
TIMESTAMP_PARAMETER = "ik-t"
18+
TIMESTAMP = "9999999999"
19+
20+
end

lib/imagekit/constants/errors.rb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
MANDATORY_INIT_MISSING = {
2+
'message': "Missing public_key or private_key or url_endpoint during ImageKit initialization",
3+
help: "",
4+
}
5+
INVALID_TRANSFORMATION_POS = {'message': "Invalid transformationPosition parameter",
6+
help: "",}
7+
INVALID_URL_GENERATION_PARAM = {'message': "Invalid url parameter", help: ""}
8+
INVALID_TRANSFORMATION_OPTIONS = {
9+
'message': "Invalid transformation parameter options",
10+
help: "",
11+
}
12+
CACHE_PURGE_URL_MISSING = {'message': "Missing URL parameter for this request",
13+
help: "",}
14+
CACHE_PURGE_STATUS_ID_MISSING = {'message': "Missing Request ID parameter for this request",
15+
help: "",}
16+
FILE_ID_MISSING = {'message': "Missing File ID parameter for this request",
17+
help: "",}
18+
UPDATE_DATA_MISSING = {'message': "Missing file update data for this request",
19+
help: "",}
20+
21+
UPDATE_DATA_TAGS_INVALID = {'message': "Invalid tags parameter for this request",
22+
help: "tags should be passed as null or an array like ['tag1', 'tag2']",}.freeze
23+
24+
UPDATE_DATA_COORDS_INVALID =
25+
{'message': "Invalid custom_coordinates parameter for this request",
26+
help: "custom_coordinates should be passed as null or a string like 'x,y,width,height'",}
27+
28+
LIST_FILES_INPUT_MISSING = {
29+
'message': "Missing options for list files",
30+
help: "If you do not want to pass any parameter for listing, pass an empty object",
31+
}
32+
MISSING_FILE_URL = {'message': "Missing file_url for purge_cache", help: ""}
33+
MISSING_UPLOAD_DATA = {'message': "Missing data for upload", help: ""}
34+
MISSING_UPLOAD_FILE_PARAMETER = {
35+
'message': "Missing file parameter for upload",
36+
help: "",
37+
}
38+
MISSING_UPLOAD_FILENAME_PARAM = {
39+
'message': "Missing fileName parameter for upload",
40+
help: "",
41+
}
42+
43+
INVALID_PHASH_VALUE =
44+
{
45+
'message': "Invalid pHash value",
46+
help: "Both pHash strings must be valid hexadecimal numbers",
47+
}
48+
49+
MISSING_PHASH_VALUE = {
50+
'message': "Missing pHash value",
51+
help: "Please pass two pHash values",
52+
}
53+
UNEQUAL_STRING_LENGTH = {
54+
'': "Unequal pHash string length",
55+
help: "For distance calculation, the two pHash strings must have equal length",
56+
}
57+
58+
MISSING_UPLOAD_FILE_PARAMETER = {'message': "Missing file parameter for upload",
59+
'help': "",}
60+
MISSING_UPLOAD_FILENAME_PARAM = {
61+
'message': "Missing fileName parameter for upload",
62+
'help': "",
63+
}
64+
65+
INVALID_PHASH_VALUE = {'message': "Invalid pHash value",
66+
'help': "Both pHash strings must be valid hexadecimal numbers",}
67+
68+
MISSING_PHASH_VALUE = {'message': "Missing pHash value",
69+
'help': "Please pass two pHash values",}
70+
UNEQUAL_STRING_LENGTH = {'message': "Unequal pHash string length",
71+
'help': "For distance calculation, the two pHash strings must have equal length",}

lib/imagekit/constants/file.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VALID_FILE_OPTIONS = %w[path fileType tags includeFolder name limit skip]
2+
3+
VALID_FILE_DETAIL_OPTIONS = ["fileID"]
4+
5+
VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
SUPPORTED_TRANS = {
2+
'height': "h",
3+
'width': "w",
4+
'aspect_ratio': "ar",
5+
'quality': "q",
6+
'crop': "c",
7+
'crop_mode': "cm",
8+
'x': "x",
9+
'y': "y",
10+
'focus': "fo",
11+
'format': "f",
12+
'radius': "r",
13+
'background': "bg",
14+
'border': "bo",
15+
'rotation': "rt",
16+
'blur': "bl",
17+
'named': "n",
18+
'overlay_image': "oi",
19+
'overlay_x': "ox",
20+
'overlay_y': "oy",
21+
'overlay_focus': "ofo",
22+
'overlay_height': "oh",
23+
'overlay_width': "ow",
24+
'overlay_text': "ot",
25+
'overlay_text_font_size': "ots",
26+
'overlay_text_font_family': "otf",
27+
'overlay_text_color': "otc",
28+
'overlay_alpha': "oa",
29+
'overlay_text_typography': "ott",
30+
'overlay_background': "obg",
31+
'overlay_image_trim': "oit",
32+
'progressive': "pr",
33+
'lossless': "lo",
34+
'trim': "t",
35+
'metadata': "md",
36+
'color_profile': "cp",
37+
'default_image': "di",
38+
'dpr': "dpr",
39+
'effect_sharpen': "e-sharpen",
40+
'effect_usm': "e-usm",
41+
'effect_contrast': "e-contrast",
42+
'effect_gray': "e-grayscale",
43+
'original': "orig",
44+
}

lib/imagekit/constants/url.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class URL
2+
# Default URL Constants
3+
BASE_URL = "https://api.imagekit.io/v1/files"
4+
PURGE_CACHE = "/purge"
5+
BULK_FILE_DELETE = "/batch/deleteByFileIds"
6+
UPLOAD = "/upload"
7+
REMOTE_METADATA_FULL_URL = "https://api.imagekit.io/v1/metadata"
8+
9+
end

0 commit comments

Comments
 (0)