wolf_core 1.0.8 → 1.0.10

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: dd280a5a5d9495d83774c3f8b0b42ab48875c8a8dd854acf43acb923435d03c2
4
- data.tar.gz: 89bafdc7352bbd1267c86215dde996e2915953100dfb10f890bc8d902b0f618a
3
+ metadata.gz: 1fc74c77d74d46328ceaeaa05d8f0bfe2339c5eb8f9c37f781d8a88b4547d5d9
4
+ data.tar.gz: 991c1049dd50452777267fdee8edef2c5491c80883c3901bd0313399456838ac
5
5
  SHA512:
6
- metadata.gz: 72fd7482aa549de335f735bfe45acaf5fde74614ac723cd781b24ff86f9965dc7fe66d35061bbeef9d1dc556951c300f40cd10473177c57bce02b318cec9533c
7
- data.tar.gz: 051ed5a7340309cc4908573cee67f3e17f8011da0a5391e9e42fe9ecfe4c42debf2d3b3fba2dea9d115f947be510e85a1ac16779abdb589c3c4286597f9d43be
6
+ metadata.gz: e0fdea166f2c88f7294dde457d39194990cdc8750df848ece6056e0830a0020c68e908eb31d91fa5e5b6dc60d8f45caecf0bde0665ef3be58201b66d92e16a2f
7
+ data.tar.gz: a0fcaf4480c92f1d0553e88cbfd65372957ed0e47450fa49c73c9f73ecfdd65b2a824cacb205552faf78c95adbf8bec97beef47a8595520c175c5db48ce1c64c
@@ -2,42 +2,42 @@ module WolfCore
2
2
  module Barton
3
3
  module Mappings
4
4
  PROVIDER_TYPE_MAPPING = {
5
- 'MD' => ENV['MD_PRICING_ID'],
6
- 'DO' => ENV['DO_PRICING_ID'],
7
- 'PA' => ENV['PA_PRICING_ID'],
8
- 'DMD' => ENV['DMD_PRICING_ID'],
9
- 'NP' => ENV['NP_PRICING_ID'],
10
- 'DDS' => ENV['DDS_PRICING_ID'],
11
- 'GP' => ENV['GP_PRICING_ID'],
5
+ "MD" => ENV["MD_PRICING_ID"],
6
+ "DO" => ENV["DO_PRICING_ID"],
7
+ "PA" => ENV["PA_PRICING_ID"],
8
+ "DMD" => ENV["DMD_PRICING_ID"],
9
+ "NP" => ENV["NP_PRICING_ID"],
10
+ "DDS" => ENV["DDS_PRICING_ID"],
11
+ "GP" => ENV["GP_PRICING_ID"]
12
12
  }
13
13
 
14
14
  LOCUM_AVAILABILITY_MAP = {
15
- 'PT' => 'Part Time',
16
- 'FT' => 'Full Time',
17
- 'PFI' => 'Not Sure Yet',
18
- 'Interim Locum' => 'Between Permanent Positions',
19
- 'Perm Only' => 'Permanent',
15
+ "PT" => "Part Time",
16
+ "FT" => "Full Time",
17
+ "PFI" => "Not Sure Yet",
18
+ "Interim Locum" => "Between Permanent Positions",
19
+ "Perm Only" => "Permanent"
20
20
  }
21
21
 
22
22
  ORDER_STATUS_MAP = {
23
- 'Listing Qualification' => 'pending',
24
- 'Pending' => 'pending',
25
- 'On Hold' => 'pending',
26
- 'Filled' => 'pending',
27
- 'Open' => 'live',
28
- 'Closed' => 'pending',
23
+ "Listing Qualification" => "pending",
24
+ "Pending" => "pending",
25
+ "On Hold" => "pending",
26
+ "Filled" => "pending",
27
+ "Open" => "live",
28
+ "Closed" => "pending"
29
29
  }
30
30
 
31
31
  SUBMITTAL_STAGE_MAP = {
32
- 'Pre-Submission' => 'wait',
33
- 'Submittal' => 'wait',
34
- 'Send Out' => 'wait',
35
- 'On Hold' => 'wait',
36
- 'Offer' => 'wait',
37
- 'Applied Online' => 'wait',
38
- 'Declined Online' => 'declined',
39
- 'Withdraw' => 'declined',
40
- 'Reject' => 'rejected',
32
+ "Pre-Submission" => "wait",
33
+ "Submittal" => "wait",
34
+ "Send Out" => "wait",
35
+ "On Hold" => "wait",
36
+ "Offer" => "wait",
37
+ "Applied Online" => "wait",
38
+ "Declined Online" => "declined",
39
+ "Withdraw" => "declined",
40
+ "Reject" => "rejected"
41
41
  }
