Class: DuffelAPI::Services::OrderChangesService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/duffel_api/services/order_changes_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::DEFAULT_ALL_PARAMS

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from DuffelAPI::Services::BaseService

Instance Method Details

#confirm(id, options = {}) ⇒ Resources::OrderChange

Confirms an order change by ID, passing across extra data required for

confirmation

Parameters:

  • id (String)
  • [required, (Hash)

    a customizable set of options

Returns:

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/duffel_api/services/order_changes_service.rb', line 37

def confirm(id, options = {})
  path = substitute_url_pattern("/air/order_changes/:id/actions/confirm",
                                "id" => id)

  params = options.delete(:params) || {}
  options[:params] = {}
  options[:params]["data"] = params

  begin
    response = make_request(:post, path, options)

    # Response doesn't raise any errors until #body is called
    response.tap(&:raw_body)
  end

  return if response.raw_body.nil?

  Resources::OrderChange.new(unenvelope_body(response.parsed_body), response)
end

#create(options = {}) ⇒ Resources::OrderChange

Creates an order chnage

Parameters:

  • [required, (Hash)

    a customizable set of options

Returns:

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/duffel_api/services/order_changes_service.rb', line 11

def create(options = {})
  path = "/air/order_changes"

  params = options.delete(:params) || {}
  options[:params] = {}
  options[:params]["data"] = params

  begin
    response = make_request(:post, path, options)

    # Response doesn't raise any errors until #body is called
    response.tap(&:raw_body)
  end

  return if response.raw_body.nil?

  Resources::OrderChange.new(unenvelope_body(response.parsed_body), response)
end

#get(id, options = {}) ⇒ Resources::OrderChange

Retrieves a single order change by ID

Parameters:

  • id (String)

Returns:

Raises:



62
63
64
65
66
67
68
69
70
# File 'lib/duffel_api/services/order_changes_service.rb', line 62

def get(id, options = {})
  path = substitute_url_pattern("/air/order_changes/:id", "id" => id)

  response = make_request(:get, path, options)

  return if response.raw_body.nil?

  Resources::OrderChange.new(unenvelope_body(response.parsed_body), response)
end