duffel_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/Appraisals +11 -0
  5. data/CHANGELOG.md +6 -0
  6. data/Gemfile +3 -2
  7. data/README.md +34 -1
  8. data/duffel_api.gemspec +6 -4
  9. data/examples/book_with_extra_baggage.rb +83 -0
  10. data/examples/book_with_seat.rb +1 -2
  11. data/lib/duffel_api/api_response.rb +35 -5
  12. data/lib/duffel_api/api_service.rb +18 -4
  13. data/lib/duffel_api/client.rb +24 -1
  14. data/lib/duffel_api/errors/error.rb +44 -1
  15. data/lib/duffel_api/list_response.rb +17 -0
  16. data/lib/duffel_api/middlewares/raise_duffel_errors.rb +18 -2
  17. data/lib/duffel_api/paginator.rb +11 -3
  18. data/lib/duffel_api/request.rb +32 -16
  19. data/lib/duffel_api/resources/aircraft.rb +7 -6
  20. data/lib/duffel_api/resources/airline.rb +7 -6
  21. data/lib/duffel_api/resources/airport.rb +21 -6
  22. data/lib/duffel_api/resources/base_resource.rb +3 -0
  23. data/lib/duffel_api/resources/offer_passenger.rb +11 -0
  24. data/lib/duffel_api/resources/offer_request.rb +15 -6
  25. data/lib/duffel_api/response.rb +24 -5
  26. data/lib/duffel_api/services/aircraft_service.rb +18 -0
  27. data/lib/duffel_api/services/airlines_service.rb +17 -0
  28. data/lib/duffel_api/services/airports_service.rb +18 -0
  29. data/lib/duffel_api/services/base_service.rb +17 -4
  30. data/lib/duffel_api/services/offer_passengers_service.rb +7 -0
  31. data/lib/duffel_api/services/offer_requests_service.rb +24 -0
  32. data/lib/duffel_api/services/offers_service.rb +18 -0
  33. data/lib/duffel_api/services/order_cancellations_service.rb +28 -0
  34. data/lib/duffel_api/services/order_change_offers_service.rb +18 -0
  35. data/lib/duffel_api/services/order_change_requests_service.rb +11 -0
  36. data/lib/duffel_api/services/order_changes_service.rb +17 -0
  37. data/lib/duffel_api/services/orders_service.rb +28 -0
  38. data/lib/duffel_api/services/payment_intents_service.rb +15 -0
  39. data/lib/duffel_api/services/payments_service.rb +5 -0
  40. data/lib/duffel_api/services/refunds_service.rb +10 -0
  41. data/lib/duffel_api/services/seat_maps_service.rb +6 -0
  42. data/lib/duffel_api/services/webhooks_service.rb +23 -2
  43. data/lib/duffel_api/version.rb +1 -1
  44. data/lib/duffel_api/webhook_event.rb +119 -0
  45. data/lib/duffel_api.rb +1 -0
  46. metadata +36 -6
  47. data/.circleci/config.yml +0 -82
  48. data/.github/dependabot.yml +0 -6
@@ -3,20 +3,24 @@
3
3
  require "json"
4
4
 
5
5
  module DuffelAPI
6
- # A class that wraps an API request
6
+ # An internal class used within the library that represents a request to be made to
7
+ # the Duffel API, and which is able to dispatch that request
7
8
  class Request
8
9
  # Initialize a request class, which makes calls to the API
9
- # @param connection
10
- # @param method [Symbol] the method to make the request with
10
+ #
11
+ # @param connection [Faraday] a Faraday connection
12
+ # @param method [Symbol] the HTTP method to make the request with
11
13
  # @param path [String] the path to make the request to
12
- # @param options [hash] options for the request
13
- # @param headers [hash] headers to send with the request
14
- def initialize(connection, method, path, options)
14
+ # @param headers [Hash] the HTTP request headers to send with the request
15
+ # @param params [Hash] Any paramters to include in the HTTP body
16
+ # @param query_params [Hash] Any parameters to include in the HTTP querystring
17
+ def initialize(connection, method, path, headers: {}, params: {}, query_params: {})
15
18
  @connection = connection
16
19
  @method = method
17
20
  @path = path
18
- @headers = (options.delete(:headers) || {}).transform_keys(&:to_s)
19
- @given_options = options
21
+ @headers = headers.transform_keys(&:to_s)
22
+ @option = params
23
+ @query_params = query_params
20
24
 