42
42
 
43
43
  STATE_ABBREVIATIONS_MAP = {
@@ -86,26 +86,26 @@ module WolfCore
86
86
  "Palau" => "PW",
87
87
  "Pennsylvania" => "PA",
88
88
  "Puerto Rico" => "PR",
89
- 'Rhode Island' => 'RI',
90
- 'South Carolina' => 'SC',
91
- 'South Dakota' => 'SD',
92
- 'Tennessee' => 'TN',
93
- 'Texas' => 'TX',
94
- 'U.S. Virgin Islands' => 'VI',
95
- 'Utah' => 'UT',
96
- 'Vermont' => 'VT',
97
- 'Virginia' => 'VA',
98
- 'Washington' => 'WA',
99
- 'West Virginia' => 'WV',
100
- 'Wisconsin' => 'WI',
101
- 'Wyoming' => 'WY'
89
+ "Rhode Island" => "RI",
90
+ "South Carolina" => "SC",
91
+ "South Dakota" => "SD",
92
+ "Tennessee" => "TN",
93
+ "Texas" => "TX",
94
+ "U.S. Virgin Islands" => "VI",
95
+ "Utah" => "UT",
96
+ "Vermont" => "VT",
97
+ "Virginia" => "VA",
98
+ "Washington" => "WA",
99
+ "West Virginia" => "WV",
100
+ "Wisconsin" => "WI",
101
+ "Wyoming" => "WY"
102
102
  }
103
103
 
104
104
  DISPLAY_PAY_RATE_UNIT_MAP = {
105
- 'hour' => 'Hourly',
106
- 'day' => 'Daily',
107
- 'week' => 'Weekly',
108
- 'month' => 'Monthly',
105
+ "hour" => "Hourly",
106
+ "day" => "Daily",
107
+ "week" => "Weekly",
108
+ "month" => "Monthly"
109
109
  }
110
110
 
111
111
  def map_provider_type_to_pricing_id(provider_type)
@@ -115,6 +115,7 @@ module WolfCore
115
115
 
116
116
  def map_pricing_id_to_provider_type(pricing_id)
117
117
  return nil if pricing_id.blank?
118
+
118
119
  pricing_id = pricing_id.to_s
119
120
  provider_type = PROVIDER_TYPE_MAPPING.invert[pricing_id]
120
121
  provider_type || pricing_id
@@ -161,4 +162,4 @@ module WolfCore
161
162
  end
162
163
  end
163
164
  end
164
- end
165
+ end
@@ -4,19 +4,18 @@ module WolfCore
4
4
  module Operations
5
5
  def get_erecruit_access_token
6
6
  response = safe_http_post(
7
- url: ENV['ERECRUIT_AUTH_URL'],
8
- headers: { 'Content-Type' => 'application/x-www-form-urlencoded' },
7
+ url: ENV["ERECRUIT_AUTH_URL"],
8
+ headers: { "Content-Type" => "application/x-www-form-urlencoded" },
9
9
  body: {
10
- client_id: ENV['ERECRUIT_AUTH_CLIENT_ID'],
11
- client_secret: ENV['ERECRUIT_AUTH_CLIENT_SECRET'],
12
- grant_type: ENV['ERECRUIT_AUTH_GRANT_TYPE'],
10
+ client_id: ENV["ERECRUIT_AUTH_CLIENT_ID"],
11
+ client_secret: ENV["ERECRUIT_AUTH_CLIENT_SECRET"],
12
+ grant_type: ENV["ERECRUIT_AUTH_GRANT_TYPE"]
13
13
  },
14
- error_message: 'Unable to get erecruit token'
14
+ error_message: "Unable to get erecruit token"
15
15
  )
16
- access_token = response.body['access_token']
17
- access_token
16
+ response.body["access_token"]
18
17
  end
19
18
  end
20
19
  end
21
20
  end
