Class: ShellSmartPayApi::FuelingController
- Inherits:
-
BaseController
- Object
- BaseController
- ShellSmartPayApi::FuelingController
- Defined in:
- lib/shell_smart_pay_api/controllers/fueling_controller.rb
Overview
FuelingController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#mpp_cancel_fueling(mpp_transaction_id) ⇒ void
Enables a partner user to cancel pump reservation from the App transaction that’s being cancelled.
-
#mpp_prepare_fueling(site_country, currency, body) ⇒ PrepareFuelingResponse
Enables a 3rd party to request to unlock a pump so that they may fill up to a pre-authorised limit.
-
#mpp_token(grant_type, client_id, client_secret) ⇒ MppAccesTokenResponse
The Digital Payments Service enables 3rd Parties to trigger the refuel process which, if successful, will unlock a pump/nozzle ready for fuelling.
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 ShellSmartPayApi::BaseController
Instance Method Details
#mpp_cancel_fueling(mpp_transaction_id) ⇒ void
This method returns an undefined value.
Enables a partner user to cancel pump reservation from the App transaction that’s being cancelled
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/shell_smart_pay_api/controllers/fueling_controller.rb', line 96 def mpp_cancel_fueling(mpp_transaction_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/Fueling/v1/fueling/{mppTransactionId}', Server::SHELL) .template_param(new_parameter(mpp_transaction_id, key: 'mppTransactionId') .should_encode(true)) .auth(And.new('oAuthTokenPost', 'MppToken'))) .response(new_response_handler .is_response_void(true) .local_error('400', 'Error Occurred. The server cannot or will not process the'\ ' request due to an apparent client error (e.g., malformed'\ ' request syntax, invalid request message). Please see below for'\ ' information regarding structure of Response Body vs. all'\ ' possible errors that could be returned.', CancelFuelingErrorResponseErrorException) .local_error('401', 'Unauthorized. Request did not include bearer token or token'\ ' provided and is invalid.', CancelFuelingErrorResponseErrorException) .local_error('403', 'Forbidden. Requestor is not permitted to call the API.', APIException) .local_error('404', 'Not Found. Request received by the server but requested URL'\ ' not found', APIException)) .execute end |
#mpp_prepare_fueling(site_country, currency, body) ⇒ PrepareFuelingResponse
Enables a 3rd party to request to unlock a pump so that they may fill up to a pre-authorised limit. The fuel types that are unlocked may also be determined by permitted fuels stored against the user/entity profile
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 |
# File 'lib/shell_smart_pay_api/controllers/fueling_controller.rb', line 58 def mpp_prepare_fueling(site_country, currency, body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/Fueling/v1/fueling', Server::SHELL) .query_param(new_parameter(site_country, key: 'siteCountry')) .query_param(new_parameter(currency, key: 'currency')) .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(And.new('oAuthTokenPost', 'MppToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PrepareFuelingResponse.method(:from_hash)) .local_error('400', 'Error Occurred. Request did not include bearer token or token'\ ' provided and is invalid.', APIException) .local_error('401', 'Unauthorized', APIException) .local_error('403', 'Forbidden. Requestor is not permitted to call the API', APIException) .local_error('404', 'Not Found. Request received by the server but requested URL'\ ' not found', APIException)) .execute end |
#mpp_token(grant_type, client_id, client_secret) ⇒ MppAccesTokenResponse
The Digital Payments Service enables 3rd Parties to trigger the refuel process which, if successful, will unlock a pump/nozzle ready for fuelling. Enables a 3rd party to request an access token to start using fueling.
APIs
grant type refers to the way an application gets an access token. OAuth 2.0 defines several grant types, including the authorization code flow. you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. app, you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. The client secret must be kept confidential.
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/shell_smart_pay_api/controllers/fueling_controller.rb', line 27 def mpp_token(grant_type, client_id, client_secret) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/Fueling/v1/oauth/token', Server::SHELL) .form_param(new_parameter(grant_type, key: 'grant_type')) .form_param(new_parameter(client_id, key: 'client_id')) .form_param(new_parameter(client_secret, key: 'client_secret')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oAuthTokenPost'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(MppAccesTokenResponse.method(:from_hash)) .local_error('401', 'Unauthorized. The request has not been applied because it'\ ' lacks valid authentication credentials for the target resource'\ '.', MppAccesTokenErrorResponseException)) .execute end |