basecrm 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c69d41cdc396cd95c74e3bdd2f778aa78ac0cf2e
4
- data.tar.gz: dc6e97c0e908d384fc7f7eb4ad3abe03f726ecfe
3
+ metadata.gz: 5e621bfe41a88f35c122a699674160402813de8b
4
+ data.tar.gz: 920db4f000725a80af23bfa9a77c1075580da116
5
5
  SHA512:
6
- metadata.gz: 1ce204616d05b6cb7a9ad00e90a910f23cf16e8ec7c4f3541e827bd7ddb9090225b1043c8717980e90e8cf35e6ee47c9960f16edc7cea28022cf1cf5c31fc8e7
7
- data.tar.gz: ffa2c34f7aafc77cf05cefeffc3e174b4fd2729bafb91c30ea8b94acbffd52cefdf3b025fa60242d4d869646c7ee815cbdc8fbb0cc19bbdec69fa8eb2924c4ac
6
+ metadata.gz: 75bbebdc011bea3940a6d2103fcff88e7e48fd78f9b35de41230c98c959fffd33063b8d56f17c6ac201b65609cec27d23f3f2900b9b64f89efa4208652928dee
7
+ data.tar.gz: 784f33b5bc21b7635887c8a29f99904d7d4dacac0f7ce5969a44172e4ebb0b5f7412db3e1018fb74f29c6cf56decbbb7fe26c99b9ac4b499ae07fe142c02cf5f
data/README.md CHANGED
@@ -174,6 +174,30 @@ Actions:
174
174
  * Create an associated contact - `client.associated_contacts.create`
175
175
  * Remove an associated contact - `client.associated_contacts.destroy`
176
176
 
177
+ ### Call
178
+
179
+ ```ruby
180
+ client = BaseCRM::Client.new(access_token: "<YOUR_PERSONAL_ACCESS_TOKEN>")
181
+ client.calls # => BaseCRM::CallsService
182
+ ```
183
+
184
+ Actions:
185
+ * Retrieve all calls - `client.calls.all`
186
+ * Create a call - `client.calls.create`
187
+ * Retrieve a single call - `client.calls.find`
188
+ * Update a call - `client.calls.update`
189
+ * Delete a call - `client.calls.destroy`
190
+
191
+ ### CallOutcome
192
+
193
+ ```ruby
194
+ client = BaseCRM::Client.new(access_token: "<YOUR_PERSONAL_ACCESS_TOKEN>")
195
+ client.call_outcomes # => BaseCRM::CallOutcomesService
196
+ ```
197
+
198
+ Actions:
199
+ * Retrieve all call outcomes - `client.call_outcomes.all`
200
+
177
201
  ### Contact
178
202
 