22
- end
21
+ end
@@ -0,0 +1,45 @@
1
+ module WolfCore # rubocop:disable Style/FrozenStringLiteralComment
2
+ module Burnett
3
+ module MatchOperations # rubocop:disable Style/Documentation
4
+ include WolfCore::HttpOperations
5
+
6
+ def create_match!(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:, error_message:)
7
+ response = safe_http_post(
8
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
9
+ url: "#{erecruit_platform_url}/",
10
+ query: { tenant: tenant },
11
+ error_message: error_message
12
+ )
13
+ nil if response.code == 200
14
+ end
15
+
16
+ def create_match(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:)
17
+ response = http_get(
18
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
19
+ url: "#{erecruit_platform_url}/",
20
+ query: { tenant: tenant }
21
+ )
22
+ nil if response.code == 200
23
+ end
24
+
25
+ def update_match!(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:, error_message:)
26
+ response = safe_http_post(
27
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
28
+ url: "#{erecruit_platform_url}/",
29
+ query: { tenant: tenant },
30
+ error_message: error_message
31
+ )
32
+ nil if response.code == 200
33
+ end
34
+
35
+ def update_match(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:)
36
+ response = http_get(
37
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
38
+ url: "#{erecruit_platform_url}/",
39
+ query: { tenant: tenant }
40
+ )
41
+ nil if response.code == 200
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ module WolfCore
2
+ module Burnett
3
+ module PositionsOperations
4
+ include WolfCore::HttpOperations
5
+
6
+ def create_position!(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:, error_message:)
7
+ response = safe_http_post(
8
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
9
+ url: "#{erecruit_platform_url}/",
10
+ query: { tenant: tenant },
11
+ error_message: error_message
12
+ )
13
+ nil if response.code == 200
14
+ end
15
+
16
+ def create_position(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:)
17
+ response = http_get(
18
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
19
+ url: "#{erecruit_platform_url}/",
20
+ query: { tenant: tenant }
21
+ )
22
+ nil if response.code == 200
23
+ end
24
+
25
+ def update_position!(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:, error_message:)
26
+ response = safe_http_post(
27
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
28
+ url: "#{erecruit_platform_url}/",
29
+ query: { tenant: tenant },
30
+ error_message: error_message
31
+ )
32
+ nil if response.code == 200
33
+ end
34
+
35
+ def update_position(erecruit_token:, erecruit_platform_url:, position_id:, candidate_id:)
36
+ response = http_get(
37
+ headers: { "Authorization" => "Bearer #{erecruit_token}" },
38
+ url: "#{erecruit_platform_url}/",
39
+ query: { tenant: tenant }
40
+ )
41
+ nil if response.code == 200
42
+ end
43
+ end
44
+ end
45
+ end
@@ -5,39 +5,40 @@ module WolfCore
5
5
 
6
6
  def fetch_order!(wolf_token:, order_id:, tenant:, wolf_platform_url:, error_message:)
7
7
  response = safe_http_get(
8
- headers: { 'Authorization' => "Bearer #{wolf_token}" },
8
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
9
9
  url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
10
10
  query: { tenant: tenant },
11
- error_message: error_message,
11
+ error_message: error_message
12
12
  )
13
13
  response_body = response.body
14
- response_body.dig('data', 'table', 'order')
14
+ response_body.dig("data", "table", "order")
15
15
  end
16
16
 
17
17
  def fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:)
18
18
  response = http_get(
19
- headers: { 'Authorization' => "Bearer #{wolf_token}" },
19
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
20
20
  url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
21
- query: { tenant: tenant },
21
+ query: { tenant: tenant }
22
22
  )
23
23
  response_body = response.body
24
24
  return unless response_body.instance_of?(Hash)
25
- response_body.dig('data', 'table', 'order')
25
+
26
+ response_body.dig("data", "table", "order")
26
27
  end
27
28
 
28
29
  def create_order!(wolf_token:, order:, tenant:, wolf_platform_url:, error_message:)
29
30
  safe_http_post(
30
- headers: { 'Authorization' => "Bearer #{wolf_token}" },
31
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
31
32
  url: "#{wolf_platform_url}/api/v2/orders",
32
33
  query: { tenant: tenant },
33
34
  body: order,
34
- error_message: error_message,
35
+ error_message: error_message
35
36
  )
36
37
  end
37
38
 
38
39
  def create_order(wolf_token:, order:, tenant:, wolf_platform_url:)
39
40
  http_post(
40
- headers: { 'Authorization' => "Bearer #{wolf_token}" },
41
+ headers: { "Authorization" => "Bearer #{wolf_token}" },
41
42
  url: "#{wolf_platform_url}/api/v2/orders",
42
43
  query: { tenant: tenant },
43
44
  body: order
@@ -45,4 +46,4 @@ module WolfCore
45
46
  end
46
47
  end
47
48
  end
48
- end
49
+ end
@@ -9,42 +9,51 @@ module WolfCore
9
9
  tenant: tenant, source: source, source_id: source_id,
10
10
  destination: destination
11
11
  )
