Class: Mailflow::Attribute
- Inherits:
-
Object
- Object
- Mailflow::Attribute
- Includes:
- APIOperations
- Defined in:
- lib/mailflow-ruby/attribute.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#label ⇒ Object
Returns the value of attribute label.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
- .delete(attributes, params = {}) ⇒ Object
- .list(options = {}) ⇒ Object
- .update(attributes, params) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(attributes) ⇒ Attribute
constructor
A new instance of Attribute.
Methods included from APIOperations
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
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/mailflow-ruby/attribute.rb', line 9 def key @key end |
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/mailflow-ruby/attribute.rb', line 9 def label @label end |
#value ⇒ Object
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
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( = {}) response = get_request('attributes', ) response.parsed_response.map do |params| Attribute.new(params) end end |
.update(attributes, params) ⇒ Object
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 |