travel_time 0.3.3 → 0.4.0

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: f6711d01c7b8c3c6803f0c4e82c5754918c160ea7e0077a0c773fe84c15705f1
4
- data.tar.gz: 1c7e9520650b1d77140f6a36f76f14d7f952d22a038c9e6ba692d09b340a8ea0
3
+ metadata.gz: e026fa4d97a7a6ed15e6255dd221b1acadaf83d77be1bee06c0d7705c7f556ca
4
+ data.tar.gz: 57f80869aee09e159742b516e0e16c6757c5c30d86dede1fa2d1bda4811f5b97
5
5
  SHA512:
6
- metadata.gz: 6437d4f698d3ef410e3483c178992d0f15233113d94b989c0f0d23c4d43f08d8dac72fe59841d77c6bfdf6388f0f38dec62cf8fd3580036d167eab924877cb6b
7
- data.tar.gz: fd7a853cf20380365981cb20420a52317acccab62cc0f23af73991d7b2f4a9045c209f6c87de5646cb2bb8a529180a3e1f978fcf3160d72a1b4b3a30919827d6
6
+ metadata.gz: 8352d34e44966cbf59256900792bfb5e3dbe4060bffcacc6a57bc3c653312ae6fdec78ed3541ff8887889c4c78dbc3907b6b52b067cf4206a9b6f7ca398dc41e
7
+ data.tar.gz: e87883a54e9e2b2585db76cebbddaf2496a1b516c4f2b29c9b39d3ad89daac83cb9617ec9b73ccb86068f2f4b28fcce9efdc2e2266f9712f2d8e8f6613355101
data/README.md CHANGED
@@ -310,6 +310,75 @@ response = client.time_filter_fast(
310
310
  puts response.body
311
311
  ```
312
312
 
313
+ ### [Time Filter (Fast) Proto](https://docs.traveltime.com/api/reference/travel-time-distance-matrix-proto)
314
+ A fast version of time filter communicating using [protocol buffers](https://github.com/protocolbuffers/protobuf).
315
+
316
+ The request parameters are much more limited and only travel time is returned. In addition, the results are only approximately correct (95% of the results are guaranteed to be within 5% of the routes returned by regular time filter).
317
+
318
+ This inflexibility comes with a benefit of faster response times (Over 5x faster compared to regular time filter) and larger limits on the amount of destination points.
319
+
320
+ Body attributes:
321
+ * origin: Origin point.
322
+ * destinations: Destination points. Cannot be more than 200,000.
323
+ * transport: Transportation type.
324
+ * travelTime: Time limit;
325
+ * country: Return the results that are within the specified country
326
+
327
+ ```ruby
328
+ origin = {
329
+ lat: 51.508930,
330
+ lng: -0.131387,
331
+ }
332
+
333
+ destinations = [{
334
+ lat: 51.508824,
335
+ lng: -0.167093,
336
+ }]
337
+
338
+ response = client.time_filter_fast_proto(
339
+ country: 'UK',
340
+ origin: origin,
341
+ destinations: destinations,
342
+ transport: 'driving+ferry',
343
+ traveltime: 7200
344
+ )
345
+ puts(response.body)
346
+ ```
347
+
348
+ ### Time Filter (Fast) Proto Distance
349
+ A version of `Time Filter (Fast) Proto` endpoint that also returns distance information. Request parameters are even more limited than `Time Filter (Fast) Proto`.
350
+
351
+ This endpoint is not enabled by default, please [contact us](https://traveltime.com/contact-us) if you wish to obtain access.
352
+
353
+ Body attributes:
354
+ * origin: Origin point.
355
+ * destinations: Destination points. Cannot be more than 200,000.
356
+ * transport: Transportation type.
357
+ * travelTime: Time limit;
358
+ * country: Return the results that are within the specified country
359
+
360
+ ```ruby
361
+ origin = {
362
+ lat: 51.508930,
363
+ lng: -0.131387,
364
+ }
365
+
366
+ destinations = [{
367
+ lat: 51.508824,
368
+ lng: -0.167093,
369
+ }]
370
+
371
+ response = client.time_filter_fast_proto_distance(
372
+ country: 'UK',
373
+ origin: origin,
374
+ destinations: destinations,
375
+ transport: 'driving+ferry',
376
+ traveltime: 7200
377
+ )
378
+ puts(response.body)
379
+ ```
380
+
381
+
313
382
  ### [Time Filter (Postcode Districts)](https://traveltime.com/docs/api/reference/postcode-district-filter)
314
383
  Find districts that have a certain coverage from origin (or to destination) and get statistics about postcodes within such districts.
315
384
  Currently only supports United Kingdom.
@@ -2,13 +2,14 @@
2
2
 
3
3
  require 'faraday'
4
4
  require 'travel_time/middleware/authentication'
5
+ require 'travel_time/middleware/proto'
5
6
 
6
7
  module TravelTime
7
8
  # The Client class provides the main interface to interact with the TravelTime API
8
9
  class Client # rubocop:disable Metrics/ClassLength
9
10
  API_BASE_URL = 'https://api.traveltimeapp.com/v4/'
10
11
 
11
- attr_reader :connection
12
+ attr_reader :connection, :proto_connection
12
13
 
13
14
  def initialize
14
15
  @connection = Faraday.new(API_BASE_URL) do |f|
@@ -19,12 +20,27 @@ module TravelTime
19
20
  f.use TravelTime::Middleware::Authentication
20
21
  f.adapter TravelTime.config.http_adapter || Faraday.default_adapter
21
22
  end
23
+
24
+ init_proto_connection
25
+ end
26
+
27
+ def init_proto_connection
28
+ @proto_connection = Faraday.new do |f|
29
+ f.use TravelTime::Middleware::ProtoMiddleware
30
+ f.response :raise_error if TravelTime.config.raise_on_failure
31
+ f.response :logger if TravelTime.config.enable_logging
32
+ f.adapter TravelTime.config.http_adapter || Faraday.default_adapter
33
+ end
22
34
  end
23
35
 
24
36
  def unwrap(response)
25
37
  Response.from_object(response)
26
38
  end
27
39
 
40
+ def unwrap_proto(response)
41
+ Response.from_object_proto(response)
42
+ end
43
+
28
44
  def perform_request
29
45
  unwrap(yield)
30
46
  rescue Faraday::Error => e
@@ -35,6 +51,12 @@ module TravelTime
35
51
  raise TravelTime::Error.new(exception: e)
36
52
  end
37
53
 
54
+ def perform_request_proto
55
+ unwrap_proto(yield)
56
+ rescue StandardError => e
57
+ raise TravelTime::Error.new(exception: e)
58
+ end
59
+
38
60
  def map_info
39
61
  perform_request { connection.get('map-info') }
40
62
  end
@@ -94,6 +116,24 @@ module TravelTime
94
116
  perform_request { connection.post('time-filter/fast', payload) }
95
117
  end
96
118
 
119
+ def time_filter_fast_proto(country:, origin:, destinations:, transport:, traveltime:)
120
+ message = ProtoUtils.make_proto_message(origin, destinations, transport, traveltime)
121
+ payload = ProtoUtils.encode_proto_message(message)
122
+ perform_request_proto do
123
+ proto_connection.post("http://proto.api.traveltimeapp.com/api/v2/#{country}/time-filter/fast/#{transport}",
124
+ payload)
125
+ end
126
+ end
127
+
128
+ def time_filter_fast_proto_distance(country:, origin:, destinations:, transport:, traveltime:)
129
+ message = ProtoUtils.make_proto_message(origin, destinations, transport, traveltime, properties: [1])
130
+ payload = ProtoUtils.encode_proto_message(message)
131
+ perform_request_proto do
132
+ proto_connection.post("https://proto-with-distance.api.traveltimeapp.com/api/v2/#{country}/time-filter/fast/#{transport}",
133
+ payload)
134
+ end
135
+ end
136
+
97
137
  def time_filter_postcodes(departure_searches: nil, arrival_searches: nil)
98
138
  payload = {
99
139
  departure_searches: departure_searches,
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'base64'
5
+
6
+ module TravelTime
7
+ module Middleware
8
+ # The Proto middleware is responsible for setting the basic auth headers for proto requests
9
+ # on each request. These are automatically taken from the `TravelTime.config`.
10
+ class ProtoMiddleware < Faraday::Middleware
11
+ def on_request(env)
12
+ env.request_headers['Authorization'] =
13
+ "Basic #{Base64.encode64("#{TravelTime.config.application_id}:#{TravelTime.config.api_key}")}"
14
+ env.request_headers['Content-Type'] = 'application/octet-stream'
15
+ env.request_headers['Accept'] = 'application/octet-stream'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,61 @@
1
+ syntax = "proto3";
2
+
3
+ package com.igeolise.traveltime.rabbitmq.requests;
4
+
5
+ message Coords {
6
+ float lat = 1;
7
+ float lng = 2;
8
+ }
9
+
10
+ message Transportation {
11
+ TransportationType type = 1;
12
+ }
13
+
14
+ enum TransportationType {
15
+ // Considers all paths found by the following steps:
16
+ // * up to 30 minutes of walking (always included even if no stops found)
17
+ // * all connections in the 30 minute walking range from public transport
18
+ // stops to other public transport stops in travel_time_limit, AND
19
+ // * up to 30 minutes of walking from public transport stops that were visited
20
+ // by public transport (IOW a path
21
+ // [origin]--walking->[stop]--walking-->[destination] is not possible but
22
+ // [origin]--walking->[stop]--public_transport-->[stop]--walking--> is.
23
+ PUBLIC_TRANSPORT = 0;
24
+ // Considers all paths found traveling by car from origin(s) to
25
+ // destination(s) within the travel_time_limit
26
+ DRIVING = 1;
27
+ // Considers all paths found by the following steps:
28
+ // * up to 30 minutes of driving (always included even no stops found)
29
+ // * all connections in the 30 minute driving range from public transport stops
30
+ // to other public transport stops in travel_time_limit, AND
31
+ // * up to 30 minutes of walking from public transport stops that were visited
32
+ // by public transport (IOW a path
33
+ // [origin]--driving->[stop]--walking-->[destination] is not possible but
34
+ // [origin]--driving->[stop]--public_transport-->[stop]--walking--> is.
35
+ // AND/OR
36
+ // * up to 30 minutes of walking
37
+ //
38
+ DRIVING_AND_PUBLIC_TRANSPORT = 2;
39
+ // Considers all paths found travelling by car from origin(s) to
40
+ // destination(s) including all paths that are traversable by ferries that
41
+ // take cars within the travel_time_limit.
42
+ DRIVING_AND_FERRY = 3;
43
+ // Considers all paths found travelling by foot from origin(s) to
44
+ // destination(s) within the travel_time_limit
45
+ WALKING = 4;
46
+ // Considers all paths found travelling by foot from origin(s) to
47
+ // destination(s) including all paths that are traversable by ferries that
48
+ // take passengers within the travel_time_limit
49
+ WALKING_AND_FERRY = 7;
50
+ // Considers all paths found travelling by bike from origin(s) to
51
+ // destination(s) within the travel_time_limit
52
+ CYCLING = 5;
53
+ // Considers all paths found travelling by bike from origin(s) to
54
+ // destination(s) including all paths that are traversable by ferries that
55
+ // take bikes within the travel_time_limit
56
+ CYCLING_AND_FERRY = 6;
57
+ }
58
+
59
+ enum TimePeriod {
60
+ WEEKDAY_MORNING = 0;
61
+ }
@@ -0,0 +1,35 @@
1
+ syntax = "proto3";
2
+
3
+ package com.igeolise.traveltime.rabbitmq.requests;
4
+
5
+ import "RequestsCommon.proto";
6
+
7
+ message TimeFilterFastRequest {
8
+ enum Property {
9
+ FARES = 0;
10
+ DISTANCES = 1;
11
+ }
12
+ message OneToMany {
13
+ Coords departureLocation = 1;
14
+ /*
15
+ * We encode arrival locations as deltas (relative to the source) using a fixedpoint encoding i.e
16
+ * deltaLat = round((lat - sourceLat) * 10^5).toInt
17
+ * deltaLon = round((lon - sourceLon) * 10^5).toInt
18
+ *
19
+ * The deltas should be interleaved in the `locationDeltas` field i.e
20
+ *
21
+ * locationDeltas[0] should be the first lat
22
+ * locationDeltas[1] should be the first lon
23
+ * locationDeltas[2] should be the second lat
24
+ * ...
25
+ * etc
26
+ */
27
+ repeated sint32 locationDeltas = 2;
28
+ Transportation transportation = 3;
29
+ TimePeriod arrivalTimePeriod = 4;
30
+ sint32 travelTime = 5;
31
+ repeated Property properties = 6;
32
+ }
33
+
34
+ OneToMany oneToManyRequest = 1;
35
+ }
@@ -0,0 +1,84 @@
1
+ syntax = "proto3";
2
+
3
+ package com.igeolise.traveltime.rabbitmq.responses;
4
+
5
+ message TimeFilterFastResponse {
6
+ message Properties {
7
+ repeated sint32 travelTimes = 1;
8
+ repeated int32 monthlyFares = 2;
9
+ repeated int32 distances = 3;
10
+ }
11
+
12
+ message Error {
13
+ ErrorType type = 1;
14
+ }
15
+
16
+ enum ErrorType {
17
+ /*
18
+ * Catch all unknown error type
19
+ */
20
+ UNKNOWN = 0;
21
+ /*
22
+ * oneToManyRequest to many field must not be null
23
+ */
24
+ ONE_TO_MANY_MUST_NOT_BE_NULL = 1;
25
+ /*
26
+ * Source (either departure or arrival location) must not be null
27
+ */
28
+ SOURCE_MUST_NOT_BE_NULL = 2;
29
+ /*
30
+ * Transportation mode must not be null.
31
+ */
32
+ TRANSPORTATION_MUST_NOT_BE_NULL = 3;
33
+ /*
34
+ * Source (either departure or arrival location) must not be null
35
+ */
36
+ SOURCE_NOT_IN_GEOMETRY = 4;
37
+
38
+ /*
39
+ * Transportation mode unrecognized.
40
+ */
41
+ UNRECOGNIZED_TRANSPORTATION_MODE = 5;
42
+
43
+ /*
44
+ * The travel time limit is too low to process this request.
45
+ */
46
+ TRAVEL_TIME_LIMIT_TOO_LOW = 6;
47
+
48
+ /*
49
+ * The travel time limit is too high to process this request.
50
+ */
51
+ TRAVEL_TIME_LIMIT_TOO_HIGH = 7;
52
+
53
+ /*
54
+ * User id not set.
55
+ */
56
+ AUTH_ERROR_NO_USER_ID = 8;
57
+
58
+ /*
59
+ * Message sent to wrong queue - transportation mode cannot be handled.
60
+ */
61
+ SERVICE_MISMATCH_WRONG_TRANSPORTATION_MODE = 9;
62
+
63
+ /*
64
+ * Source is in a area that doesn't have any points that can be out of
65
+ * search e.g a lake, mountains or other desolate areas.
66
+ */
67
+ SOURCE_OUT_OF_REACH = 10;
68
+
69
+ /*
70
+ * The interleaved deltas array should have (lat/lon) deltas and have an
71
+ * even number of elements
72
+ */
73
+ INTERLEAVED_DELTAS_INVALID_COORDINATE_PAIRS = 11;
74
+
75
+ /*
76
+ * Public transport requests do not support returning distances for
77
+ * returned points.
78
+ */
79
+ DISTANCE_PROPERTY_NOT_SUPPORTED = 12;
80
+ }
81
+
82
+ Error error = 1;
83
+ Properties properties = 2;
84
+ }
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'travel_time/proto/v2/RequestsCommon_pb'
4
+ require 'travel_time/proto/v2/TimeFilterFastRequest_pb'
5
+ require 'travel_time/proto/v2/TimeFilterFastResponse_pb'
6
+
7
+ module TravelTime
8
+ # Utilities for encoding/decoding protobuf requests
9
+ class ProtoUtils
10
+ def self.encode_fixed_point(source, target)
11
+ ((target - source) * 10.pow(5)).round
12
+ end
13
+
14
+ def self.build_deltas(departure, destinations)
15
+ deltas = destinations.map do |destination|
16
+ [encode_fixed_point(departure[:lat], destination[:lat]),
17
+ encode_fixed_point(departure[:lng], destination[:lng])]
18
+ end
19
+ deltas.flatten
20
+ end
21
+
22
+ def self.get_proto_transport_code(transport)
23
+ proto_transport_map = {
24
+ pt: 0,
25
+ 'driving+ferry': 3,
26
+ 'cycling+ferry': 6,
27
+ 'walking+ferry': 7
28
+ }
29
+ proto_transport_map[transport.to_sym]
30
+ end
31
+
32
+ def self.make_one_to_many(origin, destinations, transport, traveltime, properties)
33
+ Com::Igeolise::Traveltime::Rabbitmq::Requests::TimeFilterFastRequest::OneToMany.new(
34
+ departureLocation: origin,
35
+ locationDeltas: build_deltas(origin, destinations),
36
+ transportation: Com::Igeolise::Traveltime::Rabbitmq::Requests::Transportation.new(
37
+ { type: get_proto_transport_code(transport) }
38
+ ),
39
+ arrivalTimePeriod: 0,
40
+ travelTime: traveltime,
41
+ properties: properties
42
+ )
43
+ end
44
+
45
+ def self.make_proto_message(origin, destinations, transport, traveltime, properties: nil)
46
+ Com::Igeolise::Traveltime::Rabbitmq::Requests::TimeFilterFastRequest.new(
47
+ oneToManyRequest: make_one_to_many(origin, destinations, transport, traveltime, properties)
48
+ )
49
+ end
50
+
51
+ def self.encode_proto_message(message)
52
+ Com::Igeolise::Traveltime::Rabbitmq::Requests::TimeFilterFastRequest.encode(message)
53
+ end
54
+
55
+ def self.decode_proto_response(response)
56
+ Com::Igeolise::Traveltime::Rabbitmq::Responses::TimeFilterFastResponse.decode(response).to_h
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,44 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: RequestsCommon.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("RequestsCommon.proto", :syntax => :proto3) do
8
+ add_message "com.igeolise.traveltime.rabbitmq.requests.Coords" do
9
+ optional :lat, :float, 1
10
+ optional :lng, :float, 2
11
+ end
12
+ add_message "com.igeolise.traveltime.rabbitmq.requests.Transportation" do
13
+ optional :type, :enum, 1, "com.igeolise.traveltime.rabbitmq.requests.TransportationType"
14
+ end
15
+ add_enum "com.igeolise.traveltime.rabbitmq.requests.TransportationType" do
16
+ value :PUBLIC_TRANSPORT, 0
17
+ value :DRIVING, 1
18
+ value :DRIVING_AND_PUBLIC_TRANSPORT, 2
19
+ value :DRIVING_AND_FERRY, 3
20
+ value :WALKING, 4
21
+ value :WALKING_AND_FERRY, 7
22
+ value :CYCLING, 5
23
+ value :CYCLING_AND_FERRY, 6
24
+ end
25
+ add_enum "com.igeolise.traveltime.rabbitmq.requests.TimePeriod" do
26
+ value :WEEKDAY_MORNING, 0
27
+ end
28
+ end
29
+ end
30
+
31
+ module Com
32
+ module Igeolise
33
+ module Traveltime
34
+ module Rabbitmq
35
+ module Requests
36
+ Coords = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.Coords").msgclass
37
+ Transportation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.Transportation").msgclass
38
+ TransportationType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.TransportationType").enummodule
39
+ TimePeriod = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.TimePeriod").enummodule
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,40 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: TimeFilterFastRequest.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require_relative 'RequestsCommon_pb'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("TimeFilterFastRequest.proto", :syntax => :proto3) do
10
+ add_message "com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest" do
11
+ optional :oneToManyRequest, :message, 1, "com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.OneToMany"
12
+ end
13
+ add_message "com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.OneToMany" do
14
+ optional :departureLocation, :message, 1, "com.igeolise.traveltime.rabbitmq.requests.Coords"
15
+ repeated :locationDeltas, :sint32, 2
16
+ optional :transportation, :message, 3, "com.igeolise.traveltime.rabbitmq.requests.Transportation"
17
+ optional :arrivalTimePeriod, :enum, 4, "com.igeolise.traveltime.rabbitmq.requests.TimePeriod"
18
+ optional :travelTime, :sint32, 5
19
+ repeated :properties, :enum, 6, "com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.Property"
20
+ end
21
+ add_enum "com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.Property" do
22
+ value :FARES, 0
23
+ value :DISTANCES, 1
24
+ end
25
+ end
26
+ end
27
+
28
+ module Com
29
+ module Igeolise
30
+ module Traveltime
31
+ module Rabbitmq
32
+ module Requests
33
+ TimeFilterFastRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest").msgclass
34
+ TimeFilterFastRequest::OneToMany = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.OneToMany").msgclass
35
+ TimeFilterFastRequest::Property = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.TimeFilterFastRequest.Property").enummodule
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,51 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: TimeFilterFastResponse.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("TimeFilterFastResponse.proto", :syntax => :proto3) do
8
+ add_message "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse" do
9
+ optional :error, :message, 1, "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Error"
10
+ optional :properties, :message, 2, "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Properties"
11
+ end
12
+ add_message "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Properties" do
13
+ repeated :travelTimes, :sint32, 1
14
+ repeated :monthlyFares, :int32, 2
15
+ repeated :distances, :int32, 3
16
+ end
17
+ add_message "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Error" do
18
+ optional :type, :enum, 1, "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.ErrorType"
19
+ end
20
+ add_enum "com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.ErrorType" do
21
+ value :UNKNOWN, 0
22
+ value :ONE_TO_MANY_MUST_NOT_BE_NULL, 1
23
+ value :SOURCE_MUST_NOT_BE_NULL, 2
24
+ value :TRANSPORTATION_MUST_NOT_BE_NULL, 3
25
+ value :SOURCE_NOT_IN_GEOMETRY, 4
26
+ value :UNRECOGNIZED_TRANSPORTATION_MODE, 5
27
+ value :TRAVEL_TIME_LIMIT_TOO_LOW, 6
28
+ value :TRAVEL_TIME_LIMIT_TOO_HIGH, 7
29
+ value :AUTH_ERROR_NO_USER_ID, 8
30
+ value :SERVICE_MISMATCH_WRONG_TRANSPORTATION_MODE, 9
31
+ value :SOURCE_OUT_OF_REACH, 10
32
+ value :INTERLEAVED_DELTAS_INVALID_COORDINATE_PAIRS, 11
33
+ value :DISTANCE_PROPERTY_NOT_SUPPORTED, 12
34
+ end
35
+ end
36
+ end
37
+
38
+ module Com
39
+ module Igeolise
40
+ module Traveltime
41
+ module Rabbitmq
42
+ module Responses
43
+ TimeFilterFastResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse").msgclass
44
+ TimeFilterFastResponse::Properties = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Properties").msgclass
45
+ TimeFilterFastResponse::Error = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Error").msgclass
46
+ TimeFilterFastResponse::ErrorType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.ErrorType").enummodule
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -15,6 +15,14 @@ module TravelTime
15
15
  )
16
16
  end
17
17
 
18
+ def self.from_object_proto(response)
19
+ new(
20
+ status: response.status,
21
+ headers: response.headers,
22
+ body: ProtoUtils.decode_proto_response(response.body)
23
+ )
24
+ end
25
+
18
26
  def self.from_hash(response)
19
27
  new(
20
28
  status: response[:status],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TravelTime
4
- VERSION = '0.3.3'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/travel_time.rb CHANGED
@@ -5,6 +5,7 @@ require 'travel_time/client'
5
5
  require 'travel_time/error'
6
6
  require 'travel_time/response'
7
7
  require 'travel_time/version'
8
+ require 'travel_time/proto/utils'
8
9
 
9
10
  # Main TravelTime module
10
11
  module TravelTime
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travel_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TravelTime Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: google-protobuf
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '3.21'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 3.21.9
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '3.21'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 3.21.9
47
67
  description: TravelTime SDK for Ruby programming language
48
68
  email:
49
69
  - support@traveltime.com
@@ -61,6 +81,14 @@ files:
61
81
  - lib/travel_time/client.rb
62
82
  - lib/travel_time/error.rb
63
83
  - lib/travel_time/middleware/authentication.rb
84
+ - lib/travel_time/middleware/proto.rb
85
+ - lib/travel_time/proto/source/RequestsCommon.proto
86
+ - lib/travel_time/proto/source/TimeFilterFastRequest.proto
87
+ - lib/travel_time/proto/source/TimeFilterFastResponse.proto
88
+ - lib/travel_time/proto/utils.rb
89
+ - lib/travel_time/proto/v2/RequestsCommon_pb.rb
90
+ - lib/travel_time/proto/v2/TimeFilterFastRequest_pb.rb
91
+ - lib/travel_time/proto/v2/TimeFilterFastResponse_pb.rb
64
92
  - lib/travel_time/response.rb
65
93
  - lib/travel_time/version.rb
66
94
  homepage: https://traveltime.com