Skip to content

Commit

Permalink
Add task for codegen (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenvanvliet authored Jul 28, 2023
1 parent d0d7ffd commit 43721ec
Show file tree
Hide file tree
Showing 132 changed files with 31,816 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Test generated code
run: |
mix stripe.generate
- name: Test generated code
run: |
mix test
Expand All @@ -89,6 +92,7 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
git add priv/openapi
git add lib/generated
git add .latest-tag-stripe-openapi-sdk
echo "Update services based on ${{ env.LATEST_STRIPE_SDK_TAG }} of Stripe OpenApi SDK" >> commit-msg
echo >> commit-msg
Expand Down
920 changes: 920 additions & 0 deletions lib/generated/account.ex

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions lib/generated/account_link.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
defmodule Stripe.AccountLink do
use Stripe.Entity

@moduledoc "Account Links are the means by which a Connect platform grants a connected account permission to access\nStripe-hosted applications, such as Connect Onboarding.\n\nRelated guide: [Connect Onboarding](https://stripe.com/docs/connect/connect-onboarding)"
(
defstruct [:created, :expires_at, :object, :url]

@typedoc "The `account_link` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `expires_at` The timestamp at which this account link will expire.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `url` The URL for the account link.\n"
@type t :: %__MODULE__{created: integer, expires_at: integer, object: binary, url: binary}
)

(
nil

@doc "<p>Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/account_links`\n"
(
@spec create(
params :: %{
optional(:account) => binary,
optional(:collect) => :currently_due | :eventually_due,
optional(:expand) => list(binary),
optional(:refresh_url) => binary,
optional(:return_url) => binary,
optional(:type) =>
:account_onboarding
| :account_update
| :custom_account_update
| :custom_account_verification
},
opts :: Keyword.t()
) :: {:ok, Stripe.AccountLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/account_links", [], [])

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
end
38 changes: 38 additions & 0 deletions lib/generated/api_errors.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
defmodule Stripe.ApiErrors do
use Stripe.Entity
@moduledoc ""
(
defstruct [
:charge,
:code,
:decline_code,
:doc_url,
:message,
:param,
:payment_intent,
:payment_method,
:payment_method_type,
:request_log_url,
:setup_intent,
:source,
:type
]

@typedoc "The `api_errors` type.\n\n * `charge` For card errors, the ID of the failed charge.\n * `code` For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported.\n * `decline_code` For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://stripe.com/docs/declines#issuer-declines) if they provide one.\n * `doc_url` A URL to more information about the [error code](https://stripe.com/docs/error-codes) reported.\n * `message` A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.\n * `param` If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.\n * `payment_intent` \n * `payment_method` \n * `payment_method_type` If the error is specific to the type of payment method, the payment method type that had a problem. This field is only populated for invoice-related errors.\n * `request_log_url` A URL to the request log entry in your dashboard.\n * `setup_intent` \n * `source` \n * `type` The type of error returned. One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`\n"
@type t :: %__MODULE__{
charge: binary,
code: binary,
decline_code: binary,
doc_url: binary,
message: binary,
param: binary,
payment_intent: Stripe.PaymentIntent.t(),
payment_method: Stripe.PaymentMethod.t(),
payment_method_type: binary,
request_log_url: binary,
setup_intent: Stripe.SetupIntent.t(),
source: Stripe.PaymentSource.t(),
type: binary
}
)
end
149 changes: 149 additions & 0 deletions lib/generated/apple_pay_domain.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
defmodule Stripe.ApplePayDomain do
use Stripe.Entity
@moduledoc ""
(
defstruct [:created, :domain_name, :id, :livemode, :object]

@typedoc "The `apple_pay_domain` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `domain_name` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n"
@type t :: %__MODULE__{
created: integer,
domain_name: binary,
id: binary,
livemode: boolean,
object: binary
}
)

(
nil

@doc "<p>List apple pay domains.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apple_pay/domains`\n"
(
@spec list(
params :: %{
optional(:domain_name) => binary,
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.ApplePayDomain.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/apple_pay/domains", [], [])

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)

(
nil

@doc "<p>Create an apple pay domain.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/apple_pay/domains`\n"
(
@spec create(
params :: %{optional(:domain_name) => binary, optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.ApplePayDomain.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/apple_pay/domains", [], [])

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)

(
nil

@doc "<p>Retrieve an apple pay domain.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apple_pay/domains/{domain}`\n"
(
@spec retrieve(
domain :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.ApplePayDomain.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def retrieve(domain, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/apple_pay/domains/{domain}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "domain",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "domain",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[domain]
)

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)

(
nil

@doc "<p>Delete an apple pay domain.</p>\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/apple_pay/domains/{domain}`\n"
(
@spec delete(domain :: binary(), opts :: Keyword.t()) ::
{:ok, Stripe.DeletedApplePayDomain.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def delete(domain, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/apple_pay/domains/{domain}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "domain",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "domain",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[domain]
)

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_method(:delete)
|> Stripe.Request.make_request()
end
)
)
end
123 changes: 123 additions & 0 deletions lib/generated/application_fee.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
defmodule Stripe.ApplicationFee do
use Stripe.Entity
@moduledoc ""
(
defstruct [
:account,
:amount,
:amount_refunded,
:application,
:balance_transaction,
:charge,
:created,
:currency,
:id,
:livemode,
:object,
:originating_transaction,
:refunded,
:refunds
]

@typedoc "The `application_fee` type.\n\n * `account` ID of the Stripe account this fee was taken from.\n * `amount` Amount earned, in %s.\n * `amount_refunded` Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued)\n * `application` ID of the Connect application that earned the fee.\n * `balance_transaction` Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).\n * `charge` ID of the charge that the application fee was taken from.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `originating_transaction` ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter.\n * `refunded` Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.\n * `refunds` A list of refunds that have been applied to the fee.\n"
@type t :: %__MODULE__{
account: binary | Stripe.Account.t(),
amount: integer,
amount_refunded: integer,
application: binary | term,
balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil,
charge: binary | Stripe.Charge.t(),
created: integer,
currency: binary,
id: binary,
livemode: boolean,
object: binary,
originating_transaction: (binary | Stripe.Charge.t()) | nil,
refunded: boolean,
refunds: term
}
)

(
@typedoc nil
@type created :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)

(
nil

@doc "<p>Returns a list of application fees you’ve previously collected. The application fees are returned in sorted order, with the most recent fees appearing first.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees`\n"
(
@spec list(
params :: %{
optional(:charge) => binary,
optional(:created) => created | integer,
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:starting_after) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.ApplicationFee.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/application_fees", [], [])

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)

(
nil

@doc "<p>Retrieves the details of an application fee that your account has collected. The same information is returned when refunding the application fee.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees/{id}`\n"
(
@spec retrieve(
id :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.ApplicationFee.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
def retrieve(id, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/application_fees/{id}",
[
%OpenApiGen.Blueprint.Parameter{
in: "path",
name: "id",
required: true,
schema: %OpenApiGen.Blueprint.Parameter.Schema{
name: "id",
title: nil,
type: "string",
items: [],
properties: [],
any_of: []
}
}
],
[id]
)

Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
end
Loading

0 comments on commit 43721ec

Please sign in to comment.