class Postmen::RateCollection
This class wraps the array of Rate
models
Public Class Methods
all(options = {})
click to toggle source
Fetch all rates.
@param options [Hash] Options for the query. @see docs.postmen.com/api.html#rates-list-all-rates API documentation @example
.all # Returns all rates, default query. .all(status: :failed) # Returns only failed rates
# 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)
click to toggle source
Creates a Rate
@param params [Hash] Rate
params @see docs.postmen.com/api.html#labels-create-a-label API documentation @return [Rate]
# 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)
click to toggle source
Fetch single rate
@param id [UUID] Rate
UUID @see docs.postmen.com/api.html#rates-calculate-rates API documentation @return [Rate] @raise ResourceNotFound if Rate
with given id was not found
# File lib/postmen/rate_collection.rb, line 26 def self.find(id) get(Connection.new.get("/rates/#{id}").parsed_response) end