ZOHOCRMSDK2_0 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/src/ZOHOCRMSDK2_0.rb +6 -0
  3. data/src/com/zoho/api/authenticator/oauth_token.rb +86 -32
  4. data/src/com/zoho/api/authenticator/store/db_store.rb +71 -29
  5. data/src/com/zoho/api/authenticator/store/file_store.rb +95 -24
  6. data/src/com/zoho/api/authenticator/store/token_store.rb +7 -0
  7. data/src/com/zoho/api/logger/sdk_logger.rb +19 -9
  8. data/src/com/zoho/crm/api/contact_roles/api_exception.rb +4 -0
  9. data/src/com/zoho/crm/api/contact_roles/contact_role_wrapper.rb +61 -0
  10. data/src/com/zoho/crm/api/contact_roles/contact_roles_operations.rb +118 -0
  11. data/src/com/zoho/crm/api/contact_roles/record_action_handler.rb +10 -0
  12. data/src/com/zoho/crm/api/contact_roles/record_action_wrapper.rb +63 -0
  13. data/src/com/zoho/crm/api/contact_roles/record_body_wrapper.rb +61 -0
  14. data/src/com/zoho/crm/api/contact_roles/record_response_handler.rb +10 -0
  15. data/src/com/zoho/crm/api/contact_roles/record_response_wrapper.rb +84 -0
  16. data/src/com/zoho/crm/api/dc/au_datacenter.rb +3 -3
  17. data/src/com/zoho/crm/api/dc/cn_datacenter.rb +3 -3
  18. data/src/com/zoho/crm/api/dc/datacenter.rb +3 -2
  19. data/src/com/zoho/crm/api/dc/eu_datacenter.rb +3 -3
  20. data/src/com/zoho/crm/api/dc/in_datacenter.rb +3 -3
  21. data/src/com/zoho/crm/api/dc/us_datacenter.rb +3 -3
  22. data/src/com/zoho/crm/api/initializer.rb +44 -16
  23. data/src/com/zoho/crm/api/record/record_operations.rb +198 -1
  24. data/src/com/zoho/crm/api/related_records/related_records_operations.rb +299 -40
  25. data/src/com/zoho/crm/api/request_proxy.rb +3 -4
  26. data/src/com/zoho/crm/api/sdk_config.rb +2 -68
  27. data/src/com/zoho/crm/api/util/api_http_connector.rb +6 -6
  28. data/src/com/zoho/crm/api/util/constants.rb +113 -16
  29. data/src/com/zoho/crm/api/util/converter.rb +21 -4
  30. data/src/com/zoho/crm/api/util/data_type_converter.rb +8 -2
  31. data/src/com/zoho/crm/api/util/form_data_converter.rb +4 -16
  32. data/src/com/zoho/crm/api/util/json_converter.rb +7 -9
  33. data/src/com/zoho/crm/api/util/module_fields_handler.rb +1 -1
  34. data/src/com/zoho/crm/api/util/utility.rb +197 -82
  35. data/src/resources/JSONDetails.json +1 -1
  36. data/src/version.rb +2 -2
  37. metadata +8 -2
@@ -22,5 +22,12 @@ module Store
22
22
  def delete_token(token); end
23
23
 
24
24
  def delete_tokens; end
25
+
26
+ # This method is used to get the user token details.
27
+ # @param user A UserSignature class instance.
28
+ # @param id A String containing id
29
+ # @return A Token class instance representing the user token details.
30
+ # @raise SDKException
31
+ def get_token_by_id(id, token); end
25
32
  end
26
33
  end
@@ -4,15 +4,16 @@ require 'logger'
4
4
 
5
5
  module SDKLog
6
6
  class Log
7
- attr_accessor :level, :path
8
- def initialize(level, path)
7
+ attr_reader :level , :path
8
+ def initialize(level,path)
9
9
  @level = level
10
10
  @path = path
11
11
  end
12
12
 
13
- def self.initialize(level, path)
13
+ def self.initialize(level:, path:nil)
14
14
  Log.new(level, path)
15
15
  end
16
+
16
17
  end
17
18
 
18
19
  class SDKLogger
@@ -22,15 +23,23 @@ module SDKLog
22
23
  @@logger = nil
23
24
 
24
25
  def self.initialize(log)
