Class: Postmen::ShipperAccountCollection

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

Overview

This class wraps the array of ShipperAccount models

Class Method Summary collapse

Methods included from CollectionProxy

included, #initialize

Class Method Details

.all(options = {}) ⇒ Object

Fetch all shipper accounts.

Examples:

.all # Returns all shipper accounts, default query.
.all(slug: :aramex) # Returns only Shipper accounts from Aramex

Parameters:

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

    Options for the query.

See Also:



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

def self.all(options = {})
  new(Connection.new.get('/shipper-accounts', ShipperAccountQuery.new(options).to_query).parsed_response)
end

.create(params) ⇒ ShipperAccount

Creates a ShipperAccount

Parameters:

  • params (Hash)

    ShipperAccount params

Returns:

See Also:



35
36
37
38
39
40
41
42
# File 'lib/postmen/shipper_account_collection.rb', line 35

def self.create(params)
  ShipperAccount.new(
    Connection.new.post(
      '/shipper-accounts',
      CreateShipperAccountQuery.new(params).to_query
    ).parsed_response[:data]
  )
end

.find(id) ⇒ ShipperAccount

Fetch single ShipperAccount

Parameters:

  • id (UUID)

    ShipperAccount UUID

Returns:

Raises:

  • ResourceNotFound if ShipperAccount with given id was not found

See Also:



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

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