wolf_core 0.1.99 → 0.2.1

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: 8d2f944616b25d134e6589f0dbfcb8fd909a27dfb881cfd78eb9b76e264f900c
4
- data.tar.gz: d6644bfec1886500d96906243f1429e6d28145fc19dd3e419826309122b243c5
3
+ metadata.gz: 5a1f0b2966c7b61301a3801b584e0c47c30d33dc41da57544a9d0ae62b40d352
4
+ data.tar.gz: 4983824766da8cf8322d6ca4f4f16e16683cc829718e4ef6a21d973ab2520c5e
5
5
  SHA512:
6
- metadata.gz: afef89f59ffb52ca6dee4b5a9a5a8baf1d281ac609702c472f7e048de8d57472439b4c82fe5800aec86f1e7790b6ad9fa0c800adfb507482aad1bc49cbefd447
7
- data.tar.gz: f0f4f40b589361933bf7a7f2f5df41f7bc4e6f1ade3f3872d10b6fa10bf508b8d0fc989e2892bd1454f6345c8dc04b4e5bf40fb6fbba8d3e4ed63d39db4456d4
6
+ metadata.gz: c766631f0310e07308c84719fc7963e79d37e4cef422fb5f1f0ba62d346f4c8c4d011abe7dfcd87d243c84e2bb27b0bf27fbeb7afdbac11477466270d258ae4b
7
+ data.tar.gz: bcb84ab0f42910f4af5fd3ab074009db17385e12db30a3079f225ad001b556d6584c2d0d998125401a4286c0ffb0bd6e3ca18fc73811da3e5c4e0881c2a2d0ae
@@ -0,0 +1,27 @@
1
+ module WolfCore
2
+ module Burnett
3
+ module Mappings
4
+ JOB_TYPE_MAPPING = {
5
+ '144' => '26',
6
+ '145' => '30',
7
+ '153' => '24',
8
+ '152' => '28',
9
+ '155' => '12',
10
+ '156' => '22',
11
+ '150' => '27',
12
+ '148' => '31',
13
+ '158' => '25',
14
+ '151' => '29',
15
+ '163' => '23',
16
+ }
17
+
18
+ def map_job_type(value)
19
+ JOB_TYPE_MAPPING[value] || value
20
+ end
21
+
22
+ def revert_map_job_type(value)
23
+ JOB_TYPE_MAPPING.invert[value] || value
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,28 +3,44 @@ module WolfCore
3
3
  module JobseekerApiOperations
4
4
  include WolfCore::HttpOperations
5
5
 
6
- def fetch_jobseeker(wolf_token:, jobseeker_id:, tenant:)
6
+ def fetch_jobseeker!(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:, error_message:)
7
7
  response = safe_http_get(
8
8
  headers: { 'Authorization' => "Bearer #{wolf_token}" },
9
- url: "#{ENV['WOLF_PLATFORM_URL']}/api/v2/jobseekers/#{jobseeker_id}",
9
+ url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
10
10
  query: { tenant: tenant },
11
- error_message: 'Failed to fetch jobseeker',
11
+ error_message: error_message,
12
12
  )
13
13
  response_body = response.body
14
14
  response_body.dig('data', 'table', 'jobseeker')
15
15
  end
16
16
 
17
- def create_jobseeker(wolf_token:, jobseeker:, tenant:)
18
- response = http_post(
17
+ def fetch_jobseeker(wolf_token:, jobseeker_id:, tenant:, wolf_platform_url:)
18
+ response = http_get(
19
19
  headers: { 'Authorization' => "Bearer #{wolf_token}" },
20
+ url: "#{wolf_platform_url}/api/v2/jobseekers/#{jobseeker_id}",
20
21
  query: { tenant: tenant },
21
- url: "#{ENV['WOLF_PLATFORM_URL']}/api/v2/jobseekers",
22
- body: jobseeker
23
22
  )
24
- log_object response, title: 'create jobseeker response is'
25
- validate_http_response(
26
- response: response,
27
- message: 'Can not create jobseeker'
23
+ response_body = response.body
24
+ return unless response_body.instance_of?(Hash)
25
+ response_body.dig('data', 'table', 'jobseeker')
26
+ end
27
+
28
+ def create_jobseeker!(wolf_token:, jobseeker:, tenant:, wolf_platform_url:, error_message:)
29
+ safe_http_post(
30
+ headers: { 'Authorization' => "Bearer #{wolf_token}" },
31
+ query: { tenant: tenant },
32
+ url: "#{wolf_platform_url}/api/v2/jobseekers",
33
+ body: jobseeker,
34
+ error_message: error_message,
35
+ )
36
+ end
37
+
38
+ def create_jobseeker(wolf_token:, jobseeker:, tenant:, wolf_platform_url:)
39
+ http_post(
40
+ headers: { 'Authorization' => "Bearer #{wolf_token}" },
41
+ query: { tenant: tenant },
42
+ url: "#{wolf_platform_url}/api/v2/jobseekers",
43
+ body: jobseeker
28
44
  )
29
45
  end
30
46
  end
@@ -0,0 +1,48 @@
1
+ module WolfCore
2
+ module Integrations
3
+ module OrdersApiOperations
4
+ include WolfCore::HttpOperations
5
+
6
+ def fetch_order!(wolf_token:, order_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/orders/#{order_id}",
10
+ query: { tenant: tenant },
11
+ error_message: error_message,
12
+ )
13
+ response_body = response.body
14
+ response_body.dig('data', 'table', 'order')
15
+ end
16
+
17
+ def fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:)
18
+ response = http_get(
19
+ headers: { 'Authorization' => "Bearer #{wolf_token}" },
20
+ url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
21
+ query: { tenant: tenant },
22
+ )
23
+ response_body = response.body
24
+ return unless response_body.instance_of?(Hash)
25
+ response_body.dig('data', 'table', 'order')
26
+ end
27
+
28
+ def create_order!(wolf_token:, order:, tenant:, wolf_platform_url:, error_message:)
29
+ safe_http_post(
30
+ headers: { 'Authorization' => "Bearer #{wolf_token}" },
31
+ url: "#{wolf_platform_url}/api/v2/orders",
32
+ query: { tenant: tenant },
33
+ body: order,
34
+ error_message: error_message,
35
+ )
36
+ end
37
+
38
+ def create_order(wolf_token:, order:, tenant:, wolf_platform_url:)
39
+ http_post(
40
+ headers: { 'Authorization' => "Bearer #{wolf_token}" },
41
+ url: "#{wolf_platform_url}/api/v2/orders",
42
+ query: { tenant: tenant },
43
+ body: order
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,7 +1,8 @@
1
1
  module WolfCore
2
2
  module Integrations
3
3
  module WebhooksOperations
4
- def get_payload(event_type:, params:)
4
+ def get_payload(params:, event_type: nil)
5
+ event_type ||= get_event_type(params: params)
5
6
  return if event_type == 'SubscriptionConfirmation'
6
7
  params = JSON.parse(params['Message'] || '{}')
7
8
  JSON.parse(params['payload'] || '{}')
@@ -16,7 +17,7 @@ module WolfCore
16
17
  message['event_name']
17
18
  end
18
19
 
19
- def validate_user(params:)
20
+ def validate_user_is_not_admin(params:)
20
21
  event_type = get_event_type(params: params)
21
22
  return if event_type == 'SubscriptionConfirmation'
22
23
 
@@ -27,17 +28,15 @@ module WolfCore
27
28
  end
28
29
 
29
30
  def subscription_confirmation_request(url:)
30
- response = safe_http_get(
31
+ safe_http_get(
31
32
  url: url,
32
33
  error_message: "Can not confirm subscription",
33
34
  )
34
- response
35
35
  end
36
36
 
37
37
  def process_webhook(params:)
38
38
  event_type = get_event_type(params: params)
39
39
  event_name = get_event_name(params: params)
40
- # payload = get_payload(event_type: event_type, params: params)
41
40
  if event_type == 'SubscriptionConfirmation'
42
41
  url = params['SubscribeURL']
43
42
  elsif event_type == 'Notification'
@@ -56,6 +55,37 @@ module WolfCore
56
55
  params = JSON.parse(params['Message'] || '{}')
57
56
  params['object_id']
58
57
  end
58
+
59
+ def group_custom_values_by_custom_requirement_group(
60
+ params:,
61
+ jobseeker_file_custom_requirement_ids:,
62
+ reference_form_custom_requirement_ids:,
63
+ disclosure_form_custom_requirement_ids:
64
+ )
65
+ payload = get_payload(params: params)
66
+ custom_values = payload.dig('changes', 'custom_values')
67
+ if custom_values.blank?
68
+ custom_values = [ payload['attributes'] ]
69
+ end
70
+
71
+ custom_values.group_by do |custom_value|
72
+ custom_requirement_group = if jobseeker_file_custom_requirement_ids.include?(custom_value['custom_requirement_id'])
73
+ 'jobseeker_file'
74
+ elsif reference_form_custom_requirement_ids.include?(custom_value['custom_requirement_id'])
75
+ 'reference_form'
76
+ elsif disclosure_form_custom_requirement_ids.include?(custom_value['custom_requirement_id'])
77
+ 'disclosure_form'
78
+ elsif custom_value['user_category'] == 'Freelancer'
79
+ 'jobseeker'
80
+ elsif custom_value['user_category'] == 'Campaign'
81
+ 'order'
82
+ else
83
+ 'unknown_group'
84
+ end
85
+
86
+ custom_requirement_group
87
+ end
88
+ end
59
89
  end
60
90
  end
61
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.99"
4
+ VERSION = "0.2.1"
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: 0.1.99
4
+ version: 0.2.1
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-08 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -93,9 +93,11 @@ files:
93
93
  - lib/wolf_core/application/barton/parsing.rb
94
94
  - lib/wolf_core/application/barton/routing.rb
95
95
  - lib/wolf_core/application/burnett/auth/auth_operations.rb
96
+ - lib/wolf_core/application/burnett/data_transformation/mappings.rb
96
97
  - lib/wolf_core/application/exception_operations.rb
97
98
  - lib/wolf_core/application/integrations/change_detection.rb
98
99
  - lib/wolf_core/application/integrations/jobseeker_api_operations.rb
100
+ - lib/wolf_core/application/integrations/orders_api_operations.rb
99
101
  - lib/wolf_core/application/integrations/routing_operations.rb
100
102
  - lib/wolf_core/application/integrations/webhooks_operations.rb
101
103
  - lib/wolf_core/application/salesforce_oauth_service.rb