Class: BaseCRM::CallsService
- Inherits:
-
Object
- Object
- BaseCRM::CallsService
- Defined in:
- lib/basecrm/services/calls_service.rb
Constant Summary collapse
- OPTS_KEYS_TO_PERSIST =
Set[:user_id, :summary, :recording_url, :outcome_id, :duration, :phone_number, :incoming, :missed, :external_id, :resource_id, :resource_type, :associated_deal_ids, :made_at]
Instance Method Summary collapse
-
#all ⇒ Enumerable
Retrieve all calls.
-
#create(call) ⇒ Call
Create a call.
-
#destroy(id) ⇒ Boolean
Delete a call.
-
#find(id) ⇒ Call
Retrieve a single call.
-
#initialize(client) ⇒ CallsService
constructor
A new instance of CallsService.
-
#update(call) ⇒ Call
Update a call.
-
#where(options = {}) ⇒ Array<Call>
Retrieve all calls.
Constructor Details
#initialize(client) ⇒ CallsService
Returns a new instance of CallsService.
7 8 9 |
# File 'lib/basecrm/services/calls_service.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#all ⇒ Enumerable
Retrieve all calls
get ‘/calls’
If you want to use filtering or sorting (see #where).
17 18 19 |
# File 'lib/basecrm/services/calls_service.rb', line 17 def all PaginatedResource.new(self) end |
#create(call) ⇒ Call
Create a call
post ‘/calls’
Create a new call
50 51 52 53 54 55 56 57 |
# File 'lib/basecrm/services/calls_service.rb', line 50 def create(call) validate_type!(call) attributes = sanitize(call) _, _, root = @client.post("/calls", attributes) Call.new(root[:data]) end |
#destroy(id) ⇒ Boolean
Delete a call
delete ‘/calls/BaseCRM#id’
Delete an existing call If the specified call does not exist, this query returns an error This operation cannot be undone
106 107 108 109 |
# File 'lib/basecrm/services/calls_service.rb', line 106 def destroy(id) status, _, _ = @client.delete("/calls/#{id}") status == 204 end |
#find(id) ⇒ Call
Retrieve a single call
get ‘/calls/BaseCRM#id’
Returns a single call available to the user, according to the unique call ID provided If the specified call does not exist, this query returns an error
69 70 71 72 73 |
# File 'lib/basecrm/services/calls_service.rb', line 69 def find(id) _, _, root = @client.get("/calls/#{id}") Call.new(root[:data]) end |
#update(call) ⇒ Call
Update a call
put ‘/calls/BaseCRM#id’
Allows to attach a Contact or Lead to an existing Call, or change it’s current association
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/basecrm/services/calls_service.rb', line 84 def update(call) validate_type!(call) params = extract_params!(call, :id) id = params[:id] attributes = sanitize(call) _, _, root = @client.put("/calls/#{id}", attributes) Call.new(root[:data]) end |
#where(options = {}) ⇒ Array<Call>
Retrieve all calls
get ‘/calls’
Returns all calls available to the user, according to the parameters provided Calls are always sorted by made_at in descending order
35 36 37 38 39 |
# File 'lib/basecrm/services/calls_service.rb', line 35 def where( = {}) _, _, root = @client.get("/calls", ) root[:items].map{ |item| Call.new(item[:data]) } end |