Class: SlackWebApi::Attachment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/slack_web_api/models/attachment.rb

Overview

Attachment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, fallback: SKIP, image_bytes: SKIP, image_height: SKIP, image_url: SKIP, image_width: SKIP, additional_properties: nil) ⇒ Attachment

Returns a new instance of Attachment.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/slack_web_api/models/attachment.rb', line 64

def initialize(id:, fallback: SKIP, image_bytes: SKIP, image_height: SKIP,
               image_url: SKIP, image_width: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @fallback = fallback unless fallback == SKIP
  @id = id
  @image_bytes = image_bytes unless image_bytes == SKIP
  @image_height = image_height unless image_height == SKIP
  @image_url = image_url unless image_url == SKIP
  @image_width = image_width unless image_width == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#fallbackString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/slack_web_api/models/attachment.rb', line 14

def fallback
  @fallback
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/slack_web_api/models/attachment.rb', line 18

def id
  @id
end

#image_bytesInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/slack_web_api/models/attachment.rb', line 22

def image_bytes
  @image_bytes
end

#image_heightInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/slack_web_api/models/attachment.rb', line 26

def image_height
  @image_height
end

#image_urlString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/slack_web_api/models/attachment.rb', line 30

def image_url
  @image_url
end

#image_widthInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/slack_web_api/models/attachment.rb', line 34

def image_width
  @image_width
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/slack_web_api/models/attachment.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  fallback = hash.key?('fallback') ? hash['fallback'] : SKIP
  image_bytes = hash.key?('image_bytes') ? hash['image_bytes'] : SKIP
  image_height = hash.key?('image_height') ? hash['image_height'] : SKIP
  image_url = hash.key?('image_url') ? hash['image_url'] : SKIP
  image_width = hash.key?('image_width') ? hash['image_width'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Attachment.new(id: id,
                 fallback: fallback,
                 image_bytes: image_bytes,
                 image_height: image_height,
                 image_url: image_url,
                 image_width: image_width,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/slack_web_api/models/attachment.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fallback'] = 'fallback'
  @_hash['id'] = 'id'
  @_hash['image_bytes'] = 'image_bytes'
  @_hash['image_height'] = 'image_height'
  @_hash['image_url'] = 'image_url'
  @_hash['image_width'] = 'image_width'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/slack_web_api/models/attachment.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
# File 'lib/slack_web_api/models/attachment.rb', line 49

def self.optionals
  %w[
    fallback
    image_bytes
    image_height
    image_url
    image_width
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



117
118
119
120
121
122
123
# File 'lib/slack_web_api/models/attachment.rb', line 117

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} fallback: #{@fallback.inspect}, id: #{@id.inspect}, image_bytes:"\
  " #{@image_bytes.inspect}, image_height: #{@image_height.inspect}, image_url:"\
  " #{@image_url.inspect}, image_width: #{@image_width.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



109
110
111
112
113
114
# File 'lib/slack_web_api/models/attachment.rb', line 109

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} fallback: #{@fallback}, id: #{@id}, image_bytes: #{@image_bytes},"\
  " image_height: #{@image_height}, image_url: #{@image_url}, image_width: #{@image_width},"\
  " additional_properties: #{@additional_properties}>"
end