25
- if(log.level != Levels::OFF) && !log.path.nil? && log.path.length > 0
26
- File.new(log.path, 'w') unless File.exist? log.path if log.path != nil
27
- sdk_logger = WEBrick::BasicLog.new(log.path, @@log_levels_precedence[log.level])
28
- elsif !log.level.nil? and log.level == Levels::OFF
29
- sdk_logger = WEBrick::BasicLog.new(nil, @@log_levels_precedence[log.level])
26
+
27
+ if !log.level.nil? && log.level != Levels::OFF && !log.path.nil? && log.path.length > 0
28
+ if @@log_levels_precedence.key? log.level
29
+ File.new(log.path, 'w') unless File.exist? log.path if log.path != nil
30
+ sdk_logger = WEBrick::BasicLog.new(log.path, @@log_levels_precedence[log.level])
31
+ end
32
+ end
33
+
34
+ if !log.level.nil? && log.path.nil?
35
+ if @@log_levels_precedence.key? log.level
36
+ sdk_logger = WEBrick::BasicLog.new(nil, @@log_levels_precedence[log.level])
37
+ end
30
38
  end
39
+
31
40
  @@logger = sdk_logger
32
41
  rescue StandardError => e
33
- raise SDKException.new(nil, Constants::SDK_LOGGER_INITIALIZE, nil, e)
42
+ raise SDKException.new(nil, Constants::LOGGER_INITIALIZATION_ERROR, nil, e)
34
43
  end
35
44
 
36
45
  def self.info(message)
@@ -50,6 +59,7 @@ module SDKLog
50
59
  end
51
60
 
52
61
  def self.severe(message, exception = nil)
62
+
53
63
  message = message + exception.to_s + exception.backtrace.join("\n") unless exception.nil?
54
64
  @@logger&.fatal(Time.new.to_s + ' ' + message)
55
65
  end
@@ -5,11 +5,15 @@ module ContactRoles
5
5
  require_relative 'response_handler'
6
6
  require_relative 'action_response'
7
7
  require_relative 'action_handler'
8
+ require_relative 'record_response_handler'
9
+ require_relative 'record_action_handler'
8
10
  class APIException
9
11
  include Util::Model
10
12
  include ResponseHandler
11
13
  include ActionResponse
12
14
  include ActionHandler
15
+ include RecordResponseHandler
16
+ include RecordActionHandler
13
17
 
14
18
  # Creates an instance of APIException
15
19
  def initialize
@@ -0,0 +1,61 @@
1
+ require_relative '../util/model'
2
+
3
+ module ContactRoles
4
+ class ContactRoleWrapper
5
+ include Util::Model
6
+
7
+ # Creates an instance of ContactRoleWrapper
8
+ def initialize
9
+ @contact_role = nil
10
+ @key_modified = Hash.new
11
+ end
12
+
13
+ # The method to get the contact_role
14
+ # @return A String value
15
+
16
+ def contact_role
17
+ @contact_role
18
+ end
19
+
20
+ # The method to set the value to contact_role
21
+ # @param contact_role [String] A String
22
+
23
+ def contact_role=(contact_role)
24
+ if contact_role!=nil and !contact_role.is_a? String
25
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: contact_role EXPECTED TYPE: String', nil, nil)
26
+ end
27
+ @contact_role = contact_role
28
+ @key_modified['Contact_Role'] = 1
29
+ end
30
+
31
+ # The method to check if the user has modified the given key
32
+ # @param key [String] A String
33
+ # @return A Integer value
34
+
35
+ def is_key_modified(key)
36
+ if key!=nil and !key.is_a? String
37
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
38
+ end
39
+ if @key_modified.key?(key)
40
+ return @key_modified[key]
41
+ end
42
+
43
+ nil
44
+ end
45
+
46
+ # The method to mark the given key as modified
47
+ # @param key [String] A String
48
+ # @param modification [Integer] A Integer
49
+
50
+ def set_key_modified(key, modification)
51
+ if key!=nil and !key.is_a? String
52
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
53
+ end
54
+ if modification!=nil and !modification.is_a? Integer
55
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: Integer', nil, nil)
56
+ end
57
+ @key_modified[key] = modification
58
+ end
59
+
60
+ end
61
+ end
@@ -3,6 +3,7 @@ require_relative '../parameter_map'
3
3
  require_relative '../exception/sdk_exception'
