wolf_core 1.0.76 → 1.0.77

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: 4131957142188d7ccc2d55ddff26bc2e870be3d2f24dc2de1a8b967781732b90
4
- data.tar.gz: c66613acbdb12d9943f311bb9704609e4b4ff69b828c7fb495d5bb7117590e66
3
+ metadata.gz: 78299938906476e29c333da5adb6b67feca648350340bdde8aa3934d03a7f744
4
+ data.tar.gz: 49428fc05ee308e5b6e4f8421f9e98975f5648561182cc22b2987356b75b03c5
5
5
  SHA512:
6
- metadata.gz: a6b3abdff7a68bddd11cb97e58e3f75dbc0814293bd8d095217e95ee49bcac6feaa5a74c6bfd2b0ba6a229aedcb65fa2e35b6b6c0a1b45ddb2a57cf45180478d
7
- data.tar.gz: f7142d372a4147716a75a96913a7a91067bf1f772aef5cf393410a051140e44059be588d5c61a977d1250e5007ff0b2284670a46b7eae0ab71476b7dea8c1d7b
6
+ metadata.gz: 1a6db374f67ce4c6ed4847ebac8b333d6dc1d9e44b14d8c67980694beacdf9bdafe2f4b796f648ece803241195a09c5a723f870f6ad87917ddb97057a9da1e2f
7
+ data.tar.gz: 1c81b0487da6230c39896c8eb6393ee817e3e9587e97c026056ec4afd804ec4e118a408dec3806d008f9d69f5e3db00a98ebb58b2f8ee5fa467956e681cb5134
@@ -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:, error_data: nil, query: nil)
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:, custom_requirements_id:, error_data: nil, query: nil)
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
- custom_requirements_id: custom_requirements_id,
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:, custom_requirements_id:, query: nil)
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/#{custom_requirements_id}/custom_values",
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:, custom_value_id:, error_data: nil, query: nil)
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,41 @@ 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
92
133
  end
93
134
  end
94
135
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.0.76"
4
+ VERSION = "1.0.77"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolf_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.76
4
+ version: 1.0.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo