sugarcrm_rest 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/sugarcrm_rest.rb +12 -23
- data/lib/sugarcrm_rest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1fb0327792616cc0dfe8816647e55648ebeb6365372075abe7fdf560f78ddcb
|
4
|
+
data.tar.gz: f4a6d1c2c9968162626eb1009c4be76590b8c68fd93a7ac8a220d06f1dd0c645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c8a24bd26318b8da0abfc3c7f503c3ed39675ae9695fa4e2e596163fa8cb701cfc70609e431bdab3e745219df523e895f140fbae5270a7bbcf59c76d28112bc
|
7
|
+
data.tar.gz: 374ee990ebbd12ddcb8acec3fae44382a2b9f14776932375071806b691d402decb6686bd036cb6379ed198961a7a474e05c976156f654ea6c324e54e502d61c7
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
|
|
23
23
|
connect=SugarcrmRest::Connect.new(consumer_key,consumer_secret,username,password,platform,url) #Provide the connection object
|
24
24
|
SugarcrmRest::Fetch_Data.fetch_single_record(connect,module_name,id) #Give the record with specified id from specified module
|
25
25
|
SugarcrmRest::Fetch_Data.fetch_all_data(connect,module_name,offset,maxnum) #Fetch data from specified module according to offset
|
26
|
-
SugarcrmRest::Fetch_Data.fetch_data_with_filters(connect,module_name,filter_json,fields=["no"],offset=0) #Return a json object of data having specified fields by applying specified filters
|
26
|
+
SugarcrmRest::Fetch_Data.fetch_data_with_filters(connect,module_name,filter_json,fields=["no"],offset=0) #Return a json object of data having specified fields by applying specified filters.The filter format is filter=[{"name":"example"},{"age":{"$gte":age}}]
|
27
27
|
SugarcrmRest::Fetch_Data.upload_document(connect,id,path) #upload the file having specified path and id to doccument module
|
28
28
|
|
29
29
|
SugarcrmRest::Update_Sugar.create_new_record(connect,module_name,params) #Creating new record in specified module
|
data/lib/sugarcrm_rest.rb
CHANGED
@@ -51,6 +51,7 @@ end
|
|
51
51
|
|
52
52
|
|
53
53
|
def self.execute_uri(connect,url)
|
54
|
+
|
54
55
|
begin
|
55
56
|
uri = URI.parse url
|
56
57
|
http = Net::HTTP.new uri.host, uri.port
|
@@ -94,23 +95,7 @@ class Fetch_Data
|
|
94
95
|
return root
|
95
96
|
end
|
96
97
|
end
|
97
|
-
|
98
|
-
def self.build_filter(filter_json)
|
99
|
-
filter_hash = JSON.parse(filter_json)
|
100
|
-
filter_keys=JSON.parse(filter_json).keys
|
101
|
-
filter="?"
|
102
|
-
and_op=""
|
103
|
-
count=0
|
104
|
-
filter_keys.each do |k|
|
105
|
-
f1=filter_hash[k]
|
106
|
-
value=filter_hash[k].keys
|
107
|
-
filter=filter+"filter[0]["+"#{value[0]}"+"]["+"#{k}"+"]="+"#{f1[value[0]]}"
|
108
|
-
filter=filter+"&" if (count += 1) < filter_keys.length
|
109
|
-
|
110
|
-
end
|
111
|
-
return filter
|
112
|
-
|
113
|
-
end
|
98
|
+
|
114
99
|
def self.adding_fields(connect,module_name,filter,fields)
|
115
100
|
offset=0
|
116
101
|
count=0
|
@@ -127,8 +112,8 @@ class Fetch_Data
|
|
127
112
|
result=Hash.new
|
128
113
|
i=0
|
129
114
|
while offset >= 0 do
|
130
|
-
url =''+"#{connect.url}"+"#{module_name}"+"
|
131
|
-
|
115
|
+
url =''+"#{connect.url}"+"#{module_name}"+"?filter=#{filter}"+'&max_num=100&offset='+offset.to_s
|
116
|
+
|
132
117
|
response = Get_Token_Process_Url.execute_uri(connect,url)
|
133
118
|
if response.kind_of? Net::HTTPSuccess
|
134
119
|
root = JSON.parse response.body
|
@@ -147,14 +132,17 @@ class Fetch_Data
|
|
147
132
|
end
|
148
133
|
|
149
134
|
def self.fetch_data_with_filters(connect,module_name,filter_json,fields=["no"],offset=0)
|
150
|
-
filter=
|
135
|
+
filter=filter_json
|
151
136
|
|
152
137
|
|
153
138
|
if (fields[0]=="no")
|
154
139
|
|
155
|
-
url =''+"#{connect.url}"+"#{module_name}"+"
|
140
|
+
url =''+"#{connect.url}"+"#{module_name}"+"?filter=#{filter_json}"+'&max_num=100&offset='+offset.to_s
|
156
141
|
|
157
142
|
response = Get_Token_Process_Url.execute_uri(connect,url)
|
143
|
+
|
144
|
+
root = JSON.parse response.body
|
145
|
+
|
158
146
|
if response.kind_of? Net::HTTPSuccess
|
159
147
|
root = JSON.parse response.body
|
160
148
|
return root
|
@@ -207,7 +195,7 @@ class Fetch_Data
|
|
207
195
|
request.add_field('Content-Type','application/json')
|
208
196
|
request.body=params.to_json
|
209
197
|
response = http.request request
|
210
|
-
|
198
|
+
|
211
199
|
if response.kind_of? Net::HTTPSuccess
|
212
200
|
root = JSON.parse response.body
|
213
201
|
end
|
@@ -216,6 +204,7 @@ class Fetch_Data
|
|
216
204
|
|
217
205
|
|
218
206
|
def self.update_data(connect,module_name,params,id)
|
207
|
+
|
219
208
|
url=''+"#{connect.url}"+module_name+'/'+id
|
220
209
|
uri = URI.parse url
|
221
210
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -227,7 +216,7 @@ class Fetch_Data
|
|
227
216
|
request.body=params.to_json
|
228
217
|
|
229
218
|
response = http.request request
|
230
|
-
|
219
|
+
|
231
220
|
if response.kind_of? Net::HTTPSuccess
|
232
221
|
root = JSON.parse response.body
|
233
222
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcrm_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sruthi PN
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|