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: e857fececce75be28dbb9c7b04d0fb0b1dbc888b
4
- data.tar.gz: 1a5e21c86c3848d8c352e93cacff1b7a59258177
3
+ metadata.gz: 4b5dba94b691f6b3af1ac41b6a7d0398ee5396af
4
+ data.tar.gz: dc4611f5da086cff9fc297b0d0d0eba7aa4e5c8d
5
5
  SHA512:
6
- metadata.gz: 1d840af38306358956d6c6bcb1af17683563c1bae227fc1d03b91bdc6864b21304d2a01d1939ad50aa09466a3fe214c35b7377c3c25d1e11ff17ff4dab3ad091
7
- data.tar.gz: 34d928a71801a4f1dd7bd80e640f112af27a544439e2a96460e116636db7324f76640f277c956fa1c4930721e8489dc591b7013d93fa2c4607d370f24ebe1486
6
+ metadata.gz: 4b2683f1f4283965f1f4a4c81be839aaa72d734432aa6246d21d2dbf15e90be0161d11a8e863584863531c15af823a2375f38acd667a212733793d47fc32ad57
7
+ data.tar.gz: d7931fb298a3b542c4a9878ccb6e5b2969efa4b67eb11c47aef601b50ff681d3539d013ed25e3934c129f55a9bb3b992a269fa81e7031fe75c8dbbda5e5f7088
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
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
- uri = "/#{self.class.normalized_connec_entity_name}?#{query_params.to_query}"
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(uri, page_number)
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.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)
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, "received first page entity=#{self.class.connec_entity_name}, response=#{response_hash}")
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.3 ruby lib
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.3"
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
@@ -1,3 +1,8 @@
1
+ ## 1.0.3
2
+
3
+ ### Fixes
4
+ * Fix an issue with options that were involuntarily shared across entities
5
+
1
6
  ## 1.0.2
2
7
 
3
8
  ### Fixes
@@ -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(:create_idmap).and_return(idmap)
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
@@ -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("/#{connec_name.downcase}?")
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("/#{connec_name.downcase.pluralize}?")
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("/#{connec_name.downcase.pluralize}?")
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("/#{connec_name.downcase.pluralize}?#{uri_param}")
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("/#{connec_name.downcase.pluralize}?#{uri_param}")
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("/#{connec_name.downcase.pluralize}?#{uri_param}")
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("/#{connec_name.downcase.pluralize}?#{uri_param}")
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).twice
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Berard