21
25
  @request_body = request_body
22
26
 
@@ -26,12 +30,18 @@ module DuffelAPI
26
30
  end
27
31
  end
28
32
 
29
- # Make the request and wrap it in a Response object
30
- def request
33
+ # Dispatches the request and returns the response
34
+ #
35
+ # @return [Response] the response from the request
36
+ def call
31
37
  Response.new(make_request)
32
38
  end
33
39
 
34
- # Make the API request
40
+ private
41
+
42
+ # Actually makes the request to the API
43
+ #
44
+ # @return [Faraday::Response]
35
45
  def make_request
36
46
  @connection.send(@method) do |request|
37
47
  request.url @path
@@ -41,23 +51,29 @@ module DuffelAPI
41
51
  end
42
52
  end
43
53
 
44
- # Fetch the body to send with the request
54
+ # Fetches the appropriate parameters to put into the request body, based on the HTTP
55
+ # method
56
+ #
57
+ # @return [Hash] the parameters to put into the request body, not yet JSON-encoded
45
58
  def request_body
46
59
  if @method == :get
47
60
  nil
48
61
  elsif %i[post put delete patch].include?(@method)
49
- @given_options.fetch(:params, {})
62
+ @option
50
63
  else
51
64
  raise "Unknown request method #{@method}"
52
65
  end
53
66
  end
54
67
 
55
- # Get the query params to send with the request
68
+ # Fetches the appropriate parameters to put into the request querystring, based on
69
+ # the HTTP method
70
+ #
71
+ # @return [Hash] the parameters to put into the request querystring
56
72
  def request_query
57
73
  if @method == :get
58
- @given_options.fetch(:params, {})
74
+ @option
59
75
  else
60
- @given_options.fetch(:query_params, {})
76
+ @query_params
61
77
  end
62
78
  end
63
79
  end
@@ -3,9 +3,14 @@
3
3
 
4
4
  module DuffelAPI
5
5
  module Resources
6
- class Aircraft
6
+ class Aircraft < BaseResource
7
+ # @return [String]
7
8
  attr_reader :iata_code
9
+
10
+ # @return [String]
8
11
  attr_reader :id
12
+
13
+ # @return [String]
9
14
  attr_reader :name
10
15
 
11
16
  def initialize(object, response = nil)
@@ -15,11 +20,7 @@ module DuffelAPI
15
20
  @id = object["id"]
16
21
  @name = object["name"]
17
22
 
18
- @response = response
19
- end
20
-
21
- def api_response
22
- APIResponse.new(@response)
23
+ super(object, response)
23
24
  end
24
25
  end
25
26
  end
@@ -3,9 +3,14 @@
3
3
 
4
4
  module DuffelAPI
5
5
  module Resources
6
- class Airline
6
+ class Airline < BaseResource
7
+ # @return [String, nil]
7
8
  attr_reader :iata_code
9
+
10
+ # @return [String]
8
11
  attr_reader :id
12
+
13
+ # @return [String]
9
14
  attr_reader :name
10
15
 
11
16
  def initialize(object, response = nil)
@@ -15,11 +20,7 @@ module DuffelAPI
15
20
  @id = object["id"]
16
21
  @name = object["name"]
17
22
 
18
- @response = response
19
- end
20
-
21
- def api_response
22
- APIResponse.new(@response)
23
+ super(object, response)
23
24
  end
24
25
  end
25
26
  end
@@ -3,16 +3,35 @@
3
3
 
4
4
  module DuffelAPI
5
5
  module Resources
6
- class Airport
6
+ class Airport < BaseResource
7
+ # @return [Hash, nil]
7
8
  attr_reader :city
9
+
10
+ # @return [String]
8
11
  attr_reader :city_name
12
+
13
+ # @return [String]
9
14
  attr_reader :iata_code
15
+
16
+ # @return [String]
10
17
  attr_reader :iata_country_code
18
+
19
+ # @return [String]
11
20
  attr_reader :icao_code
21
+
22
+ # @return [String]
12
23
  attr_reader :id
24
+
25
+ # @return [Float]
13
26
  attr_reader :latitude
27
+
28
+ # @return [Float]
14
29
  attr_reader :longitude
30
+
31
+ # @return [String]
15
32
  attr_reader :name
33
+
34
+ # @return [String]
16
35
  attr_reader :time_zone
