Class: Brandmaker::ExternalMediaVariable

Inherits:
Variable
  • Object
show all
Defined in:
lib/brandmaker/external_media_variable.rb

Instance Attribute Summary collapse

Attributes inherited from Variable

#config

Instance Method Summary collapse

Methods inherited from Variable

#data, #initialize, #label, #purpose, #technical_name, #type_id

Constructor Details

This class inherits a constructor from Brandmaker::Variable

Instance Attribute Details

#downloadUrlObject

Returns the value of attribute downloadUrl.



6
7
8
# File 'lib/brandmaker/external_media_variable.rb', line 6

def downloadUrl
  @downloadUrl
end

#fileOriginalNameObject

Returns the value of attribute fileOriginalName.



7
8
9
# File 'lib/brandmaker/external_media_variable.rb', line 7

def fileOriginalName
  @fileOriginalName
end

#fileTypeObject

Returns the value of attribute fileType.



8
9
10
# File 'lib/brandmaker/external_media_variable.rb', line 8

def fileType
  @fileType
end

Instance Method Details

#reloadObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/brandmaker/external_media_variable.rb', line 14

def reload
  if value.present?
    res = RestClient.get(
      Brandmaker.configuration.external_media_service,
      {
        :params => {
          :mediaID => value,
          :secret => Brandmaker.configuration.external_media_service_secret
        }
      }
    )
    hash = JSON.parse(res)
    error = hash['ERROR'].presence
    if error
      raise error
    end
    self.fileOriginalName = hash['fileOriginalName']
    self.downloadUrl = hash['downloadUrl']
    self.fileType = hash['fileType']
    self
  end
end

#valueObject



10
11
12
# File 'lib/brandmaker/external_media_variable.rb', line 10

def value
  super.split(",").last rescue nil
end