wesley-key-sdk 3.0.7 → 4.3.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.
- checksums.yaml +4 -4
- data/README.md +156 -132
- data/bin/console +4 -4
- data/lib/webhooks_and_callbacks_api/api_helper.rb +10 -0
- data/lib/{cypress_test_api/controllers/base_controller.rb → webhooks_and_callbacks_api/apis/base_api.rb} +17 -10
- data/lib/webhooks_and_callbacks_api/apis/orders_api.rb +34 -0
- data/lib/webhooks_and_callbacks_api/client.rb +76 -0
- data/lib/{cypress_test_api → webhooks_and_callbacks_api}/configuration.rb +61 -46
- data/lib/webhooks_and_callbacks_api/events/callbacks/callbacks_a_handler.rb +66 -0
- data/lib/webhooks_and_callbacks_api/events/callbacks/callbacks_b_handler.rb +78 -0
- data/lib/webhooks_and_callbacks_api/events/signature_verification_failure.rb +33 -0
- data/lib/webhooks_and_callbacks_api/events/signature_verification_result.rb +14 -0
- data/lib/webhooks_and_callbacks_api/events/unknown_event.rb +32 -0
- data/lib/webhooks_and_callbacks_api/events/webhooks/webhooks_a_handler.rb +67 -0
- data/lib/webhooks_and_callbacks_api/events/webhooks/webhooks_b_handler.rb +86 -0
- data/lib/webhooks_and_callbacks_api/events/webhooks/webhooks_c_handler.rb +79 -0
- data/lib/webhooks_and_callbacks_api/events/webhooks/webhooks_handler.rb +67 -0
- data/lib/webhooks_and_callbacks_api/events/webhooks/webhooks_no_verification_handler.rb +39 -0
- data/lib/{cypress_test_api → webhooks_and_callbacks_api}/exceptions/api_exception.rb +4 -4
- data/lib/webhooks_and_callbacks_api/exceptions/error_exception.rb +57 -0
- data/lib/webhooks_and_callbacks_api/http/api_response.rb +19 -0
- data/lib/webhooks_and_callbacks_api/http/auth/api_key.rb +52 -0
- data/lib/webhooks_and_callbacks_api/http/auth/bearer_auth.rb +53 -0
- data/lib/webhooks_and_callbacks_api/http/http_call_back.rb +10 -0
- data/lib/webhooks_and_callbacks_api/http/http_method_enum.rb +10 -0
- data/lib/webhooks_and_callbacks_api/http/http_request.rb +10 -0
- data/lib/webhooks_and_callbacks_api/http/http_response.rb +10 -0
- data/lib/{cypress_test_api → webhooks_and_callbacks_api}/http/proxy_settings.rb +4 -4
- data/lib/webhooks_and_callbacks_api/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/webhooks_and_callbacks_api/logging/sdk_logger.rb +17 -0
- data/lib/webhooks_and_callbacks_api/models/address.rb +114 -0
- data/lib/webhooks_and_callbacks_api/models/audit_log_event.rb +115 -0
- data/lib/{cypress_test_api → webhooks_and_callbacks_api}/models/base_model.rb +4 -4
- data/lib/webhooks_and_callbacks_api/models/create_order_request.rb +131 -0
- data/lib/webhooks_and_callbacks_api/models/delivery_details.rb +104 -0
- data/lib/webhooks_and_callbacks_api/models/email_notification_callback.rb +97 -0
- data/lib/webhooks_and_callbacks_api/models/event.rb +52 -0
- data/lib/webhooks_and_callbacks_api/models/event_type.rb +26 -0
- data/lib/webhooks_and_callbacks_api/models/event_type1.rb +26 -0
- data/lib/webhooks_and_callbacks_api/models/event_type2.rb +26 -0
- data/lib/webhooks_and_callbacks_api/models/event_type3.rb +26 -0
- data/lib/webhooks_and_callbacks_api/models/fulfillment_callback.rb +411 -0
- data/lib/webhooks_and_callbacks_api/models/fulfillment_status.rb +40 -0
- data/lib/webhooks_and_callbacks_api/models/fulfillment_statuss.rb +40 -0
- data/lib/webhooks_and_callbacks_api/models/inventory_stock_decrease_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/inventory_stock_depleted_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/inventory_stock_increase_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/notification_callback.rb +119 -0
- data/lib/{cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb → webhooks_and_callbacks_api/models/oauth_scope_oauth_acg.rb} +19 -19
- data/lib/webhooks_and_callbacks_api/models/order.rb +161 -0
- data/lib/webhooks_and_callbacks_api/models/order_created_event.rb +314 -0
- data/lib/webhooks_and_callbacks_api/models/order_item.rb +102 -0
- data/lib/webhooks_and_callbacks_api/models/order_updated_event.rb +100 -0
- data/lib/webhooks_and_callbacks_api/models/package.rb +95 -0
- data/lib/webhooks_and_callbacks_api/models/payment_callback.rb +167 -0
- data/lib/webhooks_and_callbacks_api/models/payment_completed_event.rb +98 -0
- data/lib/webhooks_and_callbacks_api/models/payment_status.rb +40 -0
- data/lib/webhooks_and_callbacks_api/models/payment_status_created_event.rb +89 -0
- data/lib/webhooks_and_callbacks_api/models/payment_status_updated_event.rb +89 -0
- data/lib/webhooks_and_callbacks_api/models/primitive_collection_event.rb +98 -0
- data/lib/webhooks_and_callbacks_api/models/root_level_primitive_one_of_event_request.rb +40 -0
- data/lib/webhooks_and_callbacks_api/models/root_level_primitive_one_of_event_request1.rb +40 -0
- data/lib/webhooks_and_callbacks_api/models/sms_notification_callback.rb +95 -0
- data/lib/webhooks_and_callbacks_api/models/status.rb +44 -0
- data/lib/webhooks_and_callbacks_api/models/status1.rb +36 -0
- data/lib/webhooks_and_callbacks_api/models/status2.rb +36 -0
- data/lib/webhooks_and_callbacks_api/models/system_alert_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/system_maintenance_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/system_performance_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/user_action_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/user_preference_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/user_status_notification_event.rb +90 -0
- data/lib/webhooks_and_callbacks_api/models/webhook.rb +142 -0
- data/lib/webhooks_and_callbacks_api/models/webhook_registration.rb +103 -0
- data/lib/webhooks_and_callbacks_api/models/webhook_update.rb +105 -0
- data/lib/webhooks_and_callbacks_api/utilities/date_time_helper.rb +11 -0
- data/lib/{cypress_test_api → webhooks_and_callbacks_api}/utilities/file_wrapper.rb +4 -4
- data/lib/webhooks_and_callbacks_api/utilities/union_type_lookup.rb +172 -0
- data/lib/webhooks_and_callbacks_api.rb +122 -0
- metadata +78 -64
- data/lib/cypress_test_api/api_helper.rb +0 -10
- data/lib/cypress_test_api/client.rb +0 -58
- data/lib/cypress_test_api/controllers/api_controller.rb +0 -102
- data/lib/cypress_test_api/http/http_call_back.rb +0 -10
- data/lib/cypress_test_api/http/http_method_enum.rb +0 -10
- data/lib/cypress_test_api/http/http_request.rb +0 -10
- data/lib/cypress_test_api/http/http_response.rb +0 -10
- data/lib/cypress_test_api/models/custom_enum.rb +0 -40
- data/lib/cypress_test_api/models/deer.rb +0 -68
- data/lib/cypress_test_api/models/item.rb +0 -166
- data/lib/cypress_test_api/models/item_response.rb +0 -80
- data/lib/cypress_test_api/models/lion.rb +0 -68
- data/lib/cypress_test_api/models/message.rb +0 -68
- data/lib/cypress_test_api/models/message2.rb +0 -71
- data/lib/cypress_test_api/models/multiple_arrays_request.rb +0 -70
- data/lib/cypress_test_api/models/nac_tag.rb +0 -265
- data/lib/cypress_test_api/models/response_http400.rb +0 -62
- data/lib/cypress_test_api/models/response_http404.rb +0 -62
- data/lib/cypress_test_api/models/status11_enum.rb +0 -40
- data/lib/cypress_test_api/models/status1_enum.rb +0 -40
- data/lib/cypress_test_api/models/status_enum.rb +0 -40
- data/lib/cypress_test_api/models/tokens_request.rb +0 -60
- data/lib/cypress_test_api/utilities/date_time_helper.rb +0 -11
- data/lib/cypress_test_api.rb +0 -55
- data/test/controllers/controller_test_base.rb +0 -23
- data/test/controllers/test_api_controller.rb +0 -40
- data/test/http_response_catcher.rb +0 -19
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# WebhooksHandler is responsible for verifying request signatures
|
|
8
|
+
# and parsing incoming webhooks events into strongly typed objects.
|
|
9
|
+
class WebhooksHandler
|
|
10
|
+
include CoreLibrary
|
|
11
|
+
# Creates a new instance of the WebhooksHandler.
|
|
12
|
+
# Initializes the handler.
|
|
13
|
+
# @param [String] secret_key
|
|
14
|
+
# The secret used to generate and validate HMAC signatures for verifying request authenticity.
|
|
15
|
+
# @raise [ArgumentError] If the secret_key is not provided.
|
|
16
|
+
def initialize(secret_key)
|
|
17
|
+
raise ArgumentError, 'secret_key must be provided for signature verification.' unless secret_key
|
|
18
|
+
|
|
19
|
+
@verifier = HmacSignatureVerifier.new(
|
|
20
|
+
secret_key: secret_key,
|
|
21
|
+
signature_header: 'X-Signature',
|
|
22
|
+
hash_algorithm: 'sha256',
|
|
23
|
+
encoder: HexEncoder.new
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Perform signature verification and return the result.
|
|
28
|
+
#
|
|
29
|
+
# @param [Rack::Request] request The incoming HTTP request to verify.
|
|
30
|
+
# @return [SignatureVerificationResult] The result of the signature verification.
|
|
31
|
+
def verify(request)
|
|
32
|
+
@verifier.verify(request)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Verify the request signature and parse the event.
|
|
36
|
+
#
|
|
37
|
+
# @param [Rack::Request] request The incoming HTTP request containing the event payload.
|
|
38
|
+
# @return[OrderCreatedEvent, OrderUpdatedEvent, PaymentCompletedEvent,
|
|
39
|
+
# PrimitiveCollectionEvent, SignatureVerificationFailure, UnknownEvent]
|
|
40
|
+
# OrderCreatedEvent, OrderUpdatedEvent, PaymentCompletedEvent,
|
|
41
|
+
# PrimitiveCollectionEvent for successful parsing;
|
|
42
|
+
#
|
|
43
|
+
# SignatureVerificationFailure when signature fails;
|
|
44
|
+
# UnknownEvent for
|
|
45
|
+
# unknown events.
|
|
46
|
+
def verify_and_parse_event(request)
|
|
47
|
+
unless request.respond_to?(:env) && request.env.is_a?(Hash)
|
|
48
|
+
return SignatureVerificationFailure.new(['Invalid request env.'])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
raw_body = RackRequestHelper.read_raw_body(request)
|
|
52
|
+
return SignatureVerificationFailure.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
|
|
53
|
+
|
|
54
|
+
verification_result = verify(request)
|
|
55
|
+
return SignatureVerificationFailure.new(verification_result.errors) unless verification_result.ok
|
|
56
|
+
|
|
57
|
+
# Deserialize payload
|
|
58
|
+
begin
|
|
59
|
+
union = UnionTypeLookUp.get(:Webhooks)
|
|
60
|
+
raw = RackRequestHelper.read_raw_body(request)
|
|
61
|
+
APIHelper.deserialize_union_type(union, raw, false, true)
|
|
62
|
+
rescue StandardError => e
|
|
63
|
+
UnknownEvent.new(['Deserialization failed.', e.message])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# WebhooksNoVerificationHandler is responsible for verifying request signatures
|
|
8
|
+
# and parsing incoming webhooksNoVerification events into strongly typed objects.
|
|
9
|
+
class WebhooksNoVerificationHandler
|
|
10
|
+
include CoreLibrary
|
|
11
|
+
# Creates a new instance of the WebhooksNoVerificationHandler.
|
|
12
|
+
def initialize; end
|
|
13
|
+
|
|
14
|
+
# Parse the event.
|
|
15
|
+
#
|
|
16
|
+
# @param [Rack::Request] request The incoming HTTP request containing the event payload.
|
|
17
|
+
# @return[AuditLogEvent, RootLevelPrimitiveOneOfEventRequest, Integer,
|
|
18
|
+
# Array<RootLevelPrimitiveOneOfEventRequest1>, Array<Integer>, UnknownEvent]
|
|
19
|
+
# AuditLogEvent, RootLevelPrimitiveOneOfEventRequest, Integer,
|
|
20
|
+
# Array[RootLevelPrimitiveOneOfEventRequest1], Array[Integer] for successful
|
|
21
|
+
# parsing;
|
|
22
|
+
# UnknownEvent for unknown events.
|
|
23
|
+
def parse_event(request)
|
|
24
|
+
return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash)
|
|
25
|
+
|
|
26
|
+
raw_body = RackRequestHelper.read_raw_body(request)
|
|
27
|
+
return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty?
|
|
28
|
+
|
|
29
|
+
# Deserialize payload
|
|
30
|
+
begin
|
|
31
|
+
union = UnionTypeLookUp.get(:WebhooksNoVerification)
|
|
32
|
+
raw = RackRequestHelper.read_raw_body(request)
|
|
33
|
+
APIHelper.deserialize_union_type(union, raw, false, true)
|
|
34
|
+
rescue StandardError => e
|
|
35
|
+
UnknownEvent.new(['Deserialization failed.', e.message])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
2
|
#
|
|
3
|
-
# This file was automatically generated by
|
|
4
|
-
# ( https://www.apimatic.io ).
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
7
|
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
8
|
class APIException < CoreLibrary::ApiException
|
|
9
9
|
# Provides a human-readable string representation of the object.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Error class.
|
|
8
|
+
class ErrorException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Error code
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# Human-readable error message
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :message
|
|
19
|
+
|
|
20
|
+
# Additional error details
|
|
21
|
+
# @return [Object]
|
|
22
|
+
attr_accessor :details
|
|
23
|
+
|
|
24
|
+
# The constructor.
|
|
25
|
+
# @param [String] reason The reason for raising an exception.
|
|
26
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
27
|
+
def initialize(reason, response)
|
|
28
|
+
super(reason, response)
|
|
29
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
30
|
+
unbox(hash)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Populates this object by extracting properties from a hash.
|
|
34
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
35
|
+
# response body.
|
|
36
|
+
def unbox(hash)
|
|
37
|
+
return nil unless hash
|
|
38
|
+
|
|
39
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
|
40
|
+
@message = hash.key?('message') ? hash['message'] : nil
|
|
41
|
+
@details = hash.key?('details') ? hash['details'] : SKIP
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Provides a human-readable string representation of the object.
|
|
45
|
+
def to_s
|
|
46
|
+
class_name = self.class.name.split('::').last
|
|
47
|
+
"<#{class_name} error: #{@error}, message: #{@message}, details: #{@details}>"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
51
|
+
def inspect
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} error: #{@error.inspect}, message: #{@message.inspect}, details:"\
|
|
54
|
+
" #{@details.inspect}>"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Http response received.
|
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
|
9
|
+
# The constructor
|
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
|
11
|
+
# @param [Object] data The data field specified for the response.
|
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
|
13
|
+
def initialize(http_response,
|
|
14
|
+
data: nil,
|
|
15
|
+
errors: nil)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class ApiKey < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'ApiKey: x_api_key is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(api_key_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['X-API-Key'] = api_key_credentials.x_api_key unless
|
|
19
|
+
api_key_credentials.nil? || api_key_credentials.x_api_key.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for ApiKeyCredentials.
|
|
26
|
+
# Data class for ApiKeyCredentials.
|
|
27
|
+
class ApiKeyCredentials
|
|
28
|
+
attr_reader :x_api_key
|
|
29
|
+
|
|
30
|
+
def initialize(x_api_key:)
|
|
31
|
+
raise ArgumentError, 'x_api_key cannot be nil' if x_api_key.nil?
|
|
32
|
+
|
|
33
|
+
@x_api_key = x_api_key
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
x_api_key = ENV['API_KEY_X_API_KEY']
|
|
38
|
+
all_nil = [
|
|
39
|
+
x_api_key
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(x_api_key: x_api_key)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(x_api_key: nil)
|
|
47
|
+
x_api_key ||= self.x_api_key
|
|
48
|
+
|
|
49
|
+
ApiKeyCredentials.new(x_api_key: x_api_key)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class BearerAuth < 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
|
+
'BearerAuth: access_token is undefined.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(bearer_auth_credentials)
|
|
18
|
+
auth_params = {}
|
|
19
|
+
@_access_token = bearer_auth_credentials.access_token unless
|
|
20
|
+
bearer_auth_credentials.nil? || bearer_auth_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 BearerAuthCredentials.
|
|
28
|
+
class BearerAuthCredentials
|
|
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_AUTH_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
|
+
BearerAuthCredentials.new(access_token: access_token)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
2
|
#
|
|
3
|
-
# This file was automatically generated by
|
|
4
|
-
# ( https://www.apimatic.io ).
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
7
|
##
|
|
8
8
|
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
9
|
# including optional basic authentication.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Initializes a new instance of RequestLoggingConfiguration.
|
|
8
|
+
class RequestLoggingConfiguration < CoreLibrary::ApiRequestLoggingConfiguration
|
|
9
|
+
# @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
|
|
10
|
+
# @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
|
|
11
|
+
# @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
|
|
12
|
+
# @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
|
|
13
|
+
# @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
|
|
14
|
+
# Default is an empty array.
|
|
15
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
16
|
+
headers_to_exclude: nil, headers_to_unmask: nil,
|
|
17
|
+
include_query_in_path: false)
|
|
18
|
+
super(
|
|
19
|
+
log_body,
|
|
20
|
+
log_headers,
|
|
21
|
+
headers_to_exclude,
|
|
22
|
+
headers_to_include,
|
|
23
|
+
headers_to_unmask,
|
|
24
|
+
include_query_in_path
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
29
|
+
headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
|
|
30
|
+
log_body ||= self.log_body
|
|
31
|
+
log_headers ||= self.log_headers
|
|
32
|
+
headers_to_include ||= self.headers_to_include
|
|
33
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
34
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
35
|
+
include_query_in_path ||= self.include_query_in_path
|
|
36
|
+
|
|
37
|
+
RequestLoggingConfiguration.new(
|
|
38
|
+
log_body: log_body,
|
|
39
|
+
log_headers: log_headers,
|
|
40
|
+
headers_to_include: headers_to_include,
|
|
41
|
+
headers_to_exclude: headers_to_exclude,
|
|
42
|
+
headers_to_unmask: headers_to_unmask,
|
|
43
|
+
include_query_in_path: include_query_in_path
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.from_env
|
|
48
|
+
log_body = ENV['REQUEST_LOG_BODY']
|
|
49
|
+
log_headers = ENV['REQUEST_LOG_HEADERS']
|
|
50
|
+
headers_to_include = ENV['REQUEST_HEADERS_TO_INCLUDE']
|
|
51
|
+
headers_to_exclude = ENV['REQUEST_HEADERS_TO_EXCLUDE']
|
|
52
|
+
headers_to_unmask = ENV['REQUEST_HEADERS_TO_UNMASK']
|
|
53
|
+
include_query_in_path = ENV['REQUEST_INCLUDE_QUERY_IN_PATH']
|
|
54
|
+
|
|
55
|
+
new(
|
|
56
|
+
log_body: log_body,
|
|
57
|
+
log_headers: log_headers,
|
|
58
|
+
headers_to_include: headers_to_include,
|
|
59
|
+
headers_to_exclude: headers_to_exclude,
|
|
60
|
+
headers_to_unmask: headers_to_unmask,
|
|
61
|
+
include_query_in_path: include_query_in_path
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.any_logging_configured?
|
|
66
|
+
%w[
|
|
67
|
+
REQUEST_LOG_BODY
|
|
68
|
+
REQUEST_LOG_HEADERS
|
|
69
|
+
REQUEST_HEADERS_TO_INCLUDE
|
|
70
|
+
REQUEST_HEADERS_TO_EXCLUDE
|
|
71
|
+
REQUEST_HEADERS_TO_UNMASK
|
|
72
|
+
REQUEST_INCLUDE_QUERY_IN_PATH
|
|
73
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Initializes a new instance of ResponseLoggingConfiguration.
|
|
78
|
+
class ResponseLoggingConfiguration < CoreLibrary::ApiResponseLoggingConfiguration
|
|
79
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
80
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
81
|
+
super(
|
|
82
|
+
log_body,
|
|
83
|
+
log_headers,
|
|
84
|
+
headers_to_exclude,
|
|
85
|
+
headers_to_include,
|
|
86
|
+
headers_to_unmask
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
91
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
92
|
+
log_body ||= self.log_body
|
|
93
|
+
log_headers ||= self.log_headers
|
|
94
|
+
headers_to_include ||= self.headers_to_include
|
|
95
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
96
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
97
|
+
|
|
98
|
+
ResponseLoggingConfiguration.new(
|
|
99
|
+
log_body: log_body,
|
|
100
|
+
log_headers: log_headers,
|
|
101
|
+
headers_to_include: headers_to_include,
|
|
102
|
+
headers_to_exclude: headers_to_exclude,
|
|
103
|
+
headers_to_unmask: headers_to_unmask
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def self.from_env
|
|
108
|
+
log_body = ENV['RESPONSE_LOG_BODY']
|
|
109
|
+
log_headers = ENV['RESPONSE_LOG_HEADERS']
|
|
110
|
+
headers_to_include = ENV['RESPONSE_HEADERS_TO_INCLUDE']
|
|
111
|
+
headers_to_exclude = ENV['RESPONSE_HEADERS_TO_EXCLUDE']
|
|
112
|
+
headers_to_unmask = ENV['RESPONSE_HEADERS_TO_UNMASK']
|
|
113
|
+
|
|
114
|
+
new(
|
|
115
|
+
log_body: log_body,
|
|
116
|
+
log_headers: log_headers,
|
|
117
|
+
headers_to_include: headers_to_include,
|
|
118
|
+
headers_to_exclude: headers_to_exclude,
|
|
119
|
+
headers_to_unmask: headers_to_unmask
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.any_logging_configured?
|
|
124
|
+
%w[
|
|
125
|
+
RESPONSE_LOG_BODY
|
|
126
|
+
RESPONSE_LOG_HEADERS
|
|
127
|
+
RESPONSE_HEADERS_TO_INCLUDE
|
|
128
|
+
RESPONSE_HEADERS_TO_EXCLUDE
|
|
129
|
+
RESPONSE_HEADERS_TO_UNMASK
|
|
130
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Initializes a new instance of LoggingConfiguration.
|
|
135
|
+
class LoggingConfiguration < CoreLibrary::ApiLoggingConfiguration
|
|
136
|
+
def initialize(logger: nil, log_level: nil, mask_sensitive_headers: true,
|
|
137
|
+
request_logging_config: nil,
|
|
138
|
+
response_logging_config: nil)
|
|
139
|
+
request_logging_config ||= RequestLoggingConfiguration.new
|
|
140
|
+
response_logging_config ||= ResponseLoggingConfiguration.new
|
|
141
|
+
super(
|
|
142
|
+
logger,
|
|
143
|
+
log_level,
|
|
144
|
+
request_logging_config,
|
|
145
|
+
response_logging_config,
|
|
146
|
+
mask_sensitive_headers
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def clone_with(logger: nil, log_level: nil, mask_sensitive_headers: nil,
|
|
151
|
+
request_logging_config: nil, response_logging_config: nil)
|
|
152
|
+
logger ||= self.logger
|
|
153
|
+
log_level ||= self.log_level
|
|
154
|
+
mask_sensitive_headers ||= self.mask_sensitive_headers
|
|
155
|
+
request_logging_config ||= self.request_logging_config.clone
|
|
156
|
+
response_logging_config ||= self.response_logging_config.clone
|
|
157
|
+
|
|
158
|
+
LoggingConfiguration.new(
|
|
159
|
+
logger: logger,
|
|
160
|
+
log_level: log_level,
|
|
161
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
162
|
+
request_logging_config: request_logging_config,
|
|
163
|
+
response_logging_config: response_logging_config
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.from_env
|
|
168
|
+
log_level = ENV['LOG_LEVEL']
|
|
169
|
+
mask_sensitive_headers = ENV['MASK_SENSITIVE_HEADERS']
|
|
170
|
+
|
|
171
|
+
new(
|
|
172
|
+
log_level: log_level,
|
|
173
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
174
|
+
request_logging_config: RequestLoggingConfiguration.from_env,
|
|
175
|
+
response_logging_config: ResponseLoggingConfiguration.from_env
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def self.any_logging_configured?
|
|
180
|
+
RequestLoggingConfiguration.any_logging_configured? ||
|
|
181
|
+
ResponseLoggingConfiguration.any_logging_configured? ||
|
|
182
|
+
ENV.key?('LOG_LEVEL') ||
|
|
183
|
+
ENV.key?('MASK_SENSITIVE_HEADERS')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Represents the generic logger facade
|
|
8
|
+
class AbstractLogger < Logger
|
|
9
|
+
# Logs a message with a specified log level and additional parameters.
|
|
10
|
+
# @param level [Symbol] The log level of the message.
|
|
11
|
+
# @param message [String] The message to log.
|
|
12
|
+
# @param params [Hash] Additional parameters to include in the log message.
|
|
13
|
+
def log(level, message, params)
|
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# webhooks_and_callbacks_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WebhooksAndCallbacksApi
|
|
7
|
+
# Address Model.
|
|
8
|
+
class Address < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :street
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for this method
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :city
|
|
19
|
+
|
|
20
|
+
# TODO: Write general description for this method
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :zip
|
|
23
|
+
|
|
24
|
+
# A mapping from model property names to API property names.
|
|
25
|
+
def self.names
|
|
26
|
+
@_hash = {} if @_hash.nil?
|
|
27
|
+
@_hash['street'] = 'street'
|
|
28
|
+
@_hash['city'] = 'city'
|
|
29
|
+
@_hash['zip'] = 'zip'
|
|
30
|
+
@_hash
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# An array for optional fields
|
|
34
|
+
def self.optionals
|
|
35
|
+
%w[
|
|
36
|
+
zip
|
|
37
|
+
]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# An array for nullable fields
|
|
41
|
+
def self.nullables
|
|
42
|
+
[]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def initialize(street:, city:, zip: SKIP, additional_properties: nil)
|
|
46
|
+
# Add additional model properties to the instance
|
|
47
|
+
additional_properties = {} if additional_properties.nil?
|
|
48
|
+
|
|
49
|
+
@street = street
|
|
50
|
+
@city = city
|
|
51
|
+
@zip = zip unless zip == SKIP
|
|
52
|
+
@additional_properties = additional_properties
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Creates an instance of the object from a hash.
|
|
56
|
+
def self.from_hash(hash)
|
|
57
|
+
return nil unless hash
|
|
58
|
+
|
|
59
|
+
# Extract variables from the hash.
|
|
60
|
+
street = hash.key?('street') ? hash['street'] : nil
|
|
61
|
+
city = hash.key?('city') ? hash['city'] : nil
|
|
62
|
+
zip = hash.key?('zip') ? hash['zip'] : SKIP
|
|
63
|
+
|
|
64
|
+
# Create a new hash for additional properties, removing known properties.
|
|
65
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
|
66
|
+
|
|
67
|
+
additional_properties = APIHelper.get_additional_properties(
|
|
68
|
+
new_hash, proc { |value| value }
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Create object from extracted values.
|
|
72
|
+
Address.new(street: street,
|
|
73
|
+
city: city,
|
|
74
|
+
zip: zip,
|
|
75
|
+
additional_properties: additional_properties)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Validates an instance of the object from a given value.
|
|
79
|
+
# @param [Address | Hash] The value against the validation is performed.
|
|
80
|
+
def self.validate(value)
|
|
81
|
+
if value.instance_of? self
|
|
82
|
+
return (
|
|
83
|
+
APIHelper.valid_type?(value.street,
|
|
84
|
+
->(val) { val.instance_of? String }) and
|
|
85
|
+
APIHelper.valid_type?(value.city,
|
|
86
|
+
->(val) { val.instance_of? String })
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return false unless value.instance_of? Hash
|
|
91
|
+
|
|
92
|
+
(
|
|
93
|
+
APIHelper.valid_type?(value['street'],
|
|
94
|
+
->(val) { val.instance_of? String }) and
|
|
95
|
+
APIHelper.valid_type?(value['city'],
|
|
96
|
+
->(val) { val.instance_of? String })
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Provides a human-readable string representation of the object.
|
|
101
|
+
def to_s
|
|
102
|
+
class_name = self.class.name.split('::').last
|
|
103
|
+
"<#{class_name} street: #{@street}, city: #{@city}, zip: #{@zip}, additional_properties:"\
|
|
104
|
+
" #{@additional_properties}>"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
108
|
+
def inspect
|
|
109
|
+
class_name = self.class.name.split('::').last
|
|
110
|
+
"<#{class_name} street: #{@street.inspect}, city: #{@city.inspect}, zip: #{@zip.inspect},"\
|
|
111
|
+
" additional_properties: #{@additional_properties}>"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|