17
36
 
18
37
  def initialize(object, response = nil)
@@ -29,11 +48,7 @@ module DuffelAPI
29
48
  @name = object["name"]
30
49
  @time_zone = object["time_zone"]
31
50
 
32
- @response = response
33
- end
34
-
35
- def api_response
36
- APIResponse.new(@response)
51
+ super(object, response)
37
52
  end
38
53
  end
39
54
  end
@@ -8,6 +8,9 @@ module DuffelAPI
8
8
  @response = response
9
9
  end
10
10
 
11
+ # Returns the raw API response where this resource originated from
12
+ #
13
+ # @return [APIResponse]
11
14
  def api_response
12
15
  APIResponse.new(@response)
13
16
  end
@@ -4,11 +4,22 @@
4
4
  module DuffelAPI
5
5
  module Resources
6
6
  class OfferPassenger < BaseResource
7
+ # @return [String, nil]
7
8
  attr_reader :type
9
+
10
+ # @return [Array<Hash>]
8
11
  attr_reader :loyalty_programme_accounts
12
+
13
+ # @return [String]
9
14
  attr_reader :id
15
+
16
+ # @return [String, nil]
10
17
  attr_reader :given_name
18
+
19
+ # @return [String, nil]
11
20
  attr_reader :family_name
21
+
22
+ # @return [String, nil]
12
23
  attr_reader :age
13
24
 
14
25
  def initialize(object, response = nil)
@@ -3,13 +3,26 @@
3
3
 
4
4
  module DuffelAPI
5
5
  module Resources
6
- class OfferRequest
6
+ class OfferRequest < BaseResource
7
+ # @return [String, nil]
7
8
  attr_reader :cabin_class
9
+
10
+ # @return [String]
8
11
  attr_reader :created_at
12
+
13
+ # @return [String]
9
14
  attr_reader :id
15
+
16
+ # @return [Boolean]
10
17
  attr_reader :live_mode
18
+
19
+ # @return [Array<Hash>]
11
20
  attr_reader :offers
21
+
22
+ # @return [Array<Hash>]
12
23
  attr_reader :passengers
24
+
25
+ # @return [Array<Hash>]
13
26
  attr_reader :slices
14
27
 
15
28
  def initialize(object, response = nil)
@@ -23,11 +36,7 @@ module DuffelAPI
23
36
  @passengers = object["passengers"]
24
37
  @slices = object["slices"]
25
38
 
26
- @response = response
27
- end
28
-
29
- def api_response
30
- APIResponse.new(@response)
39
+ super(object, response)
31
40
  end
32
41
  end
33
42
  end
@@ -1,26 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DuffelAPI
4
+ # An internal class used within the library to represent a response from the Duffel
5
+ # API
4
6
  class Response
5
7
  extend Forwardable
6
8
 
7
9
  def_delegator :@response, :headers
8
10
  def_delegator :@response, :status, :status_code
9
11
 
12
+ # Wraps a `Faraday::Response` in the library's own internal response class
13
+ #
14
+ # @param [Faraday::Response] response
15
+ # @return [Response]
10
16
  def initialize(response)
11
17
  @response = response
12
18
  end
13
19
 
20
+ # Returns the raw body of the HTTP response
21
+ #
22
+ # @return [String]
14
23
  def raw_body
15
24
  @response.body
16
25
  end
17
26
 
18
- # Return the body of parsed JSON body of the API response
27
+ # Return the parsed JSON body of the API response, if a body was returned
28
+ #
29
+ # @return [Hash, nil]
19
30
  def parsed_body
20
31
  JSON.parse(raw_body) unless raw_body.empty?
21
32
  end
22
33
 
23
- # Returns the meta hash of the response
34
+ # Returns the `meta` data returned from the Duffel API, if present. If not present,
35
+ # returns an empty hash (`{}`).
36
+ #
37
+ # @return [Hash]
24
38
  def meta
25
39
  return {} if parsed_body.nil?
26
40
 
@@ -29,17 +43,22 @@ module DuffelAPI
29
43
  {}
30
44
  end
31
45
 
32
- # Returns the request ID from the response headers
46
+ # Returns the request ID from the Duffel API, included in the response headers.
47
+ # This could be `nil` if the response didn't make it to the Duffel API itself and,
48
+ # for example, only reached a load balancer.
49
+ #
50
+ # @return [String, nil]
33
51
  def request_id
