oursprivacy-ingest 0.1.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 +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +16 -0
- data/README.md +206 -0
- data/SECURITY.md +27 -0
- data/lib/oursprivacy_ingest/client.rb +64 -0
- data/lib/oursprivacy_ingest/errors.rb +228 -0
- data/lib/oursprivacy_ingest/file_part.rb +58 -0
- data/lib/oursprivacy_ingest/internal/transport/base_client.rb +573 -0
- data/lib/oursprivacy_ingest/internal/transport/pooled_net_requester.rb +204 -0
- data/lib/oursprivacy_ingest/internal/type/array_of.rb +168 -0
- data/lib/oursprivacy_ingest/internal/type/base_model.rb +534 -0
- data/lib/oursprivacy_ingest/internal/type/base_page.rb +55 -0
- data/lib/oursprivacy_ingest/internal/type/boolean.rb +77 -0
- data/lib/oursprivacy_ingest/internal/type/converter.rb +327 -0
- data/lib/oursprivacy_ingest/internal/type/enum.rb +133 -0
- data/lib/oursprivacy_ingest/internal/type/file_input.rb +111 -0
- data/lib/oursprivacy_ingest/internal/type/hash_of.rb +188 -0
- data/lib/oursprivacy_ingest/internal/type/request_parameters.rb +42 -0
- data/lib/oursprivacy_ingest/internal/type/union.rb +245 -0
- data/lib/oursprivacy_ingest/internal/type/unknown.rb +81 -0
- data/lib/oursprivacy_ingest/internal/util.rb +915 -0
- data/lib/oursprivacy_ingest/internal.rb +20 -0
- data/lib/oursprivacy_ingest/models/track_event_params.rb +1009 -0
- data/lib/oursprivacy_ingest/models/track_event_response.rb +26 -0
- data/lib/oursprivacy_ingest/models/visitor_upsert_params.rb +972 -0
- data/lib/oursprivacy_ingest/models/visitor_upsert_response.rb +26 -0
- data/lib/oursprivacy_ingest/models.rb +48 -0
- data/lib/oursprivacy_ingest/request_options.rb +79 -0
- data/lib/oursprivacy_ingest/resources/track.rb +61 -0
- data/lib/oursprivacy_ingest/resources/visitor.rb +52 -0
- data/lib/oursprivacy_ingest/version.rb +5 -0
- data/lib/oursprivacy_ingest.rb +59 -0
- data/manifest.yaml +15 -0
- data/rbi/oursprivacy_ingest/client.rbi +46 -0
- data/rbi/oursprivacy_ingest/errors.rbi +205 -0
- data/rbi/oursprivacy_ingest/file_part.rbi +37 -0
- data/rbi/oursprivacy_ingest/internal/transport/base_client.rbi +305 -0
- data/rbi/oursprivacy_ingest/internal/transport/pooled_net_requester.rbi +80 -0
- data/rbi/oursprivacy_ingest/internal/type/array_of.rbi +108 -0
- data/rbi/oursprivacy_ingest/internal/type/base_model.rbi +316 -0
- data/rbi/oursprivacy_ingest/internal/type/base_page.rbi +43 -0
- data/rbi/oursprivacy_ingest/internal/type/boolean.rbi +58 -0
- data/rbi/oursprivacy_ingest/internal/type/converter.rbi +225 -0
- data/rbi/oursprivacy_ingest/internal/type/enum.rbi +82 -0
- data/rbi/oursprivacy_ingest/internal/type/file_input.rbi +59 -0
- data/rbi/oursprivacy_ingest/internal/type/hash_of.rbi +108 -0
- data/rbi/oursprivacy_ingest/internal/type/request_parameters.rbi +33 -0
- data/rbi/oursprivacy_ingest/internal/type/union.rbi +134 -0
- data/rbi/oursprivacy_ingest/internal/type/unknown.rbi +58 -0
- data/rbi/oursprivacy_ingest/internal/util.rbi +487 -0
- data/rbi/oursprivacy_ingest/internal.rbi +18 -0
- data/rbi/oursprivacy_ingest/models/track_event_params.rbi +1072 -0
- data/rbi/oursprivacy_ingest/models/track_event_response.rbi +71 -0
- data/rbi/oursprivacy_ingest/models/visitor_upsert_params.rbi +1035 -0
- data/rbi/oursprivacy_ingest/models/visitor_upsert_response.rbi +71 -0
- data/rbi/oursprivacy_ingest/models.rbi +7 -0
- data/rbi/oursprivacy_ingest/request_options.rbi +64 -0
- data/rbi/oursprivacy_ingest/resources/track.rbi +74 -0
- data/rbi/oursprivacy_ingest/resources/visitor.rbi +58 -0
- data/rbi/oursprivacy_ingest/version.rbi +5 -0
- data/sig/oursprivacy_ingest/client.rbs +25 -0
- data/sig/oursprivacy_ingest/errors.rbs +117 -0
- data/sig/oursprivacy_ingest/file_part.rbs +21 -0
- data/sig/oursprivacy_ingest/internal/transport/base_client.rbs +131 -0
- data/sig/oursprivacy_ingest/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/oursprivacy_ingest/internal/type/array_of.rbs +48 -0
- data/sig/oursprivacy_ingest/internal/type/base_model.rbs +106 -0
- data/sig/oursprivacy_ingest/internal/type/base_page.rbs +24 -0
- data/sig/oursprivacy_ingest/internal/type/boolean.rbs +26 -0
- data/sig/oursprivacy_ingest/internal/type/converter.rbs +79 -0
- data/sig/oursprivacy_ingest/internal/type/enum.rbs +32 -0
- data/sig/oursprivacy_ingest/internal/type/file_input.rbs +25 -0
- data/sig/oursprivacy_ingest/internal/type/hash_of.rbs +48 -0
- data/sig/oursprivacy_ingest/internal/type/request_parameters.rbs +20 -0
- data/sig/oursprivacy_ingest/internal/type/union.rbs +52 -0
- data/sig/oursprivacy_ingest/internal/type/unknown.rbs +26 -0
- data/sig/oursprivacy_ingest/internal/util.rbs +185 -0
- data/sig/oursprivacy_ingest/internal.rbs +10 -0
- data/sig/oursprivacy_ingest/models/track_event_params.rbs +673 -0
- data/sig/oursprivacy_ingest/models/track_event_response.rbs +28 -0
- data/sig/oursprivacy_ingest/models/visitor_upsert_params.rbs +653 -0
- data/sig/oursprivacy_ingest/models/visitor_upsert_response.rbs +28 -0
- data/sig/oursprivacy_ingest/models.rbs +5 -0
- data/sig/oursprivacy_ingest/request_options.rbs +36 -0
- data/sig/oursprivacy_ingest/resources/track.rbs +21 -0
- data/sig/oursprivacy_ingest/resources/visitor.rbs +17 -0
- data/sig/oursprivacy_ingest/version.rbs +3 -0
- metadata +146 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OursprivacyIngest
|
|
4
|
+
module Models
|
|
5
|
+
class VisitorUpsertResponse < OursprivacyIngest::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias do
|
|
8
|
+
T.any(
|
|
9
|
+
OursprivacyIngest::Models::VisitorUpsertResponse,
|
|
10
|
+
OursprivacyIngest::Internal::AnyHash
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
sig do
|
|
15
|
+
returns(
|
|
16
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success::TaggedBoolean
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
attr_accessor :success
|
|
20
|
+
|
|
21
|
+
sig do
|
|
22
|
+
params(
|
|
23
|
+
success:
|
|
24
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success::OrBoolean
|
|
25
|
+
).returns(T.attached_class)
|
|
26
|
+
end
|
|
27
|
+
def self.new(success:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
sig do
|
|
31
|
+
override.returns(
|
|
32
|
+
{
|
|
33
|
+
success:
|
|
34
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success::TaggedBoolean
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
def to_hash
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module Success
|
|
42
|
+
extend OursprivacyIngest::Internal::Type::Enum
|
|
43
|
+
|
|
44
|
+
TaggedBoolean =
|
|
45
|
+
T.type_alias do
|
|
46
|
+
T.all(
|
|
47
|
+
T::Boolean,
|
|
48
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
OrBoolean = T.type_alias { T::Boolean }
|
|
52
|
+
|
|
53
|
+
TRUE =
|
|
54
|
+
T.let(
|
|
55
|
+
true,
|
|
56
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success::TaggedBoolean
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
sig do
|
|
60
|
+
override.returns(
|
|
61
|
+
T::Array[
|
|
62
|
+
OursprivacyIngest::Models::VisitorUpsertResponse::Success::TaggedBoolean
|
|
63
|
+
]
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
def self.values
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OursprivacyIngest
|
|
4
|
+
# Specify HTTP behaviour to use for a specific request. These options supplement
|
|
5
|
+
# or override those provided at the client level.
|
|
6
|
+
#
|
|
7
|
+
# When making a request, you can pass an actual {RequestOptions} instance, or
|
|
8
|
+
# simply pass a Hash with symbol keys matching the attributes on this class.
|
|
9
|
+
class RequestOptions < OursprivacyIngest::Internal::Type::BaseModel
|
|
10
|
+
OrHash =
|
|
11
|
+
T.type_alias do
|
|
12
|
+
T.any(
|
|
13
|
+
OursprivacyIngest::RequestOptions,
|
|
14
|
+
OursprivacyIngest::Internal::AnyHash
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @api private
|
|
19
|
+
sig { params(opts: OursprivacyIngest::RequestOptions::OrHash).void }
|
|
20
|
+
def self.validate!(opts)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Idempotency key to send with request and all associated retries. Will only be
|
|
24
|
+
# sent for write requests.
|
|
25
|
+
sig { returns(T.nilable(String)) }
|
|
26
|
+
attr_accessor :idempotency_key
|
|
27
|
+
|
|
28
|
+
# Extra query params to send with the request. These are `.merge`’d into any
|
|
29
|
+
# `query` given at the client level.
|
|
30
|
+
sig do
|
|
31
|
+
returns(
|
|
32
|
+
T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
attr_accessor :extra_query
|
|
36
|
+
|
|
37
|
+
# Extra headers to send with the request. These are `.merged`’d into any
|
|
38
|
+
# `extra_headers` given at the client level.
|
|
39
|
+
sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) }
|
|
40
|
+
attr_accessor :extra_headers
|
|
41
|
+
|
|
42
|
+
# Extra data to send with the request. These are deep merged into any data
|
|
43
|
+
# generated as part of the normal request.
|
|
44
|
+
sig { returns(T.nilable(T.anything)) }
|
|
45
|
+
attr_accessor :extra_body
|
|
46
|
+
|
|
47
|
+
# Maximum number of retries to attempt after a failed initial request.
|
|
48
|
+
sig { returns(T.nilable(Integer)) }
|
|
49
|
+
attr_accessor :max_retries
|
|
50
|
+
|
|
51
|
+
# Request timeout in seconds.
|
|
52
|
+
sig { returns(T.nilable(Float)) }
|
|
53
|
+
attr_accessor :timeout
|
|
54
|
+
|
|
55
|
+
# Returns a new instance of RequestOptions.
|
|
56
|
+
sig do
|
|
57
|
+
params(values: OursprivacyIngest::Internal::AnyHash).returns(
|
|
58
|
+
T.attached_class
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
def self.new(values = {})
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OursprivacyIngest
|
|
4
|
+
module Resources
|
|
5
|
+
class Track
|
|
6
|
+
# Track events from your server. Please include at least one of: userId,
|
|
7
|
+
# externalId, or email. These properties help us associate events with existing
|
|
8
|
+
# users. For all fields, null values unset the property and undefined values do
|
|
9
|
+
# not unset existing properties.
|
|
10
|
+
sig do
|
|
11
|
+
params(
|
|
12
|
+
token: String,
|
|
13
|
+
event: String,
|
|
14
|
+
default_properties:
|
|
15
|
+
T.nilable(
|
|
16
|
+
OursprivacyIngest::TrackEventParams::DefaultProperties::OrHash
|
|
17
|
+
),
|
|
18
|
+
distinct_id: T.nilable(String),
|
|
19
|
+
email: T.nilable(String),
|
|
20
|
+
event_properties: T.nilable(T::Hash[Symbol, T.nilable(T.anything)]),
|
|
21
|
+
external_id: T.nilable(String),
|
|
22
|
+
time: T.nilable(Float),
|
|
23
|
+
user_id: T.nilable(String),
|
|
24
|
+
user_properties:
|
|
25
|
+
T.nilable(
|
|
26
|
+
OursprivacyIngest::TrackEventParams::UserProperties::OrHash
|
|
27
|
+
),
|
|
28
|
+
request_options: OursprivacyIngest::RequestOptions::OrHash
|
|
29
|
+
).returns(OursprivacyIngest::Models::TrackEventResponse)
|
|
30
|
+
end
|
|
31
|
+
def event(
|
|
32
|
+
# The token for your Ours Privacy Source. You can find this in the Ours dashboard.
|
|
33
|
+
token:,
|
|
34
|
+
# The name of the event you're tracking. This must be whitelisted in the Ours
|
|
35
|
+
# dashboard.
|
|
36
|
+
event:,
|
|
37
|
+
# These properties are used throughout the Ours app to pass known values onto
|
|
38
|
+
# destinations
|
|
39
|
+
default_properties: nil,
|
|
40
|
+
# A unique identifier for the event. This helps prevent duplicate events.
|
|
41
|
+
distinct_id: nil,
|
|
42
|
+
# The email address of a user. We will associate this event with the user or
|
|
43
|
+
# create a user. Used for lookup if externalId and userId are not included in the
|
|
44
|
+
# request.
|
|
45
|
+
email: nil,
|
|
46
|
+
# Any additional event properties you want to pass along.
|
|
47
|
+
event_properties: nil,
|
|
48
|
+
# The externalId (the ID in your system) of a user. We will associate this event
|
|
49
|
+
# with the user or create a user. If included in the request, email lookup is
|
|
50
|
+
# ignored.
|
|
51
|
+
external_id: nil,
|
|
52
|
+
# The time at which the event occurred in milliseconds since UTC epoch. The time
|
|
53
|
+
# must be in the past and within the last 7 days.
|
|
54
|
+
time: nil,
|
|
55
|
+
# The Ours user id stored in local storage and cookies on your web properties. If
|
|
56
|
+
# userId is included in the request, we do not lookup the user by email or
|
|
57
|
+
# externalId.
|
|
58
|
+
user_id: nil,
|
|
59
|
+
# Properties to set on the visitor. (optional) You can also update these
|
|
60
|
+
# properties via the identify endpoint.
|
|
61
|
+
user_properties: nil,
|
|
62
|
+
request_options: {}
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @api private
|
|
67
|
+
sig do
|
|
68
|
+
params(client: OursprivacyIngest::Client).returns(T.attached_class)
|
|
69
|
+
end
|
|
70
|
+
def self.new(client:)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OursprivacyIngest
|
|
4
|
+
module Resources
|
|
5
|
+
class Visitor
|
|
6
|
+
# Define visitor properties on an existing visitor or create a new visitor. Note:
|
|
7
|
+
# This does not fire an event. If you want to fire an event, use the track method
|
|
8
|
+
# and include properties for the visitor.
|
|
9
|
+
sig do
|
|
10
|
+
params(
|
|
11
|
+
token: String,
|
|
12
|
+
user_properties:
|
|
13
|
+
OursprivacyIngest::VisitorUpsertParams::UserProperties::OrHash,
|
|
14
|
+
default_properties:
|
|
15
|
+
T.nilable(
|
|
16
|
+
OursprivacyIngest::VisitorUpsertParams::DefaultProperties::OrHash
|
|
17
|
+
),
|
|
18
|
+
email: T.nilable(String),
|
|
19
|
+
external_id: T.nilable(String),
|
|
20
|
+
user_id: T.nilable(String),
|
|
21
|
+
request_options: OursprivacyIngest::RequestOptions::OrHash
|
|
22
|
+
).returns(OursprivacyIngest::Models::VisitorUpsertResponse)
|
|
23
|
+
end
|
|
24
|
+
def upsert(
|
|
25
|
+
# The token for your Ours Privacy Source. You can find this in the Ours dashboard.
|
|
26
|
+
token:,
|
|
27
|
+
# User properties to associate with this user. The existing user properties will
|
|
28
|
+
# be updated. And all future events will have these properties associated with
|
|
29
|
+
# them.
|
|
30
|
+
user_properties:,
|
|
31
|
+
# These properties are used throughout the Ours app to pass known values onto
|
|
32
|
+
# destinations
|
|
33
|
+
default_properties: nil,
|
|
34
|
+
# The email address of a user. We will associate this event with the user or
|
|
35
|
+
# create a user. Used for lookup if externalId and userId are not included in the
|
|
36
|
+
# request.
|
|
37
|
+
email: nil,
|
|
38
|
+
# The externalId (the ID in your system) of a user. We will associate this event
|
|
39
|
+
# with the user or create a user. If included in the request, email lookup is
|
|
40
|
+
# ignored.
|
|
41
|
+
external_id: nil,
|
|
42
|
+
# The Ours user id stored in local storage and cookies on your web properties. If
|
|
43
|
+
# userId is included in the request, we do not lookup the user by email or
|
|
44
|
+
# externalId.
|
|
45
|
+
user_id: nil,
|
|
46
|
+
request_options: {}
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @api private
|
|
51
|
+
sig do
|
|
52
|
+
params(client: OursprivacyIngest::Client).returns(T.attached_class)
|
|
53
|
+
end
|
|
54
|
+
def self.new(client:)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
class Client < OursprivacyIngest::Internal::Transport::BaseClient
|
|
3
|
+
DEFAULT_MAX_RETRIES: 2
|
|
4
|
+
|
|
5
|
+
DEFAULT_TIMEOUT_IN_SECONDS: Float
|
|
6
|
+
|
|
7
|
+
DEFAULT_INITIAL_RETRY_DELAY: Float
|
|
8
|
+
|
|
9
|
+
DEFAULT_MAX_RETRY_DELAY: Float
|
|
10
|
+
|
|
11
|
+
attr_reader track: OursprivacyIngest::Resources::Track
|
|
12
|
+
|
|
13
|
+
attr_reader visitor: OursprivacyIngest::Resources::Visitor
|
|
14
|
+
|
|
15
|
+
def base_url_overridden?: -> bool
|
|
16
|
+
|
|
17
|
+
def initialize: (
|
|
18
|
+
?base_url: String?,
|
|
19
|
+
?max_retries: Integer,
|
|
20
|
+
?timeout: Float,
|
|
21
|
+
?initial_retry_delay: Float,
|
|
22
|
+
?max_retry_delay: Float
|
|
23
|
+
) -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
module Errors
|
|
3
|
+
class Error < StandardError
|
|
4
|
+
attr_accessor cause: StandardError?
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class ConversionError < OursprivacyIngest::Errors::Error
|
|
8
|
+
def cause: -> StandardError?
|
|
9
|
+
|
|
10
|
+
def initialize: (
|
|
11
|
+
on: Class,
|
|
12
|
+
method: Symbol,
|
|
13
|
+
target: top,
|
|
14
|
+
value: top,
|
|
15
|
+
?cause: StandardError?
|
|
16
|
+
) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class APIError < OursprivacyIngest::Errors::Error
|
|
20
|
+
attr_accessor url: URI::Generic
|
|
21
|
+
|
|
22
|
+
attr_accessor status: Integer?
|
|
23
|
+
|
|
24
|
+
attr_accessor headers: ::Hash[String, String]?
|
|
25
|
+
|
|
26
|
+
attr_accessor body: top?
|
|
27
|
+
|
|
28
|
+
def initialize: (
|
|
29
|
+
url: URI::Generic,
|
|
30
|
+
?status: Integer?,
|
|
31
|
+
?headers: ::Hash[String, String]?,
|
|
32
|
+
?body: Object?,
|
|
33
|
+
?request: nil,
|
|
34
|
+
?response: nil,
|
|
35
|
+
?message: String?
|
|
36
|
+
) -> void
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class APIConnectionError < OursprivacyIngest::Errors::APIError
|
|
40
|
+
def initialize: (
|
|
41
|
+
url: URI::Generic,
|
|
42
|
+
?status: nil,
|
|
43
|
+
?headers: ::Hash[String, String]?,
|
|
44
|
+
?body: nil,
|
|
45
|
+
?request: nil,
|
|
46
|
+
?response: nil,
|
|
47
|
+
?message: String?
|
|
48
|
+
) -> void
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class APITimeoutError < OursprivacyIngest::Errors::APIConnectionError
|
|
52
|
+
def initialize: (
|
|
53
|
+
url: URI::Generic,
|
|
54
|
+
?status: nil,
|
|
55
|
+
?headers: ::Hash[String, String]?,
|
|
56
|
+
?body: nil,
|
|
57
|
+
?request: nil,
|
|
58
|
+
?response: nil,
|
|
59
|
+
?message: String?
|
|
60
|
+
) -> void
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class APIStatusError < OursprivacyIngest::Errors::APIError
|
|
64
|
+
def self.for: (
|
|
65
|
+
url: URI::Generic,
|
|
66
|
+
status: Integer,
|
|
67
|
+
headers: ::Hash[String, String]?,
|
|
68
|
+
body: Object?,
|
|
69
|
+
request: nil,
|
|
70
|
+
response: nil,
|
|
71
|
+
?message: String?
|
|
72
|
+
) -> instance
|
|
73
|
+
|
|
74
|
+
def initialize: (
|
|
75
|
+
url: URI::Generic,
|
|
76
|
+
status: Integer,
|
|
77
|
+
headers: ::Hash[String, String]?,
|
|
78
|
+
body: Object?,
|
|
79
|
+
request: nil,
|
|
80
|
+
response: nil,
|
|
81
|
+
?message: String?
|
|
82
|
+
) -> void
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class BadRequestError < OursprivacyIngest::Errors::APIStatusError
|
|
86
|
+
HTTP_STATUS: 400
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class AuthenticationError < OursprivacyIngest::Errors::APIStatusError
|
|
90
|
+
HTTP_STATUS: 401
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class PermissionDeniedError < OursprivacyIngest::Errors::APIStatusError
|
|
94
|
+
HTTP_STATUS: 403
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class NotFoundError < OursprivacyIngest::Errors::APIStatusError
|
|
98
|
+
HTTP_STATUS: 404
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class ConflictError < OursprivacyIngest::Errors::APIStatusError
|
|
102
|
+
HTTP_STATUS: 409
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class UnprocessableEntityError < OursprivacyIngest::Errors::APIStatusError
|
|
106
|
+
HTTP_STATUS: 422
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class RateLimitError < OursprivacyIngest::Errors::APIStatusError
|
|
110
|
+
HTTP_STATUS: 429
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class InternalServerError < OursprivacyIngest::Errors::APIStatusError
|
|
114
|
+
HTTP_STATUS: Range[Integer]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
class FilePart
|
|
3
|
+
attr_reader content: Pathname | StringIO | IO | String
|
|
4
|
+
|
|
5
|
+
attr_reader content_type: String?
|
|
6
|
+
|
|
7
|
+
attr_reader filename: String?
|
|
8
|
+
|
|
9
|
+
private def read: -> String
|
|
10
|
+
|
|
11
|
+
def to_json: (*top a) -> String
|
|
12
|
+
|
|
13
|
+
def to_yaml: (*top a) -> String
|
|
14
|
+
|
|
15
|
+
def initialize: (
|
|
16
|
+
Pathname | StringIO | IO | String content,
|
|
17
|
+
?filename: (Pathname | String)?,
|
|
18
|
+
?content_type: String?
|
|
19
|
+
) -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
module Internal
|
|
3
|
+
module Transport
|
|
4
|
+
class BaseClient
|
|
5
|
+
extend OursprivacyIngest::Internal::Util::SorbetRuntimeSupport
|
|
6
|
+
|
|
7
|
+
type request_components =
|
|
8
|
+
{
|
|
9
|
+
method: Symbol,
|
|
10
|
+
path: String | ::Array[String],
|
|
11
|
+
query: ::Hash[String, (::Array[String] | String)?]?,
|
|
12
|
+
headers: ::Hash[String, (String
|
|
13
|
+
| Integer
|
|
14
|
+
| ::Array[(String | Integer)?])?]?,
|
|
15
|
+
body: top?,
|
|
16
|
+
unwrap: (Symbol
|
|
17
|
+
| Integer
|
|
18
|
+
| ::Array[(Symbol | Integer)]
|
|
19
|
+
| (^(top arg0) -> top))?,
|
|
20
|
+
page: Class?,
|
|
21
|
+
stream: Class?,
|
|
22
|
+
model: OursprivacyIngest::Internal::Type::Converter::input?,
|
|
23
|
+
options: OursprivacyIngest::request_opts?
|
|
24
|
+
}
|
|
25
|
+
type request_input =
|
|
26
|
+
{
|
|
27
|
+
method: Symbol,
|
|
28
|
+
url: URI::Generic,
|
|
29
|
+
headers: ::Hash[String, String],
|
|
30
|
+
body: top,
|
|
31
|
+
max_retries: Integer,
|
|
32
|
+
timeout: Float
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
MAX_REDIRECTS: 20
|
|
36
|
+
|
|
37
|
+
PLATFORM_HEADERS: ::Hash[String, String]
|
|
38
|
+
|
|
39
|
+
def self.validate!: (
|
|
40
|
+
OursprivacyIngest::Internal::Transport::BaseClient::request_components req
|
|
41
|
+
) -> void
|
|
42
|
+
|
|
43
|
+
def self.should_retry?: (
|
|
44
|
+
Integer status,
|
|
45
|
+
headers: ::Hash[String, String]
|
|
46
|
+
) -> bool
|
|
47
|
+
|
|
48
|
+
def self.follow_redirect: (
|
|
49
|
+
OursprivacyIngest::Internal::Transport::BaseClient::request_input request,
|
|
50
|
+
status: Integer,
|
|
51
|
+
response_headers: ::Hash[String, String]
|
|
52
|
+
) -> OursprivacyIngest::Internal::Transport::BaseClient::request_input
|
|
53
|
+
|
|
54
|
+
def self.reap_connection!: (
|
|
55
|
+
Integer | OursprivacyIngest::Errors::APIConnectionError status,
|
|
56
|
+
stream: Enumerable[String]?
|
|
57
|
+
) -> void
|
|
58
|
+
|
|
59
|
+
attr_reader base_url: URI::Generic
|
|
60
|
+
|
|
61
|
+
attr_reader timeout: Float
|
|
62
|
+
|
|
63
|
+
attr_reader max_retries: Integer
|
|
64
|
+
|
|
65
|
+
attr_reader initial_retry_delay: Float
|
|
66
|
+
|
|
67
|
+
attr_reader max_retry_delay: Float
|
|
68
|
+
|
|
69
|
+
attr_reader headers: ::Hash[String, String]
|
|
70
|
+
|
|
71
|
+
attr_reader idempotency_header: String?
|
|
72
|
+
|
|
73
|
+
# @api private
|
|
74
|
+
attr_reader requester: OursprivacyIngest::Internal::Transport::PooledNetRequester
|
|
75
|
+
|
|
76
|
+
def initialize: (
|
|
77
|
+
base_url: String,
|
|
78
|
+
?timeout: Float,
|
|
79
|
+
?max_retries: Integer,
|
|
80
|
+
?initial_retry_delay: Float,
|
|
81
|
+
?max_retry_delay: Float,
|
|
82
|
+
?headers: ::Hash[String, (String
|
|
83
|
+
| Integer
|
|
84
|
+
| ::Array[(String | Integer)?])?],
|
|
85
|
+
?idempotency_header: String?
|
|
86
|
+
) -> void
|
|
87
|
+
|
|
88
|
+
private def user_agent: -> String
|
|
89
|
+
|
|
90
|
+
private def generate_idempotency_key: -> String
|
|
91
|
+
|
|
92
|
+
private def build_request: (
|
|
93
|
+
OursprivacyIngest::Internal::Transport::BaseClient::request_components req,
|
|
94
|
+
OursprivacyIngest::request_options opts
|
|
95
|
+
) -> OursprivacyIngest::Internal::Transport::BaseClient::request_input
|
|
96
|
+
|
|
97
|
+
private def retry_delay: (
|
|
98
|
+
::Hash[String, String] headers,
|
|
99
|
+
retry_count: Integer
|
|
100
|
+
) -> Float
|
|
101
|
+
|
|
102
|
+
def send_request: (
|
|
103
|
+
OursprivacyIngest::Internal::Transport::BaseClient::request_input request,
|
|
104
|
+
redirect_count: Integer,
|
|
105
|
+
retry_count: Integer,
|
|
106
|
+
send_retry_header: bool
|
|
107
|
+
) -> [Integer, top, Enumerable[String]]
|
|
108
|
+
|
|
109
|
+
def request: (
|
|
110
|
+
Symbol method,
|
|
111
|
+
String | ::Array[String] path,
|
|
112
|
+
?query: ::Hash[String, (::Array[String] | String)?]?,
|
|
113
|
+
?headers: ::Hash[String, (String
|
|
114
|
+
| Integer
|
|
115
|
+
| ::Array[(String | Integer)?])?]?,
|
|
116
|
+
?body: top?,
|
|
117
|
+
?unwrap: (Symbol
|
|
118
|
+
| Integer
|
|
119
|
+
| ::Array[(Symbol | Integer)]
|
|
120
|
+
| (^(top arg0) -> top))?,
|
|
121
|
+
?page: Class?,
|
|
122
|
+
?stream: Class?,
|
|
123
|
+
?model: OursprivacyIngest::Internal::Type::Converter::input?,
|
|
124
|
+
?options: OursprivacyIngest::request_opts?
|
|
125
|
+
) -> top
|
|
126
|
+
|
|
127
|
+
def inspect: -> String
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
module Internal
|
|
3
|
+
module Transport
|
|
4
|
+
class PooledNetRequester
|
|
5
|
+
extend OursprivacyIngest::Internal::Util::SorbetRuntimeSupport
|
|
6
|
+
|
|
7
|
+
type request =
|
|
8
|
+
{
|
|
9
|
+
method: Symbol,
|
|
10
|
+
url: URI::Generic,
|
|
11
|
+
headers: ::Hash[String, String],
|
|
12
|
+
body: top,
|
|
13
|
+
deadline: Float
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
KEEP_ALIVE_TIMEOUT: 30
|
|
17
|
+
|
|
18
|
+
DEFAULT_MAX_CONNECTIONS: Integer
|
|
19
|
+
|
|
20
|
+
def self.connect: (URI::Generic url) -> top
|
|
21
|
+
|
|
22
|
+
def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
|
|
23
|
+
|
|
24
|
+
def self.build_request: (
|
|
25
|
+
OursprivacyIngest::Internal::Transport::PooledNetRequester::request request
|
|
26
|
+
) {
|
|
27
|
+
(String arg0) -> void
|
|
28
|
+
} -> [top, (^-> void)]
|
|
29
|
+
|
|
30
|
+
private def with_pool: (
|
|
31
|
+
URI::Generic url,
|
|
32
|
+
deadline: Float
|
|
33
|
+
) {
|
|
34
|
+
(top arg0) -> void
|
|
35
|
+
} -> void
|
|
36
|
+
|
|
37
|
+
def execute: (
|
|
38
|
+
OursprivacyIngest::Internal::Transport::PooledNetRequester::request request
|
|
39
|
+
) -> [Integer, top, Enumerable[String]]
|
|
40
|
+
|
|
41
|
+
def initialize: (?size: Integer) -> void
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module OursprivacyIngest
|
|
2
|
+
module Internal
|
|
3
|
+
module Type
|
|
4
|
+
class ArrayOf[Elem]
|
|
5
|
+
include OursprivacyIngest::Internal::Type::Converter
|
|
6
|
+
include OursprivacyIngest::Internal::Util::SorbetRuntimeSupport
|
|
7
|
+
|
|
8
|
+
def self.[]: (
|
|
9
|
+
::Hash[Symbol, top]
|
|
10
|
+
| ^-> OursprivacyIngest::Internal::Type::Converter::input
|
|
11
|
+
| OursprivacyIngest::Internal::Type::Converter::input type_info,
|
|
12
|
+
?::Hash[Symbol, top] spec
|
|
13
|
+
) -> instance
|
|
14
|
+
|
|
15
|
+
def ===: (top other) -> bool
|
|
16
|
+
|
|
17
|
+
def ==: (top other) -> bool
|
|
18
|
+
|
|
19
|
+
def hash: -> Integer
|
|
20
|
+
|
|
21
|
+
def coerce: (
|
|
22
|
+
::Array[top] | top value,
|
|
23
|
+
state: OursprivacyIngest::Internal::Type::Converter::coerce_state
|
|
24
|
+
) -> (::Array[top] | top)
|
|
25
|
+
|
|
26
|
+
def dump: (
|
|
27
|
+
::Array[top] | top value,
|
|
28
|
+
state: OursprivacyIngest::Internal::Type::Converter::dump_state
|
|
29
|
+
) -> (::Array[top] | top)
|
|
30
|
+
|
|
31
|
+
def to_sorbet_type: -> top
|
|
32
|
+
|
|
33
|
+
def item_type: -> Elem
|
|
34
|
+
|
|
35
|
+
def nilable?: -> bool
|
|
36
|
+
|
|
37
|
+
def initialize: (
|
|
38
|
+
::Hash[Symbol, top]
|
|
39
|
+
| ^-> OursprivacyIngest::Internal::Type::Converter::input
|
|
40
|
+
| OursprivacyIngest::Internal::Type::Converter::input type_info,
|
|
41
|
+
?::Hash[Symbol, top] spec
|
|
42
|
+
) -> void
|
|
43
|
+
|
|
44
|
+
def inspect: (?depth: Integer) -> String
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|