wolf_core 0.1.44 → 0.1.46

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: 805f683f93703e990a72ffaed09a720810c7951b0ee82fb3f24ea3d0c1980520
4
- data.tar.gz: 587680cdcd22b502736f4890e48441f9cb3e00035a5cca939141675c96a7be7f
3
+ metadata.gz: 24a38fbd3bf0c7ea37e0dbc325fbf0bd60e919b407b78be15a304df8e0d32ae5
4
+ data.tar.gz: 493f91f7a744554a71431f7c8b0bd08ba4515c448d01607ac6b6f7567cc4eb93
5
5
  SHA512:
6
- metadata.gz: a969b7f280041f545f2781bb385b8321128d22b6ce9aee25962f7800d8f40bbbc986f764018e5d81f30db4ed4bd3baf3685f588e5dcc0d3a589787c778d66186
7
- data.tar.gz: e5ea98f2db61df179861cb068dd6738f9723a7ca70228e5fc320bd13c042399a425fefb24af20fe00d048d38bd52ec283c1e9cf9f62216c1a29d108050e9a2ef
6
+ metadata.gz: 7a32614d5b86c00d6deaf0c3615bd7b350cfa70d7f7336e5d242b8ffc7fbc7ddd439529701a5d687fbc69e3f3526f3ea466d3ce6e659660d881f189b8083ed63
7
+ data.tar.gz: a13c04ff70b497a9331b22bd948532bc0755270000b380b2d755904b7abfa97538d10b06ece2e84dde011b1b143ec6a2cf883a70fb1cf27802d0fd425bfd13c6
@@ -0,0 +1,49 @@
1
+ module WolfCore
2
+ module Barton
3
+ module Parsing
4
+ def split_address(address_string)
5
+ address_string ||= ''
6
+ address = { street: nil, city: nil, state: nil, zip: nil }
7
+ city_and_state_regex_found = false
8
+
9
+ city_and_state_regex = /\b([A-Za-z\s]+),\s*([A-Za-z]{2})\b/
10
+ zip_regex = /\b\d{5}(?:-\d{4})?\b/
11
+ street_regex = /\A([^,]+)/
12
+ state_regex = /\b[A-Za-z]{2}\b/
13
+ city_regex = /\b[a-zA-Z0-9\s]{2,}\b/
14
+
15
+ if match_data = address_string.match(city_and_state_regex)
16
+ address[:city] = match_data[1].strip
17
+ address[:state] = match_data[2].strip
18
+ address_string.sub!(city_and_state_regex, '')
19
+ city_and_state_regex_found = true
20
+ end
21
+
22
+ if zip_match = address_string.match(zip_regex)
23
+ address[:zip] = zip_match[0].strip
24
+ address_string.sub!(zip_regex, '')
25
+ end
26
+
27
+ if street_match = address_string.match(street_regex)
28
+ address[:street] = street_match[0].strip
29
+ address[:street] = nil if address[:street].empty?
30
+ address_string.sub!(street_regex, '')
31
+ end
32
+
33
+ return address if city_and_state_regex_found
34
+
35
+ if state_match = address_string.match(state_regex)
36
+ address[:state] = state_match[0].strip
37
+ address_string.sub!(state_regex, '')
38
+ end
39
+
40
+ if city_match = address_string.match(city_regex)
41
+ address[:city] = city_match[0].strip
42
+ address_string.sub!(city_regex, '')
43
+ end
44
+
45
+ return address
46
+ end
47
+ end
48
+ end
49
+ end
@@ -24,27 +24,6 @@ module WolfCore
24
24
  )
25
25
  end
26
26
  end
27
-
28
- def import_order_description(order_id:, listing:)
29
- domain_url = ENV['GENERATE_JOB_DESCRIPTION_URL']
30
- path = 'barton/import/order_description'
31
- headers = {
32
- 'Authorization' => ENV['GENERATE_JOB_DESCRIPTION_TOKEN'],
33
- 'tenant' => ENV['GENERATE_JOB_DESCRIPTION_TENANT'],
34
- }
35
- body = { order_id: order_id, listing: listing }
36
-
37
- if domain_url.present?
38
- async_http_post(url: "#{domain_url}/#{path}", headers: headers, body: body)
39
- else
40
- function_name = PATH_TO_FUNCTION_NAME_MAPPING[path]
41
- body['headers'] = headers
42
- invoke_lambda(
43
- function_name: function_name,
44
- payload: body,
45
- )
46
- end
47
- end
48
27
  end
