Class: ImageKitIo::ApiService::CustomMetadataField
Instance Method Summary
collapse
#constants, included
validate_upload_options
camel_to_snake, format_to_json, request_formatter, snake_to_camel
Constructor Details
Returns a new instance of CustomMetadataField.
10
11
12
|
# File 'lib/imagekitio/api_service/custom_metadata_field.rb', line 10
def initialize(req_obj)
@req_obj = req_obj
end
|
Instance Method Details
#create(name: nil, label: nil, schema: nil) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/imagekitio/api_service/custom_metadata_field.rb', line 14
def create(name: nil, label: nil, schema: nil)
if name == '' || name.nil? || label == '' || label.nil? || schema == '' || schema.nil?
raise ArgumentError, 'Parameters required'
end
unless schema.is_a?(Hash)
raise ArgumentError, 'Schema must be hash object'
end
url = "#{constants.API_BASE_URL}/customMetadataFields"
payload = { 'name': name, 'label': label, 'schema': schema }.to_json
@req_obj.request('post', url, @req_obj., payload)
end
|
#delete(id: nil) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/imagekitio/api_service/custom_metadata_field.rb', line 43
def delete(id: nil)
if id == '' || id.nil?
raise ArgumentError, 'id is required'
end
url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}"
@req_obj.request('delete', url, @req_obj.)
end
|
#list(**options) ⇒ Object
26
27
28
29
30
|
# File 'lib/imagekitio/api_service/custom_metadata_field.rb', line 26
def list(**options)
url = "#{constants.API_BASE_URL}/customMetadataFields"
payload = request_formatter(options || {})
@req_obj.request('get', url, @req_obj., payload)
end
|
#update(id: nil, label: nil, schema: nil) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/imagekitio/api_service/custom_metadata_field.rb', line 32
def update(id: nil, label: nil, schema: nil)
if id == '' || id.nil?
raise ArgumentError, 'id is required'
end
url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}"
payload = {}
payload = payload.merge({ 'label': label }) unless label.nil?
payload = payload.merge({ 'schema': label }) unless schema.nil?
@req_obj.request('patch', url, @req_obj., payload.to_json)
end
|