ev-recharge-sdk 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ca475d6391b018b580ab5ab4e9b0d8edc441fcdbedc4efb0b384fc18b2622c9
4
- data.tar.gz: c103f47f6e71284c4d80d992c28270165bb484ad3118e615b08336f5bd1bbd2b
3
+ metadata.gz: 3581a5328737a93ee89d58d621cd5b0cd8ab33f77a8940b52e7a5992e96c17ae
4
+ data.tar.gz: d6397da21ac9a71c372605d673fcf9f4afddf119405becae51a32228fdf4cb50
5
5
  SHA512:
6
- metadata.gz: df1225d35d298dd416d8eac0dcba8056aa98aa9452f355fe7cc5a74526275fa0e1d0dca4d923bccdaf6f7360e95ea7b4db11225ad2da6f79e04843bc5eb3c532
7
- data.tar.gz: 1c17bd98dd14ff6e57676462e4deb24d7f59e25fdb937768b81f07332f5ce1b2b715957b18747f73680e17c99186ec71f64eb0d978d36591c702c0a8c00c735c
6
+ metadata.gz: 3b459aa49f87f0aef6aa7d6aad385b8488718c06c3b69f1d6950e4732a71d454d3649fa80f7fd89ebe72ddff63c84adc5b4b410dba9dc4585e6753f662eabe6c
7
+ data.tar.gz: a484563a4340d88c652cfbaf24ba62ad4c875e501ccabccc7cce407e68574f1d335681bb62397adf75c5a1bda963443fc065e8c810d30218b5ea3a9779a8ed5a
data/README.md CHANGED
@@ -28,16 +28,16 @@ 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
  ```ruby
31
- gem install ev-recharge-sdk -v 1.1.0
31
+ gem install ev-recharge-sdk -v 1.2.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.1.0'
37
+ gem 'ev-recharge-sdk', '1.2.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.1.0).
40
+ For additional gem details, see the [RubyGems page for the ev-recharge-sdk gem](https://rubygems.org/gems/ev-recharge-sdk/versions/1.2.0).
41
41
 
42
42
  ## Test the SDK
43
43
 
@@ -49,7 +49,7 @@ rake
49
49
 
50
50
  ## Initialize the API Client
51
51
 
52
- **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/client.md)
52
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/client.md)
53
53
 
54
54
  The following parameters are configurable for the API Client:
55
55
 
@@ -65,7 +65,7 @@ The following parameters are configurable for the API Client:
65
65
  | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
66
66
  | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
67
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.1.0/doc/$a/https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
68
+ | `client_credentials_auth_credentials` | [`ClientCredentialsAuthCredentials`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/$a/https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |
69
69
 
70
70
  The API client can be initialized as follows:
71
71
 
@@ -94,16 +94,16 @@ The SDK can be configured to use a different environment for making API calls. A
94
94
 
95
95
  This API uses the following authentication schemes.
96
96
 
97
- * [`BearerAuth (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/$a/https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/oauth-2-client-credentials-grant.md)
97
+ * [`BearerAuth (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/$a/https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/oauth-2-client-credentials-grant.md)
98
98
 
99
99
  ## List of APIs
100
100
 
101
- * [Locations](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/controllers/locations.md)
102
- * [Charging](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/controllers/charging.md)
101
+ * [Locations](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/controllers/locations.md)
102
+ * [Charging](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/controllers/charging.md)
103
103
 
104
104
  ## Classes Documentation
105
105
 
106
- * [Utility Classes](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/utility-classes.md)
107
- * [HttpResponse](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/http-response.md)
108
- * [HttpRequest](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.1.0/doc/http-request.md)
106
+ * [Utility Classes](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/utility-classes.md)
107
+ * [HttpResponse](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/http-response.md)
108
+ * [HttpRequest](https://www.github.com/sdks-io/ev-recharge-ruby-sdk/tree/1.2.0/doc/http-request.md)
109
109
 
@@ -37,7 +37,8 @@ module ShellEv
37
37
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
38
38
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
39
39
  retry_methods: %i[get put], http_callback: nil,
40
- environment: Environment::PRODUCTION,
40
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
41
+ o_auth_client_secret: nil, o_auth_token: nil,
41
42
  client_credentials_auth_credentials: nil, config: nil
42
43
  )
43
44
  @config = if config.nil?
@@ -48,6 +49,9 @@ module ShellEv
48
49
  retry_statuses: retry_statuses,
49
50
  retry_methods: retry_methods, http_callback: http_callback,
50
51
  environment: environment,
52
+ o_auth_client_id: o_auth_client_id,
53
+ o_auth_client_secret: o_auth_client_secret,
54
+ o_auth_token: o_auth_token,
51
55
  client_credentials_auth_credentials: client_credentials_auth_credentials
52
56
  )
53
57
  else
@@ -24,6 +24,18 @@ module ShellEv
24
24
  # All configuration including auth info and base URI for the API access
25
25
  # are configured in this class.
26
26
  class Configuration < CoreLibrary::HttpClientConfiguration
27
+ def o_auth_client_id
28
+ @client_credentials_auth_credentials.o_auth_client_id
29
+ end
30
+
31
+ def o_auth_client_secret
32
+ @client_credentials_auth_credentials.o_auth_client_secret
33
+ end
34
+
35
+ def o_auth_token
36
+ @client_credentials_auth_credentials.o_auth_token
37
+ end
38
+
27
39
  # The attribute readers for properties.
28
40
  attr_reader :environment, :client_credentials_auth_credentials
29
41
 
@@ -36,7 +48,8 @@ module ShellEv
36
48
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
37
49
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
38
50
  retry_methods: %i[get put], http_callback: nil,
39
- environment: Environment::PRODUCTION,
51
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
52
+ o_auth_client_secret: nil, o_auth_token: nil,
40
53
  client_credentials_auth_credentials: nil
41
54
  )
42
55
 
@@ -48,11 +61,24 @@ module ShellEv
48
61
  # Current API environment
49
62
  @environment = String(environment)
50
63
 
51
- # The object holding OAuth 2 Client Credentials Grant credentials
52
- @client_credentials_auth_credentials = client_credentials_auth_credentials
64
+ # OAuth 2 Client ID
65
+ @o_auth_client_id = o_auth_client_id
66
+
67
+ # OAuth 2 Client Secret
68
+ @o_auth_client_secret = o_auth_client_secret
69
+
70
+ # Object for storing information about the OAuth token
71
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
72
+ OAuthToken.from_hash o_auth_token.to_hash
73
+ else
74
+ o_auth_token
75
+ end
53
76
 
54
77
  # Initializing OAuth 2 Client Credentials Grant credentials with the provided auth parameters
55
- @client_credentials_auth_credentials = client_credentials_auth_credentials
78
+ @client_credentials_auth_credentials = create_auth_credentials_object(
79
+ o_auth_client_id, o_auth_client_secret, o_auth_token,
80
+ client_credentials_auth_credentials
81
+ )
56
82
 
57
83
  # The Http Client to use for making requests.
58
84
  set_http_client CoreLibrary::FaradayClient.new(self)
@@ -61,7 +87,9 @@ module ShellEv
61
87
  def clone_with(connection: nil, adapter: nil, timeout: nil,
62
88
  max_retries: nil, retry_interval: nil, backoff_factor: nil,
63
89
  retry_statuses: nil, retry_methods: nil, http_callback: nil,
64
- environment: nil, client_credentials_auth_credentials: nil)
90
+ environment: nil, o_auth_client_id: nil,
91
+ o_auth_client_secret: nil, o_auth_token: nil,
92
+ client_credentials_auth_credentials: nil)
65
93
  connection ||= self.connection
66
94
  adapter ||= self.adapter
67
95
  timeout ||= self.timeout
@@ -72,7 +100,10 @@ module ShellEv
72
100
  retry_methods ||= self.retry_methods
73
101
  http_callback ||= self.http_callback
74
102
  environment ||= self.environment
75
- client_credentials_auth_credentials ||= client_credentials_auth_credentials
103
+ client_credentials_auth_credentials = create_auth_credentials_object(
104
+ o_auth_client_id, o_auth_client_secret, o_auth_token,
105
+ client_credentials_auth_credentials || self.client_credentials_auth_credentials
106
+ )
76
107
 
77
108
  Configuration.new(
78
109
  connection: connection, adapter: adapter, timeout: timeout,
@@ -84,6 +115,30 @@ module ShellEv
84
115
  )
85
116
  end
86
117
 
118
+ def create_auth_credentials_object(o_auth_client_id, o_auth_client_secret,
119
+ o_auth_token,
120
+ client_credentials_auth_credentials)
121
+ return client_credentials_auth_credentials if o_auth_client_id.nil? &&
122
+ o_auth_client_secret.nil? &&
123
+ o_auth_token.nil?
124
+
125
+ warn('The \'o_auth_client_id\', \'o_auth_client_secret\', \'o_auth_token'\
126
+ '\' params are deprecated. Use \'client_credentials_auth_credential'\
127
+ 's\' param instead.')
128
+
129
+ unless client_credentials_auth_credentials.nil?
130
+ return client_credentials_auth_credentials.clone_with(
131
+ o_auth_client_id: o_auth_client_id,
132
+ o_auth_client_secret: o_auth_client_secret,
133
+ o_auth_token: o_auth_token
134
+ )
135
+ end
136
+
137
+ ClientCredentialsAuthCredentials.new(
138
+ o_auth_client_id: o_auth_client_id,
139
+ o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token
140
+ )
141
+ end
87
142
 
88
143
  # All the environments the SDK can run in.
89
144
  ENVIRONMENTS = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ev-recharge-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - developer sdksio