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,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Resources
|
5
|
+
class Brand
|
6
|
+
# Retrieve brand data by domain
|
7
|
+
#
|
8
|
+
# @overload retrieve(domain:, force_language: nil, request_options: {})
|
9
|
+
#
|
10
|
+
# @param domain [String] Domain name to retrieve brand data for
|
11
|
+
#
|
12
|
+
# @param force_language [Symbol, BrandDev::Models::BrandRetrieveParams::ForceLanguage] Optional parameter to force the language of the retrieved brand data
|
13
|
+
#
|
14
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
|
15
|
+
#
|
16
|
+
# @return [BrandDev::Models::BrandRetrieveResponse]
|
17
|
+
#
|
18
|
+
# @see BrandDev::Models::BrandRetrieveParams
|
19
|
+
def retrieve(params)
|
20
|
+
parsed, options = BrandDev::BrandRetrieveParams.dump_request(params)
|
21
|
+
@client.request(
|
22
|
+
method: :get,
|
23
|
+
path: "brand/retrieve",
|
24
|
+
query: parsed,
|
25
|
+
model: BrandDev::Models::BrandRetrieveResponse,
|
26
|
+
options: options
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Endpoint specially designed for platforms that want to identify transaction data
|
31
|
+
# by the transaction title.
|
32
|
+
#
|
33
|
+
# @overload identify_from_transaction(transaction_info:, request_options: {})
|
34
|
+
#
|
35
|
+
# @param transaction_info [String] Transaction information to identify the brand
|
36
|
+
#
|
37
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
|
38
|
+
#
|
39
|
+
# @return [BrandDev::Models::BrandIdentifyFromTransactionResponse]
|
40
|
+
#
|
41
|
+
# @see BrandDev::Models::BrandIdentifyFromTransactionParams
|
42
|
+
def identify_from_transaction(params)
|
43
|
+
parsed, options = BrandDev::BrandIdentifyFromTransactionParams.dump_request(params)
|
44
|
+
@client.request(
|
45
|
+
method: :get,
|
46
|
+
path: "brand/transaction_identifier",
|
47
|
+
query: parsed,
|
48
|
+
model: BrandDev::Models::BrandIdentifyFromTransactionResponse,
|
49
|
+
options: options
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Retrieve brand data by stock ticker (e.g. AAPL, TSLA, etc.)
|
54
|
+
#
|
55
|
+
# @overload retrieve_by_ticker(ticker:, request_options: {})
|
56
|
+
#
|
57
|
+
# @param ticker [String] Stock ticker symbol to retrieve brand data for (e.g. AAPL, TSLA, etc.)
|
58
|
+
#
|
59
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
|
60
|
+
#
|
61
|
+
# @return [BrandDev::Models::BrandRetrieveByTickerResponse]
|
62
|
+
#
|
63
|
+
# @see BrandDev::Models::BrandRetrieveByTickerParams
|
64
|
+
def retrieve_by_ticker(params)
|
65
|
+
parsed, options = BrandDev::BrandRetrieveByTickerParams.dump_request(params)
|
66
|
+
@client.request(
|
67
|
+
method: :get,
|
68
|
+
path: "brand/retrieve-by-ticker",
|
69
|
+
query: parsed,
|
70
|
+
model: BrandDev::Models::BrandRetrieveByTickerResponse,
|
71
|
+
options: options
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Some parameter documentations has been truncated, see
|
76
|
+
# {BrandDev::Models::BrandRetrieveNaicsParams} for more details.
|
77
|
+
#
|
78
|
+
# Endpoint to classify any brand into a 2022 NAICS code.
|
79
|
+
#
|
80
|
+
# @overload retrieve_naics(input:, request_options: {})
|
81
|
+
#
|
82
|
+
# @param input [String] Brand domain or title to retrieve NAICS code for. If a valid domain is provided
|
83
|
+
#
|
84
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
|
85
|
+
#
|
86
|
+
# @return [BrandDev::Models::BrandRetrieveNaicsResponse]
|
87
|
+
#
|
88
|
+
# @see BrandDev::Models::BrandRetrieveNaicsParams
|
89
|
+
def retrieve_naics(params)
|
90
|
+
parsed, options = BrandDev::BrandRetrieveNaicsParams.dump_request(params)
|
91
|
+
@client.request(
|
92
|
+
method: :get,
|
93
|
+
path: "brand/naics",
|
94
|
+
query: parsed,
|
95
|
+
model: BrandDev::Models::BrandRetrieveNaicsResponse,
|
96
|
+
options: options
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Search brands by query
|
101
|
+
#
|
102
|
+
# @overload search(query:, request_options: {})
|
103
|
+
#
|
104
|
+
# @param query [String] Query string to search brands
|
105
|
+
#
|
106
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
|
107
|
+
#
|
108
|
+
# @return [Array<BrandDev::Models::BrandSearchResponseItem>]
|
109
|
+
#
|
110
|
+
# @see BrandDev::Models::BrandSearchParams
|
111
|
+
def search(params)
|
112
|
+
parsed, options = BrandDev::BrandSearchParams.dump_request(params)
|
113
|
+
@client.request(
|
114
|
+
method: :get,
|
115
|
+
path: "brand/search",
|
116
|
+
query: parsed,
|
117
|
+
model: BrandDev::Internal::Type::ArrayOf[BrandDev::Models::BrandSearchResponseItem],
|
118
|
+
options: options
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
# @api private
|
123
|
+
#
|
124
|
+
# @param client [BrandDev::Client]
|
125
|
+
def initialize(client:)
|
126
|
+
@client = client
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/lib/brand_dev.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Standard libraries.
|
4
|
+
# rubocop:disable Lint/RedundantRequireStatement
|
5
|
+
require "English"
|
6
|
+
require "cgi"
|
7
|
+
require "date"
|
8
|
+
require "erb"
|
9
|
+
require "etc"
|
10
|
+
require "json"
|
11
|
+
require "net/http"
|
12
|
+
require "pathname"
|
13
|
+
require "rbconfig"
|
14
|
+
require "securerandom"
|
15
|
+
require "set"
|
16
|
+
require "stringio"
|
17
|
+
require "time"
|
18
|
+
require "uri"
|
19
|
+
# rubocop:enable Lint/RedundantRequireStatement
|
20
|
+
|
21
|
+
# We already ship the preferred sorbet manifests in the package itself.
|
22
|
+
# `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
|
23
|
+
if Object.const_defined?(:Tapioca) &&
|
24
|
+
caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) &&
|
25
|
+
ARGV.none?(/dsl/)
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
# Gems.
|
30
|
+
require "connection_pool"
|
31
|
+
|
32
|
+
# Package files.
|
33
|
+
require_relative "brand_dev/version"
|
34
|
+
require_relative "brand_dev/internal/util"
|
35
|
+
require_relative "brand_dev/internal/type/converter"
|
36
|
+
require_relative "brand_dev/internal/type/unknown"
|
37
|
+
require_relative "brand_dev/internal/type/boolean"
|
38
|
+
require_relative "brand_dev/internal/type/file_input"
|
39
|
+
require_relative "brand_dev/internal/type/enum"
|
40
|
+
require_relative "brand_dev/internal/type/union"
|
41
|
+
require_relative "brand_dev/internal/type/array_of"
|
42
|
+
require_relative "brand_dev/internal/type/hash_of"
|
43
|
+
require_relative "brand_dev/internal/type/base_model"
|
44
|
+
require_relative "brand_dev/internal/type/base_page"
|
45
|
+
require_relative "brand_dev/internal/type/request_parameters"
|
46
|
+
require_relative "brand_dev/internal"
|
47
|
+
require_relative "brand_dev/request_options"
|
48
|
+
require_relative "brand_dev/file_part"
|
49
|
+
require_relative "brand_dev/errors"
|
50
|
+
require_relative "brand_dev/internal/transport/base_client"
|
51
|
+
require_relative "brand_dev/internal/transport/pooled_net_requester"
|
52
|
+
require_relative "brand_dev/client"
|
53
|
+
require_relative "brand_dev/models/brand_identify_from_transaction_params"
|
54
|
+
require_relative "brand_dev/models/brand_identify_from_transaction_response"
|
55
|
+
require_relative "brand_dev/models/brand_retrieve_by_ticker_params"
|
56
|
+
require_relative "brand_dev/models/brand_retrieve_by_ticker_response"
|
57
|
+
require_relative "brand_dev/models/brand_retrieve_naics_params"
|
58
|
+
require_relative "brand_dev/models/brand_retrieve_naics_response"
|
59
|
+
require_relative "brand_dev/models/brand_retrieve_params"
|
60
|
+
require_relative "brand_dev/models/brand_retrieve_response"
|
61
|
+
require_relative "brand_dev/models/brand_search_params"
|
62
|
+
require_relative "brand_dev/models/brand_search_response"
|
63
|
+
require_relative "brand_dev/models"
|
64
|
+
require_relative "brand_dev/resources/brand"
|
data/manifest.yaml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
class Client < BrandDev::Internal::Transport::BaseClient
|
5
|
+
DEFAULT_MAX_RETRIES = 2
|
6
|
+
|
7
|
+
DEFAULT_TIMEOUT_IN_SECONDS = T.let(60.0, Float)
|
8
|
+
|
9
|
+
DEFAULT_INITIAL_RETRY_DELAY = T.let(0.5, Float)
|
10
|
+
|
11
|
+
DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
|
12
|
+
|
13
|
+
sig { returns(String) }
|
14
|
+
attr_reader :api_key
|
15
|
+
|
16
|
+
sig { returns(BrandDev::Resources::Brand) }
|
17
|
+
attr_reader :brand
|
18
|
+
|
19
|
+
# @api private
|
20
|
+
sig { override.returns(T::Hash[String, String]) }
|
21
|
+
private def auth_headers
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates and returns a new client for interacting with the API.
|
25
|
+
sig do
|
26
|
+
params(
|
27
|
+
api_key: T.nilable(String),
|
28
|
+
base_url: T.nilable(String),
|
29
|
+
max_retries: Integer,
|
30
|
+
timeout: Float,
|
31
|
+
initial_retry_delay: Float,
|
32
|
+
max_retry_delay: Float
|
33
|
+
).returns(T.attached_class)
|
34
|
+
end
|
35
|
+
def self.new(
|
36
|
+
# Defaults to `ENV["BRAND_DEV_API_KEY"]`
|
37
|
+
api_key: ENV["BRAND_DEV_API_KEY"],
|
38
|
+
# Override the default base URL for the API, e.g.,
|
39
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["BRAND_DEV_BASE_URL"]`
|
40
|
+
base_url: ENV["BRAND_DEV_BASE_URL"],
|
41
|
+
# Max number of retries to attempt after a failed retryable request.
|
42
|
+
max_retries: BrandDev::Client::DEFAULT_MAX_RETRIES,
|
43
|
+
timeout: BrandDev::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
44
|
+
initial_retry_delay: BrandDev::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
45
|
+
max_retry_delay: BrandDev::Client::DEFAULT_MAX_RETRY_DELAY
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Errors
|
5
|
+
class Error < StandardError
|
6
|
+
sig { returns(T.nilable(StandardError)) }
|
7
|
+
attr_accessor :cause
|
8
|
+
end
|
9
|
+
|
10
|
+
class ConversionError < BrandDev::Errors::Error
|
11
|
+
end
|
12
|
+
|
13
|
+
class APIError < BrandDev::Errors::Error
|
14
|
+
sig { returns(URI::Generic) }
|
15
|
+
attr_accessor :url
|
16
|
+
|
17
|
+
sig { returns(T.nilable(Integer)) }
|
18
|
+
attr_accessor :status
|
19
|
+
|
20
|
+
sig { returns(T.nilable(T.anything)) }
|
21
|
+
attr_accessor :body
|
22
|
+
|
23
|
+
# @api private
|
24
|
+
sig do
|
25
|
+
params(
|
26
|
+
url: URI::Generic,
|
27
|
+
status: T.nilable(Integer),
|
28
|
+
body: T.nilable(Object),
|
29
|
+
request: NilClass,
|
30
|
+
response: NilClass,
|
31
|
+
message: T.nilable(String)
|
32
|
+
).returns(T.attached_class)
|
33
|
+
end
|
34
|
+
def self.new(
|
35
|
+
url:,
|
36
|
+
status: nil,
|
37
|
+
body: nil,
|
38
|
+
request: nil,
|
39
|
+
response: nil,
|
40
|
+
message: nil
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class APIConnectionError < BrandDev::Errors::APIError
|
46
|
+
sig { void }
|
47
|
+
attr_accessor :status
|
48
|
+
|
49
|
+
sig { void }
|
50
|
+
attr_accessor :body
|
51
|
+
|
52
|
+
# @api private
|
53
|
+
sig do
|
54
|
+
params(
|
55
|
+
url: URI::Generic,
|
56
|
+
status: NilClass,
|
57
|
+
body: NilClass,
|
58
|
+
request: NilClass,
|
59
|
+
response: NilClass,
|
60
|
+
message: T.nilable(String)
|
61
|
+
).returns(T.attached_class)
|
62
|
+
end
|
63
|
+
def self.new(
|
64
|
+
url:,
|
65
|
+
status: nil,
|
66
|
+
body: nil,
|
67
|
+
request: nil,
|
68
|
+
response: nil,
|
69
|
+
message: "Connection error."
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class APITimeoutError < BrandDev::Errors::APIConnectionError
|
75
|
+
# @api private
|
76
|
+
sig do
|
77
|
+
params(
|
78
|
+
url: URI::Generic,
|
79
|
+
status: NilClass,
|
80
|
+
body: NilClass,
|
81
|
+
request: NilClass,
|
82
|
+
response: NilClass,
|
83
|
+
message: T.nilable(String)
|
84
|
+
).returns(T.attached_class)
|
85
|
+
end
|
86
|
+
def self.new(
|
87
|
+
url:,
|
88
|
+
status: nil,
|
89
|
+
body: nil,
|
90
|
+
request: nil,
|
91
|
+
response: nil,
|
92
|
+
message: "Request timed out."
|
93
|
+
)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class APIStatusError < BrandDev::Errors::APIError
|
98
|
+
# @api private
|
99
|
+
sig do
|
100
|
+
params(
|
101
|
+
url: URI::Generic,
|
102
|
+
status: Integer,
|
103
|
+
body: T.nilable(Object),
|
104
|
+
request: NilClass,
|
105
|
+
response: NilClass,
|
106
|
+
message: T.nilable(String)
|
107
|
+
).returns(T.attached_class)
|
108
|
+
end
|
109
|
+
def self.for(url:, status:, body:, request:, response:, message: nil)
|
110
|
+
end
|
111
|
+
|
112
|
+
sig { returns(Integer) }
|
113
|
+
attr_accessor :status
|
114
|
+
|
115
|
+
# @api private
|
116
|
+
sig do
|
117
|
+
params(
|
118
|
+
url: URI::Generic,
|
119
|
+
status: Integer,
|
120
|
+
body: T.nilable(Object),
|
121
|
+
request: NilClass,
|
122
|
+
response: NilClass,
|
123
|
+
message: T.nilable(String)
|
124
|
+
).returns(T.attached_class)
|
125
|
+
end
|
126
|
+
def self.new(url:, status:, body:, request:, response:, message: nil)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class BadRequestError < BrandDev::Errors::APIStatusError
|
131
|
+
HTTP_STATUS = 400
|
132
|
+
end
|
133
|
+
|
134
|
+
class AuthenticationError < BrandDev::Errors::APIStatusError
|
135
|
+
HTTP_STATUS = 401
|
136
|
+
end
|
137
|
+
|
138
|
+
class PermissionDeniedError < BrandDev::Errors::APIStatusError
|
139
|
+
HTTP_STATUS = 403
|
140
|
+
end
|
141
|
+
|
142
|
+
class NotFoundError < BrandDev::Errors::APIStatusError
|
143
|
+
HTTP_STATUS = 404
|
144
|
+
end
|
145
|
+
|
146
|
+
class ConflictError < BrandDev::Errors::APIStatusError
|
147
|
+
HTTP_STATUS = 409
|
148
|
+
end
|
149
|
+
|
150
|
+
class UnprocessableEntityError < BrandDev::Errors::APIStatusError
|
151
|
+
HTTP_STATUS = 422
|
152
|
+
end
|
153
|
+
|
154
|
+
class RateLimitError < BrandDev::Errors::APIStatusError
|
155
|
+
HTTP_STATUS = 429
|
156
|
+
end
|
157
|
+
|
158
|
+
class InternalServerError < BrandDev::Errors::APIStatusError
|
159
|
+
HTTP_STATUS = T.let((500..), T::Range[Integer])
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
class FilePart
|
5
|
+
sig { returns(T.any(Pathname, StringIO, IO, String)) }
|
6
|
+
attr_reader :content
|
7
|
+
|
8
|
+
sig { returns(T.nilable(String)) }
|
9
|
+
attr_reader :content_type
|
10
|
+
|
11
|
+
sig { returns(T.nilable(String)) }
|
12
|
+
attr_reader :filename
|
13
|
+
|
14
|
+
# @api private
|
15
|
+
sig { returns(String) }
|
16
|
+
private def read
|
17
|
+
end
|
18
|
+
|
19
|
+
sig { params(a: T.anything).returns(String) }
|
20
|
+
def to_json(*a)
|
21
|
+
end
|
22
|
+
|
23
|
+
sig { params(a: T.anything).returns(String) }
|
24
|
+
def to_yaml(*a)
|
25
|
+
end
|
26
|
+
|
27
|
+
sig do
|
28
|
+
params(
|
29
|
+
content: T.any(Pathname, StringIO, IO, String),
|
30
|
+
filename: T.nilable(String),
|
31
|
+
content_type: T.nilable(String)
|
32
|
+
).returns(T.attached_class)
|
33
|
+
end
|
34
|
+
def self.new(content, filename: nil, content_type: nil)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|