Module: Assets
- Included in:
- Content
- Defined in:
- lib/user/content/assets.rb
Instance Method Summary collapse
-
#create_asset(data) ⇒ Object
Create asset.
-
#create_asset_size(data) ⇒ Object
Create asset size.
-
#delete_asset(id) ⇒ Object
Delete asset.
-
#download_asset(id) ⇒ Object
Download asset.
-
#generate_asset_variation(data) ⇒ Object
Generate asset variation.
-
#get_asset(id, options = nil) ⇒ Object
Get asset.
-
#get_asset_doc_types ⇒ Object
Get asset doc types.
-
#get_asset_info(options) ⇒ Object
Get asset info.
-
#get_asset_link_info(data) ⇒ Object
Get asset link info.
-
#get_asset_public_route ⇒ Object
Get asset public route.
-
#get_asset_size(id) ⇒ Object
Get asset sizes.
-
#get_asset_sizes(options) ⇒ Object
Sizes.
- #get_asset_thumbnails(id) ⇒ Object
-
#get_asset_usage(options) ⇒ Object
Get asset usage.
-
#get_asset_variation(id) ⇒ Object
Variations.
-
#get_assets(options = nil, use_post = true) ⇒ Object
Assets.
-
#update_asset(id, data) ⇒ Object
Update asset.
-
#upload_asset(data) ⇒ Object
Upload asset.
Instance Method Details
#create_asset(data) ⇒ Object
Create asset.
Create a asset with data.
Parameters
- data
-
(Hash) – Data to be submitted.
Example
data = {
title: 'New Asset',
slug: 'new-asset',
}
@data = @mints_user.create_asset(data)
59 60 61 |
# File 'lib/user/content/assets.rb', line 59 def create_asset(data) @client.raw('post', '/content/assets', nil, data_transform(data)) end |
#create_asset_size(data) ⇒ Object
Create asset size.
Create an asset size by data.
Parameters
- data
-
(Hash) – Data to be submitted.
Example
data = {
aspectRadio: 'custom',
assetId: 23,
drawPosData: {
pos: {
sx: 100,
sy: 100,
swidth: 200,
sheight: 200
}
},
width: 100,
height: 100,
slug: 'fuji_size_slug',
title: 'fuji_size',
variationId: 'original'
}
@data = @mints_user.create_asset_size(data.to_json)
263 264 265 |
# File 'lib/user/content/assets.rb', line 263 def create_asset_size(data) @client.raw('post', '/content/assets/sizes', nil, data) end |
#delete_asset(id) ⇒ Object
Delete asset.
Delete a asset.
Parameters
- id
-
(Integer) – Asset id.
Example
@data = @mints_user.delete_asset(6)
88 89 90 |
# File 'lib/user/content/assets.rb', line 88 def delete_asset(id) @client.raw('delete', "/content/assets/#{id}") end |
#download_asset(id) ⇒ Object
Download asset.
Get information of an asset.
Parameters
- id
-
(Integer) – Asset id.
Example
@data = @mints_user.download_asset(2)
115 116 117 118 |
# File 'lib/user/content/assets.rb', line 115 def download_asset(id) # FIXME: File not found at path, error in result but method works @client.raw('get', "/content/assets/download/#{id}") end |
#generate_asset_variation(data) ⇒ Object
Generate asset variation.
Create an asset variation of an existing asset.
Parameters
- data
-
(Hash) – Data to be submitted.
290 291 292 293 |
# File 'lib/user/content/assets.rb', line 290 def generate_asset_variation(data) # FIXME: Trying to get property 'width' of non-object @client.raw('post', '/content/assets/generate-asset-variations', nil, data) end |
#get_asset(id, options = nil) ⇒ Object
Get asset.
Get a asset info.
Parameters
- id
-
(Integer) – Asset id.
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
First Example
@data = @mints_user.get_asset(1)
Second Example
= {
fields: 'id, title'
}
@data = @mints_user.get_asset(1, )
43 44 45 |
# File 'lib/user/content/assets.rb', line 43 def get_asset(id, = nil) @client.raw('get', "/content/assets/#{id}", ) end |
#get_asset_doc_types ⇒ Object
Get asset doc types.
Get doc types of assets.
146 147 148 |
# File 'lib/user/content/assets.rb', line 146 def get_asset_doc_types @client.raw('get', '/content/assets/docTypes') end |
#get_asset_info(options) ⇒ Object
Get asset info.
Get info of an asset. TODO: Research if is an asset or many assets
Parameters
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
140 141 142 |
# File 'lib/user/content/assets.rb', line 140 def get_asset_info() @client.raw('get', '/content/assets/getAssetInfo', ) end |
#get_asset_link_info(data) ⇒ Object
Get asset link info.
Get information of an asset by url.
Parameters
- data
-
(Hash) – Data to be submitted.
Example
data = {
link: 'https://www.example.com/img/img.jpg'
}
@data = @mints_user.get_asset_link_info(data.to_json)
103 104 105 |
# File 'lib/user/content/assets.rb', line 103 def get_asset_link_info(data) @client.raw('post', '/content/assets/getLinkInfo', nil, data) end |
#get_asset_public_route ⇒ Object
Get asset public route.
Get public route of assets.
152 153 154 |
# File 'lib/user/content/assets.rb', line 152 def get_asset_public_route @client.raw('get', '/content/assets/publicRoute') end |
#get_asset_size(id) ⇒ Object
Get asset sizes.
Get sizes of an asset.
Parameters
- id
-
(Integer) Asset id.
Example
@data = @mints_user.get_asset_sizes(2)
233 234 235 236 |
# File 'lib/user/content/assets.rb', line 233 def get_asset_size(id) # FIXME: wrong number of arguments (given 1, expected 0) @client.raw('get', "/content/assets/sizes/#{id}") end |
#get_asset_sizes(options) ⇒ Object
Sizes
Get asset sizes.
Get a collection of sizes of an asset.
Parameters
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
FIXME: Double get asset sizes method!
221 222 223 |
# File 'lib/user/content/assets.rb', line 221 def get_asset_sizes() @client.raw('get', '/content/assets/sizes', ) end |
#get_asset_thumbnails(id) ⇒ Object
120 121 122 123 |
# File 'lib/user/content/assets.rb', line 120 def get_asset_thumbnails(id) # FIXME: Returns json invalid token @client.raw('get', "/content/assets/thumbnails/#{id}") end |
#get_asset_usage(options) ⇒ Object
Get asset usage.
Get usage of an asset.
Parameters
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
130 131 132 |
# File 'lib/user/content/assets.rb', line 130 def get_asset_usage() @client.raw('get', '/content/assets/usage', ) end |
#get_asset_variation(id) ⇒ Object
Variations
Get asset variation.
Get variation of an asset.
Parameters
- id
-
(Integer) Asset variation id.
Example
@data = @mints_user.get_asset_sizes(2)
TODO: Research if is an asset id or an variation id
279 280 281 282 283 |
# File 'lib/user/content/assets.rb', line 279 def get_asset_variation(id) # FIXME: Id 1 and 4: Trying to get property 'path' of non-object maybe json conversion is bad # FIXME: Id 2 and 3: File not found at path maybe doesnt exist @client.raw('get', "/content/assets/variation/#{id}") end |
#get_assets(options = nil, use_post = true) ⇒ Object
Assets
Get assets.
Get a collection of assets.
Parameters
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
- use_post
-
(Boolean) – Variable to determine if the request is by ‘post’ or ‘get’ functions.
First Example
@data = @mints_user.get_assets
Second Example
= { fields: 'id, title' }
@data = @mints_user.get_assets()
Third Example
= { fields: 'id, title' }
@data = @mints_user.get_assets(, true)
24 25 26 |
# File 'lib/user/content/assets.rb', line 24 def get_assets( = nil, use_post = true) get_query_results('/content/assets', , use_post) end |
#update_asset(id, data) ⇒ Object
Update asset.
Update a asset info.
Parameters
- id
-
(Integer) – Asset id.
- data
-
(Hash) – Data to be submitted.
Example
data = {
title: 'New Asset Modified',
slug: 'new-asset'
}
@data = @mints_user.update_asset(5, data)
76 77 78 |
# File 'lib/user/content/assets.rb', line 76 def update_asset(id, data) @client.raw('put', "/content/assets/#{id}", nil, data_transform(data)) end |
#upload_asset(data) ⇒ Object
Upload asset.
Upload an asset. It can be images, documents and videos.
Parameters
- data
-
(Hash) – Data to be submitted.
First Example (with files)
Second Example (with urls)
data = {
title: 'asset title',
description: 'asset description',
link: 'https://link/example',
url-type: 'url-image',
slug: 'slug',
type: 'link',
father_id: 1
}
@data = @mints_user.upload_asset(data.to_json)
Third Example (with video)
data = {
title: 'Video Title',
fileType: 'video/mp4',
type: 'video',
slug: 'video-slug',
status: 'not-uploaded',
ext: 'mp4',
size: 29605264,
access_token: 'access_token',
name: 'Video Title',
videoData: {
id: 80313307,
name: 'Video Title',
type: 'video',
created: '2021-10-19T19:18:17+00:00',
updated: '2021-10-19T19:18:17+00:00',
duration: 191.936133,
hashed_id: 'hashed_id',
progress: 0.14285714285714285,
status: 'queued',
thumbnail: {
url: 'https://www.example.com/img/img.jpg',
width: 200,
height: 120
},
account_id: 1234567
}
}
@data = @mints_user.upload_asset(data.to_json)
207 208 209 210 |
# File 'lib/user/content/assets.rb', line 207 def upload_asset(data) # TODO: Research a way to upload a File across sdk @client.raw('post', '/content/assets/upload', nil, data) end |