4
4
  require_relative '../util/api_response'
5
5
  require_relative '../util/common_api_handler'
6
+ require_relative '../util/utility'
6
7
  require_relative '../util/constants'
7
8
 
8
9
  module ContactRoles
@@ -150,6 +151,116 @@ module ContactRoles
150
151
  handler_instance.api_call(ActionHandler.name, 'application/json')
151
152
  end
152
153
 
154
+ # The method to get all contact roles of deal
155
+ # @param deal_id [Integer] A Integer
156
+ # @param param_instance [ParameterMap] An instance of ParameterMap
157
+ # @return An instance of APIResponse
158
+ # @raise SDKException
159
+ def get_all_contact_roles_of_deal(deal_id, param_instance=nil)
160
+ if !deal_id.is_a? Integer
161
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: deal_id EXPECTED TYPE: Integer', nil, nil)
162
+ end
163
+ if param_instance!=nil and !param_instance.is_a? ParameterMap
164
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', nil, nil)
165
+ end
166
+ handler_instance = Handler::CommonAPIHandler.new
167
+ api_path = ''
168
+ api_path = api_path + '/crm/v2/Deals/'
169
+ api_path = api_path + deal_id.to_s
170
+ api_path = api_path + '/Contact_Roles'
171
+ handler_instance.api_path = api_path
172
+ handler_instance.http_method = Constants::REQUEST_METHOD_GET
173
+ handler_instance.category_method = 'READ'
174
+ handler_instance.param = param_instance
175
+ Util::Utility.get_fields("Contacts")
176
+ handler_instance.module_api_name = "Contacts"
177
+ require_relative 'record_response_handler'
178
+ handler_instance.api_call(RecordResponseHandler.name, 'application/json')
179
+ end
180
+
181
+ # The method to get contact role of deal
182
+ # @param contact_id [Integer] A Integer
183
+ # @param deal_id [Integer] A Integer
184
+ # @return An instance of APIResponse
185
+ # @raise SDKException
186
+ def get_contact_role_of_deal(contact_id, deal_id)
187
+ if !contact_id.is_a? Integer
188
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: contact_id EXPECTED TYPE: Integer', nil, nil)
189
+ end
190
+ if !deal_id.is_a? Integer
191
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: deal_id EXPECTED TYPE: Integer', nil, nil)
192
+ end
193
+ handler_instance = Handler::CommonAPIHandler.new
194
+ api_path = ''
195
+ api_path = api_path + '/crm/v2/Deals/'
196
+ api_path = api_path + deal_id.to_s
197
+ api_path = api_path + '/Contact_Roles/'
198
+ api_path = api_path + contact_id.to_s
199
+ handler_instance.api_path = api_path
200
+ handler_instance.http_method = Constants::REQUEST_METHOD_GET
201
+ handler_instance.category_method = 'READ'
202
+ Util::Utility.get_fields("Contacts")
203
+ handler_instance.module_api_name = "Contacts"
204
+ require_relative 'record_response_handler'
205
+ handler_instance.api_call(RecordResponseHandler.name, 'application/json')
206
+ end
207
+
208
+ # The method to add contact role to deal
209
+ # @param contact_id [Integer] A Integer
210
+ # @param deal_id [Integer] A Integer
211
+ # @param request [RecordBodyWrapper] An instance of RecordBodyWrapper
212
+ # @return An instance of APIResponse
213
+ # @raise SDKException
214
+ def add_contact_role_to_deal(contact_id, deal_id, request)
215
+ if !contact_id.is_a? Integer
216
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: contact_id EXPECTED TYPE: Integer', nil, nil)
217
+ end
218
+ if !deal_id.is_a? Integer
219
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: deal_id EXPECTED TYPE: Integer', nil, nil)
220
+ end
221
+ if request!=nil and !request.is_a? RecordBodyWrapper
222
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: RecordBodyWrapper', nil, nil)
223
+ end
224
+ handler_instance = Handler::CommonAPIHandler.new
225
+ api_path = ''
226
+ api_path = api_path + '/crm/v2/Deals/'
227
+ api_path = api_path + deal_id.to_s
228
+ api_path = api_path + '/Contact_Roles/'
229
+ api_path = api_path + contact_id.to_s
230
+ handler_instance.api_path = api_path
231
+ handler_instance.http_method = Constants::REQUEST_METHOD_PUT
232
+ handler_instance.category_method = 'UPDATE'
233
+ handler_instance.content_type = 'application/json'
234
+ handler_instance.request = request
235
+ require_relative 'record_action_handler'
236
+ handler_instance.api_call(RecordActionHandler.name, 'application/json')
237
+ end
238
+
239
+ # The method to remove contact role from deal
240
+ # @param contact_id [Integer] A Integer
241
+ # @param deal_id [Integer] A Integer
242
+ # @return An instance of APIResponse
243
+ # @raise SDKException
244
+ def remove_contact_role_from_deal(contact_id, deal_id)
245
+ if !contact_id.is_a? Integer
246
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: contact_id EXPECTED TYPE: Integer', nil, nil)
247
+ end
248
+ if !deal_id.is_a? Integer
249
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: deal_id EXPECTED TYPE: Integer', nil, nil)
250
+ end
251
+ handler_instance = Handler::CommonAPIHandler.new
252
+ api_path = ''
253
+ api_path = api_path + '/crm/v2/Deals/'
254
+ api_path = api_path + deal_id.to_s
255
+ api_path = api_path + '/Contact_Roles/'
256
+ api_path = api_path + contact_id.to_s
257
+ handler_instance.api_path = api_path
258
+ handler_instance.http_method = Constants::REQUEST_METHOD_DELETE
259
+ handler_instance.category_method = Constants::REQUEST_METHOD_DELETE
260
+ require_relative 'record_action_handler'
261
+ handler_instance.api_call(RecordActionHandler.name, 'application/json')
262
+ end
263
+
153
264
  class DeleteContactRolesParam
