wolf_core 0.1.6 → 0.1.8

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
  SHA256:
3
- metadata.gz: c7b89730ba4b46f7e4203c32de5f39c2c61d6a8da53724fbd5f362f997edb57e
4
- data.tar.gz: 7b46d6230f52fce6d921cae357140c4ad0a6b912be621fe09b7f0861d221db1e
3
+ metadata.gz: 528a60641dfb2e5ebbef08b651c0bc1cdfa1cf331f8363dc3891b55d123ee0c5
4
+ data.tar.gz: 16cfdf72aacaa1392589e86a2192bbca45461db381059a27668b1e6c4467ed9d
5
5
  SHA512:
6
- metadata.gz: 2c65138e6490c696d1b168e554f82e9c1474802f88c3adc24f623ea0c3bf912bb6a8a9d7850df07aeb479819bb7d0890c7526a8a31fb54273bc89f5bae610ac6
7
- data.tar.gz: 3ab48059727122632646efd86ba64a974ae3b939e5aa5c6f102dd272f9f367a74d881a416c323203f5af17ed159266e254beb3379878b8bf50ed6d1fc0f6d438
6
+ metadata.gz: a6a6ed0cfbe69cfefbb9bb052c291444d2179e89c5dc75dbe78c86493f984048e6667397d3e033781f4ccaf01c7b76263add88baaed4400e437cc07b65727ec0
7
+ data.tar.gz: 34c7af4cdf39488b6ba043a02a78bcaf598e1d835f892b82aed39fbb283746d187f496983d08904b6decccd1c80c22aaa8b327b3c4489c3eb01b55e09e2852e0
@@ -3,17 +3,49 @@ module WolfCore
3
3
  include WolfCore::HttpOperations
4
4
 
5
5
  def get_foreign_key_destination_id(tenant:, source:, source_id:, destination:)
6
- response_body = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
7
- foreign_keys = response_body
8
- foreign_keys.find { |fk| fk['destination'] == destination }&.dig('destination_id')
6
+ foreign_keys = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
7
+ foreign_key = foreign_keys.find { |fk| fk['destination'] == destination }
8
+ foreign_key&.dig('destination_id')
9
9
  end
10
10
 
11
11
  def get_foreign_keys(tenant:, source:, source_id:)
12
12
  response = http_get(
13
13
  url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
14
14
  )
15
+ puts 'foreign keys response is'
16
+ pp response
15
17
  validate_http_response(response: response, message: 'Error getting foreign keys')
16
18
  parse_http_response(response).body
17
19
  end
20
+
21
+ def create_foreign_key(tenant:, source:, source_id:, destination:, destination_id:)
22
+ response = http_post(
23
+ url: "#{ENV['FKM_URL']}/Prod/create",
24
+ body: {
25
+ tenant: tenant,
26
+ source: source,
27
+ source_id: source_id,
28
+ destination: destination,
29
+ destination_id: destination_id
30
+ }
31
+ )
32
+ puts 'create foreign key response is'
33
+ pp response
34
+ validate_http_response(response: response, message: 'Error creating foreign key')
35
+ parse_http_response(response).body
36
+ end
37
+
38
+ # def find_or_create_foreign_key(tenant:, source:, source_id:, destination:, destination_id:)
39
+ # destination_id = get_foreign_key_destination_id(
40
+ # tenant: tenant, source: source, source_id: source_id,
41
+ # destination: destination
42
+ # )
43
+ # return Result.success(data: { operation: :find }) if destination_id.present?
44
+ # create_foreign_key(
45
+ # tenant: tenant, source: source, source_id: source_id,
46
+ # destination: destination, destination_id: destination_id
47
+ # )
48
+ # Result.success(data: { operation: :create })
49
+ # end
18
50
  end
19
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.8"
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.6
4
+ version: 0.1.8
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-07-09 00:00:00.000000000 Z
11
+ date: 2024-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty