brand.dev 0.0.1.pre.alpha.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/README.md +229 -0
- data/SECURITY.md +23 -0
- data/lib/brand_dev/client.rb +74 -0
- data/lib/brand_dev/errors.rb +192 -0
- data/lib/brand_dev/file_part.rb +55 -0
- data/lib/brand_dev/internal/transport/base_client.rb +555 -0
- data/lib/brand_dev/internal/transport/pooled_net_requester.rb +209 -0
- data/lib/brand_dev/internal/type/array_of.rb +162 -0
- data/lib/brand_dev/internal/type/base_model.rb +484 -0
- data/lib/brand_dev/internal/type/base_page.rb +55 -0
- data/lib/brand_dev/internal/type/boolean.rb +71 -0
- data/lib/brand_dev/internal/type/converter.rb +292 -0
- data/lib/brand_dev/internal/type/enum.rb +120 -0
- data/lib/brand_dev/internal/type/file_input.rb +103 -0
- data/lib/brand_dev/internal/type/hash_of.rb +182 -0
- data/lib/brand_dev/internal/type/request_parameters.rb +42 -0
- data/lib/brand_dev/internal/type/union.rb +227 -0
- data/lib/brand_dev/internal/type/unknown.rb +75 -0
- data/lib/brand_dev/internal/util.rb +915 -0
- data/lib/brand_dev/internal.rb +20 -0
- data/lib/brand_dev/models/brand_identify_from_transaction_params.rb +22 -0
- data/lib/brand_dev/models/brand_identify_from_transaction_response.rb +435 -0
- data/lib/brand_dev/models/brand_retrieve_by_ticker_params.rb +22 -0
- data/lib/brand_dev/models/brand_retrieve_by_ticker_response.rb +432 -0
- data/lib/brand_dev/models/brand_retrieve_naics_params.rb +27 -0
- data/lib/brand_dev/models/brand_retrieve_naics_response.rb +61 -0
- data/lib/brand_dev/models/brand_retrieve_params.rb +91 -0
- data/lib/brand_dev/models/brand_retrieve_response.rb +432 -0
- data/lib/brand_dev/models/brand_search_params.rb +22 -0
- data/lib/brand_dev/models/brand_search_response.rb +35 -0
- data/lib/brand_dev/models.rb +51 -0
- data/lib/brand_dev/request_options.rb +77 -0
- data/lib/brand_dev/resources/brand.rb +130 -0
- data/lib/brand_dev/version.rb +5 -0
- data/lib/brand_dev.rb +64 -0
- data/manifest.yaml +15 -0
- data/rbi/brand_dev/client.rbi +49 -0
- data/rbi/brand_dev/errors.rbi +162 -0
- data/rbi/brand_dev/file_part.rbi +37 -0
- data/rbi/brand_dev/internal/transport/base_client.rbi +293 -0
- data/rbi/brand_dev/internal/transport/pooled_net_requester.rbi +79 -0
- data/rbi/brand_dev/internal/type/array_of.rbi +104 -0
- data/rbi/brand_dev/internal/type/base_model.rbi +302 -0
- data/rbi/brand_dev/internal/type/base_page.rbi +42 -0
- data/rbi/brand_dev/internal/type/boolean.rbi +56 -0
- data/rbi/brand_dev/internal/type/converter.rbi +162 -0
- data/rbi/brand_dev/internal/type/enum.rbi +82 -0
- data/rbi/brand_dev/internal/type/file_input.rbi +59 -0
- data/rbi/brand_dev/internal/type/hash_of.rbi +104 -0
- data/rbi/brand_dev/internal/type/request_parameters.rbi +29 -0
- data/rbi/brand_dev/internal/type/union.rbi +116 -0
- data/rbi/brand_dev/internal/type/unknown.rbi +56 -0
- data/rbi/brand_dev/internal/util.rbi +485 -0
- data/rbi/brand_dev/internal.rbi +16 -0
- data/rbi/brand_dev/models/brand_identify_from_transaction_params.rbi +46 -0
- data/rbi/brand_dev/models/brand_identify_from_transaction_response.rbi +981 -0
- data/rbi/brand_dev/models/brand_retrieve_by_ticker_params.rbi +43 -0
- data/rbi/brand_dev/models/brand_retrieve_by_ticker_response.rbi +976 -0
- data/rbi/brand_dev/models/brand_retrieve_naics_params.rbi +44 -0
- data/rbi/brand_dev/models/brand_retrieve_naics_response.rbi +127 -0
- data/rbi/brand_dev/models/brand_retrieve_params.rbi +344 -0
- data/rbi/brand_dev/models/brand_retrieve_response.rbi +949 -0
- data/rbi/brand_dev/models/brand_search_params.rbi +40 -0
- data/rbi/brand_dev/models/brand_search_response.rbi +63 -0
- data/rbi/brand_dev/models.rbi +14 -0
- data/rbi/brand_dev/request_options.rbi +59 -0
- data/rbi/brand_dev/resources/brand.rbi +89 -0
- data/rbi/brand_dev/version.rbi +5 -0
- data/sig/brand_dev/client.rbs +26 -0
- data/sig/brand_dev/errors.rbs +101 -0
- data/sig/brand_dev/file_part.rbs +21 -0
- data/sig/brand_dev/internal/transport/base_client.rbs +131 -0
- data/sig/brand_dev/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/brand_dev/internal/type/array_of.rbs +48 -0
- data/sig/brand_dev/internal/type/base_model.rbs +102 -0
- data/sig/brand_dev/internal/type/base_page.rbs +24 -0
- data/sig/brand_dev/internal/type/boolean.rbs +26 -0
- data/sig/brand_dev/internal/type/converter.rbs +56 -0
- data/sig/brand_dev/internal/type/enum.rbs +32 -0
- data/sig/brand_dev/internal/type/file_input.rbs +25 -0
- data/sig/brand_dev/internal/type/hash_of.rbs +48 -0
- data/sig/brand_dev/internal/type/request_parameters.rbs +17 -0
- data/sig/brand_dev/internal/type/union.rbs +52 -0
- data/sig/brand_dev/internal/type/unknown.rbs +26 -0
- data/sig/brand_dev/internal/util.rbs +185 -0
- data/sig/brand_dev/internal.rbs +9 -0
- data/sig/brand_dev/models/brand_identify_from_transaction_params.rbs +24 -0
- data/sig/brand_dev/models/brand_identify_from_transaction_response.rbs +418 -0
- data/sig/brand_dev/models/brand_retrieve_by_ticker_params.rbs +23 -0
- data/sig/brand_dev/models/brand_retrieve_by_ticker_response.rbs +418 -0
- data/sig/brand_dev/models/brand_retrieve_naics_params.rbs +23 -0
- data/sig/brand_dev/models/brand_retrieve_naics_response.rbs +61 -0
- data/sig/brand_dev/models/brand_retrieve_params.rbs +148 -0
- data/sig/brand_dev/models/brand_retrieve_response.rbs +418 -0
- data/sig/brand_dev/models/brand_search_params.rbs +23 -0
- data/sig/brand_dev/models/brand_search_response.rbs +29 -0
- data/sig/brand_dev/models.rbs +11 -0
- data/sig/brand_dev/request_options.rbs +34 -0
- data/sig/brand_dev/resources/brand.rbs +33 -0
- data/sig/brand_dev/version.rbs +3 -0
- metadata +160 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Models
|
5
|
+
class BrandSearchParams < BrandDev::Internal::Type::BaseModel
|
6
|
+
extend BrandDev::Internal::Type::RequestParameters::Converter
|
7
|
+
include BrandDev::Internal::Type::RequestParameters
|
8
|
+
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(BrandDev::BrandSearchParams, BrandDev::Internal::AnyHash)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Query string to search brands
|
15
|
+
sig { returns(String) }
|
16
|
+
attr_accessor :query
|
17
|
+
|
18
|
+
sig do
|
19
|
+
params(
|
20
|
+
query: String,
|
21
|
+
request_options: BrandDev::RequestOptions::OrHash
|
22
|
+
).returns(T.attached_class)
|
23
|
+
end
|
24
|
+
def self.new(
|
25
|
+
# Query string to search brands
|
26
|
+
query:,
|
27
|
+
request_options: {}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
sig do
|
32
|
+
override.returns(
|
33
|
+
{ query: String, request_options: BrandDev::RequestOptions }
|
34
|
+
)
|
35
|
+
end
|
36
|
+
def to_hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Models
|
5
|
+
class BrandSearchResponseItem < BrandDev::Internal::Type::BaseModel
|
6
|
+
OrHash =
|
7
|
+
T.type_alias do
|
8
|
+
T.any(
|
9
|
+
BrandDev::Models::BrandSearchResponseItem,
|
10
|
+
BrandDev::Internal::AnyHash
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Domain name of the brand
|
15
|
+
sig { returns(T.nilable(String)) }
|
16
|
+
attr_reader :domain
|
17
|
+
|
18
|
+
sig { params(domain: String).void }
|
19
|
+
attr_writer :domain
|
20
|
+
|
21
|
+
# URL of the brand's logo
|
22
|
+
sig { returns(T.nilable(String)) }
|
23
|
+
attr_reader :logo
|
24
|
+
|
25
|
+
sig { params(logo: String).void }
|
26
|
+
attr_writer :logo
|
27
|
+
|
28
|
+
# Title or name of the brand
|
29
|
+
sig { returns(T.nilable(String)) }
|
30
|
+
attr_reader :title
|
31
|
+
|
32
|
+
sig { params(title: String).void }
|
33
|
+
attr_writer :title
|
34
|
+
|
35
|
+
sig do
|
36
|
+
params(domain: String, logo: String, title: String).returns(
|
37
|
+
T.attached_class
|
38
|
+
)
|
39
|
+
end
|
40
|
+
def self.new(
|
41
|
+
# Domain name of the brand
|
42
|
+
domain: nil,
|
43
|
+
# URL of the brand's logo
|
44
|
+
logo: nil,
|
45
|
+
# Title or name of the brand
|
46
|
+
title: nil
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
sig { override.returns({ domain: String, logo: String, title: String }) }
|
51
|
+
def to_hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
BrandSearchResponse =
|
56
|
+
T.let(
|
57
|
+
BrandDev::Internal::Type::ArrayOf[
|
58
|
+
BrandDev::Models::BrandSearchResponseItem
|
59
|
+
],
|
60
|
+
BrandDev::Internal::Type::Converter
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
BrandIdentifyFromTransactionParams =
|
5
|
+
BrandDev::Models::BrandIdentifyFromTransactionParams
|
6
|
+
|
7
|
+
BrandRetrieveByTickerParams = BrandDev::Models::BrandRetrieveByTickerParams
|
8
|
+
|
9
|
+
BrandRetrieveNaicsParams = BrandDev::Models::BrandRetrieveNaicsParams
|
10
|
+
|
11
|
+
BrandRetrieveParams = BrandDev::Models::BrandRetrieveParams
|
12
|
+
|
13
|
+
BrandSearchParams = BrandDev::Models::BrandSearchParams
|
14
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
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 < BrandDev::Internal::Type::BaseModel
|
10
|
+
OrHash =
|
11
|
+
T.type_alias do
|
12
|
+
T.any(BrandDev::RequestOptions, BrandDev::Internal::AnyHash)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @api private
|
16
|
+
sig { params(opts: BrandDev::RequestOptions::OrHash).void }
|
17
|
+
def self.validate!(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Idempotency key to send with request and all associated retries. Will only be
|
21
|
+
# sent for write requests.
|
22
|
+
sig { returns(T.nilable(String)) }
|
23
|
+
attr_accessor :idempotency_key
|
24
|
+
|
25
|
+
# Extra query params to send with the request. These are `.merge`’d into any
|
26
|
+
# `query` given at the client level.
|
27
|
+
sig do
|
28
|
+
returns(
|
29
|
+
T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))])
|
30
|
+
)
|
31
|
+
end
|
32
|
+
attr_accessor :extra_query
|
33
|
+
|
34
|
+
# Extra headers to send with the request. These are `.merged`’d into any
|
35
|
+
# `extra_headers` given at the client level.
|
36
|
+
sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) }
|
37
|
+
attr_accessor :extra_headers
|
38
|
+
|
39
|
+
# Extra data to send with the request. These are deep merged into any data
|
40
|
+
# generated as part of the normal request.
|
41
|
+
sig { returns(T.nilable(T.anything)) }
|
42
|
+
attr_accessor :extra_body
|
43
|
+
|
44
|
+
# Maximum number of retries to attempt after a failed initial request.
|
45
|
+
sig { returns(T.nilable(Integer)) }
|
46
|
+
attr_accessor :max_retries
|
47
|
+
|
48
|
+
# Request timeout in seconds.
|
49
|
+
sig { returns(T.nilable(Float)) }
|
50
|
+
attr_accessor :timeout
|
51
|
+
|
52
|
+
# Returns a new instance of RequestOptions.
|
53
|
+
sig do
|
54
|
+
params(values: BrandDev::Internal::AnyHash).returns(T.attached_class)
|
55
|
+
end
|
56
|
+
def self.new(values = {})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Resources
|
5
|
+
class Brand
|
6
|
+
# Retrieve brand data by domain
|
7
|
+
sig do
|
8
|
+
params(
|
9
|
+
domain: String,
|
10
|
+
force_language:
|
11
|
+
BrandDev::BrandRetrieveParams::ForceLanguage::OrSymbol,
|
12
|
+
request_options: BrandDev::RequestOptions::OrHash
|
13
|
+
).returns(BrandDev::Models::BrandRetrieveResponse)
|
14
|
+
end
|
15
|
+
def retrieve(
|
16
|
+
# Domain name to retrieve brand data for
|
17
|
+
domain:,
|
18
|
+
# Optional parameter to force the language of the retrieved brand data
|
19
|
+
force_language: nil,
|
20
|
+
request_options: {}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Endpoint specially designed for platforms that want to identify transaction data
|
25
|
+
# by the transaction title.
|
26
|
+
sig do
|
27
|
+
params(
|
28
|
+
transaction_info: String,
|
29
|
+
request_options: BrandDev::RequestOptions::OrHash
|
30
|
+
).returns(BrandDev::Models::BrandIdentifyFromTransactionResponse)
|
31
|
+
end
|
32
|
+
def identify_from_transaction(
|
33
|
+
# Transaction information to identify the brand
|
34
|
+
transaction_info:,
|
35
|
+
request_options: {}
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Retrieve brand data by stock ticker (e.g. AAPL, TSLA, etc.)
|
40
|
+
sig do
|
41
|
+
params(
|
42
|
+
ticker: String,
|
43
|
+
request_options: BrandDev::RequestOptions::OrHash
|
44
|
+
).returns(BrandDev::Models::BrandRetrieveByTickerResponse)
|
45
|
+
end
|
46
|
+
def retrieve_by_ticker(
|
47
|
+
# Stock ticker symbol to retrieve brand data for (e.g. AAPL, TSLA, etc.)
|
48
|
+
ticker:,
|
49
|
+
request_options: {}
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Endpoint to classify any brand into a 2022 NAICS code.
|
54
|
+
sig do
|
55
|
+
params(
|
56
|
+
input: String,
|
57
|
+
request_options: BrandDev::RequestOptions::OrHash
|
58
|
+
).returns(BrandDev::Models::BrandRetrieveNaicsResponse)
|
59
|
+
end
|
60
|
+
def retrieve_naics(
|
61
|
+
# Brand domain or title to retrieve NAICS code for. If a valid domain is provided
|
62
|
+
# in `input`, it will be used for classification, otherwise, we will search for
|
63
|
+
# the brand using the provided title.
|
64
|
+
input:,
|
65
|
+
request_options: {}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Search brands by query
|
70
|
+
sig do
|
71
|
+
params(
|
72
|
+
query: String,
|
73
|
+
request_options: BrandDev::RequestOptions::OrHash
|
74
|
+
).returns(T::Array[BrandDev::Models::BrandSearchResponseItem])
|
75
|
+
end
|
76
|
+
def search(
|
77
|
+
# Query string to search brands
|
78
|
+
query:,
|
79
|
+
request_options: {}
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @api private
|
84
|
+
sig { params(client: BrandDev::Client).returns(T.attached_class) }
|
85
|
+
def self.new(client:)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BrandDev
|
2
|
+
class Client < BrandDev::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 api_key: String
|
12
|
+
|
13
|
+
attr_reader brand: BrandDev::Resources::Brand
|
14
|
+
|
15
|
+
private def auth_headers: -> ::Hash[String, String]
|
16
|
+
|
17
|
+
def initialize: (
|
18
|
+
?api_key: String?,
|
19
|
+
?base_url: String?,
|
20
|
+
?max_retries: Integer,
|
21
|
+
?timeout: Float,
|
22
|
+
?initial_retry_delay: Float,
|
23
|
+
?max_retry_delay: Float
|
24
|
+
) -> void
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module BrandDev
|
2
|
+
module Errors
|
3
|
+
class Error < StandardError
|
4
|
+
attr_accessor cause: StandardError?
|
5
|
+
end
|
6
|
+
|
7
|
+
class ConversionError < BrandDev::Errors::Error
|
8
|
+
end
|
9
|
+
|
10
|
+
class APIError < BrandDev::Errors::Error
|
11
|
+
attr_accessor url: URI::Generic
|
12
|
+
|
13
|
+
attr_accessor status: Integer?
|
14
|
+
|
15
|
+
attr_accessor body: top?
|
16
|
+
|
17
|
+
def initialize: (
|
18
|
+
url: URI::Generic,
|
19
|
+
?status: Integer?,
|
20
|
+
?body: Object?,
|
21
|
+
?request: nil,
|
22
|
+
?response: nil,
|
23
|
+
?message: String?
|
24
|
+
) -> void
|
25
|
+
end
|
26
|
+
|
27
|
+
class APIConnectionError < BrandDev::Errors::APIError
|
28
|
+
def initialize: (
|
29
|
+
url: URI::Generic,
|
30
|
+
?status: nil,
|
31
|
+
?body: nil,
|
32
|
+
?request: nil,
|
33
|
+
?response: nil,
|
34
|
+
?message: String?
|
35
|
+
) -> void
|
36
|
+
end
|
37
|
+
|
38
|
+
class APITimeoutError < BrandDev::Errors::APIConnectionError
|
39
|
+
def initialize: (
|
40
|
+
url: URI::Generic,
|
41
|
+
?status: nil,
|
42
|
+
?body: nil,
|
43
|
+
?request: nil,
|
44
|
+
?response: nil,
|
45
|
+
?message: String?
|
46
|
+
) -> void
|
47
|
+
end
|
48
|
+
|
49
|
+
class APIStatusError < BrandDev::Errors::APIError
|
50
|
+
def self.for: (
|
51
|
+
url: URI::Generic,
|
52
|
+
status: Integer,
|
53
|
+
body: Object?,
|
54
|
+
request: nil,
|
55
|
+
response: nil,
|
56
|
+
?message: String?
|
57
|
+
) -> instance
|
58
|
+
|
59
|
+
def initialize: (
|
60
|
+
url: URI::Generic,
|
61
|
+
status: Integer,
|
62
|
+
body: Object?,
|
63
|
+
request: nil,
|
64
|
+
response: nil,
|
65
|
+
?message: String?
|
66
|
+
) -> void
|
67
|
+
end
|
68
|
+
|
69
|
+
class BadRequestError < BrandDev::Errors::APIStatusError
|
70
|
+
HTTP_STATUS: 400
|
71
|
+
end
|
72
|
+
|
73
|
+
class AuthenticationError < BrandDev::Errors::APIStatusError
|
74
|
+
HTTP_STATUS: 401
|
75
|
+
end
|
76
|
+
|
77
|
+
class PermissionDeniedError < BrandDev::Errors::APIStatusError
|
78
|
+
HTTP_STATUS: 403
|
79
|
+
end
|
80
|
+
|
81
|
+
class NotFoundError < BrandDev::Errors::APIStatusError
|
82
|
+
HTTP_STATUS: 404
|
83
|
+
end
|
84
|
+
|
85
|
+
class ConflictError < BrandDev::Errors::APIStatusError
|
86
|
+
HTTP_STATUS: 409
|
87
|
+
end
|
88
|
+
|
89
|
+
class UnprocessableEntityError < BrandDev::Errors::APIStatusError
|
90
|
+
HTTP_STATUS: 422
|
91
|
+
end
|
92
|
+
|
93
|
+
class RateLimitError < BrandDev::Errors::APIStatusError
|
94
|
+
HTTP_STATUS: 429
|
95
|
+
end
|
96
|
+
|
97
|
+
class InternalServerError < BrandDev::Errors::APIStatusError
|
98
|
+
HTTP_STATUS: Range[Integer]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BrandDev
|
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: String?,
|
18
|
+
?content_type: String?
|
19
|
+
) -> void
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module BrandDev
|
2
|
+
module Internal
|
3
|
+
module Transport
|
4
|
+
class BaseClient
|
5
|
+
extend BrandDev::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: BrandDev::Internal::Type::Converter::input?,
|
23
|
+
options: BrandDev::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
|
+
BrandDev::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
|
+
BrandDev::Internal::Transport::BaseClient::request_input request,
|
50
|
+
status: Integer,
|
51
|
+
response_headers: ::Hash[String, String]
|
52
|
+
) -> BrandDev::Internal::Transport::BaseClient::request_input
|
53
|
+
|
54
|
+
def self.reap_connection!: (
|
55
|
+
Integer | BrandDev::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: BrandDev::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 auth_headers: -> ::Hash[String, String]
|
89
|
+
|
90
|
+
private def generate_idempotency_key: -> String
|
91
|
+
|
92
|
+
private def build_request: (
|
93
|
+
BrandDev::Internal::Transport::BaseClient::request_components req,
|
94
|
+
BrandDev::request_options opts
|
95
|
+
) -> BrandDev::Internal::Transport::BaseClient::request_input
|
96
|
+
|
97
|
+
private def retry_delay: (
|
98
|
+
::Hash[String, String] headers,
|
99
|
+
retry_count: Integer
|
100
|
+
) -> Float
|
101
|
+
|
102
|
+
private def send_request: (
|
103
|
+
BrandDev::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: BrandDev::Internal::Type::Converter::input?,
|
124
|
+
?options: BrandDev::request_opts?
|
125
|
+
) -> top
|
126
|
+
|
127
|
+
def inspect: -> String
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module BrandDev
|
2
|
+
module Internal
|
3
|
+
module Transport
|
4
|
+
class PooledNetRequester
|
5
|
+
extend BrandDev::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
|
+
BrandDev::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
|
+
BrandDev::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 BrandDev
|
2
|
+
module Internal
|
3
|
+
module Type
|
4
|
+
class ArrayOf[Elem]
|
5
|
+
include BrandDev::Internal::Type::Converter
|
6
|
+
include BrandDev::Internal::Util::SorbetRuntimeSupport
|
7
|
+
|
8
|
+
def self.[]: (
|
9
|
+
::Hash[Symbol, top]
|
10
|
+
| ^-> BrandDev::Internal::Type::Converter::input
|
11
|
+
| BrandDev::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: BrandDev::Internal::Type::Converter::coerce_state
|
24
|
+
) -> (::Array[top] | top)
|
25
|
+
|
26
|
+
def dump: (
|
27
|
+
::Array[top] | top value,
|
28
|
+
state: BrandDev::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
|
+
| ^-> BrandDev::Internal::Type::Converter::input
|
40
|
+
| BrandDev::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
|