app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-1.0.1 vs app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-1.0.2
- old
+ new
@@ -242,11 +242,11 @@
push_entity_to_external(mapped_connec_entity_with_idmap, external_entity_name)
}.compact
unless ids_to_send_to_connec.empty?
# Send the external ids to connec if it was a creation
- proc = lambda{|id| batch_op('put', {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(id[:external_id], @organization)]}, id[:connec_id], self.class.normalize_connec_entity_name(self.class.connec_entity_name)) }
+ proc = lambda{|id| batch_op('put', {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(id[:idmap].external_id, @organization)]}, id[:idmap].connec_id, self.class.normalize_connec_entity_name(self.class.connec_entity_name)) }
batch_calls(ids_to_send_to_connec, proc, self.class.connec_entity_name, true)
end
end
@@ -255,24 +255,24 @@
mapped_connec_entity = mapped_connec_entity_with_idmap[:entity]
begin
# Create and return id to send to connec!
if idmap.external_id.blank?
- connec_id = mapped_connec_entity_with_idmap[:idmap].connec_id
+ connec_id = idmap.connec_id
external_id = create_external_entity(mapped_connec_entity, external_entity_name)
idmap.update(external_id: external_id, last_push_to_external: Time.now, message: nil)
- return {connec_id: connec_id, external_id: external_id, idmap: idmap}
+ return {idmap: idmap}
# Update
else
return unless self.class.can_update_external?
update_external_entity(mapped_connec_entity, idmap.external_id, external_entity_name)
# Return the id to send it to connec! if the first push of a singleton
if self.class.singleton? && idmap.last_push_to_external.nil?
connec_id = mapped_connec_entity_with_idmap[:idmap].connec_id
idmap.update(last_push_to_external: Time.now, message: nil)
- return {connec_id: connec_id, external_id: idmap.external_id}
+ return {idmap: idmap}
else
idmap.update(last_push_to_external: Time.now, message: nil)
end
end
\ No newline at end of file