ZCRMSDK 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,250 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require_relative 'oauth_utility'
5
+ require_relative 'persistence'
6
+ module ZCRMSDK
7
+ module OAuthClient
8
+ # THIS CLASS IS USED TO STORE OAUTH RELATED CREDENTIALS
9
+ class ZohoOAuth
10
+ $OAUTH_CONFIG_PROPERTIES = {}
11
+ def self.get_instance(config_details)
12
+ ZohoOAuth.new(config_details)
13
+ end
14
+
15
+ def initialize(config_details)
16
+ $OAUTH_CONFIG_PROPERTIES = {}
17
+ $OAUTH_CONFIG_PROPERTIES = config_details
18
+ mandatory_keys = [OAuthUtility::ZohoOAuthConstants::CLIENT_ID, OAuthUtility::ZohoOAuthConstants::CLIENT_SECRET, OAuthUtility::ZohoOAuthConstants::REDIRECT_URL]
19
+ mandatory_keys.each do |item|
20
+ if $OAUTH_CONFIG_PROPERTIES[item].nil?
21
+ raise OAuthUtility::ZohoOAuthException.get_instance('initialize(config_details)', item + ' is mandatory!', 'Exception occured while reading oauth configurations', OAuthUtility::ZohoOAuthConstants::ERROR)
22
+ end
23
+ end
24
+ if $OAUTH_CONFIG_PROPERTIES.key? OAuthUtility::ZohoOAuthConstants::CURRENT_USER_EMAIL
25
+ unless $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::CURRENT_USER_EMAIL].nil?
26
+ ZCRMSDK::RestClient::ZCRMRestClient.current_user_email = $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::CURRENT_USER_EMAIL]
27
+ end
28
+ end
29
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::ACCESS_TYPE].nil?
30
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::ACCESS_TYPE] = 'offline'
31
+ end
32
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_PATH].nil?
33
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_PATH] = nil
34
+ end
35
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS].nil?
36
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS] = nil
37
+ end
38
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].nil?
39
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL] = 'https://accounts.zoho.com'
40
+ end
41
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::TOKEN_PERSISTENCE_PATH].nil?
42
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::TOKEN_PERSISTENCE_PATH] = nil
43
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_PORT].nil?
44
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_PORT] = '3306'
45
+ end
46
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_USERNAME].nil?
47
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_USERNAME] = 'root'
48
+ end
49
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_PASSWORD].nil?
50
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::DATABASE_PASSWORD] = ''
51
+ end
52
+ end
53
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::SANDBOX].nil?
54
+ $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::SANDBOX] = 'false'
55
+ end
56
+ oauth_params = OAuthUtility::ZohoOAuthParams.get_instance($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::CLIENT_ID].dup, $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::CLIENT_SECRET].dup, $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::REDIRECT_URL].dup)
57
+ ZohoOAuthClient.get_instance(oauth_params)
58
+ end
59
+
60
+ def self.get_grant_url
61
+ ($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].dup + '/oauth/v2/auth')
62
+ end
63
+
64
+ def self.get_token_url
65
+ ($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].dup + '/oauth/v2/token')
66
+ end
67
+
68
+ def self.get_refresh_token_url
69
+ ($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].dup + '/oauth/v2/token')
70
+ end
71
+
72
+ def self.get_revoke_token_url
73
+ ($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].dup + '/oauth/v2/token/revoke')
74
+ end
75
+
76
+ def self.get_user_info_url
77
+ ($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::IAM_URL].dup + '/oauth/user/info')
78
+ end
79
+
80
+ def self.get_client_instance
81
+ oauth_client_ins = ZohoOAuthClient.get_instance
82
+ if oauth_client_ins.nil?
83
+ raise OAuthUtility::ZohoOAuthException.get_instance('get_client_instance', 'ZCRMSDK::RestClient::ZCRMRestClient.init(config_details) must be called before this', 'Error occured while getting client instance', OAuthUtility::ZohoOAuthConstants::ERROR)
84
+ end
85
+
86
+ oauth_client_ins
87
+ end
88
+
89
+ def self.get_persistence_instance
90
+ if !$OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_PATH].nil?
91
+ if !File.exist?($OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_PATH])
92
+ raise OAuthUtility::ZohoOAuthException.get_instance('get_persistence_instance', 'file does not exist!', 'Error occured while getting persistence instance', OAuthUtility::ZohoOAuthConstants::ERROR)
93
+ end
94
+
95
+ require $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_PATH]
96
+ if $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS].nil?
97
+ raise OAuthUtility::ZohoOAuthException.get_instance('get_persistence_instance', 'class name not given', 'Exception occured while getting persistence instance', OAuthUtility::ZohoOAuthConstants::ERROR)
98
+ end
99
+
100
+ class_name = $OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS].dup
101
+ begin
102
+ persistence_instance = Object.const_get(class_name).new
103
+ rescue NameError
104
+ raise OAuthUtility::ZohoOAuthException.get_instance('get_persistence_instance', 'Please check the handler class details', 'Error occured while getting persistence instance', OAuthUtility::ZohoOAuthConstants::ERROR)
105
+ end
106
+ persistence_instance
107
+ elsif !$OAUTH_CONFIG_PROPERTIES[OAuthUtility::ZohoOAuthConstants::TOKEN_PERSISTENCE_PATH].nil?
108
+ Persistence::ZohoOAuthFilePersistenceHandler.get_instance
109
+ else
110
+ require 'mysql2'
111
+ Persistence::ZohoOAuthPersistenceHandler.get_instance
112
+ end
113
+ end
114
+ end
115
+ # THIS CLASS IS USED TO GENERATED TOKENS
116
+ class ZohoOAuthClient
117
+ @@oauth_params = nil
118
+ @@oauth_client_instance = nil
119
+ def initialize(oauth_params)
120
+ @@oauth_params = oauth_params
121
+ end
122
+
123
+ def self.get_oauth_params
124
+ @@oauth_params
125
+ end
126
+
127
+ def self.get_instance(param = nil)
128
+ if !param.nil?
129
+ @@oauth_client_instance = ZohoOAuthClient.new(param)
130
+ end
131
+ @@oauth_client_instance
132
+ end
133
+
134
+ def get_access_token(user_email)
135
+ handler = ZohoOAuth.get_persistence_instance
136
+ oauth_tokens = handler.get_oauth_tokens(user_email)
137
+ begin
138
+ return oauth_tokens.get_access_token
139
+ rescue ZCRMSDK::OAuthUtility::ZohoOAuthException
140
+ oauth_tokens = refresh_access_token(oauth_tokens.refresh_token, user_email)
141
+ return oauth_tokens.access_token
142
+ end
143
+ end
144
+
145
+ def generate_access_token_from_refresh_token(refresh_token,user_email)
146
+ refresh_access_token(refresh_token, user_email)
147
+ end
148
+
149
+ def refresh_access_token(refresh_token, user_email)
150
+ if refresh_token.nil?
151
+ raise OAuthUtility::ZohoOAuthException.get_instance('refresh_access_token(refresh_token, user_email)', 'Refresh token not provided!', 'Exception occured while refreshing oauthtoken', OAuthUtility::ZohoOAuthConstants::ERROR)
152
+ end
153
+
154
+ begin
155
+ connector = get_connector(ZohoOAuth.get_refresh_token_url)
156
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::GRANT_TYPE, OAuthUtility::ZohoOAuthConstants::GRANT_TYPE_REFRESH)
157
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::REFRESH_TOKEN, refresh_token)
158
+ connector.set_http_request_method(OAuthUtility::ZohoOAuthConstants::REQUEST_METHOD_POST)
159
+ response = connector.trigger_request
160
+ response_json = JSON.parse(response.body)
161
+ if response_json[OAuthUtility::ZohoOAuthConstants::ACCESS_TOKEN].nil?
162
+ raise OAuthUtility::ZohoOAuthException.get_instance('refresh_access_token(refresh_token, user_email)', 'Response is' + response_json.to_s, 'Exception occured while refreshing oauthtoken', OAuthUtility::ZohoOAuthConstants::ERROR)
163
+ else
164
+ oauth_tokens = get_tokens_from_json(response_json)
165
+ oauth_tokens.user_identifier = user_email
166
+ oauth_tokens.refresh_token = refresh_token
167
+ ZohoOAuth.get_persistence_instance.save_oauth_tokens(oauth_tokens)
168
+ return oauth_tokens
169
+ end
170
+ end
171
+ end
172
+
173
+ def generate_access_token(grant_token)
174
+ if grant_token.nil?
175
+ raise OAuthUtility::ZohoOAuthException.get_instance('generate_access_token(grant_token)', 'Grant token not provided!', 'Exception occured while fetching accesstoken from Grant Token', OAuthUtility::ZohoOAuthConstants::ERROR)
176
+ end
177
+
178
+ connector = get_connector(ZohoOAuth.get_token_url)
179
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::GRANT_TYPE, OAuthUtility::ZohoOAuthConstants::GRANT_TYPE_AUTH_CODE)
180
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::CODE, grant_token)
181
+ connector.set_http_request_method(OAuthUtility::ZohoOAuthConstants::REQUEST_METHOD_POST)
182
+ response = connector.trigger_request
183
+ response_json = JSON.parse(response.body)
184
+ if !response_json[OAuthUtility::ZohoOAuthConstants::ACCESS_TOKEN].nil?
185
+ oauth_tokens = get_tokens_from_json(response_json)
186
+ oauth_tokens.user_identifier = get_user_email_from_iam(oauth_tokens.access_token)
187
+ ZohoOAuth.get_persistence_instance.save_oauth_tokens(oauth_tokens)
188
+ return oauth_tokens
189
+ else
190
+ raise OAuthUtility::ZohoOAuthException.get_instance('generate_access_token(grant_token)', 'Response is' + response_json.to_s, 'Exception occured while fetching accesstoken from Grant Token', OAuthUtility::ZohoOAuthConstants::ERROR)
191
+ end
192
+ end
193
+
194
+ def get_tokens_from_json(response_json)
195
+ expires_in = response_json[OAuthUtility::ZohoOAuthConstants::EXPIRES_IN]
196
+ expires_in += ZCRMSDK::OAuthClient::ZohoOAuthTokens.get_current_time_in_millis
197
+ access_token = response_json[OAuthUtility::ZohoOAuthConstants::ACCESS_TOKEN]
198
+ refresh_token = nil
199
+ unless response_json[OAuthUtility::ZohoOAuthConstants::REFRESH_TOKEN].nil?
200
+ refresh_token = response_json[OAuthUtility::ZohoOAuthConstants::REFRESH_TOKEN]
201
+ end
202
+ oauth_tokens = ZohoOAuthTokens.get_instance(refresh_token, access_token, expires_in)
203
+ oauth_tokens
204
+ end
205
+
206
+ def get_connector(url)
207
+ connector = OAuthUtility::ZohoOAuthHTTPConnector.get_instance(url, {})
208
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::CLIENT_ID, OAuthClient::ZohoOAuthClient.get_oauth_params.client_id)
209
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::CLIENT_SECRET, OAuthClient::ZohoOAuthClient.get_oauth_params.client_secret)
210
+ connector.add_http_request_params(OAuthUtility::ZohoOAuthConstants::REDIRECT_URL, OAuthClient::ZohoOAuthClient.get_oauth_params.redirect_uri)
211
+ connector
212
+ end
213
+
214
+ def get_user_email_from_iam(access_token)
215
+ header = {}
216
+ header[OAuthUtility::ZohoOAuthConstants::AUTHORIZATION] = OAuthUtility::ZohoOAuthConstants::OAUTH_HEADER_PREFIX + access_token
217
+ connector = OAuthUtility::ZohoOAuthHTTPConnector.get_instance(ZohoOAuth.get_user_info_url, nil, header, nil, OAuthUtility::ZohoOAuthConstants::REQUEST_METHOD_GET)
218
+ response = connector.trigger_request
219
+ JSON.parse(response.body)[OAuthUtility::ZohoOAuthConstants::EMAIL]
220
+ end
221
+ end
222
+ # THIS CLASS IS USED TO STORE THE TOKEN AS A INSTANCE AND CHECK THE VALIDITY OF THE TOKEN
223
+ class ZohoOAuthTokens
224
+ attr_accessor :refresh_token, :access_token, :expiry_time, :user_email, :user_identifier
225
+ @user_email = nil
226
+ def self.get_instance(refresh_token, access_token, expiry_time, user_identifier = nil)
227
+ ZohoOAuthTokens.new(refresh_token, access_token, expiry_time, user_identifier)
228
+ end
229
+
230
+ def initialize(refresh_token, access_token, expiry_time, user_identifier = nil)
231
+ @refresh_token = refresh_token
232
+ @access_token = access_token
233
+ @expiry_time = expiry_time
234
+ @user_identifier = user_identifier
235
+ end
236
+
237
+ def get_access_token
238
+ if (@expiry_time - ZCRMSDK::OAuthClient::ZohoOAuthTokens.get_current_time_in_millis) > 15_000
239
+ @access_token
240
+ else
241
+ raise OAuthUtility::ZohoOAuthException.get_instance('get_access_token', 'Access token got expired!', 'Access token expired hence refreshing', OAuthUtility::ZohoOAuthConstants::INFO)
242
+ end
243
+ end
244
+
245
+ def self.get_current_time_in_millis
246
+ (Time.now.to_f * 1000).to_i
247
+ end
248
+ end
249
+ end
250
+ end
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'net/http'
5
+ require_relative 'utility'
6
+ module ZCRMSDK
7
+ module OAuthUtility
8
+ # THIS CLASS IS USED TO DECLARE CONSTANTS THAT ARE USED FREQUENTLY
9
+ class ZohoOAuthConstants
10
+ IAM_URL = 'accounts_url'
11
+ SCOPES = 'scope'
12
+ STATE = 'state'
13
+ STATE_OBTAINING_GRANT_TOKEN = 'OBTAIN_GRANT_TOKEN'
14
+ RESPONSE_TYPE = 'response_type'
15
+ RESPONSE_TYPE_CODE = 'code'
16
+ CLIENT_ID = 'client_id'
17
+ CLIENT_SECRET = 'client_secret'
18
+ REDIRECT_URL = 'redirect_uri'
19
+ ACCESS_TYPE = 'access_type'
20
+ ACCESS_TYPE_OFFLINE = 'offline'
21
+ ACCESS_TYPE_ONLINE = 'online'
22
+ PROMPT = 'prompt'
23
+ PROMPT_CONSENT = 'consent'
24
+ GRANT_TYPE = 'grant_type'
25
+ GRANT_TYPE_AUTH_CODE = 'authorization_code'
26
+ TOKEN_PERSISTENCE_PATH = 'token_persistence_path'
27
+ DATABASE_PORT = 'db_port'
28
+ DATABASE_USERNAME = 'db_username'
29
+ DATABASE_PASSWORD = 'db_password'
30
+ GRANT_TYPE_REFRESH = 'refresh_token'
31
+ CODE = 'code'
32
+ GRANT_TOKEN = 'grant_token'
33
+ ACCESS_TOKEN = 'access_token'
34
+ REFRESH_TOKEN = 'refresh_token'
35
+ EXPIRES_IN = 'expires_in'
36
+ EXPIRIY_TIME = 'expiry_time'
37
+ PERSISTENCE_HANDLER_CLASS_PATH = 'persistence_handler_class_path'
38
+ PERSISTENCE_HANDLER_CLASS = 'persistence_handler_class'
39
+ TOKEN = 'token'
40
+ DISPATCH_TO = 'dispatchTo'
41
+ OAUTH_TOKENS_PARAM = 'oauth_tokens'
42
+ SANDBOX = 'sandbox'
43
+ OAUTH_HEADER_PREFIX = 'Zoho-oauthtoken '
44
+ AUTHORIZATION = 'Authorization'
45
+ REQUEST_METHOD_GET = 'GET'
46
+ REQUEST_METHOD_POST = 'POST'
47
+ CURRENT_USER_EMAIL = 'current_user_email'
48
+ RESPONSECODE_OK = 200
49
+ EMAIL = 'Email'
50
+ ERROR = 'error'
51
+ INFO = 'info'
52
+ WARNING = 'warning'
53
+ end
54
+ # THIS CLASS IS USED TO HANDLE CUSTOM OAUTH EXCEPTIONS
55
+ class ZohoOAuthException < StandardError
56
+ attr_accessor :url, :err_message, :error, :level
57
+ def initialize(url, err_message, error, level)
58
+ @err_message = err_message
59
+ @error = error
60
+ @level = level
61
+ @url = url
62
+ Utility::SDKLogger.add_log(err_message, level, self)
63
+ end
64
+
65
+ def self.get_instance(url, err_message, error, level)
66
+ ZohoOAuthException.new(url, err_message, error, level)
67
+ end
68
+ end
69
+ # THIS CLASS IS USED TO STORE OAuthParams
70
+ class ZohoOAuthParams
71
+ attr_accessor :client_id, :client_secret, :redirect_uri
72
+ def initialize(client_id, client_secret, redirect_uri)
73
+ @client_id = client_id
74
+ @client_secret = client_secret
75
+ @redirect_uri = redirect_uri
76
+ end
77
+
78
+ def self.get_instance(client_id, client_secret, redirect_uri)
79
+ ZohoOAuthParams.new(client_id, client_secret, redirect_uri)
80
+ end
81
+ end
82
+ # THIS CLASS IS USED TO FIRE OAUTH RELATED REQUESTS
83
+ class ZohoOAuthHTTPConnector
84
+ attr_accessor :url, :req_headers, :req_method, :req_params, :req_body
85
+ def self.get_instance(url, params = nil, headers = nil, body = nil, method = nil)
86
+ ZohoOAuthHTTPConnector.new(url, params, headers, body, method)
87
+ end
88
+
89
+ def initialize(url, params = nil, headers = nil, body = nil, method = nil)
90
+ @url = url
91
+ @req_headers = headers
92
+ @req_method = method
93
+ @req_params = params
94
+ @req_body = body
95
+ end
96
+
97
+ def trigger_request
98
+ query_string = @req_params.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join('&')
99
+ if !query_string.nil? && (query_string.strip != '')
100
+ @url += '?' + query_string
101
+ end
102
+ url = URI(@url)
103
+ http = Net::HTTP.new(url.host, url.port)
104
+ http.use_ssl = true
105
+ if @req_method == OAuthUtility::ZohoOAuthConstants::REQUEST_METHOD_GET
106
+ req = Net::HTTP::Get.new(url.request_uri)
107
+ elsif @req_method == OAuthUtility::ZohoOAuthConstants::REQUEST_METHOD_POST
108
+ req = Net::HTTP::Post.new(url.request_uri)
109
+ end
110
+ unless @req_headers.nil?
111
+ @req_headers.each do |key, value|
112
+ req.add_field(key, value)
113
+ end
114
+ end
115
+ response = http.request(req)
116
+ response
117
+ end
118
+
119
+ def self.set_url(url)
120
+ @url = url
121
+ end
122
+
123
+ def self.get_url
124
+ @url
125
+ end
126
+
127
+ def add_http_header(key, value)
128
+ @req_headers[key] = value
129
+ end
130
+
131
+ def get_http_headers
132
+ req_headers
133
+ end
134
+
135
+ def set_http_request_method(method)
136
+ @req_method = method
137
+ end
138
+
139
+ def get_http_request_method
140
+ @req_method
141
+ end
142
+
143
+ def set_request_body(req_body)
144
+ @req_body = req_body
145
+ end
146
+
147
+ def get_request_body
148
+ @req_body
149
+ end
150
+
151
+ def add_http_request_params(key, value)
152
+ @req_params[key] = value
153
+ end
154
+
155
+ def get_http_request_params
156
+ @req_params
157
+ end
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,1043 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'utility'
4
+ require_relative 'handler'
5
+ module ZCRMSDK
6
+ module Operations
7
+ # THIS CLASS IS USED TO STORE AND EXECTUTE MODULE RELATED FUNCTIONS
8
+ class ZCRMModule
9
+ attr_accessor :is_inventory_template_supported, :layouts, :visibility, :is_feeds_required, :is_quick_create, :is_email_template_support, :is_webform_supported, :is_filter_supported, :is_kanban_view_supported, :generated_type, :arguments, :parent_module, :is_filter_status, :is_kanban_view, :is_presence_sub_menu, :api_name, :is_convertable, :is_creatable, :is_editable, :is_deletable, :web_link, :singular_label, :plural_label, :modified_by, :modified_time, :is_viewable, :is_api_supported, :is_custom_module, :is_scoring_supported, :id, :module_name, :business_card_field_limit, :business_card_fields, :profiles, :display_field_name, :display_field_id, :related_lists, :fields, :related_list_properties, :properties, :per_page, :search_layout_fields, :default_territory_name, :default_territory_id, :default_custom_view_id, :default_custom_view, :is_global_search_supported, :sequence_number
10
+ def initialize(module_apiname)
11
+ @api_name = module_apiname
12
+ @visibility = nil
13
+ @fields = nil
14
+ @layouts = nil
15
+ @is_convertable = nil
16
+ @is_feeds_required = nil
17
+ @is_creatable = nil
18
+ @is_editable = nil
19
+ @is_deletable = nil
20
+ @web_link = nil
21
+ @singular_label = nil
22
+ @plural_label = nil
23
+ @modified_by = nil
24
+ @modified_time = nil
25
+ @is_viewable = nil
26
+ @is_api_supported = nil
27
+ @is_custom_module = nil
28
+ @is_scoring_supported = nil
29
+ @is_webform_supported = nil
30
+ @is_email_template_support = nil
31
+ @is_inventory_template_supported = nil
32
+ @id = nil
33
+ @module_name = nil
34
+ @business_card_field_limit = nil
35
+ @business_card_fields = []
36
+ @profiles = []
37
+ @display_field_name = nil
38
+ @related_lists = nil
39
+ @related_list_properties = nil
40
+ @properties = nil
41
+ @per_page = nil
42
+ @search_layout_fields = nil
43
+ @default_territory_name = nil
44
+ @default_territory_id = nil
45
+ @default_custom_view_id = nil
46
+ @default_custom_view = nil
47
+ @is_global_search_supported = nil
48
+ @sequence_number = nil
49
+ @is_kanban_view = nil
50
+ @is_filter_status = nil
51
+ @parent_module = nil
52
+ @is_presence_sub_menu = nil
53
+ @arguments = []
54
+ @generated_type = nil
55
+ @is_quick_create = nil
56
+ @is_kanban_view_supported = nil
57
+ @is_filter_supported = nil
58
+ end
59
+
60
+ def self.get_instance(module_apiname)
61
+ ZCRMModule.new(module_apiname)
62
+ end
63
+
64
+ def get_record(entity_id)
65
+ record = ZCRMRecord.get_instance(@api_name, entity_id)
66
+ Handler::EntityAPIHandler.get_instance(record).get_record
67
+ end
68
+
69
+ def get_records(cvid = nil, sort_by = nil, sort_order = nil, page = 1, per_page = 200, headers = nil)
70
+ Handler::MassEntityAPIHandler.get_instance(self).get_records(cvid, sort_by, sort_order, page, per_page, headers)
71
+ end
72
+
73
+ def get_all_deleted_records(page = 1, per_page = 200)
74
+ Handler::MassEntityAPIHandler.get_instance(self).get_deleted_records('all', page, per_page)
75
+ end
76
+
77
+ def get_recyclebin_records(page = 1, per_page = 200)
78
+ Handler::MassEntityAPIHandler.get_instance(self).get_deleted_records('recycle', page, per_page)
79
+ end
80
+
81
+ def get_permanently_deleted_records(page = 1, per_page = 200)
82
+ Handler::MassEntityAPIHandler.get_instance(self).get_deleted_records('permanent', page, per_page)
83
+ end
84
+
85
+ def get_all_fields
86
+ Handler::ModuleAPIHandler.get_instance(self).get_all_fields
87
+ end
88
+
89
+ def get_field(field_id)
90
+ Handler::ModuleAPIHandler.get_instance(self).get_field(field_id)
91
+ end
92
+
93
+ def get_all_layouts
94
+ Handler::ModuleAPIHandler.get_instance(self).get_all_layouts
95
+ end
96
+
97
+ def get_layout(layout_id)
98
+ Handler::ModuleAPIHandler.get_instance(self).get_layout(layout_id)
99
+ end
100
+
101
+ def get_all_customviews
102
+ Handler::ModuleAPIHandler.get_instance(self).get_all_customviews
103
+ end
104
+
105
+ def get_customview(customview_id)
106
+ Handler::ModuleAPIHandler.get_instance(self).get_customview(customview_id)
107
+ end
108
+
109
+ def get_all_relatedlists
110
+ Handler::ModuleAPIHandler.get_instance(self).get_all_relatedlists
111
+ end
112
+
113
+ def get_relatedlist(relatedlist_id)
114
+ Handler::ModuleAPIHandler.get_instance(self).get_relatedlist(relatedlist_id)
115
+ end
116
+
117
+ def create_records(record_ins_list, lar_id = nil)
118
+ Handler::MassEntityAPIHandler.get_instance(self).create_records(record_ins_list, lar_id)
119
+ end
120
+
121
+ def upsert_records(record_ins_list, duplicate_check_fields = nil, lar_id = nil)
122
+ Handler::MassEntityAPIHandler.get_instance(self).upsert_records(record_ins_list, duplicate_check_fields, lar_id)
123
+ end
124
+
125
+ def update_records(record_ins_list)
126
+ Handler::MassEntityAPIHandler.get_instance(self).update_records(record_ins_list)
127
+ end
128
+
129
+ def update_customview(customview_instance)
130
+ Handler::ModuleAPIHandler.get_instance(self).update_customview(customview_instance)
131
+ end
132
+
133
+ def mass_update_records(entityid_list, field_api_name, value)
134
+ Handler::MassEntityAPIHandler.get_instance(self).mass_update_records(entityid_list, field_api_name, value)
135
+ end
136
+
137
+ def delete_records(entityid_list)
138
+ Handler::MassEntityAPIHandler.get_instance(self).delete_records(entityid_list)
139
+ end
140
+
141
+ def search_records(search_word, page = 1, per_page = 200)
142
+ Handler::MassEntityAPIHandler.get_instance(self).search_records(search_word, page, per_page, 'word')
143
+ end
144
+
145
+ def search_records_by_phone(phone, page = 1, per_page = 200)
146
+ Handler::MassEntityAPIHandler.get_instance(self).search_records(phone, page, per_page, 'phone')
147
+ end
148
+
149
+ def search_records_by_email(email, page = 1, per_page = 200)
150
+ Handler::MassEntityAPIHandler.get_instance(self).search_records(email, page, per_page, 'email')
151
+ end
152
+
153
+ def search_records_by_criteria(criteria, page = 1, per_page = 200)
154
+ Handler::MassEntityAPIHandler.get_instance(self).search_records(criteria, page, per_page, 'criteria')
155
+ end
156
+
157
+ def get_tags
158
+ Handler::TagAPIHandler.get_instance(self).get_tags
159
+ end
160
+
161
+ def get_tag_count(tag_id)
162
+ Handler::TagAPIHandler.get_instance(self).get_tag_count(tag_id)
163
+ end
164
+
165
+ def create_tags(tags_list)
166
+ Handler::TagAPIHandler.get_instance(self).create_tags(tags_list)
167
+ end
168
+
169
+ def update_tags(tags_list)
170
+ Handler::TagAPIHandler.get_instance(self).update_tags(tags_list)
171
+ end
172
+
173
+ def add_tags_to_multiple_records(tags_list, record_list)
174
+ Handler::TagAPIHandler.get_instance(self).add_tags_to_multiple_records(tags_list, record_list)
175
+ end
176
+
177
+ def remove_tags_from_multiple_records(tags_list, record_list)
178
+ Handler::TagAPIHandler.get_instance(self).remove_tags_from_multiple_records(tags_list, record_list)
179
+ end
180
+ end
181
+ # THIS CLASS IS USED TO STORE SUBFORM RELATED DATA
182
+ class ZCRMSubForm
183
+ attr_accessor :id, :name, :owner, :created_time, :modified_time, :layout, :field_data, :properties
184
+ def initialize(id = nil)
185
+ @id = id
186
+ @name = nil
187
+ @owner = nil
188
+ @created_time = nil
189
+ @modified_time = nil
190
+ @layout = nil
191
+ @field_data = {}
192
+ @properties = {}
193
+ end
194
+
195
+ def self.get_instance(id = nil)
196
+ ZCRMSubForm.new(id)
197
+ end
198
+ end
199
+ # THIS CLASS IS USED TO STORE AND EXECTUTE TAG RELATED FUNCTIONS
200
+ class ZCRMTag
201
+ attr_accessor :id, :module_apiname, :name, :created_by, :modified_by, :created_time, :modified_time, :count
202
+ def initialize(id = nil, name = nil)
203
+ @id = id
204
+ @module_apiname = nil
205
+ @name = name
206
+ @created_by = nil
207
+ @modified_by = nil
208
+ @created_time = nil
209
+ @modified_time = nil
210
+ @count = nil
211
+ end
212
+
213
+ def self.get_instance(id = nil, name = nil)
214
+ ZCRMTag.new(id, name)
215
+ end
216
+
217
+ def delete
218
+ Handler::TagAPIHandler.get_instance.delete(@id)
219
+ end
220
+
221
+ def merge(merge_tag)
222
+ Handler::TagAPIHandler.get_instance.merge(@id, merge_tag.id)
223
+ end
224
+
225
+ def update
226
+ Handler::TagAPIHandler.get_instance.update(self)
227
+ end
228
+ end
229
+ # THIS CLASS IS USED TO STORE AND EXECTUTE RECORD RELATED FUNCTIONS
230
+ class ZCRMRecord
231
+ attr_accessor :tag_list, :name, :module_api_name, :entity_id, :line_items, :lookup_label, :owner, :created_by, :modified_by, :created_time, :modified_time, :field_data, :properties, :participants, :price_details, :layout, :tax_list, :last_activity_time
232
+ def initialize(module_apiname, entity_id = nil)
233
+ @module_api_name = module_apiname
234
+ @entity_id = entity_id
235
+ @line_items = []
236
+ @lookup_label = nil
237
+ @name = nil
238
+ @owner = nil
239
+ @created_by = nil
240
+ @modified_by = nil
241
+ @created_time = nil
242
+ @modified_time = nil
243
+ @field_data = {}
244
+ @properties = {}
245
+ @participants = []
246
+ @price_details = []
247
+ @layout = nil
248
+ @tax_list = []
249
+ @tag_list = []
250
+ end
251
+
252
+ def self.get_instance(module_api_name, entity_id = nil)
253
+ ZCRMRecord.new(module_api_name, entity_id)
254
+ end
255
+
256
+ def get
257
+ Handler::EntityAPIHandler.get_instance(self).get_record
258
+ end
259
+
260
+ def create
261
+ Handler::EntityAPIHandler.get_instance(self).create_record
262
+ end
263
+
264
+ def update
265
+ Handler::EntityAPIHandler.get_instance(self).update_record
266
+ end
267
+
268
+ def delete
269
+ Handler::EntityAPIHandler.get_instance(self).delete_record
270
+ end
271
+
272
+ def convert(potential_record = nil, details = nil)
273
+ Handler::EntityAPIHandler.get_instance(self).convert_record(potential_record, details)
274
+ end
275
+
276
+ def upload_attachment(file_path)
277
+ ZCRMModuleRelation.get_instance(self, 'Attachments').upload_attachment(file_path)
278
+ end
279
+
280
+ def upload_link_as_attachment(link_url)
281
+ ZCRMModuleRelation.get_instance(self, 'Attachments').upload_link_as_attachment(link_url)
282
+ end
283
+
284
+ def download_attachment(attachment_id)
285
+ ZCRMModuleRelation.get_instance(self, 'Attachments').download_attachment(attachment_id)
286
+ end
287
+
288
+ def delete_attachment(attachment_id)
289
+ ZCRMModuleRelation.get_instance(self, 'Attachments').delete_attachment(attachment_id)
290
+ end
291
+
292
+ def upload_photo(file_path)
293
+ Handler::EntityAPIHandler.get_instance(self).upload_photo(file_path)
294
+ end
295
+
296
+ def download_photo
297
+ Handler::EntityAPIHandler.get_instance(self).download_photo
298
+ end
299
+
300
+ def delete_photo
301
+ Handler::EntityAPIHandler.get_instance(self).delete_photo
302
+ end
303
+
304
+ def add_relation(junction_record)
305
+ ZCRMModuleRelation.get_instance(self, junction_record).add_relation
306
+ end
307
+
308
+ def remove_relation(junction_record)
309
+ ZCRMModuleRelation.get_instance(self, junction_record).remove_relation
310
+ end
311
+
312
+ def add_note(note_ins)
313
+ ZCRMModuleRelation.get_instance(self, 'Notes').add_note(note_ins)
314
+ end
315
+
316
+ def update_note(note_ins)
317
+ ZCRMModuleRelation.get_instance(self, 'Notes').update_note(note_ins)
318
+ end
319
+
320
+ def delete_note(note_ins)
321
+ ZCRMModuleRelation.get_instance(self, 'Notes').delete_note(note_ins)
322
+ end
323
+
324
+ def get_notes(sort_by = nil, sort_order = nil, page = 1, per_page = 20)
325
+ ZCRMModuleRelation.get_instance(self, 'Notes').get_notes(sort_by, sort_order, page, per_page)
326
+ end
327
+
328
+ def get_attachments(page = 1, per_page = 20)
329
+ ZCRMModuleRelation.get_instance(self, 'Attachments').get_attachments(page, per_page)
330
+ end
331
+
332
+ def get_relatedlist_records(relatedlist_api_name, sort_by = nil, sort_order = nil, page = 1, per_page = 20)
333
+ ZCRMModuleRelation.get_instance(self, relatedlist_api_name).get_records(sort_by, sort_order, page, per_page)
334
+ end
335
+
336
+ def add_tags(tagnames)
337
+ Handler::TagAPIHandler.get_instance.add_tags(self, tagnames)
338
+ end
339
+
340
+ def remove_tags(tagnames)
341
+ Handler::TagAPIHandler.get_instance.remove_tags(self, tagnames)
342
+ end
343
+ end
344
+ # THIS CLASS IS USED TO STORE LINE ITEM RELATED DATA
345
+ class ZCRMInventoryLineItem
346
+ attr_accessor :product, :id, :discount_percentage, :list_price, :quantity, :description, :total, :discount, :total_after_discount, :tax_amount, :net_total, :delete_flag, :line_tax
347
+ def initialize(param = nil)
348
+ if param.is_a?(Operations::ZCRMRecord)
349
+ @product = param
350
+ @id = nil
351
+ else
352
+ @id = param
353
+ @product = nil
354
+ @list_price = nil
355
+ @quantity = nil
356
+ @description = nil
357
+ @total = nil
358
+ @discount = nil
359
+ @discount_percentage = nil
360
+ @total_after_discount = nil
361
+ @tax_amount = nil
362
+ @net_total = nil
363
+ @delete_flag = false
364
+ @line_tax = []
365
+ end
366
+ end
367
+
368
+ def self.get_instance(param = nil)
369
+ ZCRMInventoryLineItem.new(param)
370
+ end
371
+ end
372
+ # THIS CLASS IS USED TO STORE TAX RELATED DATA
373
+ class ZCRMTax
374
+ attr_accessor :name, :percentage, :value
375
+ def initialize(name)
376
+ @name = name
377
+ @percentage = nil
378
+ @value = nil
379
+ end
380
+
381
+ def self.get_instance(name)
382
+ ZCRMTax.new(name)
383
+ end
384
+ end
385
+ # THIS CLASS IS USED TO STORE ORG TAX RELATED DATA
386
+ class ZCRMOrgTax
387
+ attr_accessor :id, :name, :display_label, :value, :sequence_number
388
+ def initialize(id = nil, name = nil)
389
+ @id = id
390
+ @name = name
391
+ @display_label = nil
392
+ @value = nil
393
+ @sequence_number = nil
394
+ end
395
+
396
+ def self.get_instance(id = nil, name = nil)
397
+ ZCRMOrgTax.new(id, name)
398
+ end
399
+ end
400
+ # THIS CLASS IS USED TO STORE EVENT PARTICIPANT RELATED DATA
401
+ class ZCRMEventParticipant
402
+ attr_accessor :id, :type, :email, :name, :is_invited, :status
403
+ def initialize(participant_type, participant_id)
404
+ @id = participant_id
405
+ @type = participant_type
406
+ @email = nil
407
+ @name = nil
408
+ @is_invited = nil
409
+ @status = nil
410
+ end
411
+
412
+ def self.get_instance(participant_type, participant_id)
413
+ ZCRMEventParticipant.new(participant_type, participant_id)
414
+ end
415
+ end
416
+ # THIS CLASS IS USED TO STORE PRICING BOOK RELATED DATA
417
+ class ZCRMPriceBookPricing
418
+ attr_accessor :id, :to_range, :from_range, :discount
419
+ def initialize(price_book_id = nil)
420
+ @id = price_book_id
421
+ @to_range = nil
422
+ @from_range = nil
423
+ @discount = nil
424
+ end
425
+
426
+ def self.get_instance(price_book_id = nil)
427
+ ZCRMPriceBookPricing.new(price_book_id)
428
+ end
429
+ end
430
+ # THIS CLASS IS USED TO STORE USER RELATED DATA
431
+ class ZCRMUser
432
+ attr_accessor :id, :is_microsoft, :offset, :name, :field_apiname_vs_value, :signature, :country, :role, :customize_info, :city, :name_format, :language, :locale, :is_personal_account, :default_tab_group, :street, :alias_aka, :theme, :state, :country_locale, :fax, :first_name, :email, :zip, :decimal_separator, :website, :time_format, :profile, :mobile, :last_name, :time_zone, :zuid, :is_confirm, :full_name, :phone, :dob, :date_format, :status, :created_by, :modified_by, :territories, :reporting_to, :is_online, :currency, :created_time, :modified_time
433
+ def initialize(user_id = nil, name = nil)
434
+ @id = user_id
435
+ @name = name
436
+ @offset = nil
437
+ @is_microsoft = nil
438
+ @signature = nil
439
+ @country = nil
440
+ @role = nil
441
+ @customize_info = nil
442
+ @city = nil
443
+ @name_format = nil
444
+ @language = nil
445
+ @locale = nil
446
+ @is_personal_account = nil
447
+ @default_tab_group = nil
448
+ @street = nil
449
+ @alias_aka = nil
450
+ @theme = nil
451
+ @state = nil
452
+ @country_locale = nil
453
+ @fax = nil
454
+ @first_name = nil
455
+ @email = nil
456
+ @zip = nil
457
+ @decimal_separator = nil
458
+ @website = nil
459
+ @time_format = nil
460
+ @profile = nil
461
+ @mobile = nil
462
+ @last_name = nil
463
+ @time_zone = nil
464
+ @zuid = nil
465
+ @is_confirm = nil
466
+ @full_name = nil
467
+ @phone = nil
468
+ @dob = nil
469
+ @date_format = nil
470
+ @status = nil
471
+ @created_by = nil
472
+ @modified_by = nil
473
+ @territories = nil
474
+ @reporting_to = nil
475
+ @is_online = nil
476
+ @currency = nil
477
+ @created_time = nil
478
+ @modified_time = nil
479
+ @field_apiname_vs_value = nil
480
+ end
481
+
482
+ def self.get_instance(user_id = nil, name = nil)
483
+ ZCRMUser.new(user_id, name)
484
+ end
485
+ end
486
+ # THIS CLASS IS USED TO STORE USER CUSTOM INFO RELATED DATA
487
+ class ZCRMUserCustomizeInfo
488
+ attr_accessor :notes_desc, :is_to_show_right_panel, :is_bc_view, :is_to_show_home, :is_to_show_detail_view, :unpin_recent_item
489
+ def initialize
490
+ @notes_desc = nil
491
+ @is_to_show_right_panel = nil
492
+ @is_bc_view = nil
493
+ @is_to_show_home = nil
494
+ @is_to_show_detail_view = nil
495
+ @unpin_recent_item = nil
496
+ end
497
+
498
+ def self.get_instance
499
+ ZCRMUserCustomizeInfo.new
500
+ end
501
+ end
502
+ # THIS CLASS IS USED TO STORE USER THEME RELATED DATA
503
+ class ZCRMUserTheme
504
+ attr_accessor :normal_tab_font_color, :normal_tab_background, :selected_tab_font_color, :selected_tab_background, :new_background, :background, :screen, :type
505
+ def initialize
506
+ @normal_tab_font_color = nil
507
+ @normal_tab_background = nil
508
+ @selected_tab_font_color = nil
509
+ @selected_tab_background = nil
510
+ @new_background = nil
511
+ @background = nil
512
+ @screen = nil
513
+ @type = nil
514
+ end
515
+
516
+ def self.get_instance
517
+ ZCRMUserTheme.new
518
+ end
519
+ end
520
+ # THIS CLASS IS USED TO STORE ROLE RELATED DATA
521
+ class ZCRMRole
522
+ attr_accessor :name, :id, :reporting_to, :display_label, :is_admin, :forecast_manager, :is_share_with_peers, :description
523
+ def initialize(role_id, role_name = nil)
524
+ @name = role_name
525
+ @id = role_id
526
+ @reporting_to = nil
527
+ @display_label = nil
528
+ @is_admin = nil
529
+ @forecast_manager = nil
530
+ @is_share_with_peers = nil
531
+ @description = nil
532
+ end
533
+
534
+ def self.get_instance(role_id, role_name = nil)
535
+ ZCRMRole.new(role_id, role_name)
536
+ end
537
+ end
538
+ # THIS CLASS IS USED TO STORE LAYOUT RELATED DATA
539
+ class ZCRMLayout
540
+ attr_accessor :created_for, :id, :name, :created_time, :modified_time, :is_visible, :modified_by, :accessible_profiles, :created_by, :sections, :status, :convert_mapping
541
+ def initialize(layout_id)
542
+ @id = layout_id
543
+ @name = nil
544
+ @created_time = nil
545
+ @modified_time = nil
546
+ @is_visible = nil
547
+ @modified_by = nil
548
+ @accessible_profiles = nil
549
+ @created_by = nil
550
+ @sections = nil
551
+ @status = nil
552
+ @convert_mapping = {}
553
+ @created_for = nil
554
+ end
555
+
556
+ def self.get_instance(layout_id)
557
+ ZCRMLayout.new(layout_id)
558
+ end
559
+ end
560
+ # THIS CLASS IS USED TO STORE ATTACHMENT RELATED DATA
561
+ class ZCRMAttachment
562
+ attr_accessor :is_editable, :link_url, :file_id, :id, :parent_record, :file_name, :type, :size, :owner, :created_by, :created_time, :modified_by, :modified_time, :parent_module, :attachment_type, :parent_name, :parent_id
563
+ def initialize(parent_record, attachment_id = nil)
564
+ @id = attachment_id
565
+ @parent_record = parent_record
566
+ @file_name = nil
567
+ @type = nil
568
+ @size = nil
569
+ @owner = nil
570
+ @created_by = nil
571
+ @created_time = nil
572
+ @modified_by = nil
573
+ @modified_time = nil
574
+ @parent_module = nil
575
+ @attachment_type = nil
576
+ @parent_name = nil
577
+ @parent_id = nil
578
+ @file_id = nil
579
+ @link_url = nil
580
+ @is_editable = nil
581
+ end
582
+
583
+ def self.get_instance(parent_record, attachment_id = nil)
584
+ ZCRMAttachment.new(parent_record, attachment_id)
585
+ end
586
+ end
587
+ # THIS CLASS IS USED TO STORE CUSTOM VIEW RELATED DATA
588
+ class ZCRMCustomView
589
+ attr_accessor :is_system_defined, :shared_details, :criteria_pattern, :criteria_condition, :id, :module_api_name, :display_value, :is_default, :name, :system_name, :sort_by, :category, :fields, :favorite, :sort_order, :criteria, :categories, :is_off_line
590
+ def initialize(custom_view_id, module_api_name = nil)
591
+ @id = custom_view_id
592
+ @module_api_name = module_api_name
593
+ @display_value = nil
594
+ @is_default = nil
595
+ @name = nil
596
+ @system_name = nil
597
+ @sort_by = nil
598
+ @category = nil
599
+ @fields = []
600
+ @favorite = nil
601
+ @sort_order = nil
602
+ @criteria = nil
603
+ @criteria_pattern = nil
604
+ @criteria_condition = nil
605
+ @categories = []
606
+ @is_off_line = nil
607
+ @shared_details = nil
608
+ @is_system_defined = nil
609
+ end
610
+
611
+ def self.get_instance(custom_view_id, module_api_name = nil)
612
+ ZCRMCustomView.new(custom_view_id, module_api_name)
613
+ end
614
+
615
+ def get_records(sort_by = nil, sort_order = nil, page = 1, per_page = 200, headers = nil)
616
+ Operations::ZCRMModule.get_instance(module_api_name).get_records(id, sort_by, sort_order, page, per_page, headers)
617
+ end
618
+ end
619
+ # THIS CLASS IS USED TO STORE CUSTOMVIEW CATEGORY RELATED DATA
620
+ class ZCRMCustomViewCategory
621
+ attr_accessor :display_value, :actual_value
622
+ def initialize
623
+ @display_value = nil
624
+ @actual_value = nil
625
+ end
626
+
627
+ def self.get_instance
628
+ ZCRMCustomViewCategory.new
629
+ end
630
+ end
631
+ # THIS CLASS IS USED TO STORE CUSTOMVIEW CATEGORY CRITERIA RELATED DATA
632
+ class ZCRMCustomViewCriteria
633
+ attr_accessor :comparator, :field, :value, :group, :group_operator, :pattern, :index, :criteria
634
+ def initialize
635
+ @comparator = nil
636
+ @field = nil
637
+ @value = nil
638
+ @group = nil
639
+ @group_operator = nil
640
+ @pattern = nil
641
+ @index = nil
642
+ @criteria = nil
643
+ end
644
+
645
+ def self.get_instance
646
+ ZCRMCustomViewCriteria.new
647
+ end
648
+ end
649
+ # THIS CLASS IS USED TO STORE FIELD RELATED DATA
650
+ class ZCRMField
651
+ attr_accessor :is_webhook, :crypt, :tooltip, :is_field_read_only, :association_details, :subform, :is_mass_update, :multiselectlookup, :api_name, :is_custom_field, :lookup_field, :convert_mapping, :is_visible, :field_label, :length, :created_source, :default_value, :is_mandatory, :sequence_number, :is_read_only, :is_unique_field, :is_case_sensitive, :data_type, :is_formula_field, :is_currency_field, :id, :picklist_values, :is_auto_number, :is_business_card_supported, :field_layout_permissions, :decimal_place, :precision, :rounding_option, :formula_return_type, :formula_expression, :prefix, :suffix, :start_number, :json_type
652
+ def initialize(api_name, id = nil)
653
+ @api_name = api_name
654
+ @is_webhook = nil
655
+ @crypt = nil
656
+ @tooltip = nil
657
+ @is_field_read_only = nil
658
+ @association_details = nil
659
+ @subform = nil
660
+ @is_mass_update = nil
661
+ @multiselectlookup = {}
662
+ @is_custom_field = nil
663
+ @lookup_field = {}
664
+ @convert_mapping = nil
665
+ @is_visible = nil
666
+ @field_label = nil
667
+ @length = nil
668
+ @created_source = nil
669
+ @default_value = nil
670
+ @is_mandatory = nil
671
+ @sequence_number = nil
672
+ @is_read_only = nil
673
+ @is_unique_field = nil
674
+ @is_case_sensitive = nil
675
+ @data_type = nil
676
+ @is_formula_field = nil
677
+ @is_currency_field = nil
678
+ @id = id
679
+ @picklist_values = []
680
+ @is_auto_number = nil
681
+ @is_business_card_supported = nil
682
+ @field_layout_permissions = nil
683
+ @decimal_place = nil
684
+ @precision = nil
685
+ @rounding_option = nil
686
+ @formula_return_type = nil
687
+ @formula_expression = nil
688
+ @prefix = nil
689
+ @suffix = nil
690
+ @start_number = nil
691
+ @json_type = nil
692
+ end
693
+
694
+ def self.get_instance(api_name, id = nil)
695
+ ZCRMField.new(api_name, id)
696
+ end
697
+ end
698
+ # THIS CLASS IS USED TO STORE JUNCTION RECORD RELATED DATA
699
+ class ZCRMJunctionRecord
700
+ attr_accessor :id, :api_name, :related_data
701
+ def initialize(api_name, record_id)
702
+ @id = record_id
703
+ @api_name = api_name
704
+ @related_data = {}
705
+ end
706
+
707
+ def self.get_instance(api_name, record_id)
708
+ ZCRMJunctionRecord.new(api_name, record_id)
709
+ end
710
+ end
711
+ # THIS CLASS IS USED TO STORE LEAD CONVERT MAPPING RELATED DATA
712
+ class ZCRMLeadConvertMapping
713
+ attr_accessor :id, :name, :fields
714
+ def initialize(name, converted_id)
715
+ @id = converted_id
716
+ @name = name
717
+ @fields = []
718
+ end
719
+
720
+ def self.get_instance(name, converted_id)
721
+ ZCRMLeadConvertMapping.new(name, converted_id)
722
+ end
723
+ end
724
+ # THIS CLASS IS USED TO STORE LEAD CONVERT MAPPING FIELD RELATED DATA
725
+ class ZCRMLeadConvertMappingField
726
+ attr_accessor :id, :api_name, :field_label, :is_required
727
+ def initialize(api_name, field_id)
728
+ @id = field_id
729
+ @api_name = api_name
730
+ @field_label = nil
731
+ @is_required = nil
732
+ end
733
+
734
+ def self.get_instance(api_name, field_id)
735
+ ZCRMLeadConvertMappingField.new(api_name, field_id)
736
+ end
737
+ end
738
+ # THIS CLASS IS USED TO STORE LOOKUP FIELD RELATED DATA
739
+ class ZCRMLookupField
740
+ attr_accessor :api_name, :display_label, :module_apiname, :id
741
+ def initialize(api_name)
742
+ @api_name = api_name
743
+ @display_label = nil
744
+ @module_apiname = nil
745
+ @id = nil
746
+ end
747
+
748
+ def self.get_instance(api_name)
749
+ ZCRMLookupField.new(api_name)
750
+ end
751
+ end
752
+ # THIS CLASS IS USED TO STORE MODULE RELATED LIST RELATED DATA
753
+ class ZCRMModuleRelatedList
754
+ attr_accessor :api_name, :module_apiname, :display_label, :is_visible, :name, :id, :href, :type, :action, :sequence_number
755
+ def initialize(api_name)
756
+ @api_name = api_name
757
+ @module_apiname = nil
758
+ @display_label = nil
759
+ @is_visible = nil
760
+ @name = nil
761
+ @id = nil
762
+ @href = nil
763
+ @type = nil
764
+ @action = nil
765
+ @sequence_number = nil
766
+ end
767
+
768
+ def self.get_instance(api_name)
769
+ ZCRMModuleRelatedList.new(api_name)
770
+ end
771
+ end
772
+ # THIS CLASS IS USED TO STORE MODULE RELATION RELATED DATA
773
+ class ZCRMModuleRelation
774
+ attr_accessor :parent_record, :parent_module_api_name, :junction_record, :api_name, :label, :id, :is_visible
775
+ def initialize(parentmodule_apiname_or_parentrecord, related_list_apiname_or_junction_record = nil)
776
+ if parentmodule_apiname_or_parentrecord.is_a?(Operations::ZCRMRecord)
777
+ @parent_record = parentmodule_apiname_or_parentrecord
778
+ @parent_module_api_name = nil
779
+ else
780
+ @parent_module_api_name = parentmodule_apiname_or_parentrecord
781
+ @parent_record = nil
782
+ end
783
+ if related_list_apiname_or_junction_record.is_a?(Operations::ZCRMJunctionRecord)
784
+ @junction_record = related_list_apiname_or_junction_record
785
+ @api_name = nil
786
+ else
787
+ @api_name = related_list_apiname_or_junction_record
788
+ @junction_record = nil
789
+ end
790
+ @label = nil
791
+ @id = nil
792
+ @is_visible = nil
793
+ end
794
+
795
+ def self.get_instance(parentmodule_apiname_or_parentrecord, related_list_apiname_or_junction_record)
796
+ ZCRMModuleRelation.new(parentmodule_apiname_or_parentrecord, related_list_apiname_or_junction_record)
797
+ end
798
+
799
+ def get_records(sort_by_field = nil, sort_order = nil, page = 1, per_page = 20)
800
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).get_records(sort_by_field, sort_order, page, per_page)
801
+ end
802
+
803
+ def upload_attachment(file_path)
804
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).upload_attachment(file_path)
805
+ end
806
+
807
+ def upload_link_as_attachment(link_url)
808
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).upload_link_as_attachment(link_url)
809
+ end
810
+
811
+ def download_attachment(attachment_id)
812
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).download_attachment(attachment_id)
813
+ end
814
+
815
+ def delete_attachment(attachment_id)
816
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).delete_attachment(attachment_id)
817
+ end
818
+
819
+ def add_relation
820
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, @junction_record).add_relation
821
+ end
822
+
823
+ def remove_relation
824
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, @junction_record).remove_relation
825
+ end
826
+
827
+ def add_note(zcrm_note_ins)
828
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).add_note(zcrm_note_ins)
829
+ end
830
+
831
+ def update_note(zcrm_note_ins)
832
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).update_note(zcrm_note_ins)
833
+ end
834
+
835
+ def delete_note(zcrm_note_ins)
836
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).delete_note(zcrm_note_ins)
837
+ end
838
+
839
+ def get_notes(sort_by = nil, sort_order = nil, page = 1, per_page = 20)
840
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).get_notes(sort_by, sort_order, page, per_page)
841
+ end
842
+
843
+ def get_attachments(page = 1, per_page = 20)
844
+ Handler::RelatedListAPIHandler.get_instance(@parent_record, self).get_attachments(page, per_page)
845
+ end
846
+ end
847
+ # THIS CLASS IS USED TO STORE AND EXECUTE NOTES RELATED FUNCTIONALITY
848
+ class ZCRMNote
849
+ attr_accessor :is_editable, :id, :parent_record, :title, :content, :owner, :created_by, :created_time, :modified_by, :modified_time, :attachments, :size, :is_voice_note, :parent_module, :parent_name, :parent_id
850
+ def initialize(parent_record = nil, note_id = nil)
851
+ @id = note_id
852
+ @parent_record = parent_record
853
+ @title = nil
854
+ @content = nil
855
+ @owner = nil
856
+ @created_by = nil
857
+ @created_time = nil
858
+ @modified_by = nil
859
+ @modified_time = nil
860
+ @attachments = nil
861
+ @size = nil
862
+ @is_voice_note = nil
863
+ @parent_module = nil
864
+ @parent_name = nil
865
+ @parent_id = nil
866
+ @is_editable = nil
867
+ end
868
+
869
+ def upload_attachment(file_path)
870
+ ZCRMModuleRelation.get_instance(ZCRMRecord.get_instance('Notes', @id), 'Attachments').upload_attachment(file_path)
871
+ end
872
+
873
+ def download_attachment(attachment_id)
874
+ ZCRMModuleRelation.get_instance(ZCRMRecord.get_instance('Notes', @id), 'Attachments').download_attachment(attachment_id)
875
+ end
876
+
877
+ def get_attachments(page = 1, per_page = 20)
878
+ ZCRMModuleRelation.get_instance(ZCRMRecord.get_instance('Notes', @id), 'Attachments').get_attachments(page, per_page)
879
+ end
880
+
881
+ def delete_attachment(attachment_id)
882
+ ZCRMModuleRelation.get_instance(ZCRMRecord.get_instance('Notes', @id), 'Attachments').delete_attachment(attachment_id)
883
+ end
884
+
885
+ def self.get_instance(parent_record = nil, note_id = nil)
886
+ ZCRMNote.new(parent_record = nil, note_id)
887
+ end
888
+ end
889
+ # THIS CLASS IS USED TO STORE PROFILE PERMISSIONS RELATED DATA
890
+ class ZCRMPermission
891
+ attr_accessor :id, :name, :display_label, :module_api_name, :is_enabled
892
+ def initialize(permission_name, permission_id)
893
+ @id = permission_id
894
+ @name = permission_name
895
+ @display_label = nil
896
+ @module_api_name = nil
897
+ @is_enabled = nil
898
+ end
899
+
900
+ def self.get_instance(permission_name, permission_id)
901
+ ZCRMPermission.new(permission_name, permission_id)
902
+ end
903
+ end
904
+ # THIS CLASS IS USED TO STORE PICK LIST VALUE RELATED DATA
905
+ class ZCRMPickListValue
906
+ attr_accessor :display_value, :sequence_number, :actual_value, :maps
907
+ def initialize
908
+ @display_value = nil
909
+ @sequence_number = nil
910
+ @actual_value = nil
911
+ @maps = nil
912
+ end
913
+
914
+ def self.get_instance
915
+ ZCRMPickListValue.new
916
+ end
917
+ end
918
+ # THIS CLASS IS USED TO STORE MULTI SELECT LOOKUP RELATED DATA
919
+ class ZCRMMultiSelectLookupField
920
+ attr_accessor :display_label, :linking_module, :connected_module, :api_name, :id
921
+ def initialize(api_name)
922
+ @display_label = nil
923
+ @linking_module = nil
924
+ @connected_module = nil
925
+ @api_name = api_name
926
+ @id = nil
927
+ end
928
+
929
+ def self.get_instance(api_name)
930
+ ZCRMMultiSelectLookupField.new(api_name)
931
+ end
932
+ end
933
+ # THIS CLASS IS USED TO STORE PROFILE RELATED DATA
934
+ class ZCRMProfile
935
+ attr_accessor :name, :id, :is_default, :created_time, :modified_time, :modified_by, :description, :created_by, :category, :permissions, :sections
936
+ def initialize(profile_id, profile_name = nil)
937
+ @name = profile_name
938
+ @id = profile_id
939
+ @is_default = nil
940
+ @created_time = nil
941
+ @modified_time = nil
942
+ @modified_by = nil
943
+ @description = nil
944
+ @created_by = nil
945
+ @category = nil
946
+ @permissions = []
947
+ @sections = []
948
+ end
949
+
950
+ def self.get_instance(profile_id, profile_name = nil)
951
+ ZCRMProfile.new(profile_id, profile_name)
952
+ end
953
+ end
954
+ # THIS CLASS IS USED TO STORE PROFILE CATEGORY DATA
955
+ class ZCRMProfileCategory
956
+ attr_accessor :name, :module_api_name, :display_label, :permission_ids
957
+ def initialize(profile_category_name)
958
+ @name = profile_category_name
959
+ @module_api_name = nil
960
+ @display_label = nil
961
+ @permission_ids = []
962
+ end
963
+
964
+ def self.get_instance(profile_category_name)
965
+ ZCRMProfileCategory.new(profile_category_name)
966
+ end
967
+ end
968
+ # THIS CLASS IS USED TO STORE PROFILE SECTION DATA
969
+ class ZCRMProfileSection
970
+ attr_accessor :name, :categories
971
+ def initialize(section_name)
972
+ @name = section_name
973
+ @categories = []
974
+ end
975
+
976
+ def self.get_instance(section_name)
977
+ ZCRMProfileSection.new(section_name)
978
+ end
979
+ end
980
+ # THIS CLASS IS USED TO STORE RELATED LIST PROPERTIES RELATED DATA
981
+ class ZCRMRelatedListProperties
982
+ attr_accessor :sort_by, :sort_order, :fields
983
+ def initialize
984
+ @sort_by = nil
985
+ @sort_order = nil
986
+ @fields = nil
987
+ end
988
+
989
+ def self.get_instance
990
+ ZCRMRelatedListProperties.new
991
+ end
992
+ end
993
+ # THIS CLASS IS USED TO STORE SECTIONS RELATED DATA
994
+ class ZCRMSection
995
+ attr_accessor :properties, :api_name, :name, :display_label, :column_count, :sequence_number, :fields, :is_subform_section, :tab_traversal
996
+ def initialize(section_name)
997
+ @name = section_name
998
+ @display_label = nil
999
+ @column_count = nil
1000
+ @sequence_number = nil
1001
+ @fields = nil
1002
+ @is_subform_section = nil
1003
+ @tab_traversal = nil
1004
+ @api_name = nil
1005
+ @properties = nil
1006
+ end
1007
+
1008
+ def self.get_instance(section_name)
1009
+ ZCRMSection.new(section_name)
1010
+ end
1011
+ end
1012
+ # THIS CLASS IS USED TO STORE SECTION PROPERTIES RELATED DATA
1013
+ class ZCRMSectionProperties
1014
+ attr_accessor :reorder_rows, :tooltip, :maximum_rows
1015
+ def initialize
1016
+ @reorder_rows = nil
1017
+ @tooltip = nil
1018
+ @maximum_rows = nil
1019
+ end
1020
+
1021
+ def self.get_instance
1022
+ ZCRMSectionProperties.new
1023
+ end
1024
+ end
1025
+ # THIS CLASS IS USED TO STORE TRASH RECORD RELATED DATA
1026
+ class ZCRMTrashRecord
1027
+ attr_accessor :id, :type, :display_name, :deleted_time, :created_by, :deleted_by, :module_api_name
1028
+ def initialize(module_api_name, entity_type, entity_id = nil)
1029
+ @id = entity_id
1030
+ @module_api_name = module_api_name
1031
+ @type = entity_type
1032
+ @display_name = nil
1033
+ @deleted_time = nil
1034
+ @created_by = nil
1035
+ @deleted_by = nil
1036
+ end
1037
+
1038
+ def self.get_instance(module_api_name, entity_type, entity_id = nil)
1039
+ ZCRMTrashRecord.new(module_api_name, entity_type, entity_id)
1040
+ end
1041
+ end
1042
+ end
1043
+ end