34
52
  normalised_headers["x-request-id"]
35
53
  end
36
54
 
37
55
  private
38
56
 
57
+ # Returns the HTTP response headers, with all of their keys in lower case
58
+ #
59
+ # @return [Hash]
39
60
  def normalised_headers
40
61
  headers.transform_keys(&:downcase)
41
62
  end
42
-
43
- def json?; end
44
63
  end
45
64
  end
@@ -3,6 +3,12 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class AircraftService < BaseService
6
+ # Lists aircraft, returning a single page of results
7
+ #
8
+ # @option [Hash] :params Parameters to include in the HTTP querystring, including
9
+ # any filters
10
+ # @return [ListResponse]
11
+ # @raise [Errors::Error] when the Duffel API returns an error
6
12
  def list(options = {})
7
13
  path = "/air/aircraft"
8
14
 
@@ -15,6 +21,13 @@ module DuffelAPI
15
21
  )
16
22
  end
17
23
 
24
+ # Returns an `Enumerator` which can automatically cycle through multiple
25
+ # pages of `Resources;:Aircraft`
26
+ #
27
+ # @param options [Hash] options passed to `#list`, for example `:params` to
28
+ # send an HTTP querystring with filters
29
+ # @return [Enumerator]
30
+ # @raise [Errors::Error] when the Duffel API returns an error
18
31
  def all(options = {})
19
32
  DuffelAPI::Paginator.new(
20
33
  service: self,
@@ -22,6 +35,11 @@ module DuffelAPI
22
35
  ).enumerator
23
36
  end
24
37
 
38
+ # Retrieves a single aircraft by ID
39
+ #
40
+ # @param id [String]
41
+ # @return [Resources::Aircraft]
42
+ # @raise [Errors::Error] when the Duffel API returns an error
25
43
  def get(id, options = {})
26
44
  path = substitute_url_pattern("/air/aircraft/:id", "id" => id)
27
45
 
@@ -3,6 +3,11 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class AirlinesService < BaseService
6
+ # Lists airports, returning a single page of results
7
+ #
8
+ # @option [Hash] :params Parameters to include in the HTTP querystring, including
9
+ # any filters
10
+ # @raise [Errors::Error] when the Duffel API returns an error
6
11
  def list(options = {})
7
12
  path = "/air/airlines"
8
13
 
@@ -15,6 +20,13 @@ module DuffelAPI
15
20
  )
16
21
  end
17
22
 
23
+ # Returns an `Enumerator` which can automatically cycle through multiple
24
+ # pages of `Resources;:Airline`s
25
+ #
26
+ # @param options [Hash] options passed to `#list`, for example `:params` to
27
+ # send an HTTP querystring with filters
28
+ # @return [Enumerator]
29
+ # @raise [Errors::Error] when the Duffel API returns an error
18
30
  def all(options = {})
19
31
  DuffelAPI::Paginator.new(
20
32
  service: self,
@@ -22,6 +34,11 @@ module DuffelAPI
22
34
  ).enumerator
23
35
  end
24
36
 
37
+ # Retrieves a single airline by ID
38
+ #
39
+ # @param id [String]
40
+ # @return [Resources::Airline]
41
+ # @raise [Errors::Error] when the Duffel API returns an error
25
42
  def get(id, options = {})
26
43
  path = substitute_url_pattern("/air/airlines/:id", "id" => id)
27
44
 
@@ -3,6 +3,12 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class AirportsService < BaseService
6
+ # Lists airports, returning a single page of results
7
+ #
8
+ # @option [Hash] :params Parameters to include in the HTTP querystring, including
9
+ # any filters
10
+ # @return [ListResponse]
11
+ # @raise [Errors::Error] when the Duffel API returns an error
6
12
  def list(options = {})
7
13
  path = "/air/airports"
8
14
 
@@ -15,6 +21,13 @@ module DuffelAPI
15
21
  )
16
22
  end
17
23
 
24
+ # Returns an `Enumerator` which can automatically cycle through multiple
25
+ # pages of `Resources;:Airport`s
26
+ #
27
+ # @param options [Hash] options passed to `#list`, for example `:params` to
28
+ # send an HTTP querystring with filters
29
+ # @return [Enumerator]
30
+ # @raise [Errors::Error] when the Duffel API returns an error
18
31
  def all(options = {})