154
265
  @@ids = Param.new('ids', 'com.zoho.crm.api.ContactRoles.DeleteContactRolesParam')
155
266
  def self.ids
@@ -157,5 +268,12 @@ module ContactRoles
157
268
  end
158
269
  end
159
270
 
271
+ class GetAllContactRolesOfDealParam
272
+ @@ids = Param.new('ids', 'com.zoho.crm.api.ContactRoles.GetAllContactRolesOfDealParam')
273
+ def self.ids
274
+ @@ids
275
+ end
276
+ end
277
+
160
278
  end
161
279
  end
@@ -0,0 +1,10 @@
1
+ module ContactRoles
2
+ module RecordActionHandler
3
+
4
+ # Creates an instance of RecordActionHandler
5
+ def initialize
6
+ end
7
+
8
+
9
+ end
10
+ end
@@ -0,0 +1,63 @@
1
+ require_relative '../util/model'
2
+
3
+ module ContactRoles
4
+ require_relative 'record_action_handler'
5
+ class RecordActionWrapper
6
+ include Util::Model
7
+ include RecordActionHandler
8
+
9
+ # Creates an instance of RecordActionWrapper
10
+ def initialize
11
+ @data = nil
12
+ @key_modified = Hash.new
13
+ end
14
+
15
+ # The method to get the data
16
+ # @return An instance of Array
17
+
18
+ def data
19
+ @data
20
+ end
21
+
22
+ # The method to set the value to data
23
+ # @param data [Array] An instance of Array
24
+
25
+ def data=(data)
26
+ if data!=nil and !data.is_a? Array
27
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: Array', nil, nil)
28
+ end
29
+ @data = data
30
+ @key_modified['data'] = 1
31
+ end
32
+
33
+ # The method to check if the user has modified the given key
34
+ # @param key [String] A String
35
+ # @return A Integer value
36
+
37
+ def is_key_modified(key)
38
+ if key!=nil and !key.is_a? String
39
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
40
+ end
41
+ if @key_modified.key?(key)
42
+ return @key_modified[key]
43
+ end
44
+
45
+ nil
46
+ end
47
+
48
+ # The method to mark the given key as modified
49
+ # @param key [String] A String
50
+ # @param modification [Integer] A Integer
51
+
52
+ def set_key_modified(key, modification)
53
+ if key!=nil and !key.is_a? String
54
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
55
+ end
56
+ if modification!=nil and !modification.is_a? Integer
57
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: Integer', nil, nil)
58
+ end
59
+ @key_modified[key] = modification
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,61 @@
1
+ require_relative '../util/model'
2
+
3
+ module ContactRoles
4
+ class RecordBodyWrapper
5
+ include Util::Model
6
+
7
+ # Creates an instance of RecordBodyWrapper
8
+ def initialize
9
+ @data = nil
10
+ @key_modified = Hash.new
11
+ end
12
+
13
+ # The method to get the data
14
+ # @return An instance of Array
15
+
16
+ def data
17
+ @data
18
+ end
19
+
20
+ # The method to set the value to data
21
+ # @param data [Array] An instance of Array
22
+
23
+ def data=(data)
24
+ if data!=nil and !data.is_a? Array
25
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: Array', nil, nil)
26
+ end
27
+ @data = data
28
+ @key_modified['data'] = 1
29
+ end
30
+
31
+ # The method to check if the user has modified the given key
32
+ # @param key [String] A String
33
+ # @return A Integer value
34
+
35
+ def is_key_modified(key)
36
+ if key!=nil and !key.is_a? String
37
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
38
+ end
39
+ if @key_modified.key?(key)
40
+ return @key_modified[key]
41
+ end
42
+
43
+ nil
44
+ end
45
+
46
+ # The method to mark the given key as modified
47
+ # @param key [String] A String
48
+ # @param modification [Integer] A Integer
49
+
50
+ def set_key_modified(key, modification)
51
+ if key!=nil and !key.is_a? String
52
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
53
+ end
54
+ if modification!=nil and !modification.is_a? Integer
55
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: Integer', nil, nil)
56
+ end
57
+ @key_modified[key] = modification
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,10 @@
1
+ module ContactRoles
2
+ module RecordResponseHandler
3
+
4
+ # Creates an instance of RecordResponseHandler
5
+ def initialize
6
+ end
7
+
8
+
9
+ end
10
+ end
@@ -0,0 +1,84 @@
1
+ require_relative '../record/info'
2
+ require_relative '../record/record'
3
+ require_relative '../util/model'
4
+
5
+ module ContactRoles
6
+ require_relative 'record_response_handler'
7
+ class RecordResponseWrapper
8
+ include Util::Model
9
+ include RecordResponseHandler
10
+
11
+ # Creates an instance of RecordResponseWrapper
12
+ def initialize
13
+ @data = nil
14
+ @info = nil
15
+ @key_modified = Hash.new
16
+ end
17
+
18
+ # The method to get the data
19
+ # @return An instance of Array
20
+
21
+ def data
22
+ @data
23
+ end
24
+
25
+ # The method to set the value to data
26
+ # @param data [Array] An instance of Array
27
+
28
+ def data=(data)
29
+ if data!=nil and !data.is_a? Array
30
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: Array', nil, nil)
31
+ end
32
+ @data = data
33
+ @key_modified['data'] = 1
34
+ end
35
+
36
+ # The method to get the info
37
+ # @return An instance of Record::Info
38
+
39
+ def info
40
+ @info
41
+ end
42
+
43
+ # The method to set the value to info
44
+ # @param info [Record::Info] An instance of Record::Info
45
+
46
+ def info=(info)
47
+ if info!=nil and !info.is_a? Record::Info
48
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', nil, nil)
49
+ end
50
+ @info = info
51
+ @key_modified['info'] = 1
52
+ end
53
+
54
+ # The method to check if the user has modified the given key
55
+ # @param key [String] A String
56
+ # @return A Integer value
57
+
58
+ def is_key_modified(key)
59
+ if key!=nil and !key.is_a? String
60
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
61
+ end
62
+ if @key_modified.key?(key)
63
+ return @key_modified[key]
64
+ end
65
+
66
+ nil
67
+ end
68
+
69
+ # The method to mark the given key as modified
70
+ # @param key [String] A String
71
+ # @param modification [Integer] A Integer
72
+
73
+ def set_key_modified(key, modification)
74
+ if key!=nil and !key.is_a? String
75
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: String', nil, nil)
76
+ end
77
+ if modification!=nil and !modification.is_a? Integer
78
+ raise SDKException.new(Constants::DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: Integer', nil, nil)
79
+ end
80
+ @key_modified[key] = modification
81
+ end
82
+
83
+ end
84
+ end