maestrano-connector-rails 1.0.3 → 1.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5dba94b691f6b3af1ac41b6a7d0398ee5396af
|
4
|
+
data.tar.gz: dc4611f5da086cff9fc297b0d0d0eba7aa4e5c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b2683f1f4283965f1f4a4c81be839aaa72d734432aa6246d21d2dbf15e90be0161d11a8e863584863531c15af823a2375f38acd667a212733793d47fc32ad57
|
7
|
+
data.tar.gz: d7931fb298a3b542c4a9878ccb6e5b2969efa4b67eb11c47aef601b50ff681d3539d013ed25e3934c129f55a9bb3b992a269fa81e7031fe75c8dbbda5e5f7088
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
@@ -166,14 +166,13 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
166
166
|
# Fetch first page
|
167
167
|
page_number = 0
|
168
168
|
if last_synchronization.blank? || @opts[:full_sync]
|
169
|
-
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "entity=#{self.class.connec_entity_name}, fetching all data")
|
170
169
|
query_params[:$filter] = @opts[:$filter] if @opts[:$filter]
|
171
170
|
else
|
172
|
-
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "entity=#{self.class.connec_entity_name}, fetching data since #{last_synchronization.updated_at.iso8601}")
|
173
171
|
query_params[:$filter] = "updated_at gt '#{last_synchronization.updated_at.iso8601}'" + (@opts[:$filter] ? " and #{@opts[:$filter]}" : '')
|
174
172
|
end
|
175
173
|
|
176
|
-
|
174
|
+
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "entity=#{self.class.connec_entity_name}, fetching data with #{query_params.to_query}")
|
175
|
+
uri = "#{self.class.normalized_connec_entity_name}?#{query_params.to_query}"
|
177
176
|
response_hash = fetch_connec(uri, 0)
|
178
177
|
entities = response_hash["#{self.class.normalized_connec_entity_name}"]
|
179
178
|
entities = [entities] if self.class.singleton?
|
@@ -184,7 +183,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
184
183
|
# ugly way to convert https://api-connec/api/v2/group_id/organizations?next_page_params to /organizations?next_page_params
|
185
184
|
next_page = response_hash['pagination']['next'].gsub(/^(.*)\/#{self.class.normalized_connec_entity_name}/, self.class.normalized_connec_entity_name)
|
186
185
|
|
187
|
-
response_hash = fetch_connec(
|
186
|
+
response_hash = fetch_connec(next_page, page_number)
|
188
187
|
entities << response_hash["#{self.class.normalized_connec_entity_name}"]
|
189
188
|
end
|
190
189
|
|
@@ -325,7 +324,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
325
324
|
connec_id = entity.delete(:__connec_id)
|
326
325
|
|
327
326
|
if entity['id'].blank?
|
328
|
-
idmap = self.class.
|
327
|
+
idmap = self.class.find_or_create_idmap(organization_id: @organization.id, name: self.class.object_name_from_connec_entity_hash(entity), external_entity: external_entity_name.downcase, connec_id: connec_id)
|
329
328
|
next map_connec_entity_with_idmap(entity, external_entity_name, idmap)
|
330
329
|
end
|
331
330
|
|
@@ -492,7 +491,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
492
491
|
raise "No data received from Connec! when trying to fetch page #{page_number} of #{self.class.normalized_connec_entity_name}" unless response && !response.body.blank?
|
493
492
|
|
494
493
|
response_hash = JSON.parse(response.body)
|
495
|
-
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "
|
494
|
+
Maestrano::Connector::Rails::ConnectorLogger.log('debug', @organization, "Received page #{page_number} for entity=#{self.class.connec_entity_name}, response=#{response_hash}")
|
496
495
|
raise "Received unrecognized Connec! data when trying to fetch page #{page_number} of #{self.class.normalized_connec_entity_name}: #{response_hash}" unless response_hash["#{self.class.normalized_connec_entity_name}"]
|
497
496
|
|
498
497
|
response_hash
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maestrano-connector-rails 1.0.
|
5
|
+
# stub: maestrano-connector-rails 1.0.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/release_notes.md
CHANGED
@@ -130,7 +130,7 @@ describe 'connec to the external application' do
|
|
130
130
|
|
131
131
|
it 'does the mapping correctly' do
|
132
132
|
idmap = Entities::ConnecToExternal.create_idmap(organization_id: organization.id, external_id: ext_contact_id, connec_id: "23daf041-e18e-0133-7b6a-15461b913fab")
|
133
|
-
allow(Entities::ConnecToExternal).to receive(:
|
133
|
+
allow(Entities::ConnecToExternal).to receive(:find_or_create_idmap).and_return(idmap)
|
134
134
|
expect_any_instance_of(Entities::ConnecToExternal).to receive(:push_entities_to_external).with([{entity: mapped_entity, idmap: idmap}])
|
135
135
|
subject
|
136
136
|
end
|
data/spec/models/entity_spec.rb
CHANGED
@@ -197,7 +197,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
197
197
|
}
|
198
198
|
|
199
199
|
it 'calls get with a singularize url' do
|
200
|
-
expect(connec_client).to receive(:get).with("
|
200
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase}?")
|
201
201
|
subject.get_connec_entities(nil)
|
202
202
|
end
|
203
203
|
end
|
@@ -210,14 +210,14 @@ describe Maestrano::Connector::Rails::Entity do
|
|
210
210
|
context 'when opts[:full_sync] is true' do
|
211
211
|
let(:opts) { {full_sync: true} }
|
212
212
|
it 'performs a full get' do
|
213
|
-
expect(connec_client).to receive(:get).with("
|
213
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?")
|
214
214
|
subject.get_connec_entities(sync)
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
218
|
context 'when there is no last sync' do
|
219
219
|
it 'performs a full get' do
|
220
|
-
expect(connec_client).to receive(:get).with("
|
220
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?")
|
221
221
|
subject.get_connec_entities(nil)
|
222
222
|
end
|
223
223
|
end
|
@@ -225,7 +225,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
225
225
|
context 'when there is a last sync' do
|
226
226
|
it 'performs a time limited get' do
|
227
227
|
uri_param = {"$filter" => "updated_at gt '#{sync.updated_at.iso8601}'"}.to_query
|
228
|
-
expect(connec_client).to receive(:get).with("
|
228
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?#{uri_param}")
|
229
229
|
subject.get_connec_entities(sync)
|
230
230
|
end
|
231
231
|
end
|
@@ -234,21 +234,21 @@ describe Maestrano::Connector::Rails::Entity do
|
|
234
234
|
it 'support filter option for full sync' do
|
235
235
|
subject.instance_variable_set(:@opts, {full_sync: true, :$filter => "code eq 'PEO12'"})
|
236
236
|
uri_param = {'$filter'=>'code eq \'PEO12\''}.to_query
|
237
|
-
expect(connec_client).to receive(:get).with("
|
237
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?#{uri_param}")
|
238
238
|
subject.get_connec_entities(sync)
|
239
239
|
end
|
240
240
|
|
241
241
|
it 'support filter option for time limited sync' do
|
242
242
|
subject.instance_variable_set(:@opts, {:$filter => "code eq 'PEO12'"})
|
243
243
|
uri_param = {"$filter"=>"updated_at gt '#{sync.updated_at.iso8601}' and code eq 'PEO12'"}.to_query
|
244
|
-
expect(connec_client).to receive(:get).with("
|
244
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?#{uri_param}")
|
245
245
|
subject.get_connec_entities(sync)
|
246
246
|
end
|
247
247
|
|
248
248
|
it 'support orderby option for time limited sync' do
|
249
249
|
subject.instance_variable_set(:@opts, {:$orderby => "name asc"})
|
250
250
|
uri_param = {"$orderby"=>"name asc", "$filter"=>"updated_at gt '#{sync.updated_at.iso8601}'"}.to_query
|
251
|
-
expect(connec_client).to receive(:get).with("
|
251
|
+
expect(connec_client).to receive(:get).with("#{connec_name.downcase.pluralize}?#{uri_param}")
|
252
252
|
subject.get_connec_entities(sync)
|
253
253
|
end
|
254
254
|
end
|
@@ -259,7 +259,8 @@ describe Maestrano::Connector::Rails::Entity do
|
|
259
259
|
}
|
260
260
|
|
261
261
|
it 'calls get multiple times' do
|
262
|
-
expect(connec_client).to receive(:get).
|
262
|
+
expect(connec_client).to receive(:get).with('people?')
|
263
|
+
expect(connec_client).to receive(:get).with('people?%24skip=10&%24top=10')
|
263
264
|
subject.get_connec_entities(nil)
|
264
265
|
end
|
265
266
|
end
|