12
- foreign_key&.dig('destination_id')
12
+ foreign_key&.dig("destination_id")
13
13
  end
14
14
 
15
15
  def get_foreign_key_by_destination(tenant:, source:, source_id:, destination:)
16
16
  foreign_keys = get_foreign_keys(tenant: tenant, source: source, source_id: source_id)
17
- foreign_keys.find { |fk| fk['destination'] == destination }
17
+ foreign_keys.find { |fk| fk["destination"] == destination }
18
18
  end
19
19
 
20
20
  def get_foreign_keys(tenant:, source:, source_id:)
21
21
  response = http_get(
22
- url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
22
+ url: "#{ENV["FKM_URL"]}/Prod/lookup?tenant=#{tenant}&source=#{source}&source_id=#{source_id}"
23
23
  )
24
24
  response = parse_http_response(response)
25
- log_object response, title: 'get_foreign_keys response is'
26
- validate_http_response(response: response, message: 'Error getting foreign keys')
25
+ log_object response, title: "get_foreign_keys response is"
26
+ validate_http_response(response: response, message: "Error getting foreign keys")
27
27
  response.body
28
28
  end
29
29
 
30
30
  def get_foreign_keys_by_destination(tenant:, destination:, destination_id:)
31
31
  response = http_get(
32
- url: "#{ENV['FKM_URL']}/Prod/lookup?tenant=#{tenant}&destination=#{destination}&destination_id=#{destination_id}"
32
+ url: "#{ENV["FKM_URL"]}/Prod/lookup?tenant=#{tenant}&destination=#{destination}&destination_id=#{destination_id}"
33
33
  )
34
34
  response = parse_http_response(response)
35
- log_object response, title: 'get_foreign_keys_by_destination response is'
36
- validate_http_response(response: response, message: 'Error getting foreign keys by destination id')
35
+ log_object response, title: "get_foreign_keys_by_destination response is"
36
+ validate_http_response(response: response, message: "Error getting foreign keys by destination id")
37
37
  response.body
38
38
  end
39
39
 
40
40
  def create_foreign_key(tenant:, source:, source_id:, destination:, destination_id:)
41
- raise_service_error({ message: 'tenant is required to create a foreign key', tenant: tenant }) if tenant.blank?
42
- raise_service_error({ message: 'source is required to create a foreign key', source: source }) if source.blank?
43
- raise_service_error({ message: 'source_id is required to create a foreign key', source_id: source_id }) if source_id.blank?
44
- raise_service_error({ message: 'destination is required to create a foreign key', destination: destination }) if destination.blank?
45
- raise_service_error({ message: 'destination_id is required to create a foreign key', destination_id: destination_id }) if destination_id.blank?
41
+ raise_service_error({ message: "tenant is required to create a foreign key", tenant: tenant }) if tenant.blank?
42
+ raise_service_error({ message: "source is required to create a foreign key", source: source }) if source.blank?
43
+ if source_id.blank?
44
+ raise_service_error({ message: "source_id is required to create a foreign key",
45
+ source_id: source_id })
46
+ end
47
+ if destination.blank?
48
+ raise_service_error({ message: "destination is required to create a foreign key",
49
+ destination: destination })
50
+ end
51
+ if destination_id.blank?
52
+ raise_service_error({ message: "destination_id is required to create a foreign key",
53
+ destination_id: destination_id })
54
+ end
46
55
  response = http_post(
47
- url: "#{ENV['FKM_URL']}/Prod/create",
56
+ url: "#{ENV["FKM_URL"]}/Prod/create",
48
57
  body: {
49
58
  tenant: tenant,
50
59
  source: source,
@@ -54,8 +63,8 @@ module WolfCore
54
63
  }
55
64
  )
56
65
  response = parse_http_response(response)
57
- log_object response, title: 'create_foreign_key response is'
58
- validate_http_response(response: response, message: 'Error creating foreign key')
66
+ log_object response, title: "create_foreign_key response is"
67
+ validate_http_response(response: response, message: "Error creating foreign key")
59
68
  parse_http_response(response).body
60
69
  end
61
70
 
@@ -66,6 +75,7 @@ module WolfCore
66
75
  )
