wolf_core 1.1.18 → 1.1.19

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: e7902f57aef2702eebecbaed2c0d1440e5d240794d9aada38418188f901a19e5
4
- data.tar.gz: 49197fe42dee0f101d30a7cc33fa7410253291deb1a2126533600f49edf08e5c
3
+ metadata.gz: b0fe4cb5e85ecc712aa3a2625fbbbf5b7ded94f0fabef91d7ea4ca5bcd0d0307
4
+ data.tar.gz: fda66823c4d880b772e7da73862134c34111edae03cb4d492be573016ac62ef8
5
5
  SHA512:
6
- metadata.gz: 6f928e6b894e78ba52b7eef72bdbbab416884ec4449cfd0dc4bc07c62dbfb4efd7f1540ed91b625f609d9fc5451fc4eba16dec4049c94a3c71faf6495d009d40
7
- data.tar.gz: aa7daf76e407ff4ed29677fbd7f116bfb4405cefb8b392aef3288ee73a15963c784a5cf42b93222374d245d4ee7d902c887cf4fc0f37db08da823553ec619f9a
6
+ metadata.gz: e168ba53069007c54145bf43440b09fd918b86ebedb1c9c6b541eada9ae7cdc7db511ab3e493e4a26d21d6e47e58812dcfa454376daaabc28b8f86fb0300c1f7
7
+ data.tar.gz: 4159d44682c64b8e1291bad9cd6c3fc1ca5c1f44f7591af116fd999f954b5f225abeed64ba6ca0268a703266a639d7eaa2172d3aa80e2bac3151ededfb8cfd87
@@ -0,0 +1,75 @@
1
+ module WolfCore
2
+ module Integrations
3
+ module ContractApiOperations
4
+ include WolfCore::HttpOperations
5
+
6
+ CONTRACT_ID_REGEX = /.*-(\d+)-(\d+)/
7
+
8
+ def fetch_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, error_message:, error_data: nil, query: nil)
9
+ response = fetch_contract(
10
+ wolf_token: wolf_token,
11
+ tenant: tenant,
12
+ wolf_platform_url: wolf_platform_url,
13
+ contract_id: contract_id,
14
+ query: query
15
+ )
16
+ order_id, jobseeker_id = extract_ids_from_contract_id(contract_id)
17
+ error_data ||= {}
18
+ validate_http_response(
19
+ response: response,
20
+ message: error_message,
21
+ error_data: error_data.merge(contract_id: contract_id, order_id: order_id, jobseeker_id: jobseeker_id, query: query)
22
+ )
23
+ response.body.dig("data", "table", "contract")
24
+ end
25
+
26
+ def fetch_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, query: nil)
27
+ order_id, jobseeker_id = extract_ids_from_contract_id(contract_id)
28
+ query ||= {}
29
+ parsed_http_get(
30
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
31
+ url: "#{wolf_platform_url}/api/v2/contracts/#{order_id}/#{jobseeker_id}",
32
+ query: query.merge(tenant: tenant)
33
+ )
34
+ end
35
+
36
+ def update_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:, error_message:, error_data: nil)
37
+ response = update_contract(
38
+ wolf_token: wolf_token,
39
+ tenant: tenant,
40
+ wolf_platform_url: wolf_platform_url,
41
+ contract_id: contract_id,
42
+ contract: contract
43
+ )
44
+ order_id, jobseeker_id = extract_ids_from_contract_id(contract_id)
45
+ error_data ||= {}
46
+ validate_http_response(
47
+ response: response,
48
+ message: error_message,
49
+ error_data: error_data.merge(contract_id: contract_id, order_id: order_id, jobseeker_id: jobseeker_id, contract: contract)
50
+ )
51
+ response
52
+ end
53
+
54
+ def update_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:)
55
+ order_id, jobseeker_id = extract_ids_from_contract_id(contract_id)
56
+ parsed_http_put(
57
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
58
+ url: "#{wolf_platform_url}/api/v2/contracts/#{order_id}/#{jobseeker_id}",
59
+ query: { tenant: tenant },
60
+ body: contract
61
+ )
62
+ end
63
+
64
+ private
65
+
66
+ def extract_ids_from_contract_id(contract_id)
67
+ match = contract_id.match(CONTRACT_ID_REGEX)
68
+ raise_service_error(message: "Invalid contract_id format", data: { contract_id: contract_id }) unless match
69
+ order_id = match[1]
70
+ jobseeker_id = match[2]
71
+ [order_id, jobseeker_id]
72
+ end
73
+ end
74
+ end
75
+ end
@@ -22,15 +22,15 @@ module WolfCore
22
22
  end
23
23
  end
24
24
 
25
- def schedule_recurring(job_id:, schedule:, target:, config: {})
26
- Result.try do
27
- expr = expression_from_schedule!(schedule)
28
- normalized_target = normalize_target(target)
29
- response = schedule_with_expression(job_id: job_id, expr: expr, target: normalized_target,
30
- config: config)
31
- Result.success(data: { response: response })
32
- end
25
+ def schedule_recurring(job_id:, schedule:, target:, config: {})
26
+ Result.try do
27
+ expr = expression_from_schedule!(schedule)
28
+ normalized_target = normalize_target(target)
29
+ response = schedule_with_expression(job_id: job_id, expr: expr, target: normalized_target,
30
+ config: config)
31
+ Result.success(data: { response: response })
33
32
  end
33
+ end
34
34
 
35
35
  def cancel_schedule(job_id:, options: {})
36
36
  Result.try do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.1.18"
4
+ VERSION = "1.1.19"
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.1.18
4
+ version: 1.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo
@@ -123,6 +123,7 @@ files:
123
123
  - lib/wolf_core/application/exception_operations.rb
124
124
  - lib/wolf_core/application/integrations/change_detection.rb
125
125
  - lib/wolf_core/application/integrations/client_api_operations.rb
126
+ - lib/wolf_core/application/integrations/contract_api_operations.rb
126
127
  - lib/wolf_core/application/integrations/custom_value_api_operations.rb
127
128
  - lib/wolf_core/application/integrations/environment_operations.rb
128
129
  - lib/wolf_core/application/integrations/iterate_orders_service.rb