ev-recharge-sdk 1.3.0 → 2.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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +91 -25
  4. data/bin/console +15 -0
  5. data/lib/shell_ev/api_helper.rb +2 -2
  6. data/lib/shell_ev/client.rb +15 -4
  7. data/lib/shell_ev/configuration.rb +88 -15
  8. data/lib/shell_ev/controllers/base_controller.rb +3 -9
  9. data/lib/shell_ev/controllers/charging_controller.rb +19 -18
  10. data/lib/shell_ev/controllers/locations_controller.rb +48 -50
  11. data/lib/shell_ev/controllers/o_auth_authorization_controller.rb +5 -5
  12. data/lib/shell_ev/exceptions/api_exception.rb +13 -2
  13. data/lib/shell_ev/exceptions/bad_request_exception.rb +20 -5
  14. data/lib/shell_ev/exceptions/internal_server_error_exception.rb +21 -5
  15. data/lib/shell_ev/exceptions/not_found_exception.rb +20 -5
  16. data/lib/shell_ev/exceptions/o_auth_provider_exception.rb +21 -5
  17. data/lib/shell_ev/exceptions/serviceunavailable_exception.rb +20 -5
  18. data/lib/shell_ev/exceptions/too_many_requests_exception.rb +20 -5
  19. data/lib/shell_ev/exceptions/unauthorized_exception.rb +20 -5
  20. data/lib/shell_ev/exceptions/v2_charge_session_retrieve404_error_exception.rb +67 -0
  21. data/lib/shell_ev/exceptions/v2_charge_session_start404_error_exception.rb +67 -0
  22. data/lib/shell_ev/exceptions/v2_charge_session_stop404_error_exception.rb +67 -0
  23. data/lib/shell_ev/http/auth/o_auth2.rb +18 -3
  24. data/lib/shell_ev/http/http_call_back.rb +2 -2
  25. data/lib/shell_ev/http/http_method_enum.rb +2 -2
  26. data/lib/shell_ev/http/http_request.rb +2 -2
  27. data/lib/shell_ev/http/http_response.rb +2 -2
  28. data/lib/shell_ev/http/proxy_settings.rb +22 -0
  29. data/lib/shell_ev/models/accessibility_status_enum.rb +17 -2
  30. data/lib/shell_ev/models/{accessibility.rb → accessibility_v2.rb} +17 -14
  31. data/lib/shell_ev/models/active_response200_json.rb +15 -2
  32. data/lib/shell_ev/models/active_response200_json_status_enum.rb +15 -2
  33. data/lib/shell_ev/models/address.rb +16 -2
  34. data/lib/shell_ev/models/bad_request_err_msg.rb +16 -2
  35. data/lib/shell_ev/models/base_model.rb +2 -2
  36. data/lib/shell_ev/models/charge_error.rb +14 -2
  37. data/lib/shell_ev/models/charge_retrieve_state.rb +14 -2
  38. data/lib/shell_ev/models/chargesession_start_body.rb +15 -2
  39. data/lib/shell_ev/models/connector_types_enum.rb +100 -0
  40. data/lib/shell_ev/models/connector_v2.rb +95 -0
  41. data/lib/shell_ev/models/connector_vo_connector_type_enum.rb +31 -2
  42. data/lib/shell_ev/models/connector_vo_updated_by_enum.rb +17 -2
  43. data/lib/shell_ev/models/coordinates.rb +14 -2
  44. data/lib/shell_ev/models/coordinates1.rb +81 -0
  45. data/lib/shell_ev/models/data_active.rb +19 -2
  46. data/lib/shell_ev/models/data_retrieve.rb +19 -2
  47. data/lib/shell_ev/models/day_of_week_enum.rb +56 -0
  48. data/lib/shell_ev/models/electrical_properties_power_type_enum.rb +16 -2
  49. data/lib/shell_ev/models/{electrical_properties.rb → electrical_properties_v2.rb} +22 -8
  50. data/lib/shell_ev/models/evse_status_enum.rb +44 -0
  51. data/lib/shell_ev/models/{evse_vo.rb → evse_v2.rb} +45 -38
  52. data/lib/shell_ev/models/evse_vo_authorization_methods_enum.rb +16 -2
  53. data/lib/shell_ev/models/evse_vo_status_enum.rb +17 -2
  54. data/lib/shell_ev/models/get_charge_session_retrieve_response200_json.rb +15 -2
  55. data/lib/shell_ev/models/get_charge_session_retrieve_response200_json_status_enum.rb +15 -2
  56. data/lib/shell_ev/models/get_ev_locations_authorization_methods_enum.rb +16 -2
  57. data/lib/shell_ev/models/get_ev_locations_connector_types_enum.rb +31 -2
  58. data/lib/shell_ev/models/get_ev_locations_evse_status_enum.rb +17 -2
  59. data/lib/shell_ev/models/inline_response202.rb +17 -6
  60. data/lib/shell_ev/models/inline_response2021.rb +14 -2
  61. data/lib/shell_ev/models/inline_response2021_status_enum.rb +15 -2
  62. data/lib/shell_ev/models/inline_response202_data.rb +14 -2
  63. data/lib/shell_ev/models/inline_response202_status_enum.rb +15 -2
  64. data/lib/shell_ev/models/internal_error_object.rb +15 -2
  65. data/lib/shell_ev/models/{location_respone_object.rb → location_respone_object_v2.rb} +61 -30
  66. data/lib/shell_ev/models/locations_markers_authorization_methods_enum.rb +16 -2
  67. data/lib/shell_ev/models/locations_markers_connector_types_enum.rb +31 -2
  68. data/lib/shell_ev/models/locations_markers_evse_status_enum.rb +17 -2
  69. data/lib/shell_ev/models/multi_location_marker.rb +22 -5
  70. data/lib/shell_ev/models/multi_location_marker_v2.rb +126 -0
  71. data/lib/shell_ev/models/nearby_locations_authorization_methods_enum.rb +16 -2
  72. data/lib/shell_ev/models/nearby_locations_connector_types_enum.rb +31 -2
  73. data/lib/shell_ev/models/nearby_locations_evse_status_enum.rb +17 -2
  74. data/lib/shell_ev/models/not_found_err_msg.rb +16 -2
  75. data/lib/shell_ev/models/o_auth_provider_error_enum.rb +19 -2
  76. data/lib/shell_ev/models/o_auth_token.rb +2 -2
  77. data/lib/shell_ev/models/opening_hours_object.rb +17 -3
  78. data/lib/shell_ev/models/opening_hours_object_week_day_enum.rb +20 -2
  79. data/lib/shell_ev/models/power_range.rb +68 -0
  80. data/lib/shell_ev/models/price_component.rb +86 -0
  81. data/lib/shell_ev/models/ratelimit_err_msg.rb +16 -2
  82. data/lib/shell_ev/models/{response.rb → response_v2.rb} +22 -9
  83. data/lib/shell_ev/models/restrictions.rb +183 -0
  84. data/lib/shell_ev/models/search_by_id_connector.rb +115 -0
  85. data/lib/shell_ev/models/search_by_id_evse.rb +145 -0
  86. data/lib/shell_ev/models/search_by_id_location_respone.rb +196 -0
  87. data/lib/shell_ev/models/search_by_id_response.rb +91 -0
  88. data/lib/shell_ev/models/serviceunavailable_err_msg.rb +16 -2
  89. data/lib/shell_ev/models/single_location_marker.rb +27 -6
  90. data/lib/shell_ev/models/single_location_marker_authorization_methods_items_enum.rb +16 -2
  91. data/lib/shell_ev/models/single_location_marker_response.rb +15 -2
  92. data/lib/shell_ev/models/single_location_marker_response_v2.rb +94 -0
  93. data/lib/shell_ev/models/single_location_marker_status_enum.rb +17 -2
  94. data/lib/shell_ev/models/single_location_marker_v2.rb +157 -0
  95. data/lib/shell_ev/models/tariff.rb +20 -3
  96. data/lib/shell_ev/models/tariff_alt_text.rb +68 -0
  97. data/lib/shell_ev/models/tariff_element.rb +80 -0
  98. data/lib/shell_ev/models/tariff_type_enum.rb +44 -0
  99. data/lib/shell_ev/models/tariff_v2.rb +226 -0
  100. data/lib/shell_ev/models/tariff_vo_updated_by_enum.rb +17 -2
  101. data/lib/shell_ev/models/type_enum.rb +44 -0
  102. data/lib/shell_ev/models/unauthorized_err_msg.rb +16 -2
  103. data/lib/shell_ev/utilities/date_time_helper.rb +2 -2
  104. data/lib/shell_ev/utilities/file_wrapper.rb +16 -4
  105. data/lib/shell_ev/utilities/union_type_lookup.rb +19 -2
  106. data/lib/shell_ev.rb +34 -10
  107. data/test/controllers/controller_test_base.rb +5 -10
  108. data/test/controllers/test_charging_controller.rb +7 -11
  109. data/test/controllers/test_locations_controller.rb +8 -11
  110. data/test/http_response_catcher.rb +3 -3
  111. metadata +38 -15
  112. data/lib/shell_ev/models/connector_vo.rb +0 -131
  113. data/lib/shell_ev/models/tariff_vo.rb +0 -107
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c08d11ce3e4f2f892c4b59be20a39de22c0e7e476e5702d9be17f4b66921aaae
4
- data.tar.gz: e8494e4e2f1a1064f962d17ec9ceb54fe01cc4a952064b8f8ca40e80ec022425
3
+ metadata.gz: cde9917d56d444cf7431e26bde8bcc889478694bbecf4dd76e96df0afa64b1a6
4
+ data.tar.gz: b7e036557587fc47434681d52291df08d81e10cecf878b213097208217428236
5
5
  SHA512:
6
- metadata.gz: 25fd34b7d3077c0f930370af2daf61f31413b3ce455f4f5f1b82b8f265ee9a19b3fffb9d887d535eca31ae39679f10a2b5fc1160ea6330dd1770ce259dd8b6fb
7
- data.tar.gz: 0c057b181460a3e6d7df06ac143582ec45a8d7dd5bca887659cd26d8ff0a622e5d9181f71d1ce2ff6f47a9effdeeaea7a57bd7b304066bf18a110a0a11948cd7
6
+ metadata.gz: 66f6c2129184aef4a408ed295f57fb5c240aadfbd83dff699a3cb0e73bfaa480170a1cf18cd7c336afdd4852193b8b1566628513a45ae0d2185221f3fae2800f
7
+ data.tar.gz: 6e87e57762e2a3c3ec0cae304cee477db56707f7e8b77c06cd7227dd96aa92385c0c399b4d97e16df13a15bcd1ca535cbab4a75cc7b82447cf7e5ab624313f7d
data/LICENSE CHANGED
@@ -3,7 +3,7 @@ License:
3
3
  The MIT License (MIT)
4
4
  http://opensource.org/licenses/MIT
5
5
 
6
- Copyright (c) 2014 - 2024 APIMATIC Limited
6
+ Copyright (c) 2014 - 2026 APIMATIC Limited
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -28,16 +28,51 @@ Go to the Shell Developer Portal: [https://developer.shell.com](https://develope
28
28
  Install the gem from the command line:
29
29
 
30
30
  ```bash
31
- gem install ev-recharge-sdk -v 1.3.0
31
+ gem install ev-recharge-sdk -v 2.0.0
32
32
  ```
33
33
 
34
34
  Or add the gem to your Gemfile and run `bundle`:
35
35
 
36
36
  ```ruby
37
- gem 'ev-recharge-sdk', '1.3.0'
37
+ gem 'ev-recharge-sdk', '2.0.0'
38
38
  ```
39
39
 
40
- For additional gem details, see the [RubyGems page for the ev-recharge-sdk gem](https://rubygems.org/gems/ev-recharge-sdk/versions/1.3.0).
40
+ For additional gem details, see the [RubyGems page for the ev-recharge-sdk gem](https://rubygems.org/gems/ev-recharge-sdk/versions/2.0.0).
41
+
42
+ ## IRB Console Usage
43
+
44
+ You can explore the SDK interactively using IRB in two ways
45
+
46
+ ### 1. Use IRB with Installed Gem
47
+
48
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
49
+
50
+ ```bash
51
+ irb
52
+ ```
53
+
54
+ Now you can load the SDK in the IRB
55
+
56
+ ```ruby
57
+ require 'shell_ev'
58
+ include ShellEv
59
+ ```
60
+
61
+ ### 2. Use IRB within SDK
62
+
63
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
64
+
65
+ ```
66
+ cd path/to/shell_ev
67
+ ```
68
+
69
+ Now you can start the preconfigured irb console by running the following command
70
+
71
+ ```bash
72
+ ruby bin/console
73
+ ```
74
+
75
+ **_Note:_** This automatically loads the SDK from lib/
41
76
 
42
77
  ## Test the SDK
43
78
 
@@ -49,28 +84,34 @@ rake
49
84
 
50
85
  ## Initialize the API Client
51
86
 
52
- **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/client.md)
87
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/client.md)
53
88
 
54
89
  The following parameters are configurable for the API Client:
55
90
 
56
91
  | Parameter | Type | Description |
57
92
  | --- | --- | --- |
58
- | `environment` | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
59
- | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
60
- | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
61
- | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
62
- | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
63
- | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
64
- | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
65
- | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
66
- | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
67
- | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
68
- | `client_credentials_auth_credentials` | [`ClientCredentialsAuthCredentials`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/auth/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
93
+ | environment | [`Environment`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
94
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
95
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
96
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
97
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
98
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
99
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
100
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
101
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
102
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
103
+ | proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
104
+ | client_credentials_auth_credentials | [`ClientCredentialsAuthCredentials`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/auth/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
69
105
 
70
106
  The API client can be initialized as follows:
71
107
 
108
+ ### Code-Based Client Initialization
109
+
72
110
  ```ruby
73
- client = ShellEv::Client.new(
111
+ require 'shell_ev'
112
+ include ShellEv
113
+
114
+ client = Client.new(
74
115
  client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
75
116
  o_auth_client_id: 'OAuthClientId',
76
117
  o_auth_client_secret: 'OAuthClientSecret'
@@ -79,6 +120,18 @@ client = ShellEv::Client.new(
79
120
  )
80
121
  ```
81
122
 
123
+ ### Environment-Based Client Initialization
124
+
125
+ ```ruby
126
+ require 'shell_ev'
127
+ include ShellEv
128
+
129
+ # Create client from environment
130
+ client = Client.from_env
131
+ ```
132
+
133
+ See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/environment-based-client-initialization.md) section for details.
134
+
82
135
  ## Environments
83
136
 
84
137
  The SDK can be configured to use a different environment for making API calls. Available environments are:
@@ -87,23 +140,36 @@ The SDK can be configured to use a different environment for making API calls. A
87
140
 
88
141
  | Name | Description |
89
142
  | --- | --- |
90
- | production | **Default** Production Server |
91
- | environment2 | Test Server |
143
+ | PRODUCTION | **Default** Production Server |
144
+ | ENVIRONMENT2 | Production Server |
145
+ | ENVIRONMENT3 | Test Server |
146
+ | ENVIRONMENT4 | Test Server |
92
147
 
93
148
  ## Authorization
94
149
 
95
150
  This API uses the following authentication schemes.
96
151
 
97
- * [`BearerAuth (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/auth/oauth-2-client-credentials-grant.md)
152
+ * [`BearerAuth (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/auth/oauth-2-client-credentials-grant.md)
98
153
 
99
154
  ## List of APIs
100
155
 
101
- * [Locations](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/controllers/locations.md)
102
- * [Charging](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/controllers/charging.md)
156
+ * [Locations](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/controllers/locations.md)
157
+ * [Charging](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/controllers/charging.md)
103
158
 
104
- ## Classes Documentation
159
+ ## SDK Infrastructure
105
160
 
106
- * [Utility Classes](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/utility-classes.md)
107
- * [HttpResponse](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/http-response.md)
108
- * [HttpRequest](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.3.0/doc/http-request.md)
161
+ ### Configuration
162
+
163
+ * [ProxySettings](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/proxy-settings.md)
164
+ * [Environment-Based Client Initialization](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/environment-based-client-initialization.md)
165
+
166
+ ### HTTP
167
+
168
+ * [HttpResponse](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/http-response.md)
169
+ * [HttpRequest](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/http-request.md)
170
+
171
+ ### Utilities
172
+
173
+ * [ApiHelper](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/api-helper.md)
174
+ * [DateTimeHelper](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/2.0.0/doc/date-time-helper.md)
109
175
 
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the lib folder into Ruby's load path
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
+
6
+ # Require the gem
7
+ require 'shell_ev'
8
+
9
+ puts 'ShellEv SDK loaded!'
10
+ puts 'You can now create a client with: client = ShellEv::Client.new'
11
+ puts 'Or use from_env: client = ShellEv::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -1,7 +1,7 @@
1
1
  # shell_ev
2
2
  #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
5
 
6
6
  module ShellEv
7
7
  # API utility class
@@ -1,13 +1,17 @@
1
1
  # shell_ev
2
2
  #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
5
 
6
6
  module ShellEv
7
7
  # shell_ev client class.
8
8
  class Client
9
9
  include CoreLibrary
10
10
  attr_reader :config, :auth_managers
11
+
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
11
15
 
12
16
  # Returns the configured authentication BearerAuth instance.
13
17
  def bearer_auth
@@ -36,7 +40,7 @@ module ShellEv
36
40
  connection: nil, adapter: :net_http_persistent, timeout: 60,
37
41
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
38
42
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
39
- retry_methods: %i[get put], http_callback: nil,
43
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
40
44
  environment: Environment::PRODUCTION, o_auth_client_id: nil,
41
45
  o_auth_client_secret: nil, o_auth_token: nil,
42
46
  client_credentials_auth_credentials: nil, config: nil
@@ -48,7 +52,7 @@ module ShellEv
48
52
  backoff_factor: backoff_factor,
49
53
  retry_statuses: retry_statuses,
50
54
  retry_methods: retry_methods, http_callback: http_callback,
51
- environment: environment,
55
+ proxy_settings: proxy_settings, environment: environment,
52
56
  o_auth_client_id: o_auth_client_id,
53
57
  o_auth_client_secret: o_auth_client_secret,
54
58
  o_auth_token: o_auth_token,
@@ -77,5 +81,12 @@ module ShellEv
77
81
  http_client_config.client_credentials_auth_credentials, global_config
78
82
  )
79
83
  end
84
+
85
+ # Creates a client directly from environment variables.
86
+ def self.from_env(**overrides)
87
+ default_config = Configuration.build_default_config_from_env
88
+ new_config = default_config.clone_with(**overrides)
89
+ new(config: new_config)
90
+ end
80
91
  end
81
92
  end
@@ -1,25 +1,52 @@
1
1
  # shell_ev
2
2
  #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
5
 
6
6
  module ShellEv
7
7
  # An enum for SDK environments.
8
8
  class Environment
9
9
  # PRODUCTION: Production Server
10
- # ENVIRONMENT2: Test Server
10
+ # ENVIRONMENT2: Production Server
11
+ # ENVIRONMENT3: Test Server
12
+ # ENVIRONMENT4: Test Server
11
13
  ENVIRONMENT = [
12
14
  PRODUCTION = 'production'.freeze,
13
- ENVIRONMENT2 = 'environment2'.freeze
15
+ ENVIRONMENT2 = 'environment2'.freeze,
16
+ ENVIRONMENT3 = 'environment3'.freeze,
17
+ ENVIRONMENT4 = 'environment4'.freeze
14
18
  ].freeze
19
+
20
+ # Converts a string or symbol into a valid Environment constant.
21
+ def self.from_value(value, default_value = PRODUCTION)
22
+ return default_value if value.nil?
23
+
24
+ str = value.to_s.strip.downcase
25
+ case str
26
+ when 'production' then PRODUCTION
27
+ when 'environment2' then ENVIRONMENT2
28
+ when 'environment3' then ENVIRONMENT3
29
+ when 'environment4' then ENVIRONMENT4
30
+
31
+ else
32
+ warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
33
+ default_value
34
+ end
35
+ end
15
36
  end
16
37
 
17
38
  # An enum for API servers.
18
39
  class Server
19
40
  SERVER = [
20
- DEFAULT = 'default'.freeze,
21
- ACCESS_TOKEN_SERVER = 'access token server'.freeze
41
+ DEFAULT = 'default'.freeze
22
42
  ].freeze
43
+
44
+ # Converts a string or symbol into a valid Server constant.
45
+ def self.from_value(value, default_value = DEFAULT)
46
+ return default_value if value.nil?
47
+
48
+ default_value
49
+ end
23
50
  end
24
51
 
25
52
  # All configuration including auth info and base URI for the API access
@@ -48,16 +75,16 @@ module ShellEv
48
75
  connection: nil, adapter: :net_http_persistent, timeout: 60,
49
76
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
50
77
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
51
- retry_methods: %i[get put], http_callback: nil,
78
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
52
79
  environment: Environment::PRODUCTION, o_auth_client_id: nil,
53
80
  o_auth_client_secret: nil, o_auth_token: nil,
54
81
  client_credentials_auth_credentials: nil
55
82
  )
56
-
57
83
  super connection: connection, adapter: adapter, timeout: timeout,
58
84
  max_retries: max_retries, retry_interval: retry_interval,
59
85
  backoff_factor: backoff_factor, retry_statuses: retry_statuses,
60
- retry_methods: retry_methods, http_callback: http_callback
86
+ retry_methods: retry_methods, http_callback: http_callback,
87
+ proxy_settings: proxy_settings
61
88
 
62
89
  # Current API environment
63
90
  @environment = String(environment)
@@ -88,7 +115,7 @@ module ShellEv
88
115
  def clone_with(connection: nil, adapter: nil, timeout: nil,
89
116
  max_retries: nil, retry_interval: nil, backoff_factor: nil,
90
117
  retry_statuses: nil, retry_methods: nil, http_callback: nil,
91
- environment: nil, o_auth_client_id: nil,
118
+ proxy_settings: nil, environment: nil, o_auth_client_id: nil,
92
119
  o_auth_client_secret: nil, o_auth_token: nil,
93
120
  client_credentials_auth_credentials: nil)
94
121
  connection ||= self.connection
@@ -100,6 +127,7 @@ module ShellEv
100
127
  retry_statuses ||= self.retry_statuses
101
128
  retry_methods ||= self.retry_methods
102
129
  http_callback ||= self.http_callback
130
+ proxy_settings ||= self.proxy_settings
103
131
  environment ||= self.environment
104
132
  client_credentials_auth_credentials = create_auth_credentials_object(
105
133
  o_auth_client_id, o_auth_client_secret, o_auth_token,
@@ -111,7 +139,7 @@ module ShellEv
111
139
  max_retries: max_retries, retry_interval: retry_interval,
112
140
  backoff_factor: backoff_factor, retry_statuses: retry_statuses,
113
141
  retry_methods: retry_methods, http_callback: http_callback,
114
- environment: environment,
142
+ proxy_settings: proxy_settings, environment: environment,
115
143
  client_credentials_auth_credentials: client_credentials_auth_credentials
116
144
  )
117
145
  end
@@ -144,12 +172,16 @@ module ShellEv
144
172
  # All the environments the SDK can run in.
145
173
  ENVIRONMENTS = {
146
174
  Environment::PRODUCTION => {
147
- Server::DEFAULT => 'https://api.shell.com/ev/v1',
148
- Server::ACCESS_TOKEN_SERVER => 'https://api.shell.com/v1/oauth'
175
+ Server::DEFAULT => 'https://api.shell.com/ev'
149
176
  },
150
177
  Environment::ENVIRONMENT2 => {
151
- Server::DEFAULT => 'https://api-test.shell.com/ev/v1',
152
- Server::ACCESS_TOKEN_SERVER => 'https://api.shell.com/v1/oauth'
178
+ Server::DEFAULT => 'https://api.shell.com/v2/oauth'
179
+ },
180
+ Environment::ENVIRONMENT3 => {
181
+ Server::DEFAULT => 'https://api-test.shell.com/ev'
182
+ },
183
+ Environment::ENVIRONMENT4 => {
184
+ Server::DEFAULT => 'https://api-test.shell.com/v2/oauth'
153
185
  }
154
186
  }.freeze
155
187
 
@@ -160,5 +192,46 @@ module ShellEv
160
192
  def get_base_uri(server = Server::DEFAULT)
161
193
  ENVIRONMENTS[environment][server].clone
162
194
  end
195
+
196
+ # Builds a Configuration instance using environment variables.
197
+ def self.build_default_config_from_env
198
+ # === Core environment ===
199
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
200
+ timeout = (ENV['TIMEOUT'] || 60).to_f
201
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
202
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
203
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
204
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
205
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
206
+ .split(',')
207
+ .map(&:strip)
208
+ .map do |item|
209
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
210
+ end
211
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
212
+ .split(',')
213
+ .map(&:strip)
214
+ .map do |item|
215
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
216
+ end
217
+
218
+ # === Authentication credentials ===
219
+ client_credentials_auth_credentials = ClientCredentialsAuthCredentials.from_env
220
+
221
+ # === Proxy settings ===
222
+ proxy_settings = ProxySettings.from_env
223
+
224
+ Configuration.new(
225
+ environment: environment,
226
+ timeout: timeout,
227
+ max_retries: max_retries,
228
+ retry_interval: retry_interval,
229
+ backoff_factor: backoff_factor,
230
+ retry_statuses: retry_statuses,
231
+ retry_methods: retry_methods,
232
+ client_credentials_auth_credentials: client_credentials_auth_credentials,
233
+ proxy_settings: proxy_settings
234
+ )
235
+ end
163
236
  end
164
237
  end
@@ -1,7 +1,7 @@
1
1
  # shell_ev
2
2
  #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
5
 
6
6
  module ShellEv
7
7
  # BaseController.
@@ -26,13 +26,7 @@ module ShellEv
26
26
  @global_configuration = global_configuration
27
27
  @config = @global_configuration.client_configuration
28
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
29
+ @api_call = ApiCall.new(@global_configuration)
36
30
  end
37
31
 
38
32
  # Creates a new instance of the request builder.
@@ -1,7 +1,7 @@
1
1
  # shell_ev
2
2
  #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
5
 
6
6
  module ShellEv
7
7
  # ChargingController
@@ -14,13 +14,14 @@ module ShellEv
14
14
  # digits, displayed in five groups separated by hyphens, in the form
15
15
  # 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4
16
16
  # hyphens) <br>
17
- # @param [ChargesessionStartBody] body Optional parameter: Example:
18
- # @return [InlineResponse202] response from the API call.
17
+ # @param [ChargesessionStartBody] body Optional parameter: TODO: type
18
+ # description here
19
+ # @return [InlineResponse202] Response from the API call.
19
20
  def start(request_id,
20
21
  body: nil)
21
- new_api_call_builder
22
+ @api_call
22
23
  .request(new_request_builder(HttpMethodEnum::POST,
23
- '/charge-session/start',
24
+ '/v2/charge-session/start',
24
25
  Server::DEFAULT)
25
26
  .header_param(new_parameter(request_id, key: 'RequestId'))
26
27
  .header_param(new_parameter('application/json', key: 'Content-Type'))
@@ -43,7 +44,7 @@ module ShellEv
43
44
  UnauthorizedException)
44
45
  .local_error('404',
45
46
  'Location Not Found',
46
- NotFoundException)
47
+ V2ChargeSessionStart404ErrorException)
47
48
  .local_error('429',
48
49
  'The Request reached maximum allocated rate limit',
49
50
  TooManyRequestsException)
@@ -66,12 +67,12 @@ module ShellEv
66
67
  # 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4
67
68
  # hyphens) <br>
68
69
  # @param [String] session_id Required parameter: Session Id
69
- # @return [InlineResponse2021] response from the API call.
70
+ # @return [InlineResponse2021] Response from the API call.
70
71
  def stop(request_id,
71
72
  session_id)
72
- new_api_call_builder
73
+ @api_call
73
74
  .request(new_request_builder(HttpMethodEnum::POST,
74
- '/charge-session/stop',
75
+ '/v2/charge-session/stop',
75
76
  Server::DEFAULT)
76
77
  .header_param(new_parameter(request_id, key: 'RequestId'))
77
78
  .query_param(new_parameter(session_id, key: 'sessionId'))
@@ -92,7 +93,7 @@ module ShellEv
92
93
  UnauthorizedException)
93
94
  .local_error('404',
94
95
  'Location Not Found',
95
- NotFoundException)
96
+ V2ChargeSessionStop404ErrorException)
96
97
  .local_error('429',
97
98
  'The Request reached maximum allocated rate limit',
98
99
  TooManyRequestsException)