67
76
  log_object "find_or_create_foreign_key found_destination_id is #{found_destination_id}"
68
77
  return Result.success(data: { operation: :find }) if found_destination_id.present?
78
+
69
79
  create_foreign_key(
70
80
  tenant: tenant, source: source, source_id: source_id,
71
81
  destination: destination, destination_id: destination_id
@@ -80,9 +90,9 @@ module WolfCore
80
90
  )
81
91
  if foreign_key.present?
82
92
  update_foreign_key(
83
- tenant: tenant, auth_token: auth_token, uuid: foreign_key['uuid'],
93
+ tenant: tenant, auth_token: auth_token, uuid: foreign_key["uuid"],
84
94
  source: source, source_id: source_id,
85
- destination: destination, destination_id: destination_id,
95
+ destination: destination, destination_id: destination_id
86
96
  )
87
97
  else
88
98
  create_foreign_key(
@@ -92,34 +102,41 @@ module WolfCore
92
102
  end
93
103
  end
94
104
 
95
- def update_foreign_key(tenant:, auth_token:, uuid:, source: nil, source_id: nil, destination: nil, destination_id: nil)
96
- raise_service_error({ message: 'tenant is required to update a foreign key', tenant: tenant }) if tenant.blank?
97
- raise_service_error({ message: 'auth_token is required to update a foreign key', auth_token: auth_token }) if auth_token.blank?
98
- raise_service_error({ message: 'uuid is required to update a foreign key', uuid: uuid }) if uuid.blank?
105
+ def update_foreign_key(tenant:, auth_token:, uuid:, source: nil, source_id: nil, destination: nil,
106
+ destination_id: nil)
107
+ raise_service_error({ message: "tenant is required to update a foreign key", tenant: tenant }) if tenant.blank?
108
+ if auth_token.blank?
109
+ raise_service_error({ message: "auth_token is required to update a foreign key",
110
+ auth_token: auth_token })
111
+ end
112
+ raise_service_error({ message: "uuid is required to update a foreign key", uuid: uuid }) if uuid.blank?
99
113
 
100
114
  fields_to_update = {
101
115
  source: source,
102
116
  source_id: source_id,
103
117
  destination: destination,
104
- destination_id: destination_id,
118
+ destination_id: destination_id
105
119
  }.compact
106
120
 
107
- raise_service_error({ message: 'At least one field to update is required to update a foreign key', source: source }) if fields_to_update.blank?
121
+ if fields_to_update.blank?
122
+ raise_service_error({ message: "At least one field to update is required to update a foreign key",
123
+ source: source })
124
+ end
108
125
 
109
126
  body = {
110
127
  tenant: tenant,
111
128
  authentication_token: auth_token,
112
- uuid: uuid,
129
+ uuid: uuid
113
130
  }.merge(fields_to_update)
114
- log_object body, title: 'update_foreign_key body is'
131
+ log_object body, title: "update_foreign_key body is"
115
132
 
116
133
  response = safe_http_put(
117
- url: "#{ENV['FKM_URL']}/Prod/update",
134
+ url: "#{ENV["FKM_URL"]}/Prod/update",
118
135
  body: body,
119
- title: 'update_foreign_key response is',
120
- error_message: 'Error updating foreign key',
136
+ title: "update_foreign_key response is",
137
+ error_message: "Error updating foreign key"
121
138
  )
122
139
  response.body
123
140
  end
124
141
  end
125
- end
142
+ end
@@ -1,35 +1,33 @@
1
- require_relative 'logging_utils'
1
+ require_relative "logging_utils" # rubocop:disable Style/FrozenStringLiteralComment
2
2
 
3
3
  module WolfCore
4
- module FileUtils
4
+ module FileUtils # rubocop:disable Style/Documentation
5
5
  extend WolfCore::LoggingUtils
6
6
 
7
7
  module_function
8
8
 
9
9
  def require_relative_folder(*folders)
10
- folder_files = File.join(*folders, '**', '*.rb')
10
+ folder_files = File.join(*folders, "**", "*.rb")
11
11
  files_to_require = Dir[folder_files].sort
12
12
  # log_object files_to_require, title: 'Files to require are'
13
13
  safe_require(files_to_require)
14
14
  end
15
15
 
16
- def safe_require(missing_files)
16
+ def safe_require(missing_files) # rubocop:disable Metrics/MethodLength
17
17
  error_counter = {}
18
18
  while missing_files.any?
19
19
  files_to_require = missing_files
20
20
  missing_files = []
21
21
  files_to_require.each do |file|
22
- begin
23
- # log_object "Requiring file: #{file}"
24
- require_relative file
25
- rescue NameError => e
26
- error_counter[file] = error_counter[file].to_i + 1
27
- if error_counter[file] >= 10
28
- log_object "Error requiring file: #{file}"
29
- log_object e, title: 'Error is'
30
- end
31
- missing_files << file if error_counter[file] < 15
22
+ # log_object "Requiring file: #{file}"
23
+ require_relative file
24
+ rescue NameError => e
25
+ error_counter[file] = error_counter[file].to_i + 1
26
+ if error_counter[file] >= 10
27
+ log_object "Error requiring file: #{file}"
28
+ log_object e, title: "Error is"
32
29
  end
30
+ missing_files << file if error_counter[file] < 15
33
31
  end
34
32
  end
35
33
  end
@@ -45,39 +43,45 @@ module WolfCore
45
43
  log_object "File Deleting Process Finished! (#{files_to_delete.size} files deleted)"
46
44
  end
47
45
 
48
- def encode_file_to_base64_from_url(url)
49
- response = download_file_from_url(url)
46
+ def encode_file_to_base64_from_url(url) # rubocop:disable Metrics/MethodLength
47
+ uri, response = download_file_from_url(url).values_at(:uri, :response)
50
48
  bytes = response.body
51
49
 
52
50
  encoded_file = Base64.strict_encode64(bytes)
53
51
 
54
- content_disposition = response['content-disposition']
55
-
56
- filename = if content_disposition
57
- match = content_disposition.match(/filename="?([^"]+)"?/)
58
- match ? match[1] : File.basename(uri.path)
59
- else
60
- File.basename(uri.path)
61
- end
62
- log_object filename, title: 'filename is'
63
- return { filename: filename, encoded_file: encoded_file }
64
- rescue => e
52
+ filename = filename_from_response(response, uri)
53
+ log_object filename, title: "filename is"
54
+ { filename: filename, encoded_file: encoded_file }
55
+ rescue StandardError => e
65
56
  raise_service_error({
66
- message: 'Failed to encode file url',
67
- encode_file_error: { message: e.message, backtrace: e.backtrace },
68
- url: url,
69
- })
70
- end
71
-
72
- def bytes_from_url(url)
73
- download_file_from_url(url).body
57
+ message: "Failed to encode file url",
58
+ encode_file_error: { message: e.message, backtrace: e.backtrace },
59
+ url: url
60
+ })
74
61
  end
75
62
 
76
63
  def download_file_from_url(url)
77
64
  uri = URI.parse(url)
78
65
  response = Net::HTTP.get_response(uri)
79
- raise_service_error({ message: 'Failed to download file', url: url }) unless response.is_a?(Net::HTTPSuccess)
80
- response
66
+ raise_service_error({ message: "Failed to download file", url: url }) unless response.is_a?(Net::HTTPSuccess)
67
+ { uri: uri, response: response }
68
+ end
69
+
70
+ def bytes_from_url(url)
71
+ uri, response = download_file_from_url(url).values_at(:uri, :response)
72
+ bytes = response.body
73
+ filename = filename_from_response(response, uri)
74
+ { bytes: bytes, filename: filename }
75
+ end
76
+
77
+ def filename_from_response(response, uri)
78
+ content_disposition = response["content-disposition"]
79
+ if content_disposition
80
+ match = content_disposition.match(/filename="?([^"]+)"?/)
81
+ match ? match[1] : File.basename(uri.path)
82
+ else
83
+ File.basename(uri.path)
84
+ end
81
85
  end
82
86
  end
83
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.10"
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: 1.0.8
4
+ version: 1.0.10
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-25 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -94,6 +94,8 @@ files:
94
94
  - lib/wolf_core/application/barton/routing.rb
95
95
  - lib/wolf_core/application/burnett/auth/auth_operations.rb
96
96
  - lib/wolf_core/application/burnett/data_transformation/mappings.rb
97
+ - lib/wolf_core/application/burnett/match_operations/match_operattions.rb
98
+ - lib/wolf_core/application/burnett/positions_operations/positions_operations.rb
97
99
  - lib/wolf_core/application/exception_operations.rb
98
100
  - lib/wolf_core/application/integrations/change_detection.rb
99
101
  - lib/wolf_core/application/integrations/jobseeker_api_operations.rb