179
203
  ```ruby
@@ -14,6 +14,8 @@ require 'basecrm/models/meta'
14
14
  require 'basecrm/models/account'
15
15
  require 'basecrm/models/address'
16
16
  require 'basecrm/models/associated_contact'
17
+ require 'basecrm/models/call'
18
+ require 'basecrm/models/call_outcome'
17
19
  require 'basecrm/models/contact'
18
20
  require 'basecrm/models/deal'
19
21
  require 'basecrm/models/deal_source'
@@ -40,6 +42,8 @@ require 'basecrm/models/sync_meta'
40
42
  require 'basecrm/paginated_resource'
41
43
  require 'basecrm/services/accounts_service'
42
44
  require 'basecrm/services/associated_contacts_service'
45
+ require 'basecrm/services/calls_service'
46
+ require 'basecrm/services/call_outcomes_service'
43
47
  require 'basecrm/services/contacts_service'
44
48
  require 'basecrm/services/deals_service'
45
49
  require 'basecrm/services/deal_sources_service'
@@ -108,6 +112,24 @@ module BaseCRM
108
112
  @associated_contacts ||= AssociatedContactsService.new(@http_client)
109
113
  end
110
114
 
115
+ # Access all Calls related actions.
116
+ # @see CallsService
117
+ # @see Call
118
+ #
119
+ # @return [CallsService] Service object for resources.
120
+ def calls
121
+ @calls ||= CallsService.new(@http_client)
122
+ end
123
+
124
+ # Access all CallOutcomes related actions.
125
+ # @see CallOutcomesService
126
+ # @see CallOutcome
127
+ #
128
+ # @return [CallOutcomesService] Service object for resources.
129
+ def call_outcomes
130
+ @call_outcomes ||= CallOutcomesService.new(@http_client)
131
+ end
132
+
111
133
  # Access all Contacts related actions.
112
134
  # @see ContactsService
113
135
  # @see Contact
@@ -0,0 +1,52 @@
1
+ # WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
2
+
3
+ module BaseCRM
4
+ class Call < Model
5
+ # @!attribute [r] id
6
+ # @return [Integer] Unique identifier of the call.
7
+ # attr_reader :id
8
+ # @!attribute [r] upated_at
9
+ # @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
10
+ # attr_reader :upated_at
11
+
12
+ # @!attribute [rw] associated_deal_ids
13
+ # @return [Array<Integer>] An array of ids of deals associated to the call.
14
+ # attr_accessor :associated_deal_ids
15
+ # @!attribute [rw] duration
16
+ # @return [Integer] Duration of the call in seconds.
17
+ # attr_accessor :duration
18
+ # @!attribute [rw] external_id
19
+ # @return [String] Unique identifier of a call from an external system.
20
+ # attr_accessor :external_id
21
+ # @!attribute [rw] incoming
22
+ # @return [Boolean] Phone number of the person with which the call was made.
23
+ # attr_accessor :incoming
24
+ # @!attribute [rw] made_at
25
+ # @return [DateTime] Date and time of when the call was made (started) in UTC (ISO8601 format).
26
+ # attr_accessor :made_at
27
+ # @!attribute [rw] missed
28
+ # @return [Boolean] Indicator of whether the call was missed (not answered) by the user or not.
29
+ # attr_accessor :missed
30
+ # @!attribute [rw] outcome_id
31
+ # @return [Integer] Unique identifier of Call Outcome assigned to the call.
32
+ # attr_accessor :outcome_id
33
+ # @!attribute [rw] phone_number
34
+ # @return [String] Indicator of whether the call was incoming or not.
35
+ # attr_accessor :phone_number
36
+ # @!attribute [rw] recording_url
37
+ # @return [String] URL pointing to call recording.
38
+ # attr_accessor :recording_url
39
+ # @!attribute [rw] resource_id
40
+ # @return [Integer] Unique identifier of the resource the call is attached to.
41
+ # attr_accessor :resource_id
42
+ # @!attribute [rw] resource_type
43
+ # @return [String] Name of the resource type the call is attached to.
44
+ # attr_accessor :resource_type
45
+ # @!attribute [rw] summary
46
+ # @return [String] Content of the note about this call.
47
+ # attr_accessor :summary
48
+ # @!attribute [rw] user_id
49
+ # @return [Integer] Unique identifier of the user who performed the call.
50
+ # attr_accessor :user_id
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ # WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
2
+
3
+ module BaseCRM
4
+ class CallOutcome < Model
5
+ # @!attribute [r] created_at
6
+ # @return [DateTime] Date and time of when the call outcome was created in UTC (ISO8601 format).
7
+ # attr_reader :created_at
8
+ # @!attribute [r] creator_id
9
+ # @return [Integer] Unique identifier of the user who created the call outcome.
10
+ # attr_reader :creator_id
11
+ # @!attribute [r] id
12
+ # @return [Integer] Unique identifier of the call outcome.
13
+ # attr_reader :id
14
+ # @!attribute [r] name
15
+ # @return [String] Name of the call outcome.
16
+ # attr_reader :name
17
+ # @!attribute [r] updated_at
18
+ # @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
19
+ # attr_reader :updated_at
20
+
21
+ end
22
+ end
@@ -0,0 +1,48 @@
1
+ # WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
2
+
3
+ module BaseCRM
4
+ class CallOutcomesService
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ # Retrieve all call outcomes
10
+ #
11
+ # get '/call_outcomes'
12
+ #
13
+ # If you want to use filtering or sorting (see #where).
14
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
15
+ def all
16
+ PaginatedResource.new(self)
17
+ end
18
+
19
+ # Retrieve all call outcomes
20
+ #
21
+ # get '/call_outcomes'
22
+ #
23
+ # Returns all call outcomes available to the user, according to the parameters provided
24
+ # Call outcomes are always sorted by id in ascending order
25
+ #
26
+ # @param options [Hash] Search options
27
+ # @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.
28
+ # @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*.
29
+ # @return [Array<CallOutcome>] The list of CallOutcomes for the first page, unless otherwise specified.
30
+ def where(options = {})
31
+ _, _, root = @client.get("/call_outcomes", options)
32
+
33
+ root[:items].map{ |item| CallOutcome.new(item[:data]) }
34
+ end
35
+
36
+
37
+ private
38
+ def validate_type!(call_outcome)
39
+ raise TypeError unless call_outcome.is_a?(CallOutcome) || call_outcome.is_a?(Hash)
40
+ end
41
+
42
+ def extract_params!(call_outcome, *args)
43
+ params = call_outcome.to_h.select{ |k, _| args.include?(k) }
44
+ raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
45
+ params
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,127 @@
1
+ # WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
2
+
3
+ module BaseCRM
4
+ class CallsService
5
+ 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]
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # Retrieve all calls
12
+ #
13
+ # get '/calls'
14
+ #
15
+ # If you want to use filtering or sorting (see #where).
16
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
17
+ def all
18
+ PaginatedResource.new(self)
19
+ end
20
+
21
+ # Retrieve all calls
22
+ #
23
+ # get '/calls'
24
+ #
25
+ # Returns all calls available to the user, according to the parameters provided
26
+ # Calls are always sorted by made_at in descending order
27
+ #
28
+ # @param options [Hash] Search options
29
+ # @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.
30
+ # @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*.
31
+ # @option options [String] :ids Comma-separated list of call IDs to be returned in request.
32
+ # @option options [Integer] :resource_id Unique identifier of the resource the call is attached to.
33
+ # @option options [String] :resource_type Name of the resource type the call is attached to.
34
+ # @return [Array<Call>] The list of Calls for the first page, unless otherwise specified.
35
+ def where(options = {})
36
+ _, _, root = @client.get("/calls", options)
37
+
38
+ root[:items].map{ |item| Call.new(item[:data]) }
39
+ end
40
+
41
+
42
+ # Create a call
43
+ #
44
+ # post '/calls'
45
+ #
46
+ # Create a new call
47
+ #
48
+ # @param call [Call, Hash] Either object of the Call type or Hash. This object's attributes describe the object to be created.
49
+ # @return [Call] The resulting object represting created resource.
50
+ def create(call)
51
+ validate_type!(call)
52
+
53
+ attributes = sanitize(call)
54
+ _, _, root = @client.post("/calls", attributes)
55
+
56
+ Call.new(root[:data])
57
+ end
58
+
59
+
60
+ # Retrieve a single call
61
+ #
62
+ # get '/calls/{id}'
63
+ #
64
+ # Returns a single call available to the user, according to the unique call ID provided
65
+ # If the specified call does not exist, this query returns an error
66
+ #
67
+ # @param id [Integer] Unique identifier of a Call
68
+ # @return [Call] Searched resource object.
69
+ def find(id)
70
+ _, _, root = @client.get("/calls/#{id}")
71
+
72
+ Call.new(root[:data])
73
+ end
74
+
75
+
76
+ # Update a call
77
+ #
78
+ # put '/calls/{id}'
79
+ #
80
+ # Allows to attach a Contact or Lead to an existing Call, or change it’s current association
81
+ #
82
+ # @param call [Call, Hash] Either object of the Call type or Hash. This object's attributes describe the object to be updated.
83
+ # @return [Call] The resulting object represting updated resource.
84
+ def update(call)
85
+ validate_type!(call)
86
+ params = extract_params!(call, :id)
87
+ id = params[:id]
88
+
89
+ attributes = sanitize(call)
90
+ _, _, root = @client.put("/calls/#{id}", attributes)
91
+
92
+ Call.new(root[:data])
93
+ end
94
+
95
+
96
+ # Delete a call
97
+ #
98
+ # delete '/calls/{id}'
99
+ #
100
+ # Delete an existing call
101
+ # If the specified call does not exist, this query returns an error
102
+ # This operation cannot be undone
103
+ #
104
+ # @param id [Integer] Unique identifier of a Call
105
+ # @return [Boolean] Status of the operation.
106
+ def destroy(id)
107
+ status, _, _ = @client.delete("/calls/#{id}")
108
+ status == 204
109
+ end
110
+
111
+
112
+ private
113
+ def validate_type!(call)
114
+ raise TypeError unless call.is_a?(Call) || call.is_a?(Hash)
115
+ end
116
+
117
+ def extract_params!(call, *args)
118
+ params = call.to_h.select{ |k, _| args.include?(k) }
119
+ raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
120
+ params
121
+ end
122
+
123
+ def sanitize(call)
124
+ call.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
125
+ end
126
+ end
127
+ end
@@ -1,3 +1,3 @@
1
1
  module BaseCRM
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'securerandom'
2
+
3
+ FactoryGirl.define do
4
+ factory :call, class: BaseCRM::Call do
5
+
6
+ summary { "Schedule another call." }
7
+ recording_url { "https://api.twilio.com/2010-04-01/Accounts/hAkjsahhd719e/Recordings/RKOHurusajda" }
8
+ duration { 44 }
9
+ phone_number { "+44-208-1234567" }
10
+ incoming { true }
11
+ missed { false }
12
+ external_id { SecureRandom.hex(32) }
13
+ made_at { "2014-09-27T16:32:56+00:00" }
14
+
15
+
16
+ to_create do |call|
17
+ client.calls.create(call)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe BaseCRM::CallOutcomesService do
4
+ describe 'Responds to' do
5
+ subject { client.call_outcomes }
6
+
7
+ it { should respond_to :all }
8
+ it { should respond_to :where }
9
+ end
10
+
11
+ describe :all do
12
+ it "returns a PaginatedResource" do
13
+ expect(client.call_outcomes.all()).to be_instance_of BaseCRM::PaginatedResource
14
+ end
15
+ end
16
+
17
+ describe :where do
18
+ it "returns an array" do
19
+ expect(client.call_outcomes.where(page: 1)).to be_an Array
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe BaseCRM::CallsService do
4
+ describe 'Responds to' do
5
+ subject { client.calls }
6
+
7
+ it { should respond_to :all }
8
+ it { should respond_to :create }
9
+ it { should respond_to :destroy }
10
+ it { should respond_to :find }
11
+ it { should respond_to :update }
12
+ it { should respond_to :where }
13
+ end
14
+
15
+ describe :all do
16
+ it "returns a PaginatedResource" do
17
+ expect(client.calls.all()).to be_instance_of BaseCRM::PaginatedResource
18
+ end
19
+ end
20
+
21
+ describe :where do
22
+ it "returns an array" do
23
+ expect(client.calls.where(page: 1)).to be_an Array
24
+ end
25
+ end
26
+
27
+ describe :create do
28
+ it "returns instance of Call class" do
29
+ @call = build(:call)
30
+ expect(client.calls.create(@call)).to be_instance_of BaseCRM::Call
31
+ end
32
+ end
33
+
34
+ describe :find do
35
+ before :each do
36
+ @call = create(:call)
37
+ end
38
+
39
+ it "returns an instance of Call class" do
40
+ expect(client.calls.find(@call.id)).to be_instance_of BaseCRM::Call
41
+ end
42
+ end
43
+
44
+ describe :update do
45
+ it "returns an updated instance of Call class" do
46
+ @call = create(:call)
47
+ contact = create(:contact)
48
+
49
+ expect(client.calls.update(id: @call.id, resource_type: "contact", resource_id: contact.id)).to be_instance_of BaseCRM::Call
50
+ end
51
+ end
52
+
53
+ describe :destroy do
54
+ it "returns true on success" do
55
+ @call = create(:call)
56
+ expect(client.calls.destroy(@call.id)).to be_truthy
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - BaseCRM developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -134,6 +134,8 @@ files:
134
134
  - lib/basecrm/models/account.rb
135
135
  - lib/basecrm/models/address.rb
136
136
  - lib/basecrm/models/associated_contact.rb
137
+ - lib/basecrm/models/call.rb
138
+ - lib/basecrm/models/call_outcome.rb
137
139
  - lib/basecrm/models/contact.rb
138
140
  - lib/basecrm/models/deal.rb
139
141
  - lib/basecrm/models/deal_source.rb
@@ -160,6 +162,8 @@ files:
160
162
  - lib/basecrm/paginated_resource.rb
161
163
  - lib/basecrm/services/accounts_service.rb
162
164
  - lib/basecrm/services/associated_contacts_service.rb
165
+ - lib/basecrm/services/call_outcomes_service.rb
166
+ - lib/basecrm/services/calls_service.rb
163
167
  - lib/basecrm/services/contacts_service.rb
164
168
  - lib/basecrm/services/deal_sources_service.rb
165
169
  - lib/basecrm/services/deal_unqualified_reasons_service.rb
@@ -184,6 +188,7 @@ files:
184
188
  - lib/basecrm/version.rb
185
189
  - spec/basecrm/sync_spec.rb
186
190
  - spec/factories/associated_contact.rb
191
+ - spec/factories/call.rb
187
192
  - spec/factories/contact.rb
188
193
  - spec/factories/deal.rb
189
194
  - spec/factories/deal_source.rb
@@ -203,6 +208,8 @@ files:
203
208
  - spec/models/sync_meta_spec.rb
204
209
  - spec/services/accounts_service_spec.rb
205
210
  - spec/services/associated_contacts_service_spec.rb
211
+ - spec/services/call_outcomes_service_spec.rb
212
+ - spec/services/calls_service_spec.rb
206
213
  - spec/services/contacts_service_spec.rb
207
214
  - spec/services/deal_sources_service_spec.rb
208
215
  - spec/services/deal_unqualified_reasons_service_spec.rb
@@ -262,6 +269,7 @@ test_files:
262
269
  - spec/factories/tag.rb
263
270
  - spec/factories/contact.rb
264
271
  - spec/factories/deal.rb
272
+ - spec/factories/call.rb
265
273
  - spec/factories/product.rb
266
274
  - spec/factories/lead.rb
267
275
  - spec/factories/deal_unqualified_reason.rb
@@ -282,6 +290,7 @@ test_files:
282
290
  - spec/services/stages_service_spec.rb
283
291
  - spec/services/tags_service_spec.rb
284
292
  - spec/services/products_service_spec.rb
293
+ - spec/services/call_outcomes_service_spec.rb
285
294
  - spec/services/lead_sources_service_spec.rb
286
295
  - spec/services/associated_contacts_service_spec.rb
287
296
  - spec/services/users_service_spec.rb
@@ -289,6 +298,7 @@ test_files:
289
298
  - spec/services/line_items_service_spec.rb
290
299
  - spec/services/loss_reasons_service_spec.rb
291
300
  - spec/services/deal_sources_service_spec.rb
301
+ - spec/services/calls_service_spec.rb
292
302
  - spec/services/deal_unqualified_reasons_service_spec.rb
293
303
  - spec/services/sync_service_spec.rb
294
304
  - spec/services/lead_unqualified_reasons_service_spec.rb