wolf_core 1.0.9 → 1.0.11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1695b9abff3f7107b73cf372f8738d80211f21ba4fc5d3b5356b4f72308be859
|
4
|
+
data.tar.gz: baa798c8642f7df27c60199445b9e5834d49a75f6cb0f5e03ab1c032206280b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf06d9fcda3da1740172d0f788091dce1568560bfdd93970636828530d9ee6830ff53357e6bdc8d4cd2a5a0d39bd9af5f28b1c74827ec3be3123933580815254
|
7
|
+
data.tar.gz: ca34d60088accb6c9e9373280736521b47a34226231de8ddb451949d3be48c1ffe4bebf8ee3246fc32fb2f8861fcb59799b6a5aa5b50f7dd4ae4ca90672ef1d4
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module WolfCore
|
2
|
+
module Integrations
|
3
|
+
module ClientApiOperations
|
4
|
+
include WolfCore::HttpOperations
|
5
|
+
|
6
|
+
def fetch_client!(wolf_token:, client_id:, tenant:, wolf_platform_url:, error_message:)
|
7
|
+
response = safe_http_get(
|
8
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
9
|
+
url: "#{wolf_platform_url}/api/v2/clients/#{client_id}",
|
10
|
+
query: { tenant: tenant },
|
11
|
+
error_message: error_message
|
12
|
+
)
|
13
|
+
response_body = response.body
|
14
|
+
response_body.dig("data", "table", "client")
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_client(wolf_token:, client_id:, tenant:, wolf_platform_url:)
|
18
|
+
response = parsed_http_get(
|
19
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
20
|
+
url: "#{wolf_platform_url}/api/v2/clients/#{client_id}",
|
21
|
+
query: { tenant: tenant }
|
22
|
+
)
|
23
|
+
response_body = response.body
|
24
|
+
return unless response_body.instance_of?(Hash)
|
25
|
+
|
26
|
+
response_body.dig("data", "table", "client")
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_client!(wolf_token:, client:, tenant:, wolf_platform_url:, error_message:)
|
30
|
+
safe_http_post(
|
31
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
32
|
+
query: { tenant: tenant },
|
33
|
+
url: "#{wolf_platform_url}/api/v2/clients",
|
34
|
+
body: client,
|
35
|
+
error_message: error_message
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_client(wolf_token:, client:, tenant:, wolf_platform_url:)
|
40
|
+
parsed_http_post(
|
41
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
42
|
+
query: { tenant: tenant },
|
43
|
+
url: "#{wolf_platform_url}/api/v2/clients",
|
44
|
+
body: client
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_client!(wolf_token:, client:, tenant:, wolf_platform_url:, error_message:, client_id:)
|
49
|
+
safe_http_put(
|
50
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
51
|
+
query: { tenant: tenant },
|
52
|
+
url: "#{wolf_platform_url}/api/v2/clients/#{client_id}",
|
53
|
+
body: client,
|
54
|
+
error_message: error_message
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def update_client(wolf_token:, client:, tenant:, wolf_platform_url:, client_id:)
|
59
|
+
parsed_http_put(
|
60
|
+
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
61
|
+
query: { tenant: tenant },
|
62
|
+
url: "#{wolf_platform_url}/api/v2/clients/#{client_id}",
|
63
|
+
body: client
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -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(
|
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[
|
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[
|
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:
|
26
|
-
validate_http_response(response: response, message:
|
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[
|
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:
|
36
|
-
validate_http_response(response: response, message:
|
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:
|
42
|
-
raise_service_error({ message:
|
43
|
-
|
44
|
-
|
45
|
-
|
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[
|
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:
|
58
|
-
validate_http_response(response: response, message:
|
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[
|
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,
|
96
|
-
|
97
|
-
raise_service_error({ message:
|
98
|
-
|
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
|
-
|
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:
|
131
|
+
log_object body, title: "update_foreign_key body is"
|
115
132
|
|
116
133
|
response = safe_http_put(
|
117
|
-
url: "#{ENV[
|
134
|
+
url: "#{ENV["FKM_URL"]}/Prod/update",
|
118
135
|
body: body,
|
119
|
-
title:
|
120
|
-
error_message:
|
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
|
data/lib/wolf_core/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.11
|
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-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/wolf_core/application/burnett/positions_operations/positions_operations.rb
|
99
99
|
- lib/wolf_core/application/exception_operations.rb
|
100
100
|
- lib/wolf_core/application/integrations/change_detection.rb
|
101
|
+
- lib/wolf_core/application/integrations/client_api_operations.rb
|
101
102
|
- lib/wolf_core/application/integrations/jobseeker_api_operations.rb
|
102
103
|
- lib/wolf_core/application/integrations/orders_api_operations.rb
|
103
104
|
- lib/wolf_core/application/integrations/routing_operations.rb
|