class BaseCRM::PipelinesService

Public Class Methods

new(client) click to toggle source
# File lib/basecrm/services/pipelines_service.rb, line 5
def initialize(client)
  @client = client
end

Public Instance Methods

all() click to toggle source

Retrieve all pipelines

get '/pipelines'

If you want to use filtering or sorting (see where). @return [Enumerable] Paginated resource you can use to iterate over all the resources.

# File lib/basecrm/services/pipelines_service.rb, line 15
def all
  PaginatedResource.new(self)
end
where(options = {}) click to toggle source

Retrieve all pipelines

get '/pipelines'

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

@param options [Hash] Search options @option options [String] :ids Comma-separated list of pipeline IDs to be returned in a request. @option options [String] :name Name of the pipeline to search for. This parameter is used in a strict sense. Unsupported for now. @option options [Integer] :page (1) The page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page. @option options [Integer] :per_page (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. @option options [String] :sort_by (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. @return [Array<Pipeline>] The list of Pipelines for the first page, unless otherwise specified.

# 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

Private Instance Methods

extract_params!(pipeline, *args) click to toggle source
# File lib/basecrm/services/pipelines_service.rb, line 44
def extract_params!(pipeline, *args)
  params = pipeline.to_h.select{ |k, _| args.include?(k) }
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
  params
end
validate_type!(pipeline) click to toggle source
# File lib/basecrm/services/pipelines_service.rb, line 40
def validate_type!(pipeline)
  raise TypeError unless pipeline.is_a?(Pipeline) || pipeline.is_a?(Hash)
end