19
32
  DuffelAPI::Paginator.new(
20
33
  service: self,
@@ -22,6 +35,11 @@ module DuffelAPI
22
35
  ).enumerator
23
36
  end
24
37
 
38
+ # Retrieves a single airport by ID
39
+ #
40
+ # @param id [String]
41
+ # @return [Resources::Airport]
42
+ # @raise [Errors::Error] when the Duffel API returns an error
25
43
  def get(id, options = {})
26
44
  path = substitute_url_pattern("/air/airports/:id", "id" => id)
27
45
 
@@ -5,22 +5,35 @@ require "cgi"
5
5
  module DuffelAPI
6
6
  module Services
7
7
  class BaseService
8
+ extend Forwardable
9
+
10
+ # Sets up a resource-specific service based on an API service
11
+ #
12
+ # @param api_service [APIService]
13
+ # @return [BaseService]
8
14
  def initialize(api_service)
9
15
  @api_service = api_service
10
16
  end
11
17
 
12
- def make_request(method, path, options = {})
13
- @api_service.make_request(method, path, options)
14
- end
15
-
16
18
  private
17
19
 
20
+ def_delegator :@api_service, :make_request
21
+
22
+ # Fills in variables in a patterned URL (e.g. `/widgets/:id`)
23
+ #
24
+ # @param url [String]
25
+ # @param param_map [Hash]
26
+ # @return [String]
18
27
  def substitute_url_pattern(url, param_map)
19
28
  param_map.reduce(url) do |new_url, (param, value)|
20
29
  new_url.gsub(":#{param}", CGI.escape(value))
21
30
  end
22
31
  end
23
32
 
33
+ # Extracts the data inside the `data` envelope from an API response
34
+ #
35
+ # @param parsed_body [Hash]
36
+ # @return [Hash]
24
37
  def unenvelope_body(parsed_body)
25
38
  parsed_body["data"]
26
39
  end
@@ -3,6 +3,13 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class OfferPassengersService < BaseService
6
+ # Updates an offer passenger, based on the offer ID and passenger ID
7
+ #
8
+ # @param offer_id [String]
9
+ # @param passenger_id [String]
10
+ # @option [required, Hash] :params the payload for updating the passenger
11
+ # @return [Resources::OfferPassenger]
12
+ # @raise [Errors::Error] when the Duffel API returns an error
6
13
  def update(offer_id, passenger_id, options = {})
7
14
  path = substitute_url_pattern(
8
15
  "/air/offers/:offer_id/passengers/:passenger_id",
@@ -3,6 +3,12 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class OfferRequestsService < BaseService
6
+ # Creates an offer request
7
+ #
8
+ # @option [required, Hash] :params the payload for creating the offer request,
9
+ # including parameters to be sent in the querystring
10
+ # @return [Resources::OfferRequest]
11
+ # @raise [Errors::Error] when the Duffel API returns an error
6
12
  def create(options = {})
7
13
  path = "/air/offer_requests"
8
14
 
@@ -34,6 +40,12 @@ module DuffelAPI
34
40
  Resources::OfferRequest.new(unenvelope_body(response.parsed_body), response)
35
41
  end
36
42
 
43
+ # Lists offer requests, returning a single page of results.
44
+ #
45
+ # @option [Hash] :params Parameters to include in the HTTP querystring, including
46
+ # any filters
47
+ # @return [ListResponse]
48
+ # @raise [Errors::Error] when the Duffel API returns an error
37
49
  def list(options = {})
38
50
  path = "/air/offer_requests"
39
51
 
@@ -46,6 +58,13 @@ module DuffelAPI
46
58
  )
47
59
  end
48
60
 
61
+ # Returns an `Enumerator` which can automatically cycle through multiple
62
+ # pages of `Resources;:OfferRequest`s
63
+ #
64
+ # @param options [Hash] options passed to `#list`, for example `:params` to
65
+ # send an HTTP querystring with filters
66
+ # @return [Enumerator]
67
+ # @raise [Errors::Error] when the Duffel API returns an error
49
68
  def all(options = {})
50
69
  Paginator.new(
51
70
  service: self,
@@ -53,6 +72,11 @@ module DuffelAPI
53
72
  ).enumerator
54
73
  end
55
74
 
75
+ # Retrieves a single offer request by ID
76
+ #
77
+ # @param id [String]
78
+ # @return [Resources::OfferRequest]
79
+ # @raise [Errors::Error] when the Duffel API returns an error
56
80
  def get(id, options = {})
