wolf_core 1.0.76 → 1.0.78
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: 3cdf821478350d9768fad37e18e71dcfd64ffded145ead6b2a645ea76fadb35a
|
4
|
+
data.tar.gz: f177d7981e5a4408cee5050604502d8f96889a66bb139e035de3e9482e17297e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b45bf02cc38386e06bd132b02131328832cc0abad5d92ea24fe93de0f02d130964d94bf28b9edf3935b7dcec37cd5c12a31f16cf4f3c48602a82c8be8932ab1c
|
7
|
+
data.tar.gz: 391da00769556cf83144db1b53a139a6b9c5bd10ac8ba27ab24b4f8f6cbe47084e04501d8dac5f9ee2c98f5c538d159bceaa5e6a347b7bff8a00a2970c66b0e8
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WolfCore
|
2
4
|
module Integrations
|
3
5
|
module CustomValueApiOperations
|
@@ -23,7 +25,8 @@ module WolfCore
|
|
23
25
|
)
|
24
26
|
end
|
25
27
|
|
26
|
-
def fetch_custom_value!(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, error_message:,
|
28
|
+
def fetch_custom_value!(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, error_message:,
|
29
|
+
error_data: nil, query: nil)
|
27
30
|
response = fetch_custom_value(
|
28
31
|
wolf_token: wolf_token,
|
29
32
|
custom_value_id: custom_value_id,
|
@@ -44,30 +47,33 @@ module WolfCore
|
|
44
47
|
)
|
45
48
|
end
|
46
49
|
|
47
|
-
def create_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:,
|
50
|
+
def create_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:,
|
51
|
+
custom_requirement_id:, error_data: nil, query: nil)
|
48
52
|
response = create_custom_value(
|
49
53
|
wolf_token: wolf_token,
|
50
54
|
custom_value: custom_value,
|
51
55
|
tenant: tenant,
|
52
56
|
wolf_platform_url: wolf_platform_url,
|
53
|
-
|
57
|
+
custom_requirement_id: custom_requirement_id,
|
54
58
|
query: query
|
55
59
|
)
|
56
60
|
validate_http_response(response: response, message: error_message, error_data: error_data)
|
57
61
|
response
|
58
62
|
end
|
59
63
|
|
60
|
-
def create_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:,
|
64
|
+
def create_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_requirement_id:,
|
65
|
+
query: nil)
|
61
66
|
query ||= {}
|
62
67
|
parsed_http_post(
|
63
68
|
headers: { "Authorization" => "Bearer #{wolf_token}" },
|
64
69
|
query: query.merge(tenant: tenant),
|
65
|
-
url: "#{wolf_platform_url}/api/v2/custom_requirements/#{
|
70
|
+
url: "#{wolf_platform_url}/api/v2/custom_requirements/#{custom_requirement_id}/custom_values",
|
66
71
|
body: custom_value
|
67
72
|
)
|
68
73
|
end
|
69
74
|
|
70
|
-
def update_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:,
|
75
|
+
def update_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:,
|
76
|
+
custom_value_id:, error_data: nil, query: nil)
|
71
77
|
response = update_custom_value(
|
72
78
|
wolf_token: wolf_token,
|
73
79
|
custom_value: custom_value,
|
@@ -89,6 +95,75 @@ module WolfCore
|
|
89
95
|
body: custom_value
|
90
96
|
)
|
91
97
|
end
|
98
|
+
|
99
|
+
def upsert_custom_value!(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:,
|
100
|
+
error_message:, error_data: nil)
|
101
|
+
response = fetch_custom_values(
|
102
|
+
wolf_token: wolf_token,
|
103
|
+
tenant: tenant,
|
104
|
+
wolf_platform_url: wolf_platform_url,
|
105
|
+
query: query
|
106
|
+
)
|
107
|
+
validate_http_response(response: response, message: error_message, error_data: error_data)
|
108
|
+
custom_values = response.body.dig("data", "table", "custom_values")
|
109
|
+
|
110
|
+
if custom_values&.any?
|
111
|
+
custom_value_id = custom_values.first["id"]
|
112
|
+
update_custom_value!(
|
113
|
+
wolf_platform_url: wolf_platform_url,
|
114
|
+
tenant: tenant,
|
115
|
+
wolf_token: wolf_token,
|
116
|
+
custom_value_id: custom_value_id,
|
117
|
+
custom_value: custom_value,
|
118
|
+
error_message: error_message,
|
119
|
+
error_data: error_data
|
120
|
+
)
|
121
|
+
else
|
122
|
+
create_custom_value!(
|
123
|
+
wolf_platform_url: wolf_platform_url,
|
124
|
+
tenant: tenant,
|
125
|
+
wolf_token: wolf_token,
|
126
|
+
custom_requirement_id: custom_requirement_id,
|
127
|
+
custom_value: custom_value,
|
128
|
+
error_message: error_message,
|
129
|
+
error_data: error_data
|
130
|
+
)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def upsert_custom_value(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:, error_message:, error_data: nil)
|
135
|
+
response = fetch_custom_values(
|
136
|
+
wolf_token: wolf_token,
|
137
|
+
tenant: tenant,
|
138
|
+
wolf_platform_url: wolf_platform_url,
|
139
|
+
query: query
|
140
|
+
)
|
141
|
+
|
142
|
+
return response unless response_success?(response)
|
143
|
+
|
144
|
+
custom_values = response.body.dig("data", "table", "custom_values")
|
145
|
+
|
146
|
+
if custom_values&.any?
|
147
|
+
custom_value_id = custom_values.first["id"]
|
148
|
+
update_response = update_custom_value(
|
149
|
+
wolf_platform_url: wolf_platform_url,
|
150
|
+
tenant: tenant,
|
151
|
+
wolf_token: wolf_token,
|
152
|
+
custom_value_id: custom_value_id,
|
153
|
+
custom_value: custom_value,
|
154
|
+
query: query
|
155
|
+
)
|
156
|
+
else
|
157
|
+
create_response = create_custom_value(
|
158
|
+
wolf_platform_url: wolf_platform_url,
|
159
|
+
tenant: tenant,
|
160
|
+
wolf_token: wolf_token,
|
161
|
+
custom_requirement_id: custom_requirement_id,
|
162
|
+
custom_value: custom_value,
|
163
|
+
query: query
|
164
|
+
)
|
165
|
+
end
|
166
|
+
end
|
92
167
|
end
|
93
168
|
end
|
94
169
|
end
|
data/lib/wolf_core/version.rb
CHANGED