flightbyte 1.0.0

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.
@@ -0,0 +1,414 @@
1
+ # Type signatures for the flightbyte gem's public API.
2
+ module FlightByte
3
+ VERSION: String
4
+
5
+ FLIGHT_PHASES: Array[String]
6
+ TERMINAL_PHASES: Array[String]
7
+ SUBSCRIPTION_STATUSES: Array[String]
8
+ FLIGHT_CHANGE_TYPES: Array[String]
9
+ WEBHOOK_EVENT_TYPES: Array[String]
10
+ DELIVERY_STATUSES: Array[String]
11
+
12
+ type date_like = String | Date | Time
13
+ type json = String | Integer | Float | bool | nil | Array[json] | Hash[String, json]
14
+
15
+ def self.format_date: (Date | Time value) -> String
16
+ def self.terminal_phase?: (String? phase) -> bool
17
+ def self.best_gate_time: (EndpointTimes | Hash[String, untyped] | nil times) -> (FlightTime | Hash[String, untyped] | nil)
18
+ def self.mask_secret: (String secret) -> String
19
+
20
+ class Client
21
+ DEFAULT_BASE_URL: String
22
+ DEFAULT_TIMEOUT: Integer
23
+
24
+ attr_reader flights: Flights
25
+ attr_reader subscriptions: Subscriptions
26
+ attr_reader countries: Countries
27
+ attr_reader base_url: String
28
+ attr_reader timeout: Numeric
29
+ attr_reader user_agent: String
30
+
31
+ def initialize: (api_key: String, ?base_url: String, ?timeout: Numeric, ?user_agent: String?) -> void
32
+ def last_rate_limit: () -> RateLimit?
33
+ end
34
+
35
+ class Flights
36
+ def get: (carrier: String | Symbol, flight_number: String | Integer, date: date_like,
37
+ ?origin: String?, ?destination: String?, ?flight_id: String?, ?refresh: bool,
38
+ ?timeout: Numeric?) -> FlightSnapshot
39
+ def timeline: (carrier: String | Symbol, flight_number: String | Integer, date: date_like,
40
+ ?origin: String?, ?destination: String?, ?timeout: Numeric?) -> FlightTimeline
41
+ end
42
+
43
+ class Subscriptions
44
+ DEFAULT_PAGE_SIZE: Integer
45
+
46
+ def create: (carrier: String | Symbol, flight_number: String | Integer, date: date_like, webhook_url: String,
47
+ ?origin: String?, ?destination: String?, ?flight_id: String?, ?secret: String?,
48
+ ?events: Array[String | Symbol]?, ?delay_threshold_minutes: Integer?,
49
+ ?headers: Hash[String | Symbol, String]?, ?metadata: Hash[String | Symbol, String]?,
50
+ ?idempotency_key: String?, ?timeout: Numeric?) -> CreatedSubscription
51
+ def list: (?status: String?, ?carrier: String?, ?flight_number: (String | Integer)?, ?date: date_like?,
52
+ ?limit: Integer?, ?offset: Integer?, ?timeout: Numeric?) -> SubscriptionPage
53
+ def list_all: (?status: String?, ?carrier: String?, ?flight_number: (String | Integer)?, ?date: date_like?,
54
+ ?offset: Integer?, ?page_size: Integer, ?timeout: Numeric?) -> Enumerator[Subscription, void]
55
+ | (?status: String?, ?carrier: String?, ?flight_number: (String | Integer)?, ?date: date_like?,
56
+ ?offset: Integer?, ?page_size: Integer, ?timeout: Numeric?) { (Subscription) -> void } -> nil
57
+ alias each list_all
58
+ def get: (String id, ?timeout: Numeric?) -> Subscription
59
+ def update: (String id, ?webhook_url: String?, ?events: Array[String | Symbol]?,
60
+ ?delay_threshold_minutes: Integer?, ?headers: Hash[String | Symbol, String]?,
61
+ ?metadata: Hash[String | Symbol, String]?, ?timeout: Numeric?) -> Subscription
62
+ def delete: (String id, ?timeout: Numeric?) -> nil
63
+ def pause: (String id, ?timeout: Numeric?) -> Subscription
64
+ def resume: (String id, ?timeout: Numeric?) -> Subscription
65
+ def send_test: (String id, ?timeout: Numeric?) -> String
66
+ def deliveries: (String id, ?limit: Integer?, ?timeout: Numeric?) -> Array[DeliveryRecord]
67
+ def events: (String id, ?limit: Integer?, ?timeout: Numeric?) -> Array[WebhookEvent]
68
+ def secret: (String id, ?timeout: Numeric?) -> String
69
+ def rotate_secret: (String id, ?timeout: Numeric?) -> String
70
+ end
71
+
72
+ class Countries
73
+ def list: (?lang: String?, ?timeout: Numeric?) -> Array[Country]
74
+ def get: (String code, ?lang: String?, ?timeout: Numeric?) -> Country
75
+ def flag_url: (String code, ?square: bool) -> String
76
+ end
77
+
78
+ class RateLimitWindow < Struct[untyped]
79
+ attr_reader limit: Integer
80
+ attr_reader remaining: Integer
81
+ attr_reader reset_at: Time?
82
+ end
83
+
84
+ class RateLimit < Struct[untyped]
85
+ attr_reader minute: RateLimitWindow?
86
+ attr_reader day: RateLimitWindow?
87
+ attr_reader month: RateLimitWindow?
88
+ end
89
+
90
+ class Error < StandardError
91
+ end
92
+
93
+ class ConnectionError < Error
94
+ def timed_out?: () -> bool
95
+ end
96
+
97
+ class APIError < Error
98
+ attr_reader status: Integer
99
+ attr_reader messages: Array[String]
100
+ attr_reader body: Hash[String, untyped]
101
+ attr_reader raw_body: String
102
+ attr_reader headers: Hash[String, String]
103
+ def code: () -> String?
104
+ def request_id: () -> String?
105
+ end
106
+
107
+ class BadRequestError < APIError
108
+ def legs: () -> Array[AmbiguousLeg]
109
+ end
110
+
111
+ class AuthenticationError < APIError
112
+ end
113
+
114
+ class PaymentRequiredError < APIError
115
+ def limit: () -> Numeric?
116
+ def used: () -> Numeric?
117
+ def resets_at: () -> String?
118
+ def cap_cents: () -> Numeric?
119
+ def balance: () -> Numeric?
120
+ def expires_at: () -> String?
121
+ end
122
+
123
+ class PermissionDeniedError < APIError
124
+ end
125
+
126
+ class NotFoundError < APIError
127
+ end
128
+
129
+ class RateLimitError < APIError
130
+ def window: () -> String?
131
+ def retry_after: () -> Numeric?
132
+ end
133
+
134
+ class ServerError < APIError
135
+ end
136
+
137
+ class UpstreamError < ServerError
138
+ end
139
+
140
+ class UnexpectedStatusError < APIError
141
+ def location: () -> String?
142
+ end
143
+
144
+ class WebhookSignatureError < Error
145
+ end
146
+
147
+ module Webhook
148
+ SIGNATURE_HEADER: String
149
+ TIMESTAMP_HEADER: String
150
+ EVENT_ID_HEADER: String
151
+ EVENT_TYPE_HEADER: String
152
+ SUBSCRIPTION_ID_HEADER: String
153
+ DELIVERY_ATTEMPT_HEADER: String
154
+ SIGNATURE_ENV_KEY: String
155
+ DEFAULT_TOLERANCE: Integer
156
+ MAX_BODY_BYTES: Integer
157
+
158
+ type clock = Time | Numeric
159
+
160
+ def self.verify: (String payload, String? signature, String secret, ?tolerance: Numeric, ?now: clock?) -> true
161
+ def self.valid?: (String payload, String? signature, String secret, ?tolerance: Numeric, ?now: clock?) -> bool
162
+ def self.construct_event: (String payload, String? signature, String secret, ?tolerance: Numeric,
163
+ ?now: clock?) -> WebhookEvent
164
+ def self.sign: (String payload, String secret, ?timestamp: clock?) -> String
165
+
166
+ class RackApp
167
+ def initialize: (String secret, ?tolerance: Numeric, ?now: clock?,
168
+ ?on_error: ^(StandardError, WebhookEvent, Hash[String, untyped]) -> void)
169
+ { (WebhookEvent event, Hash[String, untyped] env) -> void } -> void
170
+ def call: (Hash[String, untyped] env) -> [Integer, Hash[String, String], Array[String]]
171
+ end
172
+ end
173
+
174
+ # A read-only view of a JSON object the API sent. Fields the API added after
175
+ # this release read as snake_case methods too (method_missing).
176
+ class Object
177
+ def self.fields: () -> Hash[String, untyped]
178
+ def self.method_name: (String | Symbol key) -> String
179
+
180
+ def initialize: (?Hash[String | Symbol, untyped] data) -> void
181
+ def []: (String | Symbol key) -> untyped
182
+ def dig: (String | Symbol | Integer key, *String | Symbol | Integer rest) -> untyped
183
+ def key?: (String | Symbol key) -> bool
184
+ def keys: () -> Array[String]
185
+ def to_h: () -> Hash[String, json]
186
+ def as_json: (*untyped) -> Hash[String, json]
187
+ def to_json: (*untyped) -> String
188
+ def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
189
+ def ==: (untyped other) -> bool
190
+ def eql?: (untyped other) -> bool
191
+ def hash: () -> Integer
192
+ def inspect: () -> String
193
+ def to_s: () -> String
194
+ end
195
+
196
+ class CountryRef < Object
197
+ def code: () -> String
198
+ def name: () -> String
199
+ def emoji: () -> String
200
+ def flag_svg: () -> String
201
+ def flag_svg_square: () -> String
202
+ end
203
+
204
+ class Country < CountryRef
205
+ def alpha2: () -> String
206
+ def has_flag: () -> bool
207
+ def has_flag?: () -> bool
208
+ end
209
+
210
+ class AirportRef < Object
211
+ def iata: () -> String
212
+ def icao: () -> String?
213
+ def code: () -> String?
214
+ def name: () -> String
215
+ def city: () -> String?
216
+ def state: () -> String?
217
+ def country: () -> CountryRef
218
+ def timezone: () -> String?
219
+ end
220
+
221
+ class FlightTime < Object
222
+ def utc: () -> String
223
+ def local: () -> String?
224
+ def timezone: () -> String?
225
+ end
226
+
227
+ class EndpointTimes < Object
228
+ def scheduled_gate: () -> FlightTime?
229
+ def estimated_gate: () -> FlightTime?
230
+ def actual_gate: () -> FlightTime?
231
+ def scheduled_runway: () -> FlightTime?
232
+ def estimated_runway: () -> FlightTime?
233
+ def actual_runway: () -> FlightTime?
234
+ def best_gate: () -> FlightTime?
235
+ end
236
+
237
+ class FlightEndpoint < Object
238
+ def airport: () -> AirportRef
239
+ def terminal: () -> String?
240
+ def gate: () -> String?
241
+ def baggage: () -> String?
242
+ def times: () -> EndpointTimes
243
+ def best_time_utc: () -> String?
244
+ def delay_minutes: () -> Integer?
245
+ end
246
+
247
+ class CarrierRef < Object
248
+ def iata: () -> String
249
+ def icao: () -> String?
250
+ def name: () -> String
251
+ end
252
+
253
+ class CodeshareRef < Object
254
+ def carrier: () -> String
255
+ def name: () -> String
256
+ def flight_number: () -> String
257
+ end
258
+
259
+ class FlightStatusInfo < Object
260
+ def code: () -> String
261
+ def label: () -> String
262
+ def description: () -> String?
263
+ def color: () -> String?
264
+ def phase: () -> String
265
+ def delayed: () -> bool
266
+ def delayed?: () -> bool
267
+ def cancelled: () -> bool
268
+ def cancelled?: () -> bool
269
+ def diverted: () -> bool
270
+ def diverted?: () -> bool
271
+ def departure_gate_delay_minutes: () -> Integer?
272
+ def arrival_gate_delay_minutes: () -> Integer?
273
+ def terminal?: () -> bool
274
+ end
275
+
276
+ class EquipmentInfo < Object
277
+ def tail_number: () -> String?
278
+ def iata: () -> String?
279
+ def name: () -> String?
280
+ def source: () -> String?
281
+ end
282
+
283
+ class DurationInfo < Object
284
+ def scheduled_minutes: () -> Integer?
285
+ def estimated_minutes: () -> Integer?
286
+ def actual_minutes: () -> Integer?
287
+ end
288
+
289
+ class TimelineEntry < Object
290
+ def occurred_at: () -> String
291
+ def title: () -> String
292
+ def source: () -> String?
293
+ def events: () -> Array[String]
294
+ end
295
+
296
+ class FlightLegRef < Object
297
+ def provider_flight_id: () -> String?
298
+ def carrier: () -> String?
299
+ def departure_iata: () -> String
300
+ def arrival_iata: () -> String
301
+ def scheduled_departure_local: () -> String?
302
+ def scheduled_arrival_local: () -> String?
303
+ def selected: () -> bool
304
+ def selected?: () -> bool
305
+ end
306
+
307
+ class FlightSnapshot < Object
308
+ def flight_key: () -> String
309
+ def carrier_code: () -> String
310
+ def flight_number: () -> String
311
+ def date: () -> String
312
+ def provider_flight_id: () -> String?
313
+ def fetched_at: () -> String
314
+ def carrier: () -> CarrierRef
315
+ def operated_by: () -> String?
316
+ def codeshares: () -> Array[CodeshareRef]
317
+ def departure: () -> FlightEndpoint
318
+ def arrival: () -> FlightEndpoint
319
+ def diverted: () -> FlightEndpoint?
320
+ def status: () -> FlightStatusInfo
321
+ def equipment: () -> EquipmentInfo
322
+ def duration: () -> DurationInfo
323
+ def timeline: () -> Array[TimelineEntry]
324
+ def alternates: () -> Array[FlightLegRef]
325
+ def fingerprint: () -> String
326
+ def cached: () -> bool?
327
+ def cached?: () -> bool
328
+ end
329
+
330
+ class FlightTimeline < Object
331
+ def flight_key: () -> String
332
+ def count: () -> Integer
333
+ def data: () -> Array[TimelineEntry]
334
+ end
335
+
336
+ class Subscription < Object
337
+ def id: () -> String
338
+ def status: () -> String
339
+ def flight_key: () -> String
340
+ def carrier: () -> String
341
+ def flight_number: () -> String
342
+ def date: () -> String
343
+ def webhook_url: () -> String
344
+ def secret_hint: () -> String?
345
+ def secret: () -> String?
346
+ def headers: () -> Hash[String, String]?
347
+ def events: () -> Array[String]
348
+ def delay_threshold_minutes: () -> Integer
349
+ def metadata: () -> Hash[String, String]?
350
+ def created_at: () -> String
351
+ def updated_at: () -> String
352
+ def last_polled_at: () -> String?
353
+ def last_change_at: () -> String?
354
+ def last_delivery_at: () -> String?
355
+ def delivered_count: () -> Integer
356
+ def failed_count: () -> Integer
357
+ def flight_resolved: () -> bool
358
+ def flight_resolved?: () -> bool
359
+ def status_reason: () -> String?
360
+ end
361
+
362
+ class CreatedSubscription < Subscription
363
+ def reused: () -> bool
364
+ def reused?: () -> bool
365
+ def flight: () -> FlightSnapshot?
366
+ end
367
+
368
+ class SubscriptionPage < Object
369
+ def total: () -> Integer
370
+ def limit: () -> Integer
371
+ def offset: () -> Integer
372
+ def data: () -> Array[Subscription]
373
+ end
374
+
375
+ class DeliveryRecord < Object
376
+ def event_id: () -> String
377
+ def attempt: () -> Integer
378
+ def status: () -> String
379
+ def http_status: () -> Integer?
380
+ def error: () -> String?
381
+ def duration_ms: () -> Integer
382
+ def at: () -> String
383
+ def change_types: () -> Array[String]
384
+ end
385
+
386
+ class FlightChange < Object
387
+ def type: () -> String
388
+ def path: () -> String
389
+ def from: () -> (String | Numeric | bool | nil)
390
+ def to: () -> (String | Numeric | bool | nil)
391
+ def message: () -> String
392
+ def delta_minutes: () -> Integer?
393
+ end
394
+
395
+ class WebhookEvent < Object
396
+ def id: () -> String
397
+ def type: () -> String
398
+ def created_at: () -> String
399
+ def subscription_id: () -> String
400
+ def flight_key: () -> String
401
+ def flight: () -> FlightSnapshot?
402
+ def changes: () -> Array[FlightChange]
403
+ def previous_fetched_at: () -> String?
404
+ def metadata: () -> Hash[String, String]?
405
+ end
406
+
407
+ class AmbiguousLeg < Object
408
+ def origin: () -> String
409
+ def destination: () -> String
410
+ def carrier: () -> String?
411
+ def scheduled_departure_local: () -> String?
412
+ def flight_id: () -> String?
413
+ end
414
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flightbyte
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - FlightByte
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Look flights up, watch them with signed webhooks and verify every delivery.
13
+ Flights, subscriptions, countries and a Rack webhook receiver, with no dependencies
14
+ outside the standard library.
15
+ email:
16
+ - support@flightbyte.dev
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE
23
+ - README.md
24
+ - lib/flightbyte.rb
25
+ - lib/flightbyte/client.rb
26
+ - lib/flightbyte/errors.rb
27
+ - lib/flightbyte/models.rb
28
+ - lib/flightbyte/object.rb
29
+ - lib/flightbyte/rate_limit.rb
30
+ - lib/flightbyte/resources/countries.rb
31
+ - lib/flightbyte/resources/flights.rb
32
+ - lib/flightbyte/resources/subscriptions.rb
33
+ - lib/flightbyte/transport.rb
34
+ - lib/flightbyte/values.rb
35
+ - lib/flightbyte/version.rb
36
+ - lib/flightbyte/webhook.rb
37
+ - lib/flightbyte/webhook/rack_app.rb
38
+ - sig/flightbyte.rbs
39
+ homepage: https://flightbyte.dev
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://flightbyte.dev
44
+ documentation_uri: https://flightbyte.dev/docs
45
+ source_code_uri: https://github.com/FlightByte-dev/flightbyte-ruby
46
+ bug_tracker_uri: https://github.com/FlightByte-dev/flightbyte-ruby/issues
47
+ changelog_uri: https://github.com/FlightByte-dev/flightbyte-ruby/blob/main/CHANGELOG.md
48
+ rubygems_mfa_required: 'true'
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '3.1'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 4.0.20
64
+ specification_version: 4
65
+ summary: Official Ruby client for the FlightByte flight status API.
66
+ test_files: []