Skip to content

Commit

Permalink
format new files
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Feb 6, 2019
1 parent 012e8a4 commit a989572
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
11 changes: 6 additions & 5 deletions lib/stripe/subscriptions/invoice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ defmodule Stripe.Invoice do
webhooks_delivered_at: Stripe.timestamp() | nil
}

@type custom_fields :: list(%{
name: String.t(),
value: String.t()
})
@type custom_fields ::
list(%{
name: String.t(),
value: String.t()
})

@type invoice_settings :: %{
@type invoice_settings :: %{
custom_fields: custom_fields | nil,
footer: String.t() | nil
}
Expand Down
19 changes: 10 additions & 9 deletions lib/stripe/subscriptions/usage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ defmodule Stripe.SubscriptionItem.Usage do
"""
@spec create(Stripe.id(), params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
:quantity => float | pos_integer | 0,
:timestamp => Stripe.timestamp() | non_neg_integer,
optional(:action) => String.t()
}
:quantity => float | pos_integer | 0,
:timestamp => Stripe.timestamp() | non_neg_integer,
optional(:action) => String.t()
}
def create(id, params, opts) do
new_request(opts)
|> put_endpoint("#{@plural_endpoint}/#{id}/usage_records")
Expand All @@ -55,12 +55,13 @@ defmodule Stripe.SubscriptionItem.Usage do
@doc """
List all subscription item period summaries
"""
@spec list(Stripe.id(), params, Stripe.options) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
@spec list(Stripe.id(), params, Stripe.options()) ::
{:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
when params: %{
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id()
}
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id()
}
def list(id, params \\ %{}, opts \\ []) do
new_request(opts)
|> put_endpoint("#{@plural_endpoint}/#{id}/usage_record_summaries")
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ defmodule Stripe.Util do

@spec object_name_to_module(String.t()) :: module
def object_name_to_module("file"), do: object_name_to_module("file_upload")

def object_name_to_module(object_name) do
module_name =
object_name
Expand Down
19 changes: 10 additions & 9 deletions test/stripe/subscriptions/usage_test.exs
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
defmodule Stripe.SubscriptionItem.UsageTest do
use Stripe.StripeCase, async: true

describe "create/2" do
test "create usage record" do
item_id = "si_123"

params = %{
quantity: 10,
timestamp: 1543335582
timestamp: 1_543_335_582
}

assert {:ok, record} = Stripe.SubscriptionItem.Usage.create(item_id, params)
assert %{subscription_item: _sub_id} = record
assert_stripe_requested(:post, "/v1/subscription_items/#{item_id}/usage_records")
end

test "create usage record with subsctiption item" do
item =
%Stripe.SubscriptionItem{
id: "si_123"
}
item = %Stripe.SubscriptionItem{
id: "si_123"
}

params = %{
quantity: 10,
timestamp: 1543335582
timestamp: 1_543_335_582
}

assert {:ok, record} = Stripe.SubscriptionItem.Usage.create(Map.get(item, :id), params)
Expand Down Expand Up @@ -51,7 +50,9 @@ defmodule Stripe.SubscriptionItem.UsageTest do
limit: 10
}

assert {:ok, %Stripe.List{data: usages}} = Stripe.SubscriptionItem.Usage.list(item_id, params)
assert {:ok, %Stripe.List{data: usages}} =
Stripe.SubscriptionItem.Usage.list(item_id, params)

assert_stripe_requested(:get, "/v1/subscription_items/#{item_id}/usage_record_summaries")
assert is_list(usages)
assert %{subscription_item: _sub_item_id} = hd(usages)
Expand Down

0 comments on commit a989572

Please sign in to comment.