Class: Postmen::RateCollection

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

Overview

This class wraps the array of Rate models

Class Method Summary collapse

Methods included from CollectionProxy

included, #initialize

Class Method Details

.all(options = {}) ⇒ Object

Fetch all rates.

Examples:

.all # Returns all rates, default query.
.all(status: :failed) # Returns only failed rates

See Also:



16
17
18
# File 'lib/postmen/rate_collection.rb', line 16

def self.all(options = {})
  new(Connection.new.get('/rates', RateQuery.new(options).to_query).parsed_response)
end

.create(params) ⇒ Rate

Creates a Rate

See Also:



35
36
37
# File 'lib/postmen/rate_collection.rb', line 35

def self.create(params)
  Rate.new(Connection.new.post('/rates', CreateRateQuery.new(params).to_query).parsed_response[:data])
end

.find(id) ⇒ Rate

Fetch single rate

Raises:

  • ResourceNotFound if Rate with given id was not found

See Also:



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

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