Current section
Files
Jump to
Current section
Files
src/types.erl
-module(types).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/types.gleam").
-export([shopify_client_decoder/0, shopify_error_decoder/0, image_decoder/0, money_decoder/0, price_range_decoder/0, product_option_decoder/0, selected_option_decoder/0, cost_decoder/0, shopify_cart_cost_decoder/0, cart_decoder/0, cart_item_edge_decoder/0, cart_item_connection_decoder/0, shopify_cart_decoder/0, product_variant_decoder/0, seo_decoder/0, product_decoder/0, products_decoder/0, product_variant_edges_decoder/0, product_variant_connection_decoder/0, shopify_product_decoder/0]).
-export_type([shopify_client/0, shopify_error/0, 'maybe'/1, connection/1, edge/1, image/0, price_range/0, money/0, product_option/0, selected_option/0, cost/0, shopify_cart_cost/0, cart/0, shopify_cart/0, merchandise/0, cart_product/0, cart_item/0, products/0, product/0, product_variant/0, seo/0, shopify_product/0]).
-type shopify_client() :: {shopify_client,
binary(),
binary(),
gleam@option:option(binary())}.
-type shopify_error() :: {shopify_error, integer(), binary()}.
-type 'maybe'(FUG) :: {'maybe', gleam@option:option(FUG)}.
-type connection(FUH) :: {connection, list(edge(FUH))}.
-type edge(FUI) :: {edge, FUI}.
-type image() :: {image, binary(), binary(), binary(), binary()}.
-type price_range() :: {price_range, money(), money()}.
-type money() :: {money, binary(), binary()}.
-type product_option() :: {product_option, binary(), binary(), list(binary())}.
-type selected_option() :: {selected_option, binary(), binary()}.
-type cost() :: {cost, money()}.
-type shopify_cart_cost() :: {shopify_cart_cost, money(), money(), money()}.
-type cart() :: {cart,
gleam@option:option(binary()),
binary(),
gleam@option:option(shopify_cart_cost()),
integer(),
list(cart_item())}.
-type shopify_cart() :: {shopify_cart,
gleam@option:option(binary()),
binary(),
gleam@option:option(shopify_cart_cost()),
connection(cart_item()),
integer()}.
-type merchandise() :: {merchandise,
binary(),
binary(),
list(selected_option()),
cart_product()}.
-type cart_product() :: {cart_product, binary(), binary(), binary(), image()}.
-type cart_item() :: {cart_item,
gleam@option:option(binary()),
integer(),
cost(),
merchandise()}.
-type products() :: {products, list(product())}.
-type product() :: {product,
binary(),
binary(),
boolean(),
binary(),
binary(),
binary(),
price_range(),
image(),
seo(),
list(binary()),
binary(),
list(product_variant()),
list(image())}.
-type product_variant() :: {product_variant,
binary(),
binary(),
boolean(),
selected_option(),
money()}.
-type seo() :: {seo, binary(), binary()}.
-type shopify_product() :: {shopify_product,
binary(),
binary(),
boolean(),
binary(),
binary(),
binary(),
price_range(),
connection(product_variant()),
image(),
connection(image()),
seo(),
list(binary()),
binary()}.
-file("src/types.gleam", 8).
-spec shopify_client_decoder() -> gleam@dynamic@decode:decoder(shopify_client()).
shopify_client_decoder() ->
gleam@dynamic@decode:field(
<<"key"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Key) ->
gleam@dynamic@decode:field(
<<"domain"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Domain) ->
gleam@dynamic@decode:field(
<<"api_version"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Api_version) ->
gleam@dynamic@decode:success(
{shopify_client, Key, Domain, Api_version}
)
end
)
end
)
end
).
-file("src/types.gleam", 19).
-spec shopify_error_decoder() -> gleam@dynamic@decode:decoder(shopify_error()).
shopify_error_decoder() ->
gleam@dynamic@decode:field(
<<"status"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Status) ->
gleam@dynamic@decode:field(
<<"body"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Body) ->
gleam@dynamic@decode:success({shopify_error, Status, Body})
end
)
end
).
-file("src/types.gleam", 41).
-spec image_decoder() -> gleam@dynamic@decode:decoder(image()).
image_decoder() ->
gleam@dynamic@decode:field(
<<"url"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Url) ->
gleam@dynamic@decode:field(
<<"alt_text"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Alt_text) ->
gleam@dynamic@decode:field(
<<"width"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Width) ->
gleam@dynamic@decode:field(
<<"height"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Height) ->
gleam@dynamic@decode:success(
{image, Url, Alt_text, Width, Height}
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 63).
-spec money_decoder() -> gleam@dynamic@decode:decoder(money()).
money_decoder() ->
gleam@dynamic@decode:field(
<<"amount"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Amount) ->
gleam@dynamic@decode:field(
<<"currency_code"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Currency_code) ->
gleam@dynamic@decode:success({money, Amount, Currency_code})
end
)
end
).
-file("src/types.gleam", 53).
-spec price_range_decoder() -> gleam@dynamic@decode:decoder(price_range()).
price_range_decoder() ->
gleam@dynamic@decode:field(
<<"max_variant_price"/utf8>>,
money_decoder(),
fun(Max_variant_price) ->
gleam@dynamic@decode:field(
<<"min_variant_price"/utf8>>,
money_decoder(),
fun(Min_variant_price) ->
gleam@dynamic@decode:success(
{price_range, Max_variant_price, Min_variant_price}
)
end
)
end
).
-file("src/types.gleam", 73).
-spec product_option_decoder() -> gleam@dynamic@decode:decoder(product_option()).
product_option_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"name"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Name) ->
gleam@dynamic@decode:field(
<<"values"/utf8>>,
gleam@dynamic@decode:list(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Values) ->
gleam@dynamic@decode:success(
{product_option, Id, Name, Values}
)
end
)
end
)
end
).
-file("src/types.gleam", 84).
-spec selected_option_decoder() -> gleam@dynamic@decode:decoder(selected_option()).
selected_option_decoder() ->
gleam@dynamic@decode:field(
<<"name"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Name) ->
gleam@dynamic@decode:field(
<<"value"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Value) ->
gleam@dynamic@decode:success({selected_option, Name, Value})
end
)
end
).
-file("src/types.gleam", 94).
-spec cost_decoder() -> gleam@dynamic@decode:decoder(cost()).
cost_decoder() ->
gleam@dynamic@decode:field(
<<"total_amount"/utf8>>,
money_decoder(),
fun(Total_amount) ->
gleam@dynamic@decode:success({cost, Total_amount})
end
).
-file("src/types.gleam", 107).
-spec shopify_cart_cost_decoder() -> gleam@dynamic@decode:decoder(shopify_cart_cost()).
shopify_cart_cost_decoder() ->
gleam@dynamic@decode:field(
<<"total_amount"/utf8>>,
money_decoder(),
fun(Total_amount) ->
gleam@dynamic@decode:field(
<<"subtotal_amount"/utf8>>,
money_decoder(),
fun(Subtotal_amount) ->
gleam@dynamic@decode:field(
<<"total_tax_amount"/utf8>>,
money_decoder(),
fun(Total_tax_amount) ->
gleam@dynamic@decode:success(
{shopify_cart_cost,
Total_amount,
Subtotal_amount,
Total_tax_amount}
)
end
)
end
)
end
).
-file("src/types.gleam", 190).
-spec cart_product_decoder() -> gleam@dynamic@decode:decoder(cart_product()).
cart_product_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"handle"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Handle) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"featured_image"/utf8>>,
image_decoder(),
fun(Featured_image) ->
gleam@dynamic@decode:success(
{cart_product,
Id,
Handle,
Title,
Featured_image}
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 175).
-spec merchandise_decoder() -> gleam@dynamic@decode:decoder(merchandise()).
merchandise_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"selected_options"/utf8>>,
gleam@dynamic@decode:list(selected_option_decoder()),
fun(Selected_options) ->
gleam@dynamic@decode:field(
<<"product"/utf8>>,
cart_product_decoder(),
fun(Product) ->
gleam@dynamic@decode:success(
{merchandise,
Id,
Title,
Selected_options,
Product}
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 207).
-spec cart_item_decoder() -> gleam@dynamic@decode:decoder(cart_item()).
cart_item_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Id) ->
gleam@dynamic@decode:field(
<<"quantity"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Quantity) ->
gleam@dynamic@decode:field(
<<"cost"/utf8>>,
cost_decoder(),
fun(Cost) ->
gleam@dynamic@decode:field(
<<"merchandise"/utf8>>,
merchandise_decoder(),
fun(Merchandise) ->
gleam@dynamic@decode:success(
{cart_item,
Id,
Quantity,
Cost,
Merchandise}
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 128).
-spec cart_decoder() -> gleam@dynamic@decode:decoder(cart()).
cart_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Id) ->
gleam@dynamic@decode:field(
<<"checkout_url"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Checkout_url) ->
gleam@dynamic@decode:field(
<<"cost"/utf8>>,
gleam@dynamic@decode:optional(
shopify_cart_cost_decoder()
),
fun(Cost) ->
gleam@dynamic@decode:field(
<<"total_quantity"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Total_quantity) ->
gleam@dynamic@decode:field(
<<"lines"/utf8>>,
gleam@dynamic@decode:list(
cart_item_decoder()
),
fun(Lines) ->
gleam@dynamic@decode:success(
{cart,
Id,
Checkout_url,
Cost,
Total_quantity,
Lines}
)
end
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 147).
-spec cart_item_edge_decoder() -> gleam@dynamic@decode:decoder(edge(cart_item())).
cart_item_edge_decoder() ->
gleam@dynamic@decode:field(
<<"node"/utf8>>,
cart_item_decoder(),
fun(Node) -> gleam@dynamic@decode:success({edge, Node}) end
).
-file("src/types.gleam", 152).
-spec cart_item_connection_decoder() -> gleam@dynamic@decode:decoder(connection(cart_item())).
cart_item_connection_decoder() ->
gleam@dynamic@decode:field(
<<"edges"/utf8>>,
gleam@dynamic@decode:list(cart_item_edge_decoder()),
fun(Edges) -> gleam@dynamic@decode:success({connection, Edges}) end
).
-file("src/types.gleam", 157).
-spec shopify_cart_decoder() -> gleam@dynamic@decode:decoder(shopify_cart()).
shopify_cart_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Id) ->
gleam@dynamic@decode:field(
<<"checkout_url"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Checkout_url) ->
gleam@dynamic@decode:field(
<<"cost"/utf8>>,
gleam@dynamic@decode:optional(
shopify_cart_cost_decoder()
),
fun(Cost) ->
gleam@dynamic@decode:field(
<<"lines"/utf8>>,
cart_item_connection_decoder(),
fun(Lines) ->
gleam@dynamic@decode:field(
<<"total_quantity"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(Total_quantity) ->
gleam@dynamic@decode:success(
{shopify_cart,
Id,
Checkout_url,
Cost,
Lines,
Total_quantity}
)
end
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 286).
-spec product_variant_decoder() -> gleam@dynamic@decode:decoder(product_variant()).
product_variant_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"available_for_sale"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Available_for_sale) ->
gleam@dynamic@decode:field(
<<"selected_options"/utf8>>,
selected_option_decoder(),
fun(Selected_options) ->
gleam@dynamic@decode:field(
<<"price"/utf8>>,
money_decoder(),
fun(Price) ->
gleam@dynamic@decode:success(
{product_variant,
Id,
Title,
Available_for_sale,
Selected_options,
Price}
)
end
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 308).
-spec seo_decoder() -> gleam@dynamic@decode:decoder(seo()).
seo_decoder() ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"description"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Description) ->
gleam@dynamic@decode:success({seo, Title, Description})
end
)
end
).
-file("src/types.gleam", 242).
-spec product_decoder() -> gleam@dynamic@decode:decoder(product()).
product_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"handle"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Handle) ->
gleam@dynamic@decode:field(
<<"available_for_sale"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Available_for_sale) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"description"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Description) ->
gleam@dynamic@decode:field(
<<"description_html"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Description_html) ->
gleam@dynamic@decode:field(
<<"price_range"/utf8>>,
price_range_decoder(),
fun(Price_range) ->
gleam@dynamic@decode:field(
<<"featured_image"/utf8>>,
image_decoder(),
fun(
Featured_image
) ->
gleam@dynamic@decode:field(
<<"seo"/utf8>>,
seo_decoder(
),
fun(Seo) ->
gleam@dynamic@decode:field(
<<"tags"/utf8>>,
gleam@dynamic@decode:list(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(
Tags
) ->
gleam@dynamic@decode:field(
<<"updated_at"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Updated_at
) ->
gleam@dynamic@decode:field(
<<"variants"/utf8>>,
gleam@dynamic@decode:list(
product_variant_decoder(
)
),
fun(
Variants
) ->
gleam@dynamic@decode:field(
<<"images"/utf8>>,
gleam@dynamic@decode:list(
image_decoder(
)
),
fun(
Images
) ->
gleam@dynamic@decode:success(
{product,
Id,
Handle,
Available_for_sale,
Title,
Description,
Description_html,
Price_range,
Featured_image,
Seo,
Tags,
Updated_at,
Variants,
Images}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/types.gleam", 219).
-spec products_decoder() -> gleam@dynamic@decode:decoder(products()).
products_decoder() ->
gleam@dynamic@decode:field(
<<"products"/utf8>>,
gleam@dynamic@decode:list(product_decoder()),
fun(Products) -> gleam@dynamic@decode:success({products, Products}) end
).
-file("src/types.gleam", 368).
-spec image_edges_decoder() -> gleam@dynamic@decode:decoder(edge(image())).
image_edges_decoder() ->
gleam@dynamic@decode:field(
<<"node"/utf8>>,
image_decoder(),
fun(Node) -> gleam@dynamic@decode:success({edge, Node}) end
).
-file("src/types.gleam", 363).
-spec image_connection_decoder() -> gleam@dynamic@decode:decoder(connection(image())).
image_connection_decoder() ->
gleam@dynamic@decode:field(
<<"edges"/utf8>>,
gleam@dynamic@decode:list(image_edges_decoder()),
fun(Edges) -> gleam@dynamic@decode:success({connection, Edges}) end
).
-file("src/types.gleam", 383).
-spec product_variant_edges_decoder() -> gleam@dynamic@decode:decoder(edge(product_variant())).
product_variant_edges_decoder() ->
gleam@dynamic@decode:field(
<<"node"/utf8>>,
product_variant_decoder(),
fun(Node) -> gleam@dynamic@decode:success({edge, Node}) end
).
-file("src/types.gleam", 373).
-spec product_variant_connection_decoder() -> gleam@dynamic@decode:decoder(connection(product_variant())).
product_variant_connection_decoder() ->
gleam@dynamic@decode:field(
<<"edges"/utf8>>,
gleam@dynamic@decode:list(product_variant_edges_decoder()),
fun(Edges) -> gleam@dynamic@decode:success({connection, Edges}) end
).
-file("src/types.gleam", 332).
-spec shopify_product_decoder() -> gleam@dynamic@decode:decoder(shopify_product()).
shopify_product_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"handle"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Handle) ->
gleam@dynamic@decode:field(
<<"available_for_sale"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Available_for_sale) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"description"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Description) ->
gleam@dynamic@decode:field(
<<"description_html"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Description_html) ->
gleam@dynamic@decode:field(
<<"price_range"/utf8>>,
price_range_decoder(),
fun(Price_range) ->
gleam@dynamic@decode:field(
<<"variants"/utf8>>,
product_variant_connection_decoder(
),
fun(Variants) ->
gleam@dynamic@decode:field(
<<"featured_image"/utf8>>,
image_decoder(
),
fun(
Featured_image
) ->
gleam@dynamic@decode:field(
<<"images"/utf8>>,
image_connection_decoder(
),
fun(
Images
) ->
gleam@dynamic@decode:field(
<<"seo"/utf8>>,
seo_decoder(
),
fun(
Seo
) ->
gleam@dynamic@decode:field(
<<"tags"/utf8>>,
gleam@dynamic@decode:list(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(
Tags
) ->
gleam@dynamic@decode:field(
<<"updated_at"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Updated_at
) ->
gleam@dynamic@decode:success(
{shopify_product,
Id,
Handle,
Available_for_sale,
Title,
Description,
Description_html,
Price_range,
Variants,
Featured_image,
Images,
Seo,
Tags,
Updated_at}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).