Module: Assets

Included in:
Content
Defined in:
lib/user/content/assets.rb

Instance Method Summary collapse

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)
[View source]

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

#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)
[View source]

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

#delete_asset(id) ⇒ Object

Delete asset.

Delete a asset.

Parameters

id

(Integer) – Asset id.

Example

@data = @mints_user.delete_asset(6)
[View source]

92
93
94
# File 'lib/user/content/assets.rb', line 92

def delete_asset(id)
    return @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)
[View source]

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

#generate_asset_variation(data) ⇒ Object

Generate asset variation.

Create an asset variation of an existing asset.

Parameters

data

(Hash) – Data to be submitted.

[View source]

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

#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

options = {
  "fields": "id, title"
}
@data = @mints_user.get_asset(1, options)
[View source]

47
48
49
# File 'lib/user/content/assets.rb', line 47

def get_asset(id, options = nil)
    return @client.raw("get", "/content/assets/#{id}", options)
end

#get_asset_doc_typesObject

Get asset doc types.

Get doc types of assets.

[View source]

149
150
151
# File 'lib/user/content/assets.rb', line 149

def get_asset_doc_types
    return @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.

[View source]

143
144
145
# File 'lib/user/content/assets.rb', line 143

def get_asset_info(options)
    return @client.raw("get", "/content/assets/getAssetInfo", options)
end

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)
[View source]

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

#get_asset_public_routeObject

Get asset public route.

Get public route of assets.

[View source]

155
156
157
# File 'lib/user/content/assets.rb', line 155

def get_asset_public_route
    return @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)
[View source]

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

#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.

[View source]

226
227
228
# File 'lib/user/content/assets.rb', line 226

def get_asset_sizes(options)
    return @client.raw("get", "/content/assets/sizes", options)
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.

[View source]

133
134
135
# File 'lib/user/content/assets.rb', line 133

def get_asset_usage(options)
    return @client.raw("get", "/content/assets/usage", options)
end

#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)
[View source]

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

#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

options = {
  "fields": "id, title"
}
@data = @mints_user.get_assets(options)

Third Example

options = {
  "fields": "id, title"
}
@data = @mints_user.get_assets(options, true)
[View source]

28
29
30
# File 'lib/user/content/assets.rb', line 28

def get_assets(options = nil, use_post = true)
    return get_query_results("/content/assets", options, 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)
[View source]

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

#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)
[View source]

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