Class: Mailflow::Attribute

Inherits:
Object
  • Object
show all
Includes:
APIOperations
Defined in:
lib/mailflow-ruby/attribute.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations

included

Constructor Details

#initialize(attributes) ⇒ Attribute

Returns a new instance of Attribute.



37
38
39
40
41
# File 'lib/mailflow-ruby/attribute.rb', line 37

def initialize(attributes)
  @key = attributes["key"]
  @label = attributes["label"]
  @value = attributes["value"]
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



9
10
11
# File 'lib/mailflow-ruby/attribute.rb', line 9

def key
  @key
end

#labelObject

Returns the value of attribute label.



9
10
11
# File 'lib/mailflow-ruby/attribute.rb', line 9

def label
  @label
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/mailflow-ruby/attribute.rb', line 9

def value
  @value
end

Class Method Details

.delete(attributes, params = {}) ⇒ Object

Raises:



28
29
30
31
32
33
# File 'lib/mailflow-ruby/attribute.rb', line 28

def delete(attributes, params = {})
  body = {attributes: attributes}.merge(params)
  response = delete_request('attributes', body)
  raise UnprocessableError if (response.code == 422 || response.code == 404)
  return true
end

.list(options = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/mailflow-ruby/attribute.rb', line 12

def list(options = {})
  response = get_request('attributes', options)
  response.parsed_response.map do |params|
    Attribute.new(params)
  end
end

.update(attributes, params) ⇒ Object

Raises:



19
20
21
22
23
24
25
26
# File 'lib/mailflow-ruby/attribute.rb', line 19

def update(attributes, params)
  body = {attributes: attributes}.merge(params)
  response = post_request('attributes', body)
  raise UnprocessableError if (response.code == 422 || response.code == 404)
  response.parsed_response.map do |attributes|
    Attribute.new(attributes)
  end
end

Instance Method Details

#==(other) ⇒ Object



43
44
45
# File 'lib/mailflow-ruby/attribute.rb', line 43

def ==(other)
  self.name == other.name
end