wolf_core 0.1.73 → 0.1.75

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eea9b9ef51211d95b0cdc5f7f84694a714fb2e5c034e8c493d68766c7dcf1fa9
4
- data.tar.gz: 04e50416cf28a41991ee3696a6cc2f465b8210cf0074b0512ffd1b52fbe13683
3
+ metadata.gz: ccd8da54fe6ce73bf327f86ccfa4b7ea3fd96793833765d21c13ee9a0a571e23
4
+ data.tar.gz: 6d090c26876e5c1a051bb27c30dda66d4094750cc3ee7ace28099a33e0d8a3f0
5
5
  SHA512:
6
- metadata.gz: 42b3c725460128051c813f74f3141f9f57f0aabb095ab03ac754410e5eeb267eec685f115ccc3ab9a0496df7c0013aa449bc1c03e14d538175b6301099f0444e
7
- data.tar.gz: 5f7d2379e3285c23aea4c314917977a29bf095a6db56f513926e1b949480f87774582cef30dab2e2a339f097021be9882e69a2a6767642d0d8ac15f49f120796
6
+ metadata.gz: 89a469e772aaabd6c2571d3db5046b38d847620d155b2ccbc54376188700efdfaed915f14eea3c28ff958b555853bdd580f1eebc788b917c890addffd6c0c2dc
7
+ data.tar.gz: 845569183bfa0a3ff1d9fece60084f27366a2a7f3ced30fdfbf6061d5570bf1ce362bfa25a672a43d88506e95a2dcf3c0ec7db8560762598a2eea97313c66fbe
@@ -21,7 +21,9 @@ module WolfCore
21
21
  'barton/export/credential' => 'BartonExportCredential',
22
22
  'barton/import/credential' => 'BartonImportCredential',
23
23
  'barton/export/reference' => 'BartonExportReference',
24
+ 'barton/import/reference' => 'BartonImportReference',
24
25
  'barton/export/disclosure' => 'BartonExportDisclosure',
26
+ 'barton/import/disclosure' => 'BartonImportDisclosure',
25
27
  }
26
28
 
27
29
  def route_event_request(path:, body:)
@@ -5,11 +5,18 @@ module WolfCore
5
5
  include WolfCore::LoggingUtils
6
6
 
7
7
  def get_foreign_key_destination_id(tenant:, source:, source_id:, destination:)
8
- foreign_keys = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
9
- foreign_key = foreign_keys.find { |fk| fk['destination'] == destination }
8
+ foreign_key = get_foreign_key_by_destination(
9
+ tenant: tenant, source: source, source_id: source_id,
10
+ destination: destination
11
+ )
10
12
  foreign_key&.dig('destination_id')
11
13
  end
12
14
 
15
+ def get_foreign_key_by_destination(tenant:, source:, source_id:, destination:)
16
+ foreign_keys = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
17
+ foreign_keys.find { |fk| fk['destination'] == destination }
18
+ end
19
+
13
20
  def get_foreign_keys(tenant:, source:, source_id:)
14
21
  response = http_get(
15
22
  url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
@@ -65,5 +72,51 @@ module WolfCore
65
72
  )
66
73
  Result.success(data: { operation: :create })
67
74
  end
75
+
76
+ def upsert_foreign_key(tenant:, source:, source_id:, destination:, destination_id:, auth_token:)
77
+ foreign_key = get_foreign_key_by_destination(
78
+ tenant: tenant, source: source, source_id: source_id,
79
+ destination: destination
80
+ )
81
+ if foreign_key.present?
82
+ update_foreign_key(
83
+ tenant: tenant, auth_token: auth_token, uuid: foreign_key['uuid'],
84
+ source: source, source_id: source_id,
85
+ destination: destination, destination_id: destination_id,
86
+ )
87
+ else
88
+ create_foreign_key(
89
+ tenant: tenant, source: source, source_id: source_id,
90
+ destination: destination, destination_id: destination_id
91
+ )
92
+ end
93
+ end
94
+
95
+ def update_foreign_key(tenant:, auth_token:, uuid:, source: nil, source_id: nil, destination: nil, destination_id: nil)
96
+ raise_service_error({ message: 'tenant is required to update a foreign key', tenant: tenant }) if tenant.blank?
97
+ raise_service_error({ message: 'auth_token is required to update a foreign key', auth_token: auth_token }) if auth_token.blank?
98
+ raise_service_error({ message: 'uuid is required to update a foreign key', uuid: uuid }) if uuid.blank?
99
+
100
+ fields_to_update = {
101
+ source: source,
102
+ source_id: source_id,
103
+ destination: destination,
104
+ destination_id: destination_id,
105
+ }.compact
106
+
107
+ raise_service_error({ message: 'At least one field to update is required to update a foreign key', source: source }) if fields_to_update.blank?
108
+
109
+ response = safe_http_put(
110
+ url: "#{ENV['FKM_URL']}/Prod/create",
111
+ body: {
112
+ tenant: tenant,
113
+ authentication_token: auth_token,
114
+ uuid: uuid,
115
+ }.merge(fields_to_update),
116
+ title: 'update_foreign_key response is',
117
+ error_message: 'Error updating foreign key',
118
+ )
119
+ response.body
120
+ end
68
121
  end
69
122
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.73"
4
+ VERSION = "0.1.75"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolf_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.73
4
+ version: 0.1.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty