vmsp-sdk 0.0.1

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 (130) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +167 -0
  4. data/bin/console +15 -0
  5. data/lib/e_mobility_vmspocpiap_is/api_helper.rb +10 -0
  6. data/lib/e_mobility_vmspocpiap_is/client.rb +138 -0
  7. data/lib/e_mobility_vmspocpiap_is/configuration.rb +176 -0
  8. data/lib/e_mobility_vmspocpiap_is/controllers/account_controller.rb +53 -0
  9. data/lib/e_mobility_vmspocpiap_is/controllers/base_controller.rb +60 -0
  10. data/lib/e_mobility_vmspocpiap_is/controllers/cd_rs_pull_controller.rb +103 -0
  11. data/lib/e_mobility_vmspocpiap_is/controllers/cd_rs_push_controller.rb +51 -0
  12. data/lib/e_mobility_vmspocpiap_is/controllers/commands_callback_controller.rb +56 -0
  13. data/lib/e_mobility_vmspocpiap_is/controllers/commands_controller.rb +102 -0
  14. data/lib/e_mobility_vmspocpiap_is/controllers/locations_pull_controller.rb +125 -0
  15. data/lib/e_mobility_vmspocpiap_is/controllers/locations_push_controller.rb +68 -0
  16. data/lib/e_mobility_vmspocpiap_is/controllers/sessions_pull_controller.rb +91 -0
  17. data/lib/e_mobility_vmspocpiap_is/controllers/sessions_push_controller.rb +74 -0
  18. data/lib/e_mobility_vmspocpiap_is/controllers/tariffs_pull_controller.rb +117 -0
  19. data/lib/e_mobility_vmspocpiap_is/controllers/tariffs_push_controller.rb +62 -0
  20. data/lib/e_mobility_vmspocpiap_is/exceptions/accounts_ocpi_error_response_exception.rb +69 -0
  21. data/lib/e_mobility_vmspocpiap_is/exceptions/accounts_ocpi_response_exception.rb +67 -0
  22. data/lib/e_mobility_vmspocpiap_is/exceptions/accounts_ocpi_unauthorized_response_exception.rb +64 -0
  23. data/lib/e_mobility_vmspocpiap_is/exceptions/api_exception.rb +21 -0
  24. data/lib/e_mobility_vmspocpiap_is/exceptions/ocpi_error_response_exception.rb +71 -0
  25. data/lib/e_mobility_vmspocpiap_is/exceptions/ocpi_response_error_exception.rb +67 -0
  26. data/lib/e_mobility_vmspocpiap_is/exceptions/ocpi_unauthorized_response_exception.rb +64 -0
  27. data/lib/e_mobility_vmspocpiap_is/exceptions/v3_commands_startsession400_error_exception.rb +67 -0
  28. data/lib/e_mobility_vmspocpiap_is/http/auth/bearer_authorization.rb +53 -0
  29. data/lib/e_mobility_vmspocpiap_is/http/auth/ocpi_authorization.rb +52 -0
  30. data/lib/e_mobility_vmspocpiap_is/http/http_call_back.rb +10 -0
  31. data/lib/e_mobility_vmspocpiap_is/http/http_method_enum.rb +10 -0
  32. data/lib/e_mobility_vmspocpiap_is/http/http_request.rb +10 -0
  33. data/lib/e_mobility_vmspocpiap_is/http/http_response.rb +10 -0
  34. data/lib/e_mobility_vmspocpiap_is/http/proxy_settings.rb +22 -0
  35. data/lib/e_mobility_vmspocpiap_is/models/account_details.rb +237 -0
  36. data/lib/e_mobility_vmspocpiap_is/models/account_details2.rb +237 -0
  37. data/lib/e_mobility_vmspocpiap_is/models/account_response.rb +98 -0
  38. data/lib/e_mobility_vmspocpiap_is/models/account_state_enum.rb +46 -0
  39. data/lib/e_mobility_vmspocpiap_is/models/account_state_reason_enum.rb +67 -0
  40. data/lib/e_mobility_vmspocpiap_is/models/add_on_fee.rb +101 -0
  41. data/lib/e_mobility_vmspocpiap_is/models/add_on_fee_type_enum.rb +52 -0
  42. data/lib/e_mobility_vmspocpiap_is/models/additional_geo_location.rb +82 -0
  43. data/lib/e_mobility_vmspocpiap_is/models/auth_method_enum.rb +40 -0
  44. data/lib/e_mobility_vmspocpiap_is/models/base_model.rb +110 -0
  45. data/lib/e_mobility_vmspocpiap_is/models/benefit.rb +181 -0
  46. data/lib/e_mobility_vmspocpiap_is/models/booking_restriction_type_enum.rb +44 -0
  47. data/lib/e_mobility_vmspocpiap_is/models/business_details.rb +84 -0
  48. data/lib/e_mobility_vmspocpiap_is/models/capability_enum.rb +88 -0
  49. data/lib/e_mobility_vmspocpiap_is/models/cdr.rb +462 -0
  50. data/lib/e_mobility_vmspocpiap_is/models/cdr1.rb +457 -0
  51. data/lib/e_mobility_vmspocpiap_is/models/cdr_dimension.rb +71 -0
  52. data/lib/e_mobility_vmspocpiap_is/models/cdr_dimension_type_enum.rb +97 -0
  53. data/lib/e_mobility_vmspocpiap_is/models/cdr_location.rb +206 -0
  54. data/lib/e_mobility_vmspocpiap_is/models/cdr_token.rb +91 -0
  55. data/lib/e_mobility_vmspocpiap_is/models/charge_type_enum.rb +52 -0
  56. data/lib/e_mobility_vmspocpiap_is/models/charging_period.rb +100 -0
  57. data/lib/e_mobility_vmspocpiap_is/models/command_response.rb +92 -0
  58. data/lib/e_mobility_vmspocpiap_is/models/command_response1.rb +91 -0
  59. data/lib/e_mobility_vmspocpiap_is/models/command_response_type_enum.rb +44 -0
  60. data/lib/e_mobility_vmspocpiap_is/models/command_result.rb +81 -0
  61. data/lib/e_mobility_vmspocpiap_is/models/command_result_type_enum.rb +64 -0
  62. data/lib/e_mobility_vmspocpiap_is/models/connector.rb +184 -0
  63. data/lib/e_mobility_vmspocpiap_is/models/connector_format_enum.rb +36 -0
  64. data/lib/e_mobility_vmspocpiap_is/models/connector_type_enum.rb +196 -0
  65. data/lib/e_mobility_vmspocpiap_is/models/day_of_week_enum.rb +56 -0
  66. data/lib/e_mobility_vmspocpiap_is/models/display_text.rb +68 -0
  67. data/lib/e_mobility_vmspocpiap_is/models/emaid.rb +137 -0
  68. data/lib/e_mobility_vmspocpiap_is/models/energy_mix.rb +127 -0
  69. data/lib/e_mobility_vmspocpiap_is/models/energy_source.rb +69 -0
  70. data/lib/e_mobility_vmspocpiap_is/models/energy_source_category_enum.rb +60 -0
  71. data/lib/e_mobility_vmspocpiap_is/models/environmental_impact.rb +68 -0
  72. data/lib/e_mobility_vmspocpiap_is/models/environmental_impact_category_enum.rb +36 -0
  73. data/lib/e_mobility_vmspocpiap_is/models/evse.rb +250 -0
  74. data/lib/e_mobility_vmspocpiap_is/models/exceptional_period.rb +84 -0
  75. data/lib/e_mobility_vmspocpiap_is/models/facility_enum.rb +108 -0
  76. data/lib/e_mobility_vmspocpiap_is/models/geo_location.rb +73 -0
  77. data/lib/e_mobility_vmspocpiap_is/models/hours.rb +127 -0
  78. data/lib/e_mobility_vmspocpiap_is/models/image.rb +114 -0
  79. data/lib/e_mobility_vmspocpiap_is/models/image_category_enum.rb +58 -0
  80. data/lib/e_mobility_vmspocpiap_is/models/location.rb +379 -0
  81. data/lib/e_mobility_vmspocpiap_is/models/location1.rb +375 -0
  82. data/lib/e_mobility_vmspocpiap_is/models/ocpi_command_response.rb +62 -0
  83. data/lib/e_mobility_vmspocpiap_is/models/ocpi_response.rb +98 -0
  84. data/lib/e_mobility_vmspocpiap_is/models/parking_direction_enum.rb +40 -0
  85. data/lib/e_mobility_vmspocpiap_is/models/parking_restriction_enum.rb +61 -0
  86. data/lib/e_mobility_vmspocpiap_is/models/parking_type_enum.rb +53 -0
  87. data/lib/e_mobility_vmspocpiap_is/models/power_type_enum.rb +48 -0
  88. data/lib/e_mobility_vmspocpiap_is/models/price.rb +80 -0
  89. data/lib/e_mobility_vmspocpiap_is/models/price_component.rb +99 -0
  90. data/lib/e_mobility_vmspocpiap_is/models/price_limit.rb +71 -0
  91. data/lib/e_mobility_vmspocpiap_is/models/product.rb +186 -0
  92. data/lib/e_mobility_vmspocpiap_is/models/publish_token_type.rb +106 -0
  93. data/lib/e_mobility_vmspocpiap_is/models/regular_hours.rb +80 -0
  94. data/lib/e_mobility_vmspocpiap_is/models/reservation_restriction_type_enum.rb +36 -0
  95. data/lib/e_mobility_vmspocpiap_is/models/session.rb +298 -0
  96. data/lib/e_mobility_vmspocpiap_is/models/session_status_enum.rb +60 -0
  97. data/lib/e_mobility_vmspocpiap_is/models/signed_data.rb +116 -0
  98. data/lib/e_mobility_vmspocpiap_is/models/signed_value.rb +85 -0
  99. data/lib/e_mobility_vmspocpiap_is/models/start_session.rb +107 -0
  100. data/lib/e_mobility_vmspocpiap_is/models/start_session_token.rb +68 -0
  101. data/lib/e_mobility_vmspocpiap_is/models/status2_enum.rb +44 -0
  102. data/lib/e_mobility_vmspocpiap_is/models/status_enum.rb +64 -0
  103. data/lib/e_mobility_vmspocpiap_is/models/status_schedule.rb +97 -0
  104. data/lib/e_mobility_vmspocpiap_is/models/stop_session.rb +70 -0
  105. data/lib/e_mobility_vmspocpiap_is/models/subscription_renewal_cadence_enum.rb +44 -0
  106. data/lib/e_mobility_vmspocpiap_is/models/tariff.rb +347 -0
  107. data/lib/e_mobility_vmspocpiap_is/models/tariff1.rb +336 -0
  108. data/lib/e_mobility_vmspocpiap_is/models/tariff_dimension_type_enum.rb +60 -0
  109. data/lib/e_mobility_vmspocpiap_is/models/tariff_element.rb +91 -0
  110. data/lib/e_mobility_vmspocpiap_is/models/tariff_restrictions.rb +310 -0
  111. data/lib/e_mobility_vmspocpiap_is/models/tariff_type_enum.rb +48 -0
  112. data/lib/e_mobility_vmspocpiap_is/models/tax_amount.rb +95 -0
  113. data/lib/e_mobility_vmspocpiap_is/models/tax_included_enum.rb +40 -0
  114. data/lib/e_mobility_vmspocpiap_is/models/token_type_enum.rb +48 -0
  115. data/lib/e_mobility_vmspocpiap_is/models/type_of_emaid_enum.rb +36 -0
  116. data/lib/e_mobility_vmspocpiap_is/models/url_enum.rb +36 -0
  117. data/lib/e_mobility_vmspocpiap_is/models/v3_cdrs_response.rb +107 -0
  118. data/lib/e_mobility_vmspocpiap_is/models/v3_cdrs_response1.rb +98 -0
  119. data/lib/e_mobility_vmspocpiap_is/models/v3_commands_startsession_response.rb +98 -0
  120. data/lib/e_mobility_vmspocpiap_is/models/v3_commands_stopsession_response.rb +98 -0
  121. data/lib/e_mobility_vmspocpiap_is/models/v3_locations_response.rb +107 -0
  122. data/lib/e_mobility_vmspocpiap_is/models/v3_locations_response1.rb +98 -0
  123. data/lib/e_mobility_vmspocpiap_is/models/v3_sessions_response.rb +107 -0
  124. data/lib/e_mobility_vmspocpiap_is/models/v3_tariffs_response.rb +107 -0
  125. data/lib/e_mobility_vmspocpiap_is/models/v3_tariffs_response1.rb +98 -0
  126. data/lib/e_mobility_vmspocpiap_is/models/vehicle_type_enum.rb +64 -0
  127. data/lib/e_mobility_vmspocpiap_is/utilities/date_time_helper.rb +11 -0
  128. data/lib/e_mobility_vmspocpiap_is/utilities/file_wrapper.rb +28 -0
  129. data/lib/e_mobility_vmspocpiap_is.rb +164 -0
  130. metadata +213 -0
