Class: Asdawqw::TestingOfMessageAPICallsController

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

Overview

TestingOfMessageAPICallsController

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/testing_of_message_api_calls_controller.rb', line 12

def instance
  @instance
end

Instance Method Details

#get_test_message_list_for_specific_thread(thread_id) ⇒ Object

Since API calls for messages depend on channel connections and these values will exist in BookingPal only if guests on channel create some message, these calls can work only on production. So for testing purposes, we’ve built an additional endpoint with the same API calls where you will be able to test these calls. This function allows the logged-in user to get a list of all messages from passed thread Id. You need to use PM credentials Note: To be able to test these calls, you need to have at least 1 property, since we will in response return you messages for 1 property from your PM.

Parameters:

  • thread_id (String)

    Required parameter: ID of thread

Returns:

  • GetMessageListForSpecificThreadResponse response from the API call



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/asdawqw/controllers/testing_of_message_api_calls_controller.rb', line 87

def get_test_message_list_for_specific_thread(thread_id)
  # Prepare query url.
  _path_url = '/messageTest/specificthread/{threadId}'
  _path_url = APIHelper.append_url_with_template_parameters(
    _path_url,
    'threadId' => thread_id
  )
  _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)
  GetMessageListForSpecificThreadResponse.from_hash(decoded)
end

#get_test_message_threads(page, limit, thread_type) ⇒ Object

This function allows the logged in user to get all message threads or message threads with an unresponded message from guest for the whole PM. You need to use PM credentials. There is also paging as optional values. If you do not pass this value, we will return the first page and 10 threads per page. Since API calls for messages depend on channel connections and these values will exist in BookingPal only if guests on channel create some message, these calls can work only on production. So for testing purposes we’ve built an additional endpoint with the same API calls where you will be able to test these calls. Note: To be able to test these calls, you need to have at least 1 property, since we will in response return you messages for 1 property from your PM. only threads with unanswered message new,all

Parameters:

  • page (Integer)

    Required parameter: Example:

  • limit (Integer)

    Required parameter: Example:

  • thread_type (String)

    Required parameter: Request all threads or

Returns:

  • GetMessageThreadsResponse response from the API call



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/asdawqw/controllers/testing_of_message_api_calls_controller.rb', line 37

def get_test_message_threads(page,
                             limit,
                             thread_type)
  # Prepare query url.
  _path_url = '/messageTest/allthreads/{threadType}'
  _path_url = APIHelper.append_url_with_template_parameters(
    _path_url,
    'threadType' => thread_type
  )
  _query_builder = Configuration.get_base_uri
  _query_builder << _path_url
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    {
      'page' => page,
      'limit' => limit
    },
    array_serialization: Configuration.array_serialization
  )
  _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)
  GetMessageThreadsResponse.from_hash(decoded)
end

#instanceObject



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

def instance
  self.class.instance
end

#post_new_test_message_for_specific_thread(body) ⇒ Object

This function will allow PM to post new messages in already existing threads. Since this call is only for testing - we will not actually save these passed values. Since API calls for messages depend on channel connections and these values will exist in BookingPal only if guests on channel create some message, these calls can work only on production. So for testing purposes, we’ve built an additional endpoint with the same API calls where you will be able to test these calls. Note: To be able to test these calls, you need to have at least 1 property, since we will in response return to you messages for 1 property from your PM. Example:

Parameters:

Returns:

  • APIResponseWithoutData response from the API call



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/asdawqw/controllers/testing_of_message_api_calls_controller.rb', line 129

def post_new_test_message_for_specific_thread(body)
  # Prepare query url.
  _path_url = '/messageTest'
  _query_builder = Configuration.get_base_uri
  _query_builder << _path_url
  _query_url = APIHelper.clean_url _query_builder
  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8',
    'x-api-key' => Configuration.x_api_key
  }
  # 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)
  APIResponseWithoutData.from_hash(decoded)
end