Class: BaseCRM::StagesService

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ StagesService

Returns a new instance of StagesService.



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

def initialize(client)
  @client = client
end

Instance Method Details

#allEnumerable

Retrieve all stages

get ‘/stages’

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/stages_service.rb', line 15

def all
  PaginatedResource.new(self)
end

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

Retrieve all stages

get ‘/stages’

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

Parameters:

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

    Search options

Options Hash (options):

  • :active (Boolean)

    Parameter that determines whether to return active or inactive stages. Unsupported for now.

  • :ids (String)

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

  • :name (String)

    Name of the stage you’re searching 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 return per page. The default limit is 25 and the maximum number that can be returned is 100.

  • :pipeline_id (Integer) — default: 1

    The unique identifier of the pipeline that contains this stage.

  • :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<Stage>)

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



34
35
36
37
38
# File 'lib/basecrm/services/stages_service.rb', line 34

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

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