class Postmen::LabelCollection
This class wraps the array of Label
models
Public Class Methods
all(options = {})
click to toggle source
Fetch all labels.
@param options [Hash] Options for the query. @see docs.postmen.com/api.html#labels-list-all-labels API documentation @example
.all # Returns all labels, default query. .all(status: :cancelled) # Returns only cancelled labels
# File lib/postmen/label_collection.rb, line 16 def self.all(options = {}) new(Connection.new.get('/labels', LabelQuery.new(options).to_query).parsed_response) end
create(params)
click to toggle source
Creates a label
@param params [Hash] Label
params @see docs.postmen.com/api.html#labels-create-a-label API documentation @return [Label]
# File lib/postmen/label_collection.rb, line 35 def self.create(params) Label.new(Connection.new.post('/labels', CreateLabelQuery.new(params).to_query).parsed_response[:data]) end
find(id)
click to toggle source
Fetch single label
@param id [UUID] Label
UUID @see docs.postmen.com/api.html#labels-retrieve-a-label API documentation @return [Label] @raise ResourceNotFound if label with given id was not fount
# File lib/postmen/label_collection.rb, line 26 def self.find(id) get(Connection.new.get("/labels/#{id}").parsed_response) end