49
28
  end
50
29
  end
@@ -2,18 +2,30 @@ module WolfCore
2
2
  module HttpOperations
3
3
  include WolfCore::ExceptionOperations
4
4
  include WolfCore::AsyncUtils
5
+ include WolfCore::LoggingUtils
5
6
 
6
7
  def async_http_get(**args)
7
- puts "starting async_http_get"
8
- puts "async_http_get args are"
9
- pp args
8
+ log_object 'starting async_http_get'
9
+ log_object args, title: 'async_http_get args are'
10
10
  run_async do
11
11
  response = http_get(**args)
12
- puts "async_http_get response is"
13
- pp parse_http_response(response).to_h
12
+ log_object parse_http_response(response), title: 'async_http_get response is'
14
13
  end
15
14
  end
16
15
 
16
+ def safe_http_get(url:, headers: {}, query: nil, error_message: nil, title: nil)
17
+ response = http_get(url: url, headers: headers, query: query)
18
+ response = parse_http_response(response)
19
+
20
+ title ||= 'safe_http_get response is'
21
+ log_object response, title: title
22
+
23
+ error_message ||= 'Error on safe_http_get'
24
+ validate_http_response(response: response, message: error_message)
25
+
26
+ response
27
+ end
28
+
17
29
  def http_get(url:, headers: {}, query: nil)
18
30
  WolfCore::HttpDataSource.http_get(url: url, headers: headers, query: query)
19
31
  end
@@ -21,29 +33,54 @@ module WolfCore
21
33
  def async_http_post(**args)
22
34
  puts "starting async_http_post"
23
35
  puts "async_http_post args are"
24
- pp args
36
+ log_object args
25
37
  run_async do
26
38
  response = http_post(**args)
27
39
  puts "async_http_post response is"
28
- pp parse_http_response(response).to_h
40
+ log_object parse_http_response(response).to_h
29
41
  end
30
42
  end
31
43
 
44
+ def safe_http_post(url:, headers: {}, body: nil, query: nil, error_message: nil, title: nil)
45
+ response = http_post(url: url, headers: headers, body: body, query: query)
46
+ response = parse_http_response(response)
47
+
48
+ title ||= 'safe_http_post response is'
49
+ log_object response, title: title
50
+
51
+ error_message ||= 'Error on safe_http_post'
52
+ validate_http_response(response: response, message: error_message)
53
+
54
+ response
55
+ end
56
+
32
57
  def http_post(url:, headers: {}, body: nil, query: nil)
33
58
  WolfCore::HttpDataSource.http_post(url: url, headers: headers, query: query, body: body)
34
59
  end
35
60
 
36
61
  def async_http_put(**args)
37
- puts "starting async_http_put"
38
- puts "async_http_put args are"
39
- pp args
62
+ log_object 'starting async_http_put'
63
+ log_object args, title: 'async_http_put args are'
40
64
  run_async do
41
65
  response = http_put(**args)
42
66
  puts "async_http_put response is"
43
- pp parse_http_response(response).to_h
67
+ log_object parse_http_response(response).to_h
44
68
  end
45
69
  end
46
70
 
71
+ def safe_http_put(url:, headers: {}, body: nil, query: nil, error_message: nil, title: nil)
72
+ response = http_put(url: url, headers: headers, body: body, query: query)
73
+ response = parse_http_response(response)
74
+
75
+ title ||= 'safe_http_put response is'
76
+ log_object response, title: title
77
+
78
+ error_message ||= 'Error on safe_http_put'
79
+ validate_http_response(response: response, message: error_message)
80
+
81
+ response
82
+ end
83
+
47
84
  def http_put(url:, headers: {}, body: nil, query: nil)
48
85
  WolfCore::HttpDataSource.http_put(url: url, headers: headers, query: query, body: body)
49
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.44"
4
+ VERSION = "0.1.46"
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.44
4
+ version: 0.1.46
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-07-26 00:00:00.000000000 Z
11
+ date: 2024-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -62,6 +62,7 @@ files:
62
62
  - lib/wolf_core.rb
63
63
  - lib/wolf_core/application/application_service.rb
64
64
  - lib/wolf_core/application/barton/mappings.rb
65
+ - lib/wolf_core/application/barton/parsing.rb
65
66
  - lib/wolf_core/application/barton/routing.rb
66
67
  - lib/wolf_core/application/exception_operations.rb
67
68
  - lib/wolf_core/application/salesforce_oauth_service.rb