Class: Raas::OrdersController
- Inherits:
-
BaseController
- Object
- BaseController
- Raas::OrdersController
- Defined in:
- lib/raas/controllers/orders_controller.rb
Constant Summary collapse
- @@instance =
OrdersController.new
Instance Attribute Summary
Attributes inherited from BaseController
Class Method Summary collapse
-
.instance ⇒ Object
Singleton instance of the controller class.
Instance Method Summary collapse
-
#create_order(body) ⇒ Object
TODO: type endpoint description here.
-
#create_resend_order(reference_order_id) ⇒ Object
TODO: type endpoint description here.
-
#get_order(reference_order_id) ⇒ Object
TODO: type endpoint description here.
-
#get_orders(options = Hash.new) ⇒ Object
TODO: type endpoint description here.
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from Raas::BaseController
Class Method Details
.instance ⇒ Object
Singleton instance of the controller class
7 8 9 |
# File 'lib/raas/controllers/orders_controller.rb', line 7 def self.instance @@instance end |
Instance Method Details
#create_order(body) ⇒ Object
TODO: type endpoint description here
14 15 16 17 18 19 20 21 22 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 50 51 52 53 |
# File 'lib/raas/controllers/orders_controller.rb', line 14 def create_order(body) begin @logger.info("create_order called.") # validate required parameters @logger.info("Validating required parameters for create_order.") validate_parameters({ 'body' => body }) # prepare query url @logger.info("Preparing query URL for create_order.") _query_builder = Configuration.get_base_uri() _query_builder << '/orders' _query_url = APIHelper.clean_url _query_builder # prepare headers @logger.info("Preparing headers for create_order.") _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # prepare and execute HttpRequest @logger.info('Preparing and executing HttpRequest for create_order.') _request = @http_client.post _query_url, headers: _headers, parameters: body.to_json BasicAuth.apply(_request) _context = execute_request(_request, name: 'create_order') validate_response(_context) # return appropriate response type @logger.info("Returning response for create_order.") decoded = APIHelper.json_deserialize(_context.response.raw_body) return OrderModel.from_hash(decoded) rescue Exception => e @logger.error(e) raise e end end |
#create_resend_order(reference_order_id) ⇒ Object
TODO: type endpoint description here
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 |
# File 'lib/raas/controllers/orders_controller.rb', line 104 def create_resend_order(reference_order_id) begin @logger.info("create_resend_order called.") # validate required parameters @logger.info("Validating required parameters for create_resend_order.") validate_parameters({ 'reference_order_id' => reference_order_id }) # prepare query url @logger.info("Preparing query URL for create_resend_order.") _query_builder = Configuration.get_base_uri() _query_builder << '/orders/{referenceOrderID}/resends' _query_builder = APIHelper.append_url_with_template_parameters _query_builder, { 'referenceOrderID' => reference_order_id } _query_url = APIHelper.clean_url _query_builder # prepare headers @logger.info("Preparing headers for create_resend_order.") _headers = { 'accept' => 'application/json' } # prepare and execute HttpRequest @logger.info('Preparing and executing HttpRequest for create_resend_order.') _request = @http_client.post _query_url, headers: _headers BasicAuth.apply(_request) _context = execute_request(_request, name: 'create_resend_order') validate_response(_context) # return appropriate response type @logger.info("Returning response for create_resend_order.") decoded = APIHelper.json_deserialize(_context.response.raw_body) return ResendOrderResponseModel.from_hash(decoded) rescue Exception => e @logger.error(e) raise e end end |
#get_order(reference_order_id) ⇒ Object
TODO: type endpoint description here
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/raas/controllers/orders_controller.rb', line 58 def get_order(reference_order_id) begin @logger.info("get_order called.") # validate required parameters @logger.info("Validating required parameters for get_order.") validate_parameters({ 'reference_order_id' => reference_order_id }) # prepare query url @logger.info("Preparing query URL for get_order.") _query_builder = Configuration.get_base_uri() _query_builder << '/orders/{referenceOrderID}' _query_builder = APIHelper.append_url_with_template_parameters _query_builder, { 'referenceOrderID' => reference_order_id } _query_url = APIHelper.clean_url _query_builder # prepare headers @logger.info("Preparing headers for get_order.") _headers = { 'accept' => 'application/json' } # prepare and execute HttpRequest @logger.info('Preparing and executing HttpRequest for get_order.') _request = @http_client.get _query_url, headers: _headers BasicAuth.apply(_request) _context = execute_request(_request, name: 'get_order') validate_response(_context) # return appropriate response type @logger.info("Returning response for get_order.") decoded = APIHelper.json_deserialize(_context.response.raw_body) return OrderModel.from_hash(decoded) rescue Exception => e @logger.error(e) raise e end end |
#get_orders(options = Hash.new) ⇒ Object
TODO: type endpoint description here
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/raas/controllers/orders_controller.rb', line 156 def get_orders( = Hash.new) begin @logger.info("get_orders called.") # prepare query url @logger.info("Preparing query URL for get_orders.") _query_builder = Configuration.get_base_uri() _query_builder << '/orders' _query_builder = APIHelper.append_url_with_query_parameters _query_builder, { 'accountIdentifier' => ['account_identifier'], 'customerIdentifier' => ['customer_identifier'], 'externalRefID' => ['external_ref_id'], 'startDate' => ['start_date'], 'endDate' => ['end_date'], 'elementsPerBlock' => ['elements_per_block'], 'page' => ['page'] }, array_serialization: Configuration.array_serialization _query_url = APIHelper.clean_url _query_builder # prepare headers @logger.info("Preparing headers for get_orders.") _headers = { 'accept' => 'application/json' } # prepare and execute HttpRequest @logger.info('Preparing and executing HttpRequest for get_orders.') _request = @http_client.get _query_url, headers: _headers BasicAuth.apply(_request) _context = execute_request(_request, name: 'get_orders') validate_response(_context) # return appropriate response type @logger.info("Returning response for get_orders.") decoded = APIHelper.json_deserialize(_context.response.raw_body) return GetOrdersResponseModel.from_hash(decoded) rescue Exception => e @logger.error(e) raise e end end |