dscf-marketplace 0.6.8 → 0.6.9
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47ccdaa6c3f673186ebd2eded4b02d820ca4a5f04c488289a7ae36fd632e86cf
|
|
4
|
+
data.tar.gz: ddc2b3716afba0714a92f9fd3814598eedffd39288a8a01e99eca5c36d320bdc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dfed84c310ca8365fb97fa54fa9dc46fa9a1603119cf2a05ed0a46c0c1de8834792ad6d03a3427feaf123ce2b0e19392f487e45a79a3c0fd00d5c1350e9d521
|
|
7
|
+
data.tar.gz: 0b68966531e15177a951d62f3737a91f1246f16ac17a3ce72b716fd7efdf1d995c1443fa594fbeea3dc508e6d5eb065d2d42d11ed18b01e639288bd7ed3d53d0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Marketplace
|
|
3
|
+
class LocationsController < ApplicationController
|
|
4
|
+
def get_location
|
|
5
|
+
place_name = params[:name]
|
|
6
|
+
|
|
7
|
+
if place_name.blank?
|
|
8
|
+
render_error(
|
|
9
|
+
"locations.errors.name_required",
|
|
10
|
+
status: :unprocessable_entity
|
|
11
|
+
)
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
service = GebetaService.new
|
|
16
|
+
locations = service.geocode(place_name)
|
|
17
|
+
|
|
18
|
+
render_success(data: locations, status: :ok)
|
|
19
|
+
rescue => e
|
|
20
|
+
render_error(
|
|
21
|
+
"locations.errors.geocoding_failed",
|
|
22
|
+
errors: [ e.message ],
|
|
23
|
+
status: :unprocessable_entity
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Dscf::Marketplace
|
|
2
2
|
class DeliveryOrderItem < ApplicationRecord
|
|
3
|
-
enum :status, {pending: 0, picked_up: 1, delivered: 2, receiver_confirmed: 3, damaged: 4, missing: 5, disputed: 6, wrong_item: 7
|
|
3
|
+
enum :status, {pending: 0, picked_up: 1, delivered: 2, receiver_confirmed: 3, damaged: 4, missing: 5, disputed: 6, wrong_item: 7}
|
|
4
4
|
|
|
5
5
|
belongs_to :delivery_order
|
|
6
6
|
belongs_to :delivery_stop, class_name: "Dscf::Marketplace::DeliveryStop", optional: true
|
|
@@ -4,18 +4,35 @@ module Dscf
|
|
|
4
4
|
module Marketplace
|
|
5
5
|
class GebetaService
|
|
6
6
|
include HTTParty
|
|
7
|
+
|
|
7
8
|
base_uri "https://mapapi.gebeta.app/api"
|
|
8
9
|
debug_output $stdout if Rails.env.development?
|
|
9
10
|
|
|
10
11
|
def initialize(api_key: ENV["GEBETA_MAPS_API_KEY"])
|
|
11
12
|
# Sanitize the key: strip whitespace and remove surrounding quotes if any
|
|
12
13
|
@api_key = api_key.to_s.strip.gsub(/\A['"]+|['"]+\z/, "")
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
if @api_key.blank?
|
|
15
16
|
Rails.logger.error "[GebetaService] GEBETA_MAPS_API_KEY is missing or blank"
|
|
16
17
|
else
|
|
17
18
|
masked_key = "#{@api_key[0...4]}...#{@api_key[-4..-1]}" if @api_key.length > 8
|
|
18
|
-
Rails.logger.info "[GebetaService] Initialized with key: #{masked_key ||
|
|
19
|
+
Rails.logger.info "[GebetaService] Initialized with key: #{masked_key || "too short"}, length: #{@api_key.length}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Forward Geocoding
|
|
24
|
+
# @param place_name [String] The name of the place to search for
|
|
25
|
+
# @return [Array] Array of matching location objects
|
|
26
|
+
def geocode(place_name)
|
|
27
|
+
response = self.class.get("/v1/route/geocoding", query: {
|
|
28
|
+
name: place_name,
|
|
29
|
+
apiKey: @api_key
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
if response.success?
|
|
33
|
+
response.parsed_response
|
|
34
|
+
else
|
|
35
|
+
raise StandardError, "Gebeta API Error: #{response.code} - #{response.body}"
|
|
19
36
|
end
|
|
20
37
|
end
|
|
21
38
|
|
|
@@ -25,10 +42,10 @@ module Dscf
|
|
|
25
42
|
def tsp(locations)
|
|
26
43
|
# Gebeta TSS API expects a custom string format: [{lat,lon},{lat,lon},...]
|
|
27
44
|
# Example: [{8.9,38.7},{9.0,38.8}] - Literal curly braces, comma sep lat/lon
|
|
28
|
-
|
|
45
|
+
|
|
29
46
|
custom_payload = "[" + locations.map { |loc| "{#{loc[0]},#{loc[1]}}" }.join(",") + "]"
|
|
30
|
-
|
|
31
|
-
# We pass this string directly to the json query param.
|
|
47
|
+
|
|
48
|
+
# We pass this string directly to the json query param.
|
|
32
49
|
# HTTParty will encode the characters (e.g., { becomes %7B), which is expected.
|
|
33
50
|
response = self.class.get("/route/tss", query: {
|
|
34
51
|
apiKey: @api_key,
|
data/config/routes.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dscf-marketplace
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Asrat
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-01-01 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -423,6 +423,7 @@ files:
|
|
|
423
423
|
- app/controllers/dscf/marketplace/delivery_stops_controller.rb
|
|
424
424
|
- app/controllers/dscf/marketplace/delivery_vehicles_controller.rb
|
|
425
425
|
- app/controllers/dscf/marketplace/listings_controller.rb
|
|
426
|
+
- app/controllers/dscf/marketplace/locations_controller.rb
|
|
426
427
|
- app/controllers/dscf/marketplace/order_items_controller.rb
|
|
427
428
|
- app/controllers/dscf/marketplace/orders_controller.rb
|
|
428
429
|
- app/controllers/dscf/marketplace/products_controller.rb
|