Class: Asdawqw::ProductController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::ProductController
- Defined in:
- lib/asdawqw/controllers/product_controller.rb
Overview
ProductController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_activation_list_product(content_type, body) ⇒ Object
This function allows logged in user to activate a list of products in BookingPal.
-
#create_deactivation_list_product(content_type, body) ⇒ Object
This function allows the logged in user to deactivate a list of products.
-
#create_product(content_type, body) ⇒ Object
This function allows a logged in user to create new product.
-
#delete_list_product(content_type, body) ⇒ Object
This function allows logged in user to delete list of products.
-
#delete_product(product_id) ⇒ Object
This function allows the logged in user to delete product.
-
#get_product_by_id(product_id) ⇒ Object
This function allows logged in user to get a specific product.
-
#get_product_list ⇒ Object
This API call will return a list of properties that belong to the current user.
- #instance ⇒ Object
-
#update_product(content_type, body) ⇒ Object
This function allows a logged in user to update product details.
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from Asdawqw::BaseController
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
12 13 14 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_activation_list_product(content_type, body) ⇒ Object
This function allows logged in user to activate a list of products in BookingPal. Products MUST be activated successfully before they can be distributed to any channel. Note: When a product is successfully activated it will be queued for the internal BP validation function and you will receive async push messages when the validation is completed - like it is described in the Validation section.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 221 def create_activation_list_product(content_type, body) # Prepare query url. _path_url = '/product/activation' _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) APIResponseWithoutData.from_hash(decoded) end |
#create_deactivation_list_product(content_type, body) ⇒ Object
This function allows the logged in user to deactivate a list of products. This function will also close the calendars on every channel the products have been listed on.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 254 def create_deactivation_list_product(content_type, body) # Prepare query url. _path_url = '/product/deactivation' _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) APIResponseWithoutData.from_hash(decoded) end |
#create_product(content_type, body) ⇒ Object
This function allows a logged in user to create new product. You can only send one product in each request.
53 54 55 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/product_controller.rb', line 53 def create_product(content_type, body) # Prepare query url. _path_url = '/product' _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) ProductResponse.from_hash(decoded) end |
#delete_list_product(content_type, body) ⇒ Object
This function allows logged in user to delete list of products.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 184 def delete_list_product(content_type, body) # Prepare query url. _path_url = '/product' _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.delete( _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 |
#delete_product(product_id) ⇒ Object
This function allows the logged in user to delete product.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 152 def delete_product(product_id) # Prepare query url. _path_url = '/product/{productId}' _path_url = APIHelper.append_url_with_template_parameters( _path_url, 'productId' => product_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.delete( _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) APIResponseWithoutData.from_hash(decoded) end |
#get_product_by_id(product_id) ⇒ Object
This function allows logged in user to get a specific product.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 121 def get_product_by_id(product_id) # Prepare query url. _path_url = '/product/{productId}' _path_url = APIHelper.append_url_with_template_parameters( _path_url, 'productId' => product_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) ProductResponse.from_hash(decoded) end |
#get_product_list ⇒ Object
This API call will return a list of properties that belong to the current user. This means that a user has to be logged in with products created already. Every API call in this section should be with PM credentials.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 24 def get_product_list # Prepare query url. _path_url = '/product' _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) ProductResponse.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 15 def instance self.class.instance end |
#update_product(content_type, body) ⇒ Object
This function allows a logged in user to update product details. Request parameters and request example will be the same as in the create product API. The only field that must be added is the product id. You need to have all other parameters which were used in the create API call that you want to keep (AltID can’t be updated). Everything that you do not send as an update will be deleted (overwritten). Response parameters and response examples are the same as in the create product API.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/asdawqw/controllers/product_controller.rb', line 91 def update_product(content_type, body) # Prepare query url. _path_url = '/product' _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.put( _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) ProductResponse.from_hash(decoded) end |