Class: Asdawqw::ImagesController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::ImagesController
- Defined in:
- lib/asdawqw/controllers/images_controller.rb
Overview
ImagesController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_images(content_type, body) ⇒ Object
This function allows the logged in user to upload images for the existing product.
-
#delete_all_images_per_property(content_type, product_id) ⇒ Object
This function allows logged in user to delete images.
-
#delete_list_of_images(content_type, body) ⇒ Object
This function allows the logged in user to delete image(s) from the existing product.
-
#get_image_list_by_product_id(product_id) ⇒ Object
This function allows logged in user to get image list for the existing product.
- #instance ⇒ Object
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/images_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_images(content_type, body) ⇒ Object
This function allows the logged in user to upload images for the existing product. Every new image will be sorted to the end. The first image sent will be used as the “Main Image”. (Image re-ordering can also be done within the BookingPal platform manually by users)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/asdawqw/controllers/images_controller.rb', line 58 def create_images(content_type, body) # Prepare query url. _path_url = '/image' _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 |
#delete_all_images_per_property(content_type, product_id) ⇒ Object
This function allows logged in user to delete images. you want to delete all images
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 148 149 150 |
# File 'lib/asdawqw/controllers/images_controller.rb', line 122 def delete_all_images_per_property(content_type, product_id) # Prepare query url. _path_url = '/image/{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, 'Content-Type' => content_type } # 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 |
#delete_list_of_images(content_type, body) ⇒ Object
This function allows the logged in user to delete image(s) from the existing product.
90 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 |
# File 'lib/asdawqw/controllers/images_controller.rb', line 90 def delete_list_of_images(content_type, body) # Prepare query url. _path_url = '/image' _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 |
#get_image_list_by_product_id(product_id) ⇒ Object
This function allows logged in user to get image list for the existing product
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/asdawqw/controllers/images_controller.rb', line 23 def get_image_list_by_product_id(product_id) # Prepare query url. _path_url = '/image/{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) GetImageListByProductID.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/images_controller.rb', line 15 def instance self.class.instance end |