Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 238
openapi_spec_hash: 7f33ff43b4b498d0954b28032669a1a6
config_hash: 2ae0d8aaecf01b38cbf9f9e112822c23
configured_endpoints: 239
openapi_spec_hash: ea35154a418c5a3cabaedc30f766fcac
config_hash: 1ca082e374ef7000e2a5971e8da740e0
1 change: 1 addition & 0 deletions lib/increase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
require_relative "increase/models/fednow_transfer_list_params"
require_relative "increase/models/fednow_transfer_retrieve_params"
require_relative "increase/models/file"
require_relative "increase/models/file_contents_params"
require_relative "increase/models/file_create_params"
require_relative "increase/models/file_link"
require_relative "increase/models/file_link_create_params"
Expand Down
41 changes: 5 additions & 36 deletions lib/increase/internal/transport/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ class BaseClient
# from whatwg fetch spec
MAX_REDIRECTS = 20

# rubocop:disable Style/MutableConstant
PLATFORM_HEADERS =
{
"x-stainless-arch" => Increase::Internal::Util.arch,
"x-stainless-lang" => "ruby",
"x-stainless-os" => Increase::Internal::Util.os,
"x-stainless-package-version" => Increase::VERSION,
"x-stainless-runtime" => ::RUBY_ENGINE,
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
}
# rubocop:enable Style/MutableConstant

class << self
# @api private
#
Expand Down Expand Up @@ -198,7 +186,6 @@ def initialize(
)
@requester = Increase::Internal::Transport::PooledNetRequester.new
@headers = Increase::Internal::Util.normalized_headers(
self.class::PLATFORM_HEADERS,
{
"accept" => "application/json",
"content-type" => "application/json",
Expand Down Expand Up @@ -287,14 +274,7 @@ def initialize(
headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key }
end

unless headers.key?("x-stainless-retry-count")
headers["x-stainless-retry-count"] = "0"
end

timeout = opts.fetch(:timeout, @timeout).to_f.clamp(0..)
unless headers.key?("x-stainless-timeout") || timeout.zero?
headers["x-stainless-timeout"] = timeout.to_s
end

headers.reject! { |_, v| v.to_s.empty? }

Expand Down Expand Up @@ -369,18 +349,12 @@ def initialize(
#
# @param retry_count [Integer]
#
# @param send_retry_header [Boolean]
#
# @raise [Increase::Errors::APIError]
# @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
def send_request(request, redirect_count:, retry_count:, send_retry_header:)
url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
def send_request(request, redirect_count:, retry_count:)
url, max_retries, timeout = request.fetch_values(:url, :max_retries, :timeout)
input = {**request.except(:timeout), deadline: Increase::Internal::Util.monotonic_secs + timeout}

if send_retry_header
headers["x-stainless-retry-count"] = retry_count.to_s
end

begin
status, response, stream = @requester.execute(input)
rescue Increase::Errors::APIConnectionError => e
Expand All @@ -403,8 +377,7 @@ def send_request(request, redirect_count:, retry_count:, send_retry_header:)
send_request(
request,
redirect_count: redirect_count + 1,
retry_count: retry_count,
send_retry_header: send_retry_header
retry_count: retry_count
)
in Increase::Errors::APIConnectionError if retry_count >= max_retries
raise status
Expand Down Expand Up @@ -432,8 +405,7 @@ def send_request(request, redirect_count:, retry_count:, send_retry_header:)
send_request(
request,
redirect_count: redirect_count,
retry_count: retry_count + 1,
send_retry_header: send_retry_header
retry_count: retry_count + 1
)
end
end
Expand Down Expand Up @@ -486,13 +458,10 @@ def request(req)
request = build_request(req.except(:options), opts)
url = request.fetch(:url)

# Don't send the current retry count in the headers if the caller modified the header defaults.
send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0"
status, response, stream = send_request(
request,
redirect_count: 0,
retry_count: 0,
send_retry_header: send_retry_header
retry_count: 0
)

headers = Increase::Internal::Util.normalized_headers(response.each_header.to_h)
Expand Down
2 changes: 2 additions & 0 deletions lib/increase/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ module Increase

File = Increase::Models::File

FileContentsParams = Increase::Models::FileContentsParams

FileCreateParams = Increase::Models::FileCreateParams

FileLink = Increase::Models::FileLink
Expand Down
6 changes: 6 additions & 0 deletions lib/increase/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ module Category
# Occurs whenever a Physical Check is updated.
PHYSICAL_CHECK_UPDATED = :"physical_check.updated"

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED = :"physical_check_book.created"

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED = :"physical_check_book.updated"

# Occurs whenever a Program is created.
PROGRAM_CREATED = :"program.created"

Expand Down
6 changes: 6 additions & 0 deletions lib/increase/models/event_list_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ module In
# Occurs whenever a Physical Check is updated.
PHYSICAL_CHECK_UPDATED = :"physical_check.updated"

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED = :"physical_check_book.created"

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED = :"physical_check_book.updated"

# Occurs whenever a Program is created.
PROGRAM_CREATED = :"program.created"

Expand Down
6 changes: 6 additions & 0 deletions lib/increase/models/event_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ module EventCategory
# Occurs whenever a Physical Check is updated.
PHYSICAL_CHECK_UPDATED = :"physical_check.updated"

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED = :"physical_check_book.created"

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED = :"physical_check_book.updated"

# Occurs whenever a Program is created.
PROGRAM_CREATED = :"program.created"

Expand Down
6 changes: 6 additions & 0 deletions lib/increase/models/event_subscription_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ module EventCategory
# Occurs whenever a Physical Check is updated.
PHYSICAL_CHECK_UPDATED = :"physical_check.updated"

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED = :"physical_check_book.created"

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED = :"physical_check_book.updated"

# Occurs whenever a Program is created.
PROGRAM_CREATED = :"program.created"

Expand Down
22 changes: 22 additions & 0 deletions lib/increase/models/file_contents_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Increase
module Models
# @see Increase::Resources::Files#contents
class FileContentsParams < Increase::Internal::Type::BaseModel
extend Increase::Internal::Type::RequestParameters::Converter
include Increase::Internal::Type::RequestParameters

# @!attribute file_id
# The identifier of the File.
#
# @return [String]
required :file_id, String

# @!method initialize(file_id:, request_options: {})
# @param file_id [String] The identifier of the File.
#
# @param request_options [Increase::RequestOptions, Hash{Symbol=>Object}]
end
end
end
6 changes: 6 additions & 0 deletions lib/increase/models/unwrap_webhook_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ module Category
# Occurs whenever a Physical Check is updated.
PHYSICAL_CHECK_UPDATED = :"physical_check.updated"

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED = :"physical_check_book.created"

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED = :"physical_check_book.updated"

# Occurs whenever a Program is created.
PROGRAM_CREATED = :"program.created"

Expand Down
28 changes: 28 additions & 0 deletions lib/increase/resources/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,34 @@ def list(params = {})
)
end

# Download the contents of a File. Responds with a 307 redirect whose `Location`
# header points at a short-lived, pre-signed URL. Our
# [SDKs](/documentation/software-development-kits) follow the redirect and return
# the File's contents; if you call the API directly, follow the redirect to
# download it. The pre-signed URL serves the File with a `Content-Type` matching
# its `mime` and a `Content-Disposition` header set to its `filename`. It expires
# in 10 minutes. To share a File with someone who doesn't have access to your API
# key, create a File Link.
#
# @overload contents(file_id, request_options: {})
#
# @param file_id [String] The identifier of the File.
#
# @param request_options [Increase::RequestOptions, Hash{Symbol=>Object}, nil]
#
# @return [StringIO]
#
# @see Increase::Models::FileContentsParams
def contents(file_id, params = {})
@client.request(
method: :get,
path: ["files/%1$s/contents", file_id],
headers: {"accept" => "application/octet-stream"},
model: StringIO,
options: params[:request_options]
)
end

# @api private
#
# @param client [Increase::Client]
Expand Down
12 changes: 2 additions & 10 deletions rbi/increase/internal/transport/base_client.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ module Increase
# from whatwg fetch spec
MAX_REDIRECTS = 20

PLATFORM_HEADERS = T::Hash[String, String]

class << self
# @api private
sig do
Expand Down Expand Up @@ -213,16 +211,10 @@ module Increase
params(
request: Increase::Internal::Transport::BaseClient::RequestInput,
redirect_count: Integer,
retry_count: Integer,
send_retry_header: T::Boolean
retry_count: Integer
).returns([Integer, Net::HTTPResponse, T::Enumerable[String]])
end
def send_request(
request,
redirect_count:,
retry_count:,
send_retry_header:
)
def send_request(request, redirect_count:, retry_count:)
end

# Execute the request specified by `req`. This is the method that all resource
Expand Down
2 changes: 2 additions & 0 deletions rbi/increase/models.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ module Increase

File = Increase::Models::File

FileContentsParams = Increase::Models::FileContentsParams

FileCreateParams = Increase::Models::FileCreateParams

FileLink = Increase::Models::FileLink
Expand Down
14 changes: 14 additions & 0 deletions rbi/increase/models/event.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,20 @@ module Increase
Increase::Event::Category::TaggedSymbol
)

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED =
T.let(
:"physical_check_book.created",
Increase::Event::Category::TaggedSymbol
)

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED =
T.let(
:"physical_check_book.updated",
Increase::Event::Category::TaggedSymbol
)

# Occurs whenever a Program is created.
PROGRAM_CREATED =
T.let(:"program.created", Increase::Event::Category::TaggedSymbol)
Expand Down
14 changes: 14 additions & 0 deletions rbi/increase/models/event_list_params.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,20 @@ module Increase
Increase::EventListParams::Category::In::TaggedSymbol
)

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED =
T.let(
:"physical_check_book.created",
Increase::EventListParams::Category::In::TaggedSymbol
)

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED =
T.let(
:"physical_check_book.updated",
Increase::EventListParams::Category::In::TaggedSymbol
)

# Occurs whenever a Program is created.
PROGRAM_CREATED =
T.let(
Expand Down
14 changes: 14 additions & 0 deletions rbi/increase/models/event_subscription.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,20 @@ module Increase
Increase::EventSubscription::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED =
T.let(
:"physical_check_book.created",
Increase::EventSubscription::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED =
T.let(
:"physical_check_book.updated",
Increase::EventSubscription::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Program is created.
PROGRAM_CREATED =
T.let(
Expand Down
14 changes: 14 additions & 0 deletions rbi/increase/models/event_subscription_create_params.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,20 @@ module Increase
Increase::EventSubscriptionCreateParams::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Physical Check Book is created.
PHYSICAL_CHECK_BOOK_CREATED =
T.let(
:"physical_check_book.created",
Increase::EventSubscriptionCreateParams::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Physical Check Book is updated.
PHYSICAL_CHECK_BOOK_UPDATED =
T.let(
:"physical_check_book.updated",
Increase::EventSubscriptionCreateParams::SelectedEventCategory::EventCategory::TaggedSymbol
)

# Occurs whenever a Program is created.
PROGRAM_CREATED =
T.let(
Expand Down
Loading