wolf_core 1.0.9 → 1.0.10

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: 82a7cb08945e955a025445c25fc2ef2e870ee862f554c5cc605236cfe765932c
4
- data.tar.gz: c48627a923a8305923f751ea1b6204ef1ccb9976e42cb4a7071ff9ffb619fa1f
3
+ metadata.gz: 1fc74c77d74d46328ceaeaa05d8f0bfe2339c5eb8f9c37f781d8a88b4547d5d9
4
+ data.tar.gz: 991c1049dd50452777267fdee8edef2c5491c80883c3901bd0313399456838ac
5
5
  SHA512:
6
- metadata.gz: 9ed382ab307462e355acef58096444cd29d5d762625e8ff49d447e0c529cf11f1a772d4ebb9876a3a58817210fb8fa1ad1b567614939ed28902bd1b45718054b
7
- data.tar.gz: 62bca4dbf76087e2e03e0a021a5a95355de8d55efd85da1bcdeec9dcefb4c59bcc41dbc816584e487e9ed4cd6c5f0c76ba2352cf3ace97c4d72a134978a9c39c
6
+ metadata.gz: e0fdea166f2c88f7294dde457d39194990cdc8750df848ece6056e0830a0020c68e908eb31d91fa5e5b6dc60d8f45caecf0bde0665ef3be58201b66d92e16a2f
7
+ data.tar.gz: a0fcaf4480c92f1d0553e88cbfd65372957ed0e47450fa49c73c9f73ecfdd65b2a824cacb205552faf78c95adbf8bec97beef47a8595520c175c5db48ce1c64c
@@ -9,42 +9,51 @@ module WolfCore
9
9
  tenant: tenant, source: source, source_id: source_id,
10
10
  destination: destination
11
11
  )
12
- foreign_key&.dig('destination_id')
12
+ foreign_key&.dig("destination_id")
13
13
  end
14
14
 
15
15
  def get_foreign_key_by_destination(tenant:, source:, source_id:, destination:)
16
16
  foreign_keys = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
17
- foreign_keys.find { |fk| fk['destination'] == destination }
17
+ foreign_keys.find { |fk| fk["destination"] == destination }
18
18
  end
19
19
 
20
20
  def get_foreign_keys(tenant:, source:, source_id:)
21
21
  response = http_get(
22
- url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
22
+ url: "#{ENV["FKM_URL"]}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
23
23
  )
24
24
  response = parse_http_response(response)
25
- log_object response, title: 'get_foreign_keys response is'
26
- validate_http_response(response: response, message: 'Error getting foreign keys')
25
+ log_object response, title: "get_foreign_keys response is"
26
+ validate_http_response(response: response, message: "Error getting foreign keys")
27
27
  response.body
28
28
  end
29
29
 
30
30
  def get_foreign_keys_by_destination(tenant:, destination:, destination_id:)
31
31
  response = http_get(
32
- url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&destination=#{destination}&destination_id=#{destination_id}"
32
+ url: "#{ENV["FKM_URL"]}/Prod/lookup?tenant=#{tenant}&destination=#{destination}&destination_id=#{destination_id}"
33
33
  )
34
34
  response = parse_http_response(response)
35
- log_object response, title: 'get_foreign_keys_by_destination response is'
36
- validate_http_response(response: response, message: 'Error getting foreign keys by destination id')
35
+ log_object response, title: "get_foreign_keys_by_destination response is"
36
+ validate_http_response(response: response, message: "Error getting foreign keys by destination id")
37
37
  response.body
38
38
  end
39
39
 
40
40
  def create_foreign_key(tenant:, source:, source_id:, destination:, destination_id:)
