Skip to content

Commit 98afb05

Browse files
feat(api): Add idempotency key to cards POST and PATCH endpoints
1 parent 0466f6a commit 98afb05

File tree

5 files changed

+70
-49
lines changed

5 files changed

+70
-49
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 176
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-6e800837b020104545778d65b7b16bae277e6667d98044e83f3bfeacebdb489b.yml
3-
openapi_spec_hash: 94788968e119e8665a1b0d4742565984
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-eeeb62a4869ba1436c9252f9630006a829695178e86305aea232f6be0d1e3d81.yml
3+
openapi_spec_hash: 25bf9c499cd22240949862e622c534f2
44
config_hash: 2af43c32faa12490c9c9caa2ce62bccb

src/resources/cards/cards.ts

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ export class Cards extends APIResource {
3737
* });
3838
* ```
3939
*/
40-
create(body: CardCreateParams, options?: RequestOptions): APIPromise<Card> {
41-
return this._client.post('/v1/cards', { body, ...options });
40+
create(params: CardCreateParams, options?: RequestOptions): APIPromise<Card> {
41+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
42+
return this._client.post('/v1/cards', {
43+
body,
44+
...options,
45+
headers: buildHeaders([
46+
{ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) },
47+
options?.headers,
48+
]),
49+
});
4250
}
4351

4452
/**
@@ -851,7 +859,7 @@ export namespace CardWebProvisionResponse {
851859

852860
export interface CardCreateParams {
853861
/**
854-
* Card types:
862+
* Body param: Card types:
855863
*
856864
* - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
857865
* wallet like Apple Pay or Google Pay (if the card program is digital
@@ -871,95 +879,99 @@ export interface CardCreateParams {
871879
type: 'MERCHANT_LOCKED' | 'PHYSICAL' | 'SINGLE_USE' | 'VIRTUAL' | 'UNLOCKED' | 'DIGITAL_WALLET';
872880

873881
/**
874-
* Globally unique identifier for the account that the card will be associated
875-
* with. Required for programs enrolling users using the
882+
* Body param: Globally unique identifier for the account that the card will be
883+
* associated with. Required for programs enrolling users using the
876884
* [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc).
877885
* See [Managing Your Program](doc:managing-your-program) for more information.
878886
*/
879887
account_token?: string;
880888

881889
/**
882-
* Globally unique identifier for an existing bulk order to associate this card
883-
* with. When specified, the card will be added to the bulk order for batch
884-
* shipment. Only applicable to cards of type PHYSICAL
890+
* Body param: Globally unique identifier for an existing bulk order to associate
891+
* this card with. When specified, the card will be added to the bulk order for
892+
* batch shipment. Only applicable to cards of type PHYSICAL
885893
*/
886894
bulk_order_token?: string;
887895

888896
/**
889-
* For card programs with more than one BIN range. This must be configured with
890-
* Lithic before use. Identifies the card program/BIN range under which to create
891-
* the card. If omitted, will utilize the program's default `card_program_token`.
892-
* In Sandbox, use 00000000-0000-0000-1000-000000000000 and
897+
* Body param: For card programs with more than one BIN range. This must be
898+
* configured with Lithic before use. Identifies the card program/BIN range under
899+
* which to create the card. If omitted, will utilize the program's default
900+
* `card_program_token`. In Sandbox, use 00000000-0000-0000-1000-000000000000 and
893901
* 00000000-0000-0000-2000-000000000000 to test creating cards on specific card
894902
* programs.
895903
*/
896904
card_program_token?: string;
897905

906+
/**
907+
* Body param
908+
*/
898909
carrier?: Shared.Carrier;
899910

900911
/**
901-
* Specifies the digital card art to be displayed in the user’s digital wallet
902-
* after tokenization. This artwork must be approved by Mastercard and configured
903-
* by Lithic to use. See
912+
* Body param: Specifies the digital card art to be displayed in the user’s digital
913+
* wallet after tokenization. This artwork must be approved by Mastercard and
914+
* configured by Lithic to use. See
904915
* [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
905916
*/
906917
digital_card_art_token?: string;
907918

908919
/**
909-
* Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided,
910-
* an expiration date will be generated.
920+
* Body param: Two digit (MM) expiry month. If neither `exp_month` nor `exp_year`
921+
* is provided, an expiration date will be generated.
911922
*/
912923
exp_month?: string;
913924

914925
/**
915-
* Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is
916-
* provided, an expiration date will be generated.
926+
* Body param: Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year`
927+
* is provided, an expiration date will be generated.
917928
*/
918929
exp_year?: string;
919930

920931
/**
921-
* Friendly name to identify the card.
932+
* Body param: Friendly name to identify the card.
922933
*/
923934
memo?: string;
924935

925936
/**
926-
* Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and
927-
* `VIRTUAL`. See
937+
* Body param: Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL`
938+
* and `VIRTUAL`. See
928939
* [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
929940
*/
930941
pin?: string;
931942

932943
/**
933-
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic
934-
* before use. Specifies the configuration (i.e., physical card art) that the card
935-
* should be manufactured with.
944+
* Body param: Only applicable to cards of type `PHYSICAL`. This must be configured
945+
* with Lithic before use. Specifies the configuration (i.e., physical card art)
946+
* that the card should be manufactured with.
936947
*/
937948
product_id?: string;
938949

