class BaseCRM::CallOutcomesService

Public Class Methods

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

Public Instance Methods

all() click to toggle source

Retrieve all call outcomes

get '/call_outcomes'

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/call_outcomes_service.rb, line 15
def all
  PaginatedResource.new(self)
end
where(options = {}) click to toggle source

Retrieve all call outcomes

get '/call_outcomes'

Returns all call outcomes available to the user, according to the parameters provided Call outcomes are always sorted by id in ascending order

@param options [Hash] Search options @option options [Integer] :page (1) 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) Number of records to return per page. The default limit is 25 and the maximum number that can be returned at one time is 100. @return [Array<CallOutcome>] The list of CallOutcomes for the first page, unless otherwise specified.

# File lib/basecrm/services/call_outcomes_service.rb, line 30
def where(options = {})
  _, _, root = @client.get("/call_outcomes", options)

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

Private Instance Methods

extract_params!(call_outcome, *args) click to toggle source
# File lib/basecrm/services/call_outcomes_service.rb, line 42
def extract_params!(call_outcome, *args)
  params = call_outcome.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!(call_outcome) click to toggle source
# File lib/basecrm/services/call_outcomes_service.rb, line 38
def validate_type!(call_outcome)
  raise TypeError unless call_outcome.is_a?(CallOutcome) || call_outcome.is_a?(Hash)
end