41
- raise_service_error({ message: 'tenant is required to create a foreign key', tenant: tenant }) if tenant.blank?
42
- raise_service_error({ message: 'source is required to create a foreign key', source: source }) if source.blank?
43
- raise_service_error({ message: 'source_id is required to create a foreign key', source_id: source_id }) if source_id.blank?
44
- raise_service_error({ message: 'destination is required to create a foreign key', destination: destination }) if destination.blank?
45
- raise_service_error({ message: 'destination_id is required to create a foreign key', destination_id: destination_id }) if destination_id.blank?
41
+ raise_service_error({ message: "tenant is required to create a foreign key", tenant: tenant }) if tenant.blank?
42
+ raise_service_error({ message: "source is required to create a foreign key", source: source }) if source.blank?
43
+ if source_id.blank?
44
+ raise_service_error({ message: "source_id is required to create a foreign key",
45
+ source_id: source_id })
46
+ end
47
+ if destination.blank?
48
+ raise_service_error({ message: "destination is required to create a foreign key",
49
+ destination: destination })
50
+ end
51
+ if destination_id.blank?
52
+ raise_service_error({ message: "destination_id is required to create a foreign key",
53
+ destination_id: destination_id })
54
+ end
46
55
  response = http_post(
47
- url: "#{ENV['FKM_URL']}/Prod/create",
56
+ url: "#{ENV["FKM_URL"]}/Prod/create",
48
57
  body: {
49
58
  tenant: tenant,
50
59
  source: source,
@@ -54,8 +63,8 @@ module WolfCore
54
63
  }
55
64
  )
56
65
  response = parse_http_response(response)
57
- log_object response, title: 'create_foreign_key response is'
58
- validate_http_response(response: response, message: 'Error creating foreign key')
66
+ log_object response, title: "create_foreign_key response is"
67
+ validate_http_response(response: response, message: "Error creating foreign key")
59
68
  parse_http_response(response).body
60
69
  end
61
70
 
@@ -66,6 +75,7 @@ module WolfCore
66
75
  )
67
76
  log_object "find_or_create_foreign_key found_destination_id is #{found_destination_id}"
68
77
  return Result.success(data: { operation: :find }) if found_destination_id.present?
78
+
69
79
  create_foreign_key(
70
80
  tenant: tenant, source: source, source_id: source_id,
71
81
  destination: destination, destination_id: destination_id
@@ -80,9 +90,9 @@ module WolfCore
80
90
  )
81
91
  if foreign_key.present?
82
92
  update_foreign_key(
83
- tenant: tenant, auth_token: auth_token, uuid: foreign_key['uuid'],
93
+ tenant: tenant, auth_token: auth_token, uuid: foreign_key["uuid"],
84
94
  source: source, source_id: source_id,
85
- destination: destination, destination_id: destination_id,
95
+ destination: destination, destination_id: destination_id
86
96
  )
87
97
  else
88
98
  create_foreign_key(
@@ -92,34 +102,41 @@ module WolfCore
92
102
  end
93
103
  end
94
104
 
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?
105
+ def update_foreign_key(tenant:, auth_token:, uuid:, source: nil, source_id: nil, destination: nil,
106
+ destination_id: nil)
107
+ raise_service_error({ message: "tenant is required to update a foreign key", tenant: tenant }) if tenant.blank?
108
+ if auth_token.blank?
109
+ raise_service_error({ message: "auth_token is required to update a foreign key",
110
+ auth_token: auth_token })
111
+ end
112
+ raise_service_error({ message: "uuid is required to update a foreign key", uuid: uuid }) if uuid.blank?
99
113
 
100
114
  fields_to_update = {
101
115
  source: source,
102
116
  source_id: source_id,
103
117
  destination: destination,
104
- destination_id: destination_id,
118
+ destination_id: destination_id
105
119
  }.compact
106
120
 
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?
121
+ if fields_to_update.blank?
122
+ raise_service_error({ message: "At least one field to update is required to update a foreign key",
123
+ source: source })
124
+ end
108
125
 
109
126
  body = {
110
127
  tenant: tenant,
111
128
  authentication_token: auth_token,
112
- uuid: uuid,
129
+ uuid: uuid
113
130
  }.merge(fields_to_update)
114
- log_object body, title: 'update_foreign_key body is'
131
+ log_object body, title: "update_foreign_key body is"
115
132
 
116
133
  response = safe_http_put(
117
- url: "#{ENV['FKM_URL']}/Prod/update",
134
+ url: "#{ENV["FKM_URL"]}/Prod/update",
118
135
  body: body,
119
- title: 'update_foreign_key response is',
120
- error_message: 'Error updating foreign key',
136
+ title: "update_foreign_key response is",
137
+ error_message: "Error updating foreign key"
121
138
  )
122
139
  response.body
123
140
  end
124
141
  end
125
- end
142
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.0.9"
4
+ VERSION = "1.0.10"
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: 1.0.9
4
+ version: 1.0.10
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-10-26 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty