Skip to content

Commit d9f9600

Browse files
chore(internal): codegen related update
1 parent 659f771 commit d9f9600

41 files changed

Lines changed: 300 additions & 46 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,40 @@ on:
1313
- 'stl-preview-base/**'
1414

1515
jobs:
16+
build:
17+
timeout-minutes: 10
18+
name: build
19+
permissions:
20+
contents: read
21+
id-token: write
22+
runs-on: ${{ github.repository == 'stainless-sdks/lithic-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
23+
if: |-
24+
github.repository == 'stainless-sdks/lithic-ruby' &&
25+
(github.event_name == 'push' || github.event.pull_request.head.repo.fork)
26+
steps:
27+
- uses: actions/checkout@v6
28+
- name: Set up Ruby
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
bundler-cache: false
32+
- run: |-
33+
bundle install
34+
35+
- name: Get GitHub OIDC Token
36+
if: github.repository == 'stainless-sdks/lithic-ruby'
37+
id: github-oidc
38+
uses: actions/github-script@v8
39+
with:
40+
script: core.setOutput('github_token', await core.getIDToken());
41+
42+
- name: Build and upload gem artifacts
43+
if: github.repository == 'stainless-sdks/lithic-ruby'
44+
env:
45+
URL: https://pkg.stainless.com/s
46+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
47+
SHA: ${{ github.sha }}
48+
PACKAGE_NAME: lithic
49+
run: ./scripts/utils/upload-artifact.sh
1650
lint:
1751
timeout-minutes: 10
1852
name: lint

lib/lithic/internal/util.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,37 @@ def writable_enum(&blk)
490490
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491491

492492
class << self
493+
# @api private
494+
#
495+
# @param query [Hash{Symbol=>Object}]
496+
#
497+
# @return [Hash{Symbol=>Object}]
498+
def encode_query_params(query)
499+
out = {}
500+
query.each { write_query_param_element!(out, _1, _2) }
501+
out
502+
end
503+
504+
# @api private
505+
#
506+
# @param collection [Hash{Symbol=>Object}]
507+
# @param key [String]
508+
# @param element [Object]
509+
#
510+
# @return [nil]
511+
private def write_query_param_element!(collection, key, element)
512+
case element
513+
in Hash
514+
element.each do |name, value|
515+
write_query_param_element!(collection, "#{key}[#{name}]", value)
516+
end
517+
in Array
518+
collection[key] = element.map(&:to_s).join(",")
519+
else
520+
collection[key] = element.to_s
521+
end
522+
end
523+
493524
# @api private
494525
#
495526
# @param y [Enumerator::Yielder]

lib/lithic/resources/account_activity.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ class AccountActivity
3939
# @see Lithic::Models::AccountActivityListParams
4040
def list(params = {})
4141
parsed, options = Lithic::AccountActivityListParams.dump_request(params)
42+
query = Lithic::Internal::Util.encode_query_params(parsed)
4243
@client.request(
4344
method: :get,
4445
path: "v1/account_activity",
45-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
46+
query: query.transform_keys(begin_: "begin", end_: "end"),
4647
page: Lithic::Internal::CursorPage,
4748
model: Lithic::Models::AccountActivityListResponse,
4849
options: options

lib/lithic/resources/account_holders.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,11 @@ def update(account_holder_token, params = {})
196196
# @see Lithic::Models::AccountHolderListParams
197197
def list(params = {})
198198
parsed, options = Lithic::AccountHolderListParams.dump_request(params)
199+
query = Lithic::Internal::Util.encode_query_params(parsed)
199200
@client.request(
200201
method: :get,
201202
path: "v1/account_holders",
202-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
203+
query: query.transform_keys(begin_: "begin", end_: "end"),
203204
page: Lithic::Internal::SinglePage,
204205
model: Lithic::AccountHolder,
205206
options: options

lib/lithic/resources/accounts.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ def update(account_token, params = {})
8888
# @see Lithic::Models::AccountListParams
8989
def list(params = {})
9090
parsed, options = Lithic::AccountListParams.dump_request(params)
91+
query = Lithic::Internal::Util.encode_query_params(parsed)
9192
@client.request(
9293
method: :get,
9394
path: "v1/accounts",
94-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
95+
query: query.transform_keys(begin_: "begin", end_: "end"),
9596
page: Lithic::Internal::CursorPage,
9697
model: Lithic::Account,
9798
options: options

lib/lithic/resources/auth_rules/v2.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ def update(auth_rule_token, params = {})
142142
# @see Lithic::Models::AuthRules::V2ListParams
143143
def list(params = {})
144144
parsed, options = Lithic::AuthRules::V2ListParams.dump_request(params)
145+
query = Lithic::Internal::Util.encode_query_params(parsed)
145146
@client.request(
146147
method: :get,
147148
path: "v2/auth_rules",
148-
query: parsed,
149+
query: query,
149150
page: Lithic::Internal::CursorPage,
150151
model: Lithic::AuthRules::AuthRule,
151152
options: options
@@ -234,10 +235,11 @@ def draft(auth_rule_token, params = {})
234235
# @see Lithic::Models::AuthRules::V2ListResultsParams
235236
def list_results(params = {})
236237
parsed, options = Lithic::AuthRules::V2ListResultsParams.dump_request(params)
238+
query = Lithic::Internal::Util.encode_query_params(parsed)
237239
@client.request(
238240
method: :get,
239241
path: "v2/auth_rules/results",
240-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
242+
query: query.transform_keys(begin_: "begin", end_: "end"),
241243
page: Lithic::Internal::CursorPage,
242244
model: Lithic::Models::AuthRules::V2ListResultsResponse,
243245
options: options
@@ -286,10 +288,11 @@ def promote(auth_rule_token, params = {})
286288
# @see Lithic::Models::AuthRules::V2RetrieveFeaturesParams
287289
def retrieve_features(auth_rule_token, params = {})
288290
parsed, options = Lithic::AuthRules::V2RetrieveFeaturesParams.dump_request(params)
291+
query = Lithic::Internal::Util.encode_query_params(parsed)
289292
@client.request(
290293
method: :get,
291294
path: ["v2/auth_rules/%1$s/features", auth_rule_token],
292-
query: parsed,
295+
query: query,
293296
model: Lithic::Models::AuthRules::V2RetrieveFeaturesResponse,
294297
options: options
295298
)
@@ -324,10 +327,11 @@ def retrieve_features(auth_rule_token, params = {})
324327
# @see Lithic::Models::AuthRules::V2RetrieveReportParams
325328
def retrieve_report(auth_rule_token, params)
326329
parsed, options = Lithic::AuthRules::V2RetrieveReportParams.dump_request(params)
330+
query = Lithic::Internal::Util.encode_query_params(parsed)
327331
@client.request(
328332
method: :get,
329333
path: ["v2/auth_rules/%1$s/report", auth_rule_token],
330-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
334+
query: query.transform_keys(begin_: "begin", end_: "end"),
331335
model: Lithic::Models::AuthRules::V2RetrieveReportResponse,
332336
options: options
333337
)

lib/lithic/resources/balances.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class Balances
2525
# @see Lithic::Models::BalanceListParams
2626
def list(params = {})
2727
parsed, options = Lithic::BalanceListParams.dump_request(params)
28+
query = Lithic::Internal::Util.encode_query_params(parsed)
2829
@client.request(
2930
method: :get,
3031
path: "v1/balances",
31-
query: parsed,
32+
query: query,
3233
page: Lithic::Internal::SinglePage,
3334
model: Lithic::Balance,
3435
options: options

lib/lithic/resources/book_transfers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ def retrieve(book_transfer_token, params = {})
105105
# @see Lithic::Models::BookTransferListParams
106106
def list(params = {})
107107
parsed, options = Lithic::BookTransferListParams.dump_request(params)
108+
query = Lithic::Internal::Util.encode_query_params(parsed)
108109
@client.request(
109110
method: :get,
110111
path: "v1/book_transfers",
111-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
112+
query: query.transform_keys(begin_: "begin", end_: "end"),
112113
page: Lithic::Internal::CursorPage,
113114
model: Lithic::BookTransferResponse,
114115
options: options

lib/lithic/resources/card_bulk_orders.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ def update(bulk_order_token, params)
106106
# @see Lithic::Models::CardBulkOrderListParams
107107
def list(params = {})
108108
parsed, options = Lithic::CardBulkOrderListParams.dump_request(params)
109+
query = Lithic::Internal::Util.encode_query_params(parsed)
109110
@client.request(
110111
method: :get,
111112
path: "v1/card_bulk_orders",
112-
query: parsed.transform_keys(begin_: "begin", end_: "end"),
113+
query: query.transform_keys(begin_: "begin", end_: "end"),
113114
page: Lithic::Internal::CursorPage,
114115
model: Lithic::CardBulkOrder,
115116
options: options

lib/lithic/resources/card_programs.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ def retrieve(card_program_token, params = {})
4343
# @see Lithic::Models::CardProgramListParams
4444
def list(params = {})
4545
parsed, options = Lithic::CardProgramListParams.dump_request(params)
46+
query = Lithic::Internal::Util.encode_query_params(parsed)
4647
@client.request(
4748
method: :get,
4849
path: "v1/card_programs",
49-
query: parsed,
50+
query: query,
5051
page: Lithic::Internal::CursorPage,
5152
model: Lithic::CardProgram,
5253
options: options

0 commit comments

Comments
 (0)