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
FIXME: Double get asset sizes method! === Get asset sizes.
-
#get_asset_usage(options) ⇒ Object
Get asset usage.
-
#get_asset_variation(id) ⇒ Object
Get asset variation.
-
#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
permalink #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)
63 64 65 |
# File 'lib/user/content/assets.rb', line 63 def create_asset(data) return @client.raw("post", "/content/assets", nil, data_transform(data)) end |
permalink #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)
267 268 269 |
# File 'lib/user/content/assets.rb', line 267 def create_asset_size(data) return @client.raw("post", "/content/assets/sizes", nil, data) end |
permalink #delete_asset(id) ⇒ Object
Delete asset.
Delete a asset.
Parameters
- id
-
(Integer) – Asset id.
Example
@data = @mints_user.delete_asset(6)
92 93 94 |
# File 'lib/user/content/assets.rb', line 92 def delete_asset(id) return @client.raw("delete", "/content/assets/#{id}") end |
permalink #download_asset(id) ⇒ Object
Download asset.
Get information of an asset.
Parameters
- id
-
(Integer) – Asset id.
Example
@data = @mints_user.download_asset(2)
119 120 121 |
# File 'lib/user/content/assets.rb', line 119 def download_asset(id) #FIXME: File not found at path, error in result but method works return @client.raw("get", "/content/assets/download/#{id}") end |
permalink #generate_asset_variation(data) ⇒ Object
Generate asset variation.
Create an asset variation of an existing asset.
Parameters
- data
-
(Hash) – Data to be submitted.
296 297 298 |
# File 'lib/user/content/assets.rb', line 296 def generate_asset_variation(data) #FIXME: Trying to get property 'width' of non-object return @client.raw("post", "/content/assets/generate-asset-variations", nil, data) end |
permalink #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, )
47 48 49 |
# File 'lib/user/content/assets.rb', line 47 def get_asset(id, = nil) return @client.raw("get", "/content/assets/#{id}", ) end |
permalink #get_asset_doc_types ⇒ Object
Get asset doc types.
Get doc types of assets.
149 150 151 |
# File 'lib/user/content/assets.rb', line 149 def get_asset_doc_types return @client.raw("get", "/content/assets/docTypes") end |
permalink #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.
143 144 145 |
# File 'lib/user/content/assets.rb', line 143 def get_asset_info() return @client.raw("get", "/content/assets/getAssetInfo", ) end |
permalink #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)
107 108 109 |
# File 'lib/user/content/assets.rb', line 107 def get_asset_link_info(data) return @client.raw("post", "/content/assets/getLinkInfo", nil, data) end |
permalink #get_asset_public_route ⇒ Object
Get asset public route.
Get public route of assets.
155 156 157 |
# File 'lib/user/content/assets.rb', line 155 def get_asset_public_route return @client.raw("get", "/content/assets/publicRoute") end |
permalink #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)
238 239 240 |
# File 'lib/user/content/assets.rb', line 238 def get_asset_size(id) #FIXME: wrong number of arguments (given 1, expected 0) return @client.raw("get", "/content/assets/sizes/#{id}") end |
permalink #get_asset_sizes(options) ⇒ Object
FIXME: Double get asset sizes method!
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.
226 227 228 |
# File 'lib/user/content/assets.rb', line 226 def get_asset_sizes() return @client.raw("get", "/content/assets/sizes", ) end |
permalink #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.
133 134 135 |
# File 'lib/user/content/assets.rb', line 133 def get_asset_usage() return @client.raw("get", "/content/assets/usage", ) end |
permalink #get_asset_variation(id) ⇒ Object
Get asset variation.
Get variation of an asset.
Parameters
- id
-
(Integer) Asset variation id. #TODO: Research if is an asset id or an variation id
Example
@data = @mints_user.get_asset_sizes(2)
285 286 287 288 289 |
# File 'lib/user/content/assets.rb', line 285 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 return @client.raw("get", "/content/assets/variation/#{id}") end |
permalink #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)
28 29 30 |
# File 'lib/user/content/assets.rb', line 28 def get_assets( = nil, use_post = true) return get_query_results("/content/assets", , use_post) end |
permalink #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)
80 81 82 |
# File 'lib/user/content/assets.rb', line 80 def update_asset(id, data) return @client.raw("put", "/content/assets/#{id}", nil, data_transform(data)) end |
permalink #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)
210 211 212 |
# File 'lib/user/content/assets.rb', line 210 def upload_asset(data) #TODO: Research a way to upload a File accross sdk return @client.raw("post", "/content/assets/upload", nil, data) end |