Class: Rerout::CreateTagInput

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/create_tag_input.rb

Overview

Request body for ‘POST /v1/projects/me/tags`. `name` is required; `color` is optional and omitted from the payload when not set (the server validates it against its palette and defaults to `“teal”`).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, color: nil) ⇒ CreateTagInput

Returns a new instance of CreateTagInput.

Parameters:

  • name (String)

    required, the tag label.

  • color (String, nil) (defaults to: nil)

    optional tag color. Server default: ‘“teal”`.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'lib/rerout/create_tag_input.rb', line 12

def initialize(name:, color: nil)
  raise ArgumentError, 'name is required' if name.nil? || name.to_s.empty?

  @name = name
  @color = color
  freeze
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



8
9
10
# File 'lib/rerout/create_tag_input.rb', line 8

def color
  @color
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/rerout/create_tag_input.rb', line 8

def name
  @name
end

Instance Method Details

#to_hObject

Serialize for the wire. ‘color` is only included when set.



21
22
23
24
25
# File 'lib/rerout/create_tag_input.rb', line 21

def to_h
  hash = { 'name' => name }
  hash['color'] = color unless color.nil?
  hash
end