Class: Asdawqw::PushNotificationController

Inherits:
BaseController show all
Defined in:
lib/asdawqw/controllers/push_notification_controller.rb

Overview

PushNotificationController

Class Attribute Summary collapse

Attributes inherited from BaseController

#http_call_back, #http_client

Instance Method Summary collapse

Methods inherited from BaseController

#execute_request, #initialize, #validate_parameters, #validate_response

Constructor Details

This class inherits a constructor from Asdawqw::BaseController

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



12
13
14
# File 'lib/asdawqw/controllers/push_notification_controller.rb', line 12

def instance
  @instance
end

Instance Method Details

Provide the links on which the requests about new reservation and cancel reservation will be sent. Links should be https. These links should be set on PMS level, so please use your PMS credentials.

Parameters:

Returns:

  • PushNotificationLinksResponse response from the API call



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/asdawqw/controllers/push_notification_controller.rb', line 26

def create_push_notification_links(content_type,
                                   body)
  # Prepare query url.
  _path_url = '/info'
  _query_builder = Configuration.get_base_uri
  _query_builder << _path_url
  _query_url = APIHelper.clean_url _query_builder
  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'x-api-key' => Configuration.x_api_key,
    'Content-Type' => content_type
  }
  # Prepare and execute HttpRequest.
  _request = @http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  CustomQueryAuth.apply(_request)
  _context = execute_request(_request)
  validate_response(_context)
  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
  PushNotificationLinksResponse.from_hash(decoded)
end

This will return all notification URLs which are set. It will work on PMS level, so use PMS credentials.

Returns:

  • PushNotificationLinksResponse response from the API call



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/asdawqw/controllers/push_notification_controller.rb', line 56

def get_notification_links
  # Prepare query url.
  _path_url = '/info'
  _query_builder = Configuration.get_base_uri
  _query_builder << _path_url
  _query_url = APIHelper.clean_url _query_builder
  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'x-api-key' => Configuration.x_api_key
  }
  # Prepare and execute HttpRequest.
  _request = @http_client.get(
    _query_url,
    headers: _headers
  )
  CustomQueryAuth.apply(_request)
  _context = execute_request(_request)
  validate_response(_context)
  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
  PushNotificationLinksResponse.from_hash(decoded)
end

#instanceObject



15
16
17
# File 'lib/asdawqw/controllers/push_notification_controller.rb', line 15

def instance
  self.class.instance
end