Class: Mailflow::Tag
- Inherits:
-
Object
- Object
- Mailflow::Tag
- Includes:
- APIOperations
- Defined in:
- lib/mailflow-ruby/tag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .create(tags, params = {}, trigger = false) ⇒ Object
- .list(options = {}) ⇒ Object
- .untag(tags, params = {}) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #delete ⇒ Object
-
#initialize(attributes) ⇒ Tag
constructor
A new instance of Tag.
Methods included from APIOperations
Constructor Details
#initialize(attributes) ⇒ Tag
Returns a new instance of Tag.
39 40 41 |
# File 'lib/mailflow-ruby/tag.rb', line 39 def initialize(attributes) @name = attributes["name"] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/mailflow-ruby/tag.rb', line 9 def name @name end |
Class Method Details
.create(tags, params = {}, trigger = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mailflow-ruby/tag.rb', line 19 def create(, params = {}, trigger = false) = .map { |tag| {name: tag}} body = {tags: } body.merge!(params) body.merge!({trigger: trigger}) if trigger response = post_request('tags', body) raise UnprocessableError if (response.code == 422 || response.code == 404) response.parsed_response.map do |attributes| Tag.new(attributes) end end |
.list(options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/mailflow-ruby/tag.rb', line 12 def list( = {}) response = get_request('tags', ) response.parsed_response.map do |attributes| Tag.new(attributes) end end |
.untag(tags, params = {}) ⇒ Object
32 33 34 35 |
# File 'lib/mailflow-ruby/tag.rb', line 32 def untag(, params = {}) = .map { |tag| {name: tag}} delete_request('tags', {tags: }.merge(params)) end |