@@ -0,0 +1,64 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module EMobilityVmspocpiapIs
8
+ # OCPIUnauthorizedResponse class.
9
+ class OCPIUnauthorizedResponseException < APIException
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # OCPI status code.
14
+ # @return [Integer]
15
+ attr_accessor :status_code
16
+
17
+ # Human-readable error description.
18
+ # @return [String]
19
+ attr_accessor :status_message
20
+
21
+ # Human-readable error description.
22
+ # @return [DateTime]
23
+ attr_accessor :timestamp
24
+
25
+ # The constructor.
26
+ # @param [String] reason The reason for raising an exception.
27
+ # @param [HttpResponse] response The HttpReponse of the API call.
28
+ def initialize(reason, response)
29
+ super(reason, response)
30
+ hash = APIHelper.json_deserialize(@response.raw_body)
31
+ unbox(hash)
32
+ end
33
+
34
+ # Populates this object by extracting properties from a hash.
35
+ # @param [Hash] hash The deserialized response sent by the server in the
36
+ # response body.
37
+ def unbox(hash)
38
+ return nil unless hash
39
+
40
+ @status_code = hash.key?('status_code') ? hash['status_code'] : SKIP
41
+ @status_message =
42
+ hash.key?('status_message') ? hash['status_message'] : SKIP
43
+ @timestamp = if hash.key?('timestamp')
44
+ (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
45
+ else
46
+ SKIP
47
+ end
48
+ end
49
+
50
+ # Provides a human-readable string representation of the object.
51
+ def to_s
52
+ class_name = self.class.name.split('::').last
53
+ "<#{class_name} status_code: #{@status_code}, status_message: #{@status_message},"\
54
+ " timestamp: #{@timestamp}>"
55
+ end
56
+
57
+ # Provides a debugging-friendly string with detailed object information.
58
+ def inspect
59
+ class_name = self.class.name.split('::').last
60
+ "<#{class_name} status_code: #{@status_code.inspect}, status_message:"\
61
+ " #{@status_message.inspect}, timestamp: #{@timestamp.inspect}>"
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,67 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module EMobilityVmspocpiapIs
8
+ # V3 Commands START SESSION 400 Error class.
9
+ class V3CommandsSTARTSESSION400ErrorException < APIException
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # OCPI status code, 1000 for success.
14
+ # @return [Integer]
15
+ attr_accessor :status_code
16
+
17
+ # An optional status message which may help when debugging.
18
+ # @return [String]
19
+ attr_accessor :status_message
20
+
21
+ # The time this message was generated.
22
+ # @return [DateTime]
23
+ attr_accessor :timestamp
24
+
25
+ # Response data object or list of objects.
26
+ # @return [Object]
27
+ attr_accessor :data
28
+
29
+ # The constructor.
30
+ # @param [String] reason The reason for raising an exception.
31
+ # @param [HttpResponse] response The HttpReponse of the API call.
32
+ def initialize(reason, response)
33
+ super(reason, response)
34
+ hash = APIHelper.json_deserialize(@response.raw_body)
35
+ unbox(hash)
36
+ end
37
+
38
+ # Populates this object by extracting properties from a hash.
39
+ # @param [Hash] hash The deserialized response sent by the server in the
40
+ # response body.
41
+ def unbox(hash)
42
+ return nil unless hash
43
+
44
+ @status_code = hash.key?('status_code') ? hash['status_code'] : nil
45
+ @status_message =
46
+ hash.key?('status_message') ? hash['status_message'] : SKIP
47
+ @timestamp = if hash.key?('timestamp')
48
+ (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
49
+ end
50
+ @data = hash.key?('data') ? hash['data'] : SKIP
51
+ end
52
+
53
+ # Provides a human-readable string representation of the object.
54
+ def to_s
55
+ class_name = self.class.name.split('::').last
56
+ "<#{class_name} status_code: #{@status_code}, status_message: #{@status_message},"\
57
+ " timestamp: #{@timestamp}, data: #{@data}>"
58
+ end
59
+
60
+ # Provides a debugging-friendly string with detailed object information.
61
+ def inspect
62
+ class_name = self.class.name.split('::').last
63
+ "<#{class_name} status_code: #{@status_code.inspect}, status_message:"\
64
+ " #{@status_message.inspect}, timestamp: #{@timestamp.inspect}, data: #{@data.inspect}>"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,53 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # Utility class for OAuth 2 authorization and token management.
8
+ class BearerAuthorization < CoreLibrary::HeaderAuth
9
+ include CoreLibrary
10
+ # Display error message on occurrence of authentication failure.
11
+ # @returns [String] The oAuth error message.
12
+ def error_message
13
+ 'BearerAuthorization: access_token is undefined.'
14
+ end
15
+
16
+ # Initialization constructor.
17
+ def initialize(bearer_authorization_credentials)
18
+ auth_params = {}
19
+ @_access_token = bearer_authorization_credentials.access_token unless
20
+ bearer_authorization_credentials.nil? || bearer_authorization_credentials.access_token.nil?
21
+ auth_params[:Authorization] = "Bearer #{@_access_token}" unless @_access_token.nil?
22
+
23
+ super auth_params
24
+ end
25
+ end
26
+
27
+ # Data class for BearerAuthorizationCredentials.
28
+ class BearerAuthorizationCredentials
29
+ attr_reader :access_token
30
+
31
+ def initialize(access_token:)
32
+ raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
33
+
34
+ @access_token = access_token
35
+ end
36
+
37
+ def self.from_env
38
+ access_token = ENV['BEARER_AUTHORIZATION_ACCESS_TOKEN']
39
+ all_nil = [
40
+ access_token
41
+ ].all?(&:nil?)
42
+ return nil if all_nil
43
+
44
+ new(access_token: access_token)
45
+ end
46
+
47
+ def clone_with(access_token: nil)
48
+ access_token ||= self.access_token
49
+
50
+ BearerAuthorizationCredentials.new(access_token: access_token)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,52 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # Utility class for custom header authorization.
8
+ class OcpiAuthorization < CoreLibrary::HeaderAuth
9
+ # Display error message on occurrence of authentication failure.
10
+ # @returns [String] The oAuth error message.
11
+ def error_message
12
+ 'OcpiAuthorization: authorization is undefined.'
13
+ end
14
+
15
+ # Initialization constructor.
16
+ def initialize(ocpi_authorization_credentials)
17
+ auth_params = {}
18
+ auth_params['Authorization'] = ocpi_authorization_credentials.authorization unless
19
+ ocpi_authorization_credentials.nil? || ocpi_authorization_credentials.authorization.nil?
20
+
21
+ super auth_params
22
+ end
23
+ end
24
+
25
+ # Data class for OcpiAuthorizationCredentials.
26
+ # Data class for OcpiAuthorizationCredentials.
27
+ class OcpiAuthorizationCredentials
28
+ attr_reader :authorization
29
+
30
+ def initialize(authorization:)
31
+ raise ArgumentError, 'authorization cannot be nil' if authorization.nil?
32
+
33
+ @authorization = authorization
34
+ end
35
+
36
+ def self.from_env
37
+ authorization = ENV['OCPI_AUTHORIZATION_AUTHORIZATION']
38
+ all_nil = [
39
+ authorization
40
+ ].all?(&:nil?)
41
+ return nil if all_nil
42
+
43
+ new(authorization: authorization)
44
+ end
45
+
46
+ def clone_with(authorization: nil)
47
+ authorization ||= self.authorization
48
+
49
+ OcpiAuthorizationCredentials.new(authorization: authorization)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack < CoreLibrary::HttpCallback
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module EMobilityVmspocpiapIs
7
+ ##
8
+ # ProxySettings encapsulates HTTP proxy configuration for Faraday,
9
+ # including optional basic authentication.
10
+ #
11
+ class ProxySettings < CoreLibrary::ProxySettings
12
+ def self.from_env
13
+ address = ENV['PROXY_ADDRESS']
14
+ port = ENV['PROXY_PORT']
15
+ username = ENV['PROXY_USERNAME']
16
+ password = ENV['PROXY_PASSWORD']
17
+ return nil if address.nil? || address.strip.empty?
18
+
19
+ new(address: address, port: port, username: username, password: password)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,237 @@
1
+ # e_mobility_vmspocpiap_is
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module EMobilityVmspocpiapIs
8
+ # AccountDetails Model.
9
+ class AccountDetails < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Unique identifier for the account
14
+ # @return [String]
15
+ attr_accessor :account_id
16
+
17
+ # Current state of the account:
18
+ # * PENDING: user data stored at Shell (after accepting Shell terms → also
19
+ # trigger account linking with GCDM), but account creation flow not finished
20
+ # (e.g. payment setup not completed) → on new webscreens link out, redirect
21
+ # customer directly to pending account creation step
22
+ # * ACTIVE: user creation fully finished, e.g. also payment method added
23
+ # * BLOCKED: user account blocked due to terms updated, pending deletion,
24
+ # payment invalid (CC deleted or expired)
25
+ # @return [AccountStateEnum]
26
+ attr_accessor :account_state
27
+
28
+ # Reason for the current account state:
29
+ # * UNKNOWN: Used for unknown reasons when account_state is BLOCKED - Maps
30
+ # to status_code 2904
31
+ # * USER_PENDING_DELETION: Oauth2OemUserDetails.pendingDeletion is true -
32
+ # user pending deletion - Maps to status_code 2900
33
+ # * USER_TERMS_NOT_ACCEPTED: User has not accepted terms and conditions -
34
+ # Maps to status_code 2903
35
+ # * PAYMENT_METHOD_NOT_SET_UP: Payment method not configured in payment
36
+ # system - Maps to status_code 2906
37
+ # * PAYMENT_METHOD_CARD_EXPIRED: Payment card has expired - Maps to
38
+ # status_code 2907
39
+ # * EMAID_NOT_CREATED: EMAID not created - Maps to status_code 2908
40
+ # * PAYMENT_FAILED: Account in blocked state due to payment collection
41
+ # failure - Maps to status_code 2910
42
+ # The field is undefined: No specific reason (returned with status_code 1000
43
+ # when account_state is ACTIVE, or 2902 when PENDING)
44
+ # @return [AccountStateReasonEnum]
45
+ attr_accessor :account_state_reason
46
+
47
+ # Reason for the current account state:
48
+ # * UNKNOWN: Used for unknown reasons when account_state is BLOCKED - Maps
49
+ # to status_code 2904
50
+ # * USER_PENDING_DELETION: Oauth2OemUserDetails.pendingDeletion is true -
51
+ # user pending deletion - Maps to status_code 2900
52
+ # * USER_TERMS_NOT_ACCEPTED: User has not accepted terms and conditions -
53
+ # Maps to status_code 2903
54
+ # * PAYMENT_METHOD_NOT_SET_UP: Payment method not configured in payment
55
+ # system - Maps to status_code 2906
56
+ # * PAYMENT_METHOD_CARD_EXPIRED: Payment card has expired - Maps to
57
+ # status_code 2907
58
+ # * EMAID_NOT_CREATED: EMAID not created - Maps to status_code 2908
59
+ # * PAYMENT_FAILED: Account in blocked state due to payment collection
60
+ # failure - Maps to status_code 2910
61
+ # The field is undefined: No specific reason (returned with status_code 1000
62
+ # when account_state is ACTIVE, or 2902 when PENDING)
63
+ # @return [Array[Product]]
64
+ attr_accessor :products
65
+
66
+ # Reason for the current account state:
67
+ # * UNKNOWN: Used for unknown reasons when account_state is BLOCKED - Maps
68
+ # to status_code 2904
69
+ # * USER_PENDING_DELETION: Oauth2OemUserDetails.pendingDeletion is true -
70
+ # user pending deletion - Maps to status_code 2900
71
+ # * USER_TERMS_NOT_ACCEPTED: User has not accepted terms and conditions -
72
+ # Maps to status_code 2903
73
+ # * PAYMENT_METHOD_NOT_SET_UP: Payment method not configured in payment
74
+ # system - Maps to status_code 2906
75
+ # * PAYMENT_METHOD_CARD_EXPIRED: Payment card has expired - Maps to
76
+ # status_code 2907
77
+ # * EMAID_NOT_CREATED: EMAID not created - Maps to status_code 2908
78
+ # * PAYMENT_FAILED: Account in blocked state due to payment collection
79
+ # failure - Maps to status_code 2910
80
+ # The field is undefined: No specific reason (returned with status_code 1000
81
+ # when account_state is ACTIVE, or 2902 when PENDING)
82
+ # @return [Array[Benefit]]
83
+ attr_accessor :benefits
84
+
85
+ # Reason for the current account state:
86
+ # * UNKNOWN: Used for unknown reasons when account_state is BLOCKED - Maps
87
+ # to status_code 2904
88
+ # * USER_PENDING_DELETION: Oauth2OemUserDetails.pendingDeletion is true -
89
+ # user pending deletion - Maps to status_code 2900
90
+ # * USER_TERMS_NOT_ACCEPTED: User has not accepted terms and conditions -
91
+ # Maps to status_code 2903
92
+ # * PAYMENT_METHOD_NOT_SET_UP: Payment method not configured in payment
93
+ # system - Maps to status_code 2906
94
+ # * PAYMENT_METHOD_CARD_EXPIRED: Payment card has expired - Maps to
95
+ # status_code 2907
96
+ # * EMAID_NOT_CREATED: EMAID not created - Maps to status_code 2908
97
+ # * PAYMENT_FAILED: Account in blocked state due to payment collection
98
+ # failure - Maps to status_code 2910
99
+ # The field is undefined: No specific reason (returned with status_code 1000
100
+ # when account_state is ACTIVE, or 2902 when PENDING)
101
+ # @return [Array[Emaid]]
102
+ attr_accessor :emaids
103
+
104
+ # Timestamp when the account was created.
105
+ # @return [DateTime]
106
+ attr_accessor :created_at
107
+
108
+ # Timestamp when the account was last updated. In initial account creation,
109
+ # same as created_at.
110
+ # @return [DateTime]
111
+ attr_accessor :updated_at
112
+
113
+ # A mapping from model property names to API property names.
114
+ def self.names
115
+ @_hash = {} if @_hash.nil?
116
+ @_hash['account_id'] = 'account_id'
117
+ @_hash['account_state'] = 'account_state'
118
+ @_hash['account_state_reason'] = 'account_state_reason'
119
+ @_hash['products'] = 'products'
120
+ @_hash['benefits'] = 'benefits'
121
+ @_hash['emaids'] = 'emaids'
122
+ @_hash['created_at'] = 'created_at'
123
+ @_hash['updated_at'] = 'updated_at'
124
+ @_hash
125
+ end
126
+
127
+ # An array for optional fields
128
+ def self.optionals
129
+ %w[
130
+ account_state_reason
131
+ benefits
132
+ emaids
133
+ ]
134
+ end
135
+
136
+ # An array for nullable fields
137
+ def self.nullables
138
+ []
139
+ end
140
+
141
+ def initialize(account_id = nil, account_state = nil, products = nil,
142
+ created_at = nil, updated_at = nil,
143
+ account_state_reason = SKIP, benefits = SKIP, emaids = SKIP)
144
+ @account_id = account_id
145
+ @account_state = account_state
146
+ @account_state_reason = account_state_reason unless account_state_reason == SKIP
147
+ @products = products
148
+ @benefits = benefits unless benefits == SKIP
149
+ @emaids = emaids unless emaids == SKIP
150
+ @created_at = created_at
151
+ @updated_at = updated_at
152
+ end
153
+
154
+ # Creates an instance of the object from a hash.
155
+ def self.from_hash(hash)
156
+ return nil unless hash
157
+
158
+ # Extract variables from the hash.
159
+ account_id = hash.key?('account_id') ? hash['account_id'] : nil
160
+ account_state = hash.key?('account_state') ? hash['account_state'] : nil
161
+ # Parameter is an array, so we need to iterate through it
162
+ products = nil
163
+ unless hash['products'].nil?
164
+ products = []
165
+ hash['products'].each do |structure|
166
+ products << (Product.from_hash(structure) if structure)
167
+ end
168
+ end
169
+
170
+ products = nil unless hash.key?('products')
171
+ created_at = if hash.key?('created_at')
172
+ (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
173
+ end
174
+ updated_at = if hash.key?('updated_at')
175
+ (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
176
+ end
177
+ account_state_reason =
178
+ hash.key?('account_state_reason') ? hash['account_state_reason'] : SKIP
179
+ # Parameter is an array, so we need to iterate through it
180
+ benefits = nil
181
+ unless hash['benefits'].nil?
182
+ benefits = []
183
+ hash['benefits'].each do |structure|
184
+ benefits << (Benefit.from_hash(structure) if structure)
185
+ end
186
+ end
187
+
188
+ benefits = SKIP unless hash.key?('benefits')
189
+ # Parameter is an array, so we need to iterate through it
190
+ emaids = nil
191
+ unless hash['emaids'].nil?
192
+ emaids = []
193
+ hash['emaids'].each do |structure|
194
+ emaids << (Emaid.from_hash(structure) if structure)
195
+ end
196
+ end
197
+
198
+ emaids = SKIP unless hash.key?('emaids')
199
+
200
+ # Create object from extracted values.
201
+ AccountDetails.new(account_id,
202
+ account_state,
203
+ products,
204
+ created_at,
205
+ updated_at,
206
+ account_state_reason,
207
+ benefits,
208
+ emaids)
209
+ end
210
+
211
+ def to_custom_created_at
212
+ DateTimeHelper.to_rfc3339(created_at)
213
+ end
214
+
215
+ def to_custom_updated_at
216
+ DateTimeHelper.to_rfc3339(updated_at)
217
+ end
218
+
219
+ # Provides a human-readable string representation of the object.
220
+ def to_s
221
+ class_name = self.class.name.split('::').last
222
+ "<#{class_name} account_id: #{@account_id}, account_state: #{@account_state},"\
223
+ " account_state_reason: #{@account_state_reason}, products: #{@products}, benefits:"\
224
+ " #{@benefits}, emaids: #{@emaids}, created_at: #{@created_at}, updated_at: #{@updated_at}>"
225
+ end
226
+
227
+ # Provides a debugging-friendly string with detailed object information.
228
+ def inspect
229
+ class_name = self.class.name.split('::').last
230
+ "<#{class_name} account_id: #{@account_id.inspect}, account_state:"\
231
+ " #{@account_state.inspect}, account_state_reason: #{@account_state_reason.inspect},"\
232
+ " products: #{@products.inspect}, benefits: #{@benefits.inspect}, emaids:"\
233
+ " #{@emaids.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
234
+ " #{@updated_at.inspect}>"
235
+ end
236
+ end
237
+ end