Class: Postmen::LabelCollection

Inherits:
Object
  • Object
show all
Includes:
CollectionProxy
Defined in:
lib/postmen/label_collection.rb

Overview

This class wraps the array of Label models

Class Method Summary collapse

Methods included from CollectionProxy

included, #initialize

Class Method Details

.all(options = {}) ⇒ Object

Fetch all labels.

Examples:

.all # Returns all labels, default query.
.all(status: :cancelled) # Returns only cancelled labels

Parameters:

  • options (Hash) (defaults to: {})

    Options for the query.

See Also:



16
17
18
# 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) ⇒ Label

Creates a label

Parameters:

  • params (Hash)

    Label params

Returns:

See Also:



35
36
37
# 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) ⇒ Label

Fetch single label

Parameters:

  • id (UUID)

    Label UUID

Returns:

Raises:

  • ResourceNotFound if label with given id was not fount

See Also:



26
27
28
# File 'lib/postmen/label_collection.rb', line 26

def self.find(id)
  get(Connection.new.get("/labels/#{id}").parsed_response)
end