Module: Worldline::Acquiring::SDK::Authentication::OAuth2Scopes
- Defined in:
- lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb
Class Method Summary collapse
-
.all ⇒ Object
Returns all available scopes.
-
.for_api_version(api_version) ⇒ Object
Returns all scopes needed for all operations of the given API version.
-
.for_filtered_operations(filter) ⇒ Object
Returns all scopes needed for the operations that pass the given filter.
-
.for_operation(api_version, operation_id) ⇒ Object
Returns all scopes needed for the given operation of the given API version.
-
.for_operations(api_version, *operation_ids) ⇒ Object
Returns all scopes needed for the given operations of the given API version.
Class Method Details
.all ⇒ Object
Returns all available scopes.
36 37 38 |
# File 'lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb', line 36 def self.all ALL_SCOPES end |
.for_api_version(api_version) ⇒ Object
Returns all scopes needed for all operations of the given API version.
41 42 43 44 |
# File 'lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb', line 41 def self.for_api_version(api_version) operations = SCOPES_BY_OPERATION[api_version] || {} operations.values.flatten.uniq.freeze end |
.for_filtered_operations(filter) ⇒ Object
Returns all scopes needed for the operations that pass the given filter. The first argument to the filter is the API version, the second is the operation id.
61 62 63 64 65 66 67 68 |
# File 'lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb', line 61 def self.for_filtered_operations(filter) SCOPES_BY_OPERATION.keys.map { |api_version| operations = SCOPES_BY_OPERATION[api_version] operations.keys .filter { |operation_id| filter.call(api_version, operation_id) } .map { |operation_id| operations[operation_id] } }.flatten.uniq.freeze end |
.for_operation(api_version, operation_id) ⇒ Object
Returns all scopes needed for the given operation of the given API version.
47 48 49 50 51 |
# File 'lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb', line 47 def self.for_operation(api_version, operation_id) operations = SCOPES_BY_OPERATION[api_version] || {} scopes = operations[operation_id] || [] scopes.uniq.freeze end |
.for_operations(api_version, *operation_ids) ⇒ Object
Returns all scopes needed for the given operations of the given API version.
54 55 56 57 |
# File 'lib/worldline/acquiring/sdk/authentication/oauth2_scopes.rb', line 54 def self.for_operations(api_version, *operation_ids) operations = SCOPES_BY_OPERATION[api_version] || {} operation_ids.map { |operation_id| operations[operation_id] || [] }.flatten.uniq.freeze end |