57
81
  path = substitute_url_pattern("/air/offer_requests/:id", "id" => id)
58
82
 
@@ -3,6 +3,12 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class OffersService < BaseService
6
+ # Lists offers, returning a single page of results.
7
+ #
8
+ # @option [required, Hash] :params Parameters to include in the HTTP querystring,
9
+ # including any filters
10
+ # @return [ListResponse]
11
+ # @raise [Errors::Error] when the Duffel API returns an error
6
12
  def list(options = {})
7
13
  path = "/air/offers"
8
14
 
@@ -15,6 +21,13 @@ module DuffelAPI
15
21
  )
16
22
  end
17
23
 
24
+ # Returns an `Enumerator` which can automatically cycle through multiple
25
+ # pages of `Resources;:Offers`s
26
+ #
27
+ # @param options [Hash] options passed to `#list`, for example `:params` to
28
+ # send an HTTP querystring with filters
29
+ # @return [Enumerator]
30
+ # @raise [Errors::Error] when the Duffel API returns an error
18
31
  def all(options = {})
19
32
  Paginator.new(
20
33
  service: self,
@@ -22,6 +35,11 @@ module DuffelAPI
22
35
  ).enumerator
23
36
  end
24
37
 
38
+ # Retrieves a single offer by ID
39
+ #
40
+ # @param id [String]
41
+ # @return [Resources::Offer]
42
+ # @raise [Errors::Error] when the Duffel API returns an error
25
43
  def get(id, options = {})
26
44
  path = substitute_url_pattern("/air/offers/:id", "id" => id)
27
45
 
@@ -3,6 +3,11 @@
3
3
  module DuffelAPI
4
4
  module Services
5
5
  class OrderCancellationsService < BaseService
6
+ # Creates an order cancellation
7
+ #
8
+ # @option [required, Hash] :params the payload for creating the order cancellation
9
+ # @return [Resources::OrderCancellation]
10
+ # @raise [Errors::Error] when the Duffel API returns an error
6
11
  def create(options = {})
7
12
  path = "/air/order_cancellations"
8
13
 
@@ -22,6 +27,11 @@ module DuffelAPI
22
27
  Resources::OrderCancellation.new(unenvelope_body(response.parsed_body), response)
23
28
  end
24
29
 
30
+ # Confirms an order cancellation by ID
31
+ #
32
+ # @param id [String]
33
+ # @return [Resources::OrderCancellation]
34
+ # @raise [Errors::Error] when the Duffel API returns an error
25
35
  def confirm(id, options = {})
26
36
  path = substitute_url_pattern("/air/order_cancellations/:id/actions/confirm",
27
37
  "id" => id)
@@ -42,6 +52,12 @@ module DuffelAPI
42
52
  Resources::OrderCancellation.new(unenvelope_body(response.parsed_body), response)
43
53
  end
44
54
 
55
+ # Lists offers, returning a single page of results.
56
+ #
57
+ # @option [Hash] :params Parameters to include in the HTTP querystring, including
58
+ # any filters
59
+ # @return [ListResponse]
60
+ # @raise [Errors::Error] when the Duffel API returns an error
45
61
  def list(options = {})
46
62
  path = "/air/order_cancellations"
47
63
 
@@ -54,6 +70,13 @@ module DuffelAPI
54
70
  )
55
71
  end
56
72
 
73
+ # Returns an `Enumerator` which can automatically cycle through multiple
74
+ # pages of `Resources;:OrderCancellation`s
75
+ #
76
+ # @param options [Hash] options passed to `#list`, for example `:params` to
77
+ # send an HTTP querystring with filters
78
+ # @return [Enumerator]
79
+ # @raise [Errors::Error] when the Duffel API returns an error
57
80
  def all(options = {})
58
81
  Paginator.new(
59
82
  service: self,
@@ -61,6 +84,11 @@ module DuffelAPI
61
84
  ).enumerator
62
85
  end
63
86
 
87
+ # Retrieves a single order cancellation by ID
88
+ #
89
+ # @param id [String]
90
+ # @return [Resources::OrderCancellation]
91
+ # @raise [Errors::Error] when the Duffel API returns an error
64
92
  def get(id, options = {})
65
93
  path = substitute_url_pattern("/air/order_cancellations/:id", "id" => id)
66
94