Class: ShellEv::ChargingController
- Inherits:
-
BaseController
- Object
- BaseController
- ShellEv::ChargingController
- Defined in:
- lib/shell_ev/controllers/charging_controller.rb
Overview
ChargingController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#active(ema_id, request_id) ⇒ ActiveResponse200Json
This API retrieves the list of active sessions for a given set of EMAIds Identifier(Ema-ID) in GUID format.
-
#get_charge_session_retrieve(request_id, session_id, uuid) ⇒ GetChargeSessionRetrieveResponse200Json
This API retrieves the status and details of the session which was started by the user.
-
#start_charge_session(request_id, body: nil) ⇒ InlineResponse202
This API initiates to start a session on a EVSE (Electric Vehicle Supply Equipement).
-
#stop_charge_session(request_id, uuid, body: nil) ⇒ InlineResponse2021
This API stops a session by providing the session ID which was retrieved when starting the session.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from ShellEv::BaseController
Instance Method Details
#active(ema_id, request_id) ⇒ ActiveResponse200Json
This API retrieves the list of active sessions for a given set of EMAIds Identifier(Ema-ID) in GUID format. The value is written to the Shell API Platform audit log for end to end traceability of a request.
176 177 178 179 180 181 182 183 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 210 211 212 213 214 |
# File 'lib/shell_ev/controllers/charging_controller.rb', line 176 def active(ema_id, request_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/ev/v1/charge-session/active', Server::DEFAULT) .query_param(new_parameter(ema_id, key: 'EmaId')) .header_param(new_parameter(request_id, key: 'RequestId')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ActiveResponse200Json.method(:from_hash)) .local_error('400', "Bad Request\n", M400ErrorResponseError1Exception) .local_error('401', 'Unauthorized', M401ErrorResponseError1Exception) .local_error('404', 'Session not found or Session has already been stopped. Map 410'\ ' Error message into 404.', M404ErrorResponseError1Exception) .local_error('405', 'Method Not Allowed', M405ErrorResponseError1Exception) .local_error('429', 'Too Many Requests', M429ErrorResponseError1Exception) .local_error('500', 'Internal Server Error', M500ErrorResponseError1Exception) .local_error('503', "Returned when a connectivity failure is encountered like DB'\ ' connection failed, endpoint failed etc or when max number of'\ ' retries are completed\n", M503ErrorResponseError1Exception)) .execute end |
#get_charge_session_retrieve(request_id, session_id, uuid) ⇒ GetChargeSessionRetrieveResponse200Json
This API retrieves the status and details of the session which was started by the user. The session ID generated earlier needs to be passed in this API in order to retrieve the status. in GUID format. The value is written to the Shell API Platform audit log for end to end traceability of a request. fetched was generated to activate a charging session.
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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/shell_ev/controllers/charging_controller.rb', line 129 def get_charge_session_retrieve(request_id, session_id, uuid) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/ev/v1/charge-session/retrieve/{uuid}', Server::DEFAULT) .header_param(new_parameter(request_id, key: 'RequestId')) .query_param(new_parameter(session_id, key: 'SessionId')) .template_param(new_parameter(uuid, key: 'uuid') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetChargeSessionRetrieveResponse200Json.method(:from_hash)) .local_error('400', 'Bad Request', M400ErrorResponseError1Exception) .local_error('401', 'Unauthorized', M401ErrorResponseError1Exception) .local_error('404', 'Not Found', M404ErrorResponseError1Exception) .local_error('405', 'Method Not Allowed', M405ErrorResponseError1Exception) .local_error('429', 'Too Many Requests', M429ErrorResponseError1Exception) .local_error('500', 'Internal Server Error', M500ErrorResponseError1Exception) .local_error('503', 'Service Unavailable', M503ErrorResponseError1Exception)) .execute end |
#start_charge_session(request_id, body: nil) ⇒ InlineResponse202
This API initiates to start a session on a EVSE (Electric Vehicle Supply Equipement). When the EV Charge Card number and the unique EVSE ID on the location is provided, the session is initiated. Please note that this is an asynchronous request, the request will be passed on to the operator/platform to be processed further. in GUID format. The value is written to the Shell API Platform audit log for end to end traceability of a request.
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 54 55 56 57 58 59 |
# File 'lib/shell_ev/controllers/charging_controller.rb', line 19 def start_charge_session(request_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/ev/v1/charge-session/start', Server::DEFAULT) .header_param(new_parameter(request_id, key: 'RequestId')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(InlineResponse202.method(:from_hash)) .local_error('400', "Bad Request\n", M400ErrorResponseError1Exception) .local_error('401', 'Unauthorized', HTTP401ErrorResponseException) .local_error('404', "Invalid charge token with given EmaId was not found.\n\nBackend'\ ' HTTP 410 should be transformed to 404.", M404ErrorResponseError1Exception) .local_error('405', 'Method Not Allowed', M405ErrorResponseError1Exception) .local_error('429', 'Too Many Requests', M429ErrorResponseError1Exception) .local_error('500', 'Internal Server Error', M500ErrorResponseError1Exception) .local_error('503', 'Returned when a connectivity failure is encountered like DB'\ ' connection failed, endpoint failed etc or when max number of'\ ' retries are completed', M503ErrorResponseError1Exception)) .execute end |
#stop_charge_session(request_id, uuid, body: nil) ⇒ InlineResponse2021
This API stops a session by providing the session ID which was retrieved when starting the session. HTTP 202 response will be returned if the request is accepted. Once the session is stopped the response will contain the DateTime on which it is stopped. operationId: Stop in GUID format. The value is written to the Shell API Platform audit log for end to end traceability of a request. was generated to activate a charging session. Example:
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/shell_ev/controllers/charging_controller.rb', line 73 def stop_charge_session(request_id, uuid, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/ev/v1/charge-session/stop/{uuid}', Server::DEFAULT) .header_param(new_parameter(request_id, key: 'RequestId')) .template_param(new_parameter(uuid, key: 'uuid') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(InlineResponse2021.method(:from_hash)) .local_error('400', "Bad Request\n", M400ErrorResponseError1Exception) .local_error('401', 'Unauthorized', M401ErrorResponseError1Exception) .local_error('404', 'Session not found or Session has already been stopped. Map 410'\ ' Error message into 404.', M404ErrorResponseError1Exception) .local_error('405', 'Method Not Allowed', M405ErrorResponseError1Exception) .local_error('429', 'Too Many Requests', M429ErrorResponseError1Exception) .local_error('500', 'Internal Server Error', M500ErrorResponseError1Exception) .local_error('503', "Returned when a connectivity failure is encountered like DB'\ ' connection failed, endpoint failed etc or when max number of'\ ' retries are completed\n", M503ErrorResponseError1Exception)) .execute end |