Class: Sendly::LabelsResource
- Inherits:
-
Object
- Object
- Sendly::LabelsResource
- Defined in:
- lib/sendly/labels_resource.rb
Instance Method Summary collapse
- #create(name:, color: nil, description: nil) ⇒ Object
- #delete(id) ⇒ Object
-
#initialize(client) ⇒ LabelsResource
constructor
A new instance of LabelsResource.
- #list ⇒ Object
Constructor Details
#initialize(client) ⇒ LabelsResource
Returns a new instance of LabelsResource.
5 6 7 |
# File 'lib/sendly/labels_resource.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(name:, color: nil, description: nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/sendly/labels_resource.rb', line 9 def create(name:, color: nil, description: nil) body = { name: name } body[:color] = color if color body[:description] = description if description response = @client.post("/labels", body) Label.new(response) end |
#delete(id) ⇒ Object
23 24 25 26 27 |
# File 'lib/sendly/labels_resource.rb', line 23 def delete(id) raise ValidationError, "Label ID is required" if id.nil? || id.empty? @client.delete("/labels/#{URI.encode_www_form_component(id)}") end |