@@ -114,12 +115,12 @@ module ShellEv
114
115
  # 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4
115
116
  # hyphens) <br>
116
117
  # @param [String] session_id Required parameter: Session Id
117
- # @return [GetChargeSessionRetrieveResponse200Json] response from the API call.
118
+ # @return [GetChargeSessionRetrieveResponse200Json] Response from the API call.
118
119
  def get_charge_session_retrieve(request_id,
119
120
  session_id)
120
- new_api_call_builder
121
+ @api_call
121
122
  .request(new_request_builder(HttpMethodEnum::GET,
122
- '/charge-session/retrieve',
123
+ '/v2/charge-session/retrieve',
123
124
  Server::DEFAULT)
124
125
  .header_param(new_parameter(request_id, key: 'RequestId'))
125
126
  .query_param(new_parameter(session_id, key: 'sessionId'))
@@ -140,7 +141,7 @@ module ShellEv
140
141
  UnauthorizedException)
141
142
  .local_error('404',
142
143
  'Location Not Found',
143
- NotFoundException)
144
+ V2ChargeSessionRetrieve404ErrorException)
144
145
  .local_error('429',
145
146
  'The Request reached maximum allocated rate limit',
146
147
  TooManyRequestsException)
@@ -163,12 +164,12 @@ module ShellEv
163
164
  # hyphens) <br>
164
165
  # @param [String] ema_id Required parameter: Emobility Account
165
166
  # Identifier(Ema-ID)
166
- # @return [ActiveResponse200Json] response from the API call.
167
+ # @return [ActiveResponse200Json] Response from the API call.
167
168
  def active(request_id,
168
169
  ema_id)
169
- new_api_call_builder
170
+ @api_call
170
171
  .request(new_request_builder(HttpMethodEnum::GET,
171
- '/charge-session/active',
172
+ '/v2/charge-session/active',
172
173
  Server::DEFAULT)
173
174
  .header_param(new_parameter(request_id, key: 'RequestId'))
174
175
  .query_param(new_parameter(ema_id, key: 'emaId'))