wolf_core 0.2.0 → 0.2.1

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: 72dc3ed5c7b6520f4baa43f27e45a304ac21b7b68d5167beeed386fd088ee2e9
4
- data.tar.gz: 87fa7ece4f89b46d81f7ca97c0e1470fa7f3ceff03de7725d5e3bc31b7b09d2e
3
+ metadata.gz: 5a1f0b2966c7b61301a3801b584e0c47c30d33dc41da57544a9d0ae62b40d352
4
+ data.tar.gz: 4983824766da8cf8322d6ca4f4f16e16683cc829718e4ef6a21d973ab2520c5e
5
5
  SHA512:
6
- metadata.gz: 570ad8e75a0c36bab766171acc847ecf0cf73e668890c425da83ed89bda51ca2890df07a9fb3a97dab425ded238287abfd239c4e510726ad44826bdd3be7b102
7
- data.tar.gz: ae521dc9bc683c8cbc960abaf0b23037b5a804e2bcbeabb18b088b6fd7d36b345a679d81158152173a4d739effcbc45f4cae1f5ef0571996a1916fa3bebf9b06
6
+ metadata.gz: c766631f0310e07308c84719fc7963e79d37e4cef422fb5f1f0ba62d346f4c8c4d011abe7dfcd87d243c84e2bb27b0bf27fbeb7afdbac11477466270d258ae4b
7
+ data.tar.gz: bcb84ab0f42910f4af5fd3ab074009db17385e12db30a3079f225ad001b556d6584c2d0d998125401a4286c0ffb0bd6e3ca18fc73811da3e5c4e0881c2a2d0ae
@@ -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.2.0"
4
+ VERSION = "0.2.1"
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: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo