digital-payments-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +85 -0
- data/lib/shell_ev/api_helper.rb +10 -0
- data/lib/shell_ev/client.rb +86 -0
- data/lib/shell_ev/configuration.rb +104 -0
- data/lib/shell_ev/controllers/base_controller.rb +66 -0
- data/lib/shell_ev/controllers/digital_payment_enablement_controller.rb +56 -0
- data/lib/shell_ev/controllers/fueling_controller.rb +126 -0
- data/lib/shell_ev/controllers/partner_notification_controller.rb +95 -0
- data/lib/shell_ev/controllers/shell_api_platform_security_authentication_controller.rb +44 -0
- data/lib/shell_ev/controllers/station_locator_controller.rb +76 -0
- data/lib/shell_ev/exceptions/access_token_error_exception.rb +37 -0
- data/lib/shell_ev/exceptions/api_exception.rb +10 -0
- data/lib/shell_ev/exceptions/cancel_fueling_error_response_error_exception.rb +64 -0
- data/lib/shell_ev/exceptions/mpp_acces_token_error_response_exception.rb +44 -0
- data/lib/shell_ev/exceptions/payment_enablement_error_response_exception.rb +37 -0
- data/lib/shell_ev/exceptions/station_locator_bad_request_exception.rb +38 -0
- data/lib/shell_ev/exceptions/station_locator_forbidden_exception.rb +38 -0
- data/lib/shell_ev/exceptions/station_locator_internal_server_error_exception.rb +38 -0
- data/lib/shell_ev/exceptions/station_locator_not_found_exception.rb +38 -0
- data/lib/shell_ev/exceptions/station_locator_unauthorized_exception.rb +38 -0
- data/lib/shell_ev/http/auth/mpp_token.rb +42 -0
- data/lib/shell_ev/http/auth/o_auth_token_post.rb +44 -0
- data/lib/shell_ev/http/http_call_back.rb +10 -0
- data/lib/shell_ev/http/http_method_enum.rb +10 -0
- data/lib/shell_ev/http/http_request.rb +10 -0
- data/lib/shell_ev/http/http_response.rb +10 -0
- data/lib/shell_ev/models/access_token_response.rb +71 -0
- data/lib/shell_ev/models/around_location_array.rb +109 -0
- data/lib/shell_ev/models/around_location_array_data_items.rb +242 -0
- data/lib/shell_ev/models/around_location_array_data_items_loc.rb +99 -0
- data/lib/shell_ev/models/around_location_array_data_items_opening_hours_items.rb +148 -0
- data/lib/shell_ev/models/base_model.rb +62 -0
- data/lib/shell_ev/models/cancel_fueling_error_response.rb +92 -0
- data/lib/shell_ev/models/cancel_fueling_request.rb +61 -0
- data/lib/shell_ev/models/collecting_company.rb +50 -0
- data/lib/shell_ev/models/fault_response.rb +50 -0
- data/lib/shell_ev/models/fault_response_fault.rb +60 -0
- data/lib/shell_ev/models/fault_response_fault_detail.rb +50 -0
- data/lib/shell_ev/models/finalise_fueling_request.rb +181 -0
- data/lib/shell_ev/models/finalise_fueling_request_payment.rb +71 -0
- data/lib/shell_ev/models/finalise_fueling_request_products_items.rb +70 -0
- data/lib/shell_ev/models/loyalty_details.rb +59 -0
- data/lib/shell_ev/models/mobile_payment_registration_request.rb +134 -0
- data/lib/shell_ev/models/mpp_acces_token_response.rb +81 -0
- data/lib/shell_ev/models/mpp_error.rb +94 -0
- data/lib/shell_ev/models/mpp_token_request_body.rb +73 -0
- data/lib/shell_ev/models/oauth_token_post_request_body.rb +73 -0
- data/lib/shell_ev/models/partner_token_request_body.rb +73 -0
- data/lib/shell_ev/models/payment_details_items.rb +78 -0
- data/lib/shell_ev/models/payment_enablement_response.rb +48 -0
- data/lib/shell_ev/models/payment_properties.rb +169 -0
- data/lib/shell_ev/models/prepare_fueling_request.rb +183 -0
- data/lib/shell_ev/models/prepare_fueling_request_device_details_items.rb +95 -0
- data/lib/shell_ev/models/prepare_fueling_response.rb +66 -0
- data/lib/shell_ev/utilities/date_time_helper.rb +11 -0
- data/lib/shell_ev/utilities/file_wrapper.rb +16 -0
- data/lib/shell_ev.rb +85 -0
- data/test/controllers/controller_test_base.rb +29 -0
- data/test/controllers/test_fueling_controller.rb +61 -0
- data/test/controllers/test_partner_notification_controller.rb +60 -0
- data/test/controllers/test_shell_api_platform_security_authentication_controller.rb +36 -0
- data/test/controllers/test_station_locator_controller.rb +44 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85269c005e73dd5a3780e4bf7b5c4cbe4b1740e04b07fe7a032b90ecd90586c3
|
4
|
+
data.tar.gz: 1327313a9dfaf08dec8fdad95552d4310e201b5c57d91285623b40cf3bd06546
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5a7a8e729813efedc83746a546e425037a0ab8b206e6491c413fff42293d67873a617c233a0514bebbee614275c5838e5c84d51eb5f009b6c3566ea12c99d48
|
7
|
+
data.tar.gz: 6096cd6065c02c13f4d24e076f6aea2d57ad2900f4fc252787e4dd334c0bfe7a6b3cf574e076c0d5ece4ccf925b0eaf982757fa17e1006297ea636046ccdf597
|
data/LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
License:
|
2
|
+
========
|
3
|
+
The MIT License (MIT)
|
4
|
+
http://opensource.org/licenses/MIT
|
5
|
+
|
6
|
+
Copyright (c) 2014 - 2024 APIMATIC Limited
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
10
|
+
in the Software without restriction, including without limitation the rights
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
13
|
+
furnished to do so, subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
16
|
+
all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
THE SOFTWARE.
|
25
|
+
|
26
|
+
Trade Mark:
|
27
|
+
==========
|
28
|
+
APIMATIC is a trade mark for APIMATIC Limited
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
|
2
|
+
# Getting Started with Shell EV
|
3
|
+
|
4
|
+
## Introduction
|
5
|
+
|
6
|
+
The APIs detailed within this document will enable Shell's Fleet Solutions Customers to digitalize Shell Card/s and use them to pay to refuel their vehicles at Shell Stations.
|
7
|
+
|
8
|
+
## Install the Package
|
9
|
+
|
10
|
+
Install the gem from the command line:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem install digital-payments-sdk -v 1.0.0
|
14
|
+
```
|
15
|
+
|
16
|
+
Or add the gem to your Gemfile and run `bundle`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'digital-payments-sdk', '1.0.0'
|
20
|
+
```
|
21
|
+
|
22
|
+
For additional gem details, see the [RubyGems page for the digital-payments-sdk gem](https://rubygems.org/gems/digital-payments-sdk/versions/1.0.0).
|
23
|
+
|
24
|
+
## Test the SDK
|
25
|
+
|
26
|
+
To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
|
27
|
+
|
28
|
+
```
|
29
|
+
rake
|
30
|
+
```
|
31
|
+
|
32
|
+
## Initialize the API Client
|
33
|
+
|
34
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/client.md)
|
35
|
+
|
36
|
+
The following parameters are configurable for the API Client:
|
37
|
+
|
38
|
+
| Parameter | Type | Description |
|
39
|
+
| --- | --- | --- |
|
40
|
+
| `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
41
|
+
| `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
42
|
+
| `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
|
43
|
+
| `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
44
|
+
| `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
|
45
|
+
| `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
|
46
|
+
| `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
47
|
+
| `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
48
|
+
| `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
49
|
+
| `mpp_token_credentials` | [`MppTokenCredentials`](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/$a/https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/custom-header-signature.md) | The credential object for Custom Header Signature |
|
50
|
+
| `o_auth_token_post_credentials` | [`OAuthTokenPostCredentials`](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/$a/https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/custom-header-signature-1.md) | The credential object for Custom Header Signature |
|
51
|
+
|
52
|
+
The API client can be initialized as follows:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
client = ShellEv::Client.new(
|
56
|
+
mpp_token_credentials: MppTokenCredentials.new(
|
57
|
+
authorization: 'Authorization'
|
58
|
+
),
|
59
|
+
o_auth_token_post_credentials: OAuthTokenPostCredentials.new(
|
60
|
+
x_apigee_authorization: 'X-Apigee-Authorization'
|
61
|
+
)
|
62
|
+
)
|
63
|
+
```
|
64
|
+
|
65
|
+
## Authorization
|
66
|
+
|
67
|
+
This API uses the following authentication schemes.
|
68
|
+
|
69
|
+
* [`MppToken (Custom Header Signature)`](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/$a/https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/custom-header-signature.md)
|
70
|
+
* [`oAuthTokenPost (Custom Header Signature)`](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/$a/https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/custom-header-signature-1.md)
|
71
|
+
|
72
|
+
## List of APIs
|
73
|
+
|
74
|
+
* [Shell API Platform Security Authentication](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/controllers/shell-api-platform-security-authentication.md)
|
75
|
+
* [Digital Payment Enablement](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/controllers/digital-payment-enablement.md)
|
76
|
+
* [Station Locator](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/controllers/station-locator.md)
|
77
|
+
* [Partner Notification](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/controllers/partner-notification.md)
|
78
|
+
* [Fueling](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/controllers/fueling.md)
|
79
|
+
|
80
|
+
## Classes Documentation
|
81
|
+
|
82
|
+
* [Utility Classes](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/utility-classes.md)
|
83
|
+
* [HttpResponse](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/http-response.md)
|
84
|
+
* [HttpRequest](https://www.github.com/sdks-io/digital-payments-ruby-sdk/tree/1.0.0/doc/http-request.md)
|
85
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# shell_ev client class.
|
8
|
+
class Client
|
9
|
+
include CoreLibrary
|
10
|
+
attr_reader :config, :auth_managers
|
11
|
+
|
12
|
+
# Access to shell_api_platform_security_authentication controller.
|
13
|
+
# @return [ShellAPIPlatformSecurityAuthenticationController] Returns the controller instance.
|
14
|
+
def shell_api_platform_security_authentication
|
15
|
+
@shell_api_platform_security_authentication ||= ShellAPIPlatformSecurityAuthenticationController.new @global_configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
# Access to digital_payment_enablement controller.
|
19
|
+
# @return [DigitalPaymentEnablementController] Returns the controller instance.
|
20
|
+
def digital_payment_enablement
|
21
|
+
@digital_payment_enablement ||= DigitalPaymentEnablementController.new @global_configuration
|
22
|
+
end
|
23
|
+
|
24
|
+
# Access to station_locator controller.
|
25
|
+
# @return [StationLocatorController] Returns the controller instance.
|
26
|
+
def station_locator
|
27
|
+
@station_locator ||= StationLocatorController.new @global_configuration
|
28
|
+
end
|
29
|
+
|
30
|
+
# Access to fueling controller.
|
31
|
+
# @return [FuelingController] Returns the controller instance.
|
32
|
+
def fueling
|
33
|
+
@fueling ||= FuelingController.new @global_configuration
|
34
|
+
end
|
35
|
+
|
36
|
+
# Access to partner_notification controller.
|
37
|
+
# @return [PartnerNotificationController] Returns the controller instance.
|
38
|
+
def partner_notification
|
39
|
+
@partner_notification ||= PartnerNotificationController.new @global_configuration
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize(
|
43
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
44
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
45
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
46
|
+
retry_methods: %i[get put], http_callback: nil,
|
47
|
+
environment: Environment::PRODUCTION, mpp_token_credentials: nil,
|
48
|
+
o_auth_token_post_credentials: nil, config: nil
|
49
|
+
)
|
50
|
+
@config = if config.nil?
|
51
|
+
Configuration.new(
|
52
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
53
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
54
|
+
backoff_factor: backoff_factor,
|
55
|
+
retry_statuses: retry_statuses,
|
56
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
57
|
+
environment: environment,
|
58
|
+
mpp_token_credentials: mpp_token_credentials,
|
59
|
+
o_auth_token_post_credentials: o_auth_token_post_credentials
|
60
|
+
)
|
61
|
+
else
|
62
|
+
config
|
63
|
+
end
|
64
|
+
|
65
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
66
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
67
|
+
.global_errors(BaseController::GLOBAL_ERRORS)
|
68
|
+
.user_agent(BaseController.user_agent)
|
69
|
+
|
70
|
+
initialize_auth_managers(@global_configuration)
|
71
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
75
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
76
|
+
def initialize_auth_managers(global_config)
|
77
|
+
@auth_managers = {}
|
78
|
+
http_client_config = global_config.client_configuration
|
79
|
+
%w[MppToken oAuthTokenPost].each { |auth| @auth_managers[auth] = nil }
|
80
|
+
@auth_managers['MppToken'] = MppToken.new(http_client_config.mpp_token_credentials)
|
81
|
+
@auth_managers['oAuthTokenPost'] = OAuthTokenPost.new(
|
82
|
+
http_client_config.o_auth_token_post_credentials
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# An enum for SDK environments.
|
8
|
+
class Environment
|
9
|
+
# PRODUCTION: Digital Payment APIs
|
10
|
+
ENVIRONMENT = [
|
11
|
+
PRODUCTION = 'production'.freeze
|
12
|
+
].freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
# An enum for API servers.
|
16
|
+
class Server
|
17
|
+
SERVER = [
|
18
|
+
DEFAULT = 'default'.freeze
|
19
|
+
].freeze
|
20
|
+
end
|
21
|
+
|
22
|
+
# All configuration including auth info and base URI for the API access
|
23
|
+
# are configured in this class.
|
24
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
25
|
+
# The attribute readers for properties.
|
26
|
+
attr_reader :environment, :mpp_token_credentials,
|
27
|
+
:o_auth_token_post_credentials
|
28
|
+
|
29
|
+
class << self
|
30
|
+
attr_reader :environments
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(
|
34
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
35
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
36
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
37
|
+
retry_methods: %i[get put], http_callback: nil,
|
38
|
+
environment: Environment::PRODUCTION, mpp_token_credentials: nil,
|
39
|
+
o_auth_token_post_credentials: nil
|
40
|
+
)
|
41
|
+
|
42
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
43
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
44
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
45
|
+
retry_methods: retry_methods, http_callback: http_callback
|
46
|
+
|
47
|
+
# Current API environment
|
48
|
+
@environment = String(environment)
|
49
|
+
|
50
|
+
# The object holding Custom Header Signature credentials
|
51
|
+
@mpp_token_credentials = mpp_token_credentials
|
52
|
+
|
53
|
+
# The object holding Custom Header Signature credentials
|
54
|
+
@o_auth_token_post_credentials = o_auth_token_post_credentials
|
55
|
+
|
56
|
+
# The Http Client to use for making requests.
|
57
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
58
|
+
end
|
59
|
+
|
60
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
61
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
62
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
63
|
+
environment: nil, mpp_token_credentials: nil,
|
64
|
+
o_auth_token_post_credentials: nil)
|
65
|
+
connection ||= self.connection
|
66
|
+
adapter ||= self.adapter
|
67
|
+
timeout ||= self.timeout
|
68
|
+
max_retries ||= self.max_retries
|
69
|
+
retry_interval ||= self.retry_interval
|
70
|
+
backoff_factor ||= self.backoff_factor
|
71
|
+
retry_statuses ||= self.retry_statuses
|
72
|
+
retry_methods ||= self.retry_methods
|
73
|
+
http_callback ||= self.http_callback
|
74
|
+
environment ||= self.environment
|
75
|
+
mpp_token_credentials ||= self.mpp_token_credentials
|
76
|
+
o_auth_token_post_credentials ||= self.o_auth_token_post_credentials
|
77
|
+
|
78
|
+
Configuration.new(
|
79
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
80
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
81
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
82
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
83
|
+
environment: environment, mpp_token_credentials: mpp_token_credentials,
|
84
|
+
o_auth_token_post_credentials: o_auth_token_post_credentials
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# All the environments the SDK can run in.
|
90
|
+
ENVIRONMENTS = {
|
91
|
+
Environment::PRODUCTION => {
|
92
|
+
Server::DEFAULT => 'https://api-test.shell.com/ShellDigitalCommerceServices/Payments/B2B/Partner'
|
93
|
+
}
|
94
|
+
}.freeze
|
95
|
+
|
96
|
+
# Generates the appropriate base URI for the environment and the server.
|
97
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
98
|
+
# required.
|
99
|
+
# @return [String] The base URI.
|
100
|
+
def get_base_uri(server = Server::DEFAULT)
|
101
|
+
ENVIRONMENTS[environment][server].clone
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# BaseController.
|
8
|
+
class BaseController
|
9
|
+
include CoreLibrary
|
10
|
+
attr_accessor :config, :http_call_back
|
11
|
+
|
12
|
+
def self.user_agent
|
13
|
+
'APIMATIC 3.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
GLOBAL_ERRORS = {
|
18
|
+
'default' => ErrorCase.new
|
19
|
+
.error_message('HTTP response not OK.')
|
20
|
+
.exception_type(APIException)
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
# Initialization constructor.
|
24
|
+
# @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
|
25
|
+
def initialize(global_configuration)
|
26
|
+
@global_configuration = global_configuration
|
27
|
+
@config = @global_configuration.client_configuration
|
28
|
+
@http_call_back = @config.http_callback
|
29
|
+
@api_call = ApiCall.new(@global_configuration)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a new builder for the Api Call instance.
|
33
|
+
# @return [ApiCall] The instance of ApiCall.
|
34
|
+
def new_api_call_builder
|
35
|
+
@api_call.new_builder
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new instance of the request builder.
|
39
|
+
# @param [String] http_method The HTTP method to use in the request.
|
40
|
+
# @param [String] path The endpoint path to use in the request.
|
41
|
+
# @param [String] server The server to extract the base uri for the request.
|
42
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
43
|
+
def new_request_builder(http_method, path, server)
|
44
|
+
RequestBuilder.new
|
45
|
+
.http_method(http_method)
|
46
|
+
.path(path)
|
47
|
+
.server(server)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates a new instance of the response handler.
|
51
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
52
|
+
def new_response_handler
|
53
|
+
ResponseHandler.new
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates a new instance of the parameter.
|
57
|
+
# @param [String|optional] key The key of the parameter.
|
58
|
+
# @param [Object] value The value of the parameter.
|
59
|
+
# @return [Parameter] The instance of Parameter.
|
60
|
+
def new_parameter(value, key: nil)
|
61
|
+
Parameter.new
|
62
|
+
.key(key)
|
63
|
+
.value(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# DigitalPaymentEnablementController
|
8
|
+
class DigitalPaymentEnablementController < BaseController
|
9
|
+
# Generates a DPAN and stores the relationship between the Reference ID,
|
10
|
+
# DPAN and the real PAN. This method is called during the customer
|
11
|
+
# registration process, ahead of any payment. The Reference ID is an
|
12
|
+
# identifier chosen by the client system for mobile payment registration. It
|
13
|
+
# must be unique in context of the client system, and is the key to
|
14
|
+
# obtaining and managing the payment details later.
|
15
|
+
# @param [MobilePaymentRegistrationRequest] body Required parameter:
|
16
|
+
# Example:
|
17
|
+
# @return [PaymentEnablementResponse] response from the API call
|
18
|
+
def mpay_v1_tokens_ref_put(body)
|
19
|
+
new_api_call_builder
|
20
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
21
|
+
'/PaymentEnablement/v1/ref',
|
22
|
+
Server::DEFAULT)
|
23
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
24
|
+
.body_param(new_parameter(body))
|
25
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
26
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
27
|
+
.auth(Single.new('oAuthTokenPost')))
|
28
|
+
.response(new_response_handler
|
29
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
30
|
+
.deserialize_into(PaymentEnablementResponse.method(:from_hash))
|
31
|
+
.local_error('400',
|
32
|
+
'Error Occurred. The server cannot or will not process the'\
|
33
|
+
' request due to an apparent client error (e.g., malformed'\
|
34
|
+
' request syntax, invalid request message).',
|
35
|
+
PaymentEnablementErrorResponseException)
|
36
|
+
.local_error('401',
|
37
|
+
'Unauthorized. The request has not been applied because it lacks'\
|
38
|
+
' valid authentication credentials for the target resource.',
|
39
|
+
APIException)
|
40
|
+
.local_error('403',
|
41
|
+
'Forbidden. The server understood the request but refuses to'\
|
42
|
+
' authorize it.',
|
43
|
+
APIException)
|
44
|
+
.local_error('404',
|
45
|
+
'Not Found. The origin server did not find a current'\
|
46
|
+
' representation for the target resource or is not willing to'\
|
47
|
+
' disclose that one exists.',
|
48
|
+
APIException)
|
49
|
+
.local_error('500',
|
50
|
+
'Internal Server Error. The server encountered an unexpected'\
|
51
|
+
' condition that prevented it from fulfilling the request.',
|
52
|
+
APIException))
|
53
|
+
.execute
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# FuelingController
|
8
|
+
class FuelingController < BaseController
|
9
|
+
# The Digital Payments Service enables 3rd Parties to trigger the refuel
|
10
|
+
# process which, if successful, will unlock a pump/nozzle ready for
|
11
|
+
# fuelling. Enables a 3rd party to request an access token to start using
|
12
|
+
# fueling.
|
13
|
+
# APIs
|
14
|
+
# @param [String] grant_type Required parameter: In OAuth 2.0, the term
|
15
|
+
# grant type refers to the way an application gets an access token. OAuth
|
16
|
+
# 2.0 defines several grant types, including the authorization code flow.
|
17
|
+
# @param [String] client_id Required parameter: After registering your app,
|
18
|
+
# you will receive a client ID and a client secret. The client ID is
|
19
|
+
# considered public information, and is used to build login URLs, or
|
20
|
+
# included in Javascript source code on a page.
|
21
|
+
# @param [String] client_secret Required parameter: After registering your
|
22
|
+
# app, you will receive a client ID and a client secret. The client ID is
|
23
|
+
# considered public information, and is used to build login URLs, or
|
24
|
+
# included in Javascript source code on a page. The client secret must be
|
25
|
+
# kept confidential.
|
26
|
+
# @return [MppAccesTokenResponse] response from the API call
|
27
|
+
def mpp_token(grant_type,
|
28
|
+
client_id,
|
29
|
+
client_secret)
|
30
|
+
new_api_call_builder
|
31
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
32
|
+
'/Fueling/v1/oauth/token',
|
33
|
+
Server::DEFAULT)
|
34
|
+
.form_param(new_parameter(grant_type, key: 'grant_type'))
|
35
|
+
.form_param(new_parameter(client_id, key: 'client_id'))
|
36
|
+
.form_param(new_parameter(client_secret, key: 'client_secret'))
|
37
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
38
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
39
|
+
.auth(Single.new('oAuthTokenPost')))
|
40
|
+
.response(new_response_handler
|
41
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
42
|
+
.deserialize_into(MppAccesTokenResponse.method(:from_hash))
|
43
|
+
.local_error('401',
|
44
|
+
'Unauthorized. The request has not been applied because it lacks'\
|
45
|
+
' valid authentication credentials for the target resource.',
|
46
|
+
MppAccesTokenErrorResponseException))
|
47
|
+
.execute
|
48
|
+
end
|
49
|
+
|
50
|
+
# Enables a 3rd party to request to unlock a pump so that they may fill up
|
51
|
+
# to a pre-authorised limit. The fuel types that are unlocked may also be
|
52
|
+
# determined by permitted fuels stored against the user/entity profile
|
53
|
+
# @param [String] site_country Required parameter: Country ISO code
|
54
|
+
# @param [String] currency Required parameter: Currency ISO code
|
55
|
+
# @param [PrepareFuelingRequest] body Required parameter: Example:
|
56
|
+
# @return [PrepareFuelingResponse] response from the API call
|
57
|
+
def mpp_prepare_fueling(site_country,
|
58
|
+
currency,
|
59
|
+
body)
|
60
|
+
new_api_call_builder
|
61
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
62
|
+
'/Fueling/v1/fueling',
|
63
|
+
Server::DEFAULT)
|
64
|
+
.query_param(new_parameter(site_country, key: 'siteCountry'))
|
65
|
+
.query_param(new_parameter(currency, key: 'currency'))
|
66
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
67
|
+
.body_param(new_parameter(body))
|
68
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
69
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
70
|
+
.auth(And.new('oAuthTokenPost', 'MppToken')))
|
71
|
+
.response(new_response_handler
|
72
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
73
|
+
.deserialize_into(PrepareFuelingResponse.method(:from_hash))
|
74
|
+
.local_error('400',
|
75
|
+
'Error Occurred. Request did not include bearer token or token'\
|
76
|
+
' provided and is invalid.',
|
77
|
+
APIException)
|
78
|
+
.local_error('401',
|
79
|
+
'Unauthorized',
|
80
|
+
APIException)
|
81
|
+
.local_error('403',
|
82
|
+
'Forbidden. Requestor is not permitted to call the API',
|
83
|
+
APIException)
|
84
|
+
.local_error('404',
|
85
|
+
'Not Found. Request received by the server but requested URL not'\
|
86
|
+
' found',
|
87
|
+
APIException))
|
88
|
+
.execute
|
89
|
+
end
|
90
|
+
|
91
|
+
# Enables a partner user to cancel pump reservation from the App
|
92
|
+
# @param [String] mpp_transaction_id Required parameter: The ID of the
|
93
|
+
# transaction that’s being cancelled
|
94
|
+
# @return [void] response from the API call
|
95
|
+
def mpp_cancel_fueling(mpp_transaction_id)
|
96
|
+
new_api_call_builder
|
97
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
98
|
+
'/Fueling/v1/fueling/{mppTransactionId}',
|
99
|
+
Server::DEFAULT)
|
100
|
+
.template_param(new_parameter(mpp_transaction_id, key: 'mppTransactionId')
|
101
|
+
.should_encode(true))
|
102
|
+
.auth(And.new('oAuthTokenPost', 'MppToken')))
|
103
|
+
.response(new_response_handler
|
104
|
+
.is_response_void(true)
|
105
|
+
.local_error('400',
|
106
|
+
'Error Occurred. The server cannot or will not process the'\
|
107
|
+
' request due to an apparent client error (e.g., malformed'\
|
108
|
+
' request syntax, invalid request message). Please see below for'\
|
109
|
+
' information regarding structure of Response Body vs. all'\
|
110
|
+
' possible errors that could be returned.',
|
111
|
+
CancelFuelingErrorResponseErrorException)
|
112
|
+
.local_error('401',
|
113
|
+
'Unauthorized. Request did not include bearer token or token'\
|
114
|
+
' provided and is invalid.',
|
115
|
+
CancelFuelingErrorResponseErrorException)
|
116
|
+
.local_error('403',
|
117
|
+
'Forbidden. Requestor is not permitted to call the API.',
|
118
|
+
APIException)
|
119
|
+
.local_error('404',
|
120
|
+
'Not Found. Request received by the server but requested URL not'\
|
121
|
+
' found',
|
122
|
+
APIException))
|
123
|
+
.execute
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# shell_ev
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ShellEv
|
7
|
+
# PartnerNotificationController
|
8
|
+
class PartnerNotificationController < BaseController
|
9
|
+
# To access the Partner’s endpoints, for sending callback messages, Shell
|
10
|
+
# will need to connect to the Partner API end points. It is recemmended that
|
11
|
+
# the partner offers OAuth 2.0 as a standard for call back APIs and will
|
12
|
+
# require the OAuth 2.0 token for authentication. Note this needs to be
|
13
|
+
# implemented over HTTPS
|
14
|
+
# @param [String] grant_type Required parameter: In OAuth 2.0, the term
|
15
|
+
# grant typee refers to the way an application gets an access token. OAuth
|
16
|
+
# 2.0 defines several grant types, including the authorization code flow.
|
17
|
+
# @param [String] client_id Required parameter: After registering your app,
|
18
|
+
# you will receive a client ID and a client secret. The client ID is
|
19
|
+
# considered public information, and is used to build login URLs, or
|
20
|
+
# included in Javascript source code on a page.
|
21
|
+
# @param [String] client_secret Required parameter: After registering your
|
22
|
+
# app, you will receive a client ID and a client secret. The client ID is
|
23
|
+
# considered public information, and is used to build login URLs, or
|
24
|
+
# included in Javascript source code on a page. The client secret must be
|
25
|
+
# kept confidential.
|
26
|
+
# @return [AccessTokenResponse] response from the API call
|
27
|
+
def partner_token(grant_type,
|
28
|
+
client_id,
|
29
|
+
client_secret)
|
30
|
+
new_api_call_builder
|
31
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
32
|
+
'/token',
|
33
|
+
Server::DEFAULT)
|
34
|
+
.form_param(new_parameter(grant_type, key: 'grant_type'))
|
35
|
+
.form_param(new_parameter(client_id, key: 'client_id'))
|
36
|
+
.form_param(new_parameter(client_secret, key: 'client_secret'))
|
37
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
38
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
39
|
+
.response(new_response_handler
|
40
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
41
|
+
.deserialize_into(AccessTokenResponse.method(:from_hash))
|
42
|
+
.local_error('401',
|
43
|
+
'Unauthorized',
|
44
|
+
AccessTokenErrorException))
|
45
|
+
.execute
|
46
|
+
end
|
47
|
+
|
48
|
+
# Enables Shell to inform partner of the successful completion of a
|
49
|
+
# transaction. Note this needs to be implemented over HTTPS
|
50
|
+
# @param [FinaliseFuelingRequest] body Optional parameter: Example:
|
51
|
+
# @return [void] response from the API call
|
52
|
+
def finalise_fueling(body: nil)
|
53
|
+
new_api_call_builder
|
54
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
55
|
+
'/finaliseFueling',
|
56
|
+
Server::DEFAULT)
|
57
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
58
|
+
.body_param(new_parameter(body))
|
59
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
60
|
+
.response(new_response_handler
|
61
|
+
.is_response_void(true)
|
62
|
+
.local_error('400',
|
63
|
+
'Bad Request',
|
64
|
+
APIException)
|
65
|
+
.local_error('401',
|
66
|
+
'Unauthorized',
|
67
|
+
APIException))
|
68
|
+
.execute
|
69
|
+
end
|
70
|
+
|
71
|
+
# Enables Shell to inform partner that a Mobile Payment transaction has been
|
72
|
+
# cancelled by Shell as an error/issue occured. Note this needs to be
|
73
|
+
# implemented over HTTPS
|
74
|
+
# @param [CancelFuelingRequest] body Optional parameter: Example:
|
75
|
+
# @return [void] response from the API call
|
76
|
+
def cancel_fueling(body: nil)
|
77
|
+
new_api_call_builder
|
78
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
79
|
+
'/cancelFueling',
|
80
|
+
Server::DEFAULT)
|
81
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
82
|
+
.body_param(new_parameter(body))
|
83
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
84
|
+
.response(new_response_handler
|
85
|
+
.is_response_void(true)
|
86
|
+
.local_error('400',
|
87
|
+
'Bad Request',
|
88
|
+
APIException)
|
89
|
+
.local_error('401',
|
90
|
+
'Unauthorized',
|
91
|
+
APIException))
|
92
|
+
.execute
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|