Class: BaseCRM::PipelinesService

Inherits:
Object
  • Object
show all
Defined in:
lib/basecrm/services/pipelines_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PipelinesService

Returns a new instance of PipelinesService.



5
6
7
# File 'lib/basecrm/services/pipelines_service.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#allEnumerable

Retrieve all pipelines

get ‘/pipelines’

If you want to use filtering or sorting (see #where).

Returns:

  • (Enumerable)

    Paginated resource you can use to iterate over all the resources.



15
16
17
# File 'lib/basecrm/services/pipelines_service.rb', line 15

def all
  PaginatedResource.new(self)
end

#where(options = {}) ⇒ Array<Pipeline>

Retrieve all pipelines

get ‘/pipelines’

Returns all pipelines available to the user, according to the parameters provided

Parameters:

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

    Search options

Options Hash (options):

  • :ids (String)

    Comma-separated list of pipeline IDs to be returned in a request.

  • :name (String)

    Name of the pipeline to search for. This parameter is used in a strict sense. Unsupported for now.

  • :page (Integer) — default: 1

    The page number to start from. Page numbering starts at 1, and omitting the ‘page` parameter will return the first page.

  • :per_page (Integer) — default: 25

    The number of records to be returned per page. The default limit is 25 and the maximum number that can be returned is 100.

  • :sort_by (String) — default: id:asc

    Comma-separated list of fields to sort by. The sort criteria is applied in the order specified. The default ordering is ascending. If you want to change the sort ordering to descending, append ‘:desc` to the field e.g. `sort_by=position:desc`. Unsupported for now.

Returns:

  • (Array<Pipeline>)

    The list of Pipelines for the first page, unless otherwise specified.



32
33
34
35
36
# File 'lib/basecrm/services/pipelines_service.rb', line 32

def where(options = {})
  _, _, root = @client.get("/pipelines", options)

  root[:items].map{ |item| Pipeline.new(item[:data]) }
end