Skip to content

Commit

Permalink
try to fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Lossenko committed Aug 28, 2024
1 parent d316520 commit d04af28
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# The directory Mix downloads your dependencies sources to.
/deps/

# Dialyzer PLT files
/priv/plts/*.plt
/priv/plts/*.plt.hash

# Where third-party dependencies like ExDoc output generated docs.
/doc/

Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 26.1.2
elixir 1.16.0-otp-26
erlang 26.2.5.1
elixir 1.17.2-otp-26
16 changes: 10 additions & 6 deletions lib/stripe/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ defmodule Stripe.API do
defp do_perform_request_and_retry(method, url, headers, body, opts, {:attempts, attempts}) do
{idempotency_key, attempt} = log_request(method, url, headers, attempts)

response = track_request_time(method, url, idempotency_key, attempt,
fn -> http_module().request(method, url, headers, body, opts) end
)
response =
track_request_time(method, url, idempotency_key, attempt, fn ->
http_module().request(method, url, headers, body, opts)
end)

do_perform_request_and_retry(
method,
Expand All @@ -404,7 +405,8 @@ defmodule Stripe.API do
attempt: attempt
}

:telemetry.span([:stripity_stripe, :request],
:telemetry.span(
[:stripity_stripe, :request],
start_metadata,
fn ->
result = request_fn.()
Expand All @@ -424,9 +426,11 @@ defmodule Stripe.API do
# attempts are 0-index based
attempt = "attempt=#{attempts + 1}"

Logger.info("[stripity_stripe] Performing #{http_method_url} #{attempt}#{idempotency_key_msg}")
Logger.info(
"[stripity_stripe] Performing #{http_method_url} #{attempt}#{idempotency_key_msg}"
)

{idempotency_key, attempts+1}
{idempotency_key, attempts + 1}
end

defp get_idempotency_key_from_headers(method, _headers) when method in [:get, :headers], do: nil
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/core_resources/charge.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ defmodule Stripe.Charge do
livemode: boolean,
metadata: Stripe.Types.metadata(),
on_behalf_of: Stripe.id() | Stripe.Account.t() | nil,
order: Stripe.id() | Stripe.Order.t() | nil,
order: Stripe.id() | nil,
outcome: charge_outcome | nil,
paid: boolean,
payment_intent: Stripe.id() | Stripe.PaymentIntent.t() | nil,
Expand Down
3 changes: 2 additions & 1 deletion lib/stripe/core_resources/customer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ defmodule Stripe.Customer do
{:ok, cash_Balance} = Stripe.Customer.update_cash_balance("cus_123")
"""
@spec update_cash_balance(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
@spec update_cash_balance(Stripe.id() | t, params, Stripe.options()) ::
{:ok, t} | {:error, Stripe.Error.t()}
when params:
%{
optional(:settings) => Stripe.Types.metadata()
Expand Down
4 changes: 0 additions & 4 deletions lib/stripe/core_resources/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ defmodule Stripe.Event do
| Stripe.FileUpload.t()
| Stripe.Invoice.t()
| Stripe.Invoiceitem.t()
| Stripe.Order.t()
| Stripe.OrderReturn.t()
| Stripe.Payout.t()
| Stripe.Plan.t()
| Stripe.Relay.Product.t()
| Stripe.Price.t()
| Stripe.Product.t()
| Stripe.Recipient.t()
| Stripe.Review.t()
| Stripe.Sku.t()
| Stripe.Source.t()
| Stripe.Transfer.t()
| map
Expand Down
3 changes: 2 additions & 1 deletion lib/stripe/core_resources/payment_intent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ defmodule Stripe.PaymentIntent do
See the [Stripe docs](https://stripe.com/docs/api/payment_intents/apply_customer_balance).
"""

@spec apply_customer_balance(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
@spec apply_customer_balance(Stripe.id() | t, params, Stripe.options()) ::
{:ok, t} | {:error, Stripe.Error.t()}
when params: %{
optional(:amount) => non_neg_integer,
optional(:currency) => String.t()
Expand Down
4 changes: 1 addition & 3 deletions lib/stripe/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ defmodule Stripe.Error do
source: :network,
code: :network_error,
message:
"An error occurred while making the network request. The HTTP client returned the following reason: #{
inspect(reason)
}",
"An error occurred while making the network request. The HTTP client returned the following reason: #{inspect(reason)}",
extra: %{
hackney_reason: reason
}
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/payment_methods/card.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule Stripe.Card do
last4: String.t(),
metadata: Stripe.Types.metadata(),
name: String.t() | nil,
recipient: Stripe.id() | Stripe.Recipient.t() | nil,
recipient: Stripe.id() | nil,
tokenization_method: String.t() | nil
}

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/relay/order_item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Stripe.OrderItem do
amount: pos_integer,
currency: String.t(),
description: String.t(),
parent: nil | Stripe.id() | Stripe.Sku.t(),
parent: nil | Stripe.id(),
quantity: nil | pos_integer,
type: String.t()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/subscriptions/credit_note.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Stripe.CreditNote do

@type discount :: %{
amount: integer,
discount: String.t(),
discount: String.t()
}

@type t :: %__MODULE__{
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/subscriptions/credit_note_line_item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Stripe.CreditNoteLineItem do

@type discount :: %{
amount: integer,
discount: String.t(),
discount: String.t()
}

@type t :: %__MODULE__{
Expand Down
5 changes: 4 additions & 1 deletion lib/stripe/subscriptions/invoice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ defmodule Stripe.Invoice do
@spec upcoming(map, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
def upcoming(params, opts \\ [])
def upcoming(params = %{customer: _customer}, opts), do: get_upcoming(params, opts)
def upcoming(params = %{customer_details: _customer_details}, opts), do: get_upcoming(params, opts)

def upcoming(params = %{customer_details: _customer_details}, opts),
do: get_upcoming(params, opts)

def upcoming(params = %{subscription: _subscription}, opts), do: get_upcoming(params, opts)

defp get_upcoming(params, opts) do
Expand Down

0 comments on commit d04af28

Please sign in to comment.