diff --git a/lib/lemon_ex/customers/customer.ex b/lib/lemon_ex/customers/customer.ex index 88f2ad9..153d3d2 100644 --- a/lib/lemon_ex/customers/customer.ex +++ b/lib/lemon_ex/customers/customer.ex @@ -14,6 +14,7 @@ defmodule LemonEx.Customers.Customer do :country_formatted, :total_revenue_currency_formatted, :mrr_formatted, + :urls, :created_at, :updated_at, :test_mode @@ -21,6 +22,7 @@ defmodule LemonEx.Customers.Customer do def from_json(map) do attributes = map["attributes"] + urls = attributes["urls"] %__MODULE__{ id: map["id"], @@ -37,6 +39,9 @@ defmodule LemonEx.Customers.Customer do country_formatted: attributes["country_formatted"], total_revenue_currency_formatted: attributes["total_revenue_currency_formatted"], mrr_formatted: attributes["mrr_formatted"], + urls: %{ + customer_portal: urls["customer_portal"] + }, created_at: attributes["created_at"], updated_at: attributes["updated_at"], test_mode: attributes["test_mode"] diff --git a/test/lemon_ex/customers/customers_test.exs b/test/lemon_ex/customers/customers_test.exs index b863a7a..55ff5fb 100644 --- a/test/lemon_ex/customers/customers_test.exs +++ b/test/lemon_ex/customers/customers_test.exs @@ -32,42 +32,50 @@ defmodule LemonEx.CustomersTest do %LemonEx.PaginatedResponse{ data: [ %LemonEx.Customers.Customer{ - created_at: "2023-10-14T17:52:43.000000Z", - id: "1406556", - status: "subscribed", - status_formatted: "Subscribed", - store_id: 48264, - test_mode: true, - updated_at: "2023-10-14T17:52:44.000000Z", city: nil, country: "ES", country_formatted: "Spain", + created_at: "2023-10-14T17:52:43.000000Z", email: "liza@example.com", + id: "1406556", mrr: 3600, mrr_formatted: "$36.00", name: "Liza May", region: nil, - total_revenue_currency: 0, - total_revenue_currency_formatted: "$0.00" - }, - %LemonEx.Customers.Customer{ - created_at: "2023-10-14T17:35:40.000000Z", - id: "1406493", status: "subscribed", status_formatted: "Subscribed", store_id: 48264, test_mode: true, - updated_at: "2023-10-27T07:32:25.000000Z", + total_revenue_currency: 0, + total_revenue_currency_formatted: "$0.00", + updated_at: "2023-10-14T17:52:44.000000Z", + urls: %{ + customer_portal: + "https://mystore.lemonsqueezy.com/billing?expires=1698446369&user=1412358&signature=fed8b8bea09639c923353eeec8a5295471803f15a3bebc703b7b66bd8ebab862" + } + }, + %LemonEx.Customers.Customer{ city: nil, country: nil, country_formatted: nil, + created_at: "2023-10-14T17:35:40.000000Z", email: "joe@example.com", + id: "1406493", mrr: 14400, mrr_formatted: "$144.00", name: "Joe Burns", region: nil, + status: "subscribed", + status_formatted: "Subscribed", + store_id: 48264, + test_mode: true, total_revenue_currency: 0, - total_revenue_currency_formatted: "$0.00" + total_revenue_currency_formatted: "$0.00", + updated_at: "2023-10-27T07:32:25.000000Z", + urls: %{ + customer_portal: + "https://mystore.lemonsqueezy.com/billing?expires=1698446369&user=1461055&signature=2b699e59adcf00238f503e722a6e8efbbba35849b47b71e6d94fcf7cce05b5f4" + } } ], links: %{ @@ -89,23 +97,27 @@ defmodule LemonEx.CustomersTest do { :ok, %LemonEx.Customers.Customer{ - created_at: "2023-10-14T17:52:43.000000Z", - id: "1406556", - status: "subscribed", - status_formatted: "Subscribed", - store_id: 48264, - test_mode: true, - updated_at: "2023-10-14T17:52:44.000000Z", city: nil, country: "ES", country_formatted: "Spain", + created_at: "2023-10-14T17:52:43.000000Z", email: "liza@example.com", + id: "1406556", mrr: 3600, mrr_formatted: "$36.00", name: "Liza May", region: nil, + status: "subscribed", + status_formatted: "Subscribed", + store_id: 48264, + test_mode: true, total_revenue_currency: 0, - total_revenue_currency_formatted: "$0.00" + total_revenue_currency_formatted: "$0.00", + updated_at: "2023-10-14T17:52:44.000000Z", + urls: %{ + customer_portal: + "https://mystore.lemonsqueezy.com/billing?expires=1698446663&user=1412358&signature=cb8dfe5c40dbec4af7082d8a1b082c07cc12d4ba0a91000d6280d2d5b9c2fdc3" + } } } end