939950
/**
940-
* Restricted field limited to select use cases. Lithic will reach out directly if
941-
* this field should be used. Globally unique identifier for the replacement card's
942-
* account. If this field is specified, `replacement_for` must also be specified.
943-
* If `replacement_for` is specified and this field is omitted, the replacement
944-
* card's account will be inferred from the card being replaced.
951+
* Body param: Restricted field limited to select use cases. Lithic will reach out
952+
* directly if this field should be used. Globally unique identifier for the
953+
* replacement card's account. If this field is specified, `replacement_for` must
954+
* also be specified. If `replacement_for` is specified and this field is omitted,
955+
* the replacement card's account will be inferred from the card being replaced.
945956
*/
946957
replacement_account_token?: string;
947958

948959
/**
949-
* Additional context or information related to the card that this card will
950-
* replace.
960+
* Body param: Additional context or information related to the card that this card
961+
* will replace.
951962
*/
952963
replacement_comment?: string;
953964

954965
/**
955-
* Globally unique identifier for the card that this card will replace. If the card
956-
* type is `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is
957-
* `VIRTUAL` it will be replaced by a `VIRTUAL` card.
966+
* Body param: Globally unique identifier for the card that this card will replace.
967+
* If the card type is `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the
968+
* card type is `VIRTUAL` it will be replaced by a `VIRTUAL` card.
958969
*/
959970
replacement_for?: string;
960971

961972
/**
962-
* Card state substatus values for the card that this card will replace:
973+
* Body param: Card state substatus values for the card that this card will
974+
* replace:
963975
*
964976
* - `LOST` - The physical card is no longer in the cardholder's possession due to
965977
* being lost or never received by the cardholder.
@@ -1000,11 +1012,14 @@ export interface CardCreateParams {
10001012
| 'UNDELIVERABLE'
10011013
| 'OTHER';
10021014

1015+
/**
1016+
* Body param
1017+
*/
10031018
shipping_address?: Shared.ShippingAddress;
10041019

10051020
/**
1006-
* Shipping method for the card. Only applies to cards of type PHYSICAL. Use of
1007-
* options besides `STANDARD` require additional permissions.
1021+
* Body param: Shipping method for the card. Only applies to cards of type
1022+
* PHYSICAL. Use of options besides `STANDARD` require additional permissions.
10081023
*
10091024
* - `STANDARD` - USPS regular mail or similar international option, with no
10101025
* tracking
@@ -1029,16 +1044,16 @@ export interface CardCreateParams {
10291044
| 'STANDARD_WITH_TRACKING';
10301045

10311046
/**
1032-
* Amount (in cents) to limit approved authorizations (e.g. 100000 would be a
1033-
* $1,000 limit). Transaction requests above the spend limit will be declined. Note
1034-
* that a spend limit of 0 is effectively no limit, and should only be used to
1035-
* reset or remove a prior limit. Only a limit of 1 or above will result in
1036-
* declined transactions due to checks against the card limit.
1047+
* Body param: Amount (in cents) to limit approved authorizations (e.g. 100000
1048+
* would be a $1,000 limit). Transaction requests above the spend limit will be
1049+
* declined. Note that a spend limit of 0 is effectively no limit, and should only
1050+
* be used to reset or remove a prior limit. Only a limit of 1 or above will result
1051+
* in declined transactions due to checks against the card limit.
10371052
*/
10381053
spend_limit?: number;
10391054

10401055
/**
1041-
* Spend limit duration values:
1056+
* Body param: Spend limit duration values:
10421057
*
10431058
* - `ANNUALLY` - Card will authorize transactions up to spend limit for the
10441059
* trailing year.
@@ -1054,14 +1069,19 @@ export interface CardCreateParams {
10541069
spend_limit_duration?: SpendLimitDuration;
10551070

10561071
/**
1057-
* Card state values:
1072+
* Body param: Card state values:
10581073
*
10591074
* - `OPEN` - Card will approve authorizations (if they match card and account
10601075
* parameters).
10611076
* - `PAUSED` - Card will decline authorizations, but can be resumed at a later
10621077
* time.
10631078
*/
10641079
state?: 'OPEN' | 'PAUSED';
1080+
1081+
/**
1082+
* Header param: Idempotency key for the request
1083+
*/
1084+
'Idempotency-Key'?: string;
10651085
}
10661086

10671087
export interface CardUpdateParams {

src/resources/financial-accounts/financial-accounts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export interface FinancialAccountCreateParams {
492492
is_for_benefit_of?: boolean;
493493

494494
/**
495-
* Header param
495+
* Header param: Idempotency key for the request
496496
*/
497497
'Idempotency-Key'?: string;
498498
}

tests/api-resources/cards/cards.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('resource cards', () => {
5353
spend_limit: 1000,
5454
spend_limit_duration: 'TRANSACTION',
5555
state: 'OPEN',
56+
'Idempotency-Key': '65a9dad4-1b60-4686-83fd-65b25078a4b4',
5657
});
5758
});
5859

tests/api-resources/financial-accounts/financial-accounts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('resource financialAccounts', () => {
2525
type: 'OPERATING',
2626
account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
2727
is_for_benefit_of: true,
28-
'Idempotency-Key': '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
28+
'Idempotency-Key': '65a9dad4-1b60-4686-83fd-65b25078a4b4',
2929
});
3030
});
3131

0 commit comments

Comments
 (0)