diff --git a/config.yml b/config.yml index 08720ac..54da755 100644 --- a/config.yml +++ b/config.yml @@ -43,6 +43,7 @@ interfaces: description: "Get a list of changes to an account." http_method: "GET" path: "/accounts/:account_id/changes" + response_schema: "AccountChanges" arguments: - "account_id" parameters: @@ -56,6 +57,7 @@ interfaces: description: "Get candlestick data for an instrument." http_method: "GET" path: "/instruments/:instrument/candles" + response_schema: "ListCandles" arguments: - "instrument" parameters: @@ -97,17 +99,7 @@ interfaces: type: "string" doc: "The day of the week used for granularities that have weekly alignment." default: "Friday" - - function_name: "list_order_book" - description: "Get order book data for an instrument." - http_method: "GET" - path: "/instruments/:instrument/orderBook" - arguments: - - "instrument" - parameters: - - name: "time" - type: "string" - doc: "The time of the snapshot to fetch using either RFC 3339 or Unix format. If not specified, then the most recent snapshot is fetched." - - function_name: "list_position_book" + description: "Get position book data for an instrument." http_method: "GET" path: "/instruments/:instrument/positionBook" @@ -131,6 +123,7 @@ interfaces: description: "Get a list of orders for an account." http_method: "GET" path: "/accounts/:account_id/orders" + response_schema: "ListOrders" arguments: - "account_id" parameters: @@ -154,12 +147,14 @@ interfaces: description: "Get a list of pending orders for an account." http_method: "GET" path: "/accounts/:account_id/pendingOrders" + response_schema: "ListPendingOrders" arguments: - "account_id" - function_name: "find" description: "Get details for a single order in an account." http_method: "GET" path: "/accounts/:account_id/orders/:order_id" + response_schema: "FindOrder" arguments: - "account_id" - "order_id" diff --git a/lib/models/response/accounts/order.ex b/lib/models/response/order.ex similarity index 100% rename from lib/models/response/accounts/order.ex rename to lib/models/response/order.ex diff --git a/lib/models/response/orders/find_order.ex b/lib/models/response/orders/find_order.ex new file mode 100644 index 0000000..ea94798 --- /dev/null +++ b/lib/models/response/orders/find_order.ex @@ -0,0 +1,22 @@ +defmodule ExOanda.FindOrder do + @moduledoc """ + Schema for Oanda find order response. + """ + + use TypedEctoSchema + import Ecto.Changeset + + @primary_key false + + typed_embedded_schema do + embeds_one :order, Order + field(:last_transaction_id, :string) + end + + @doc false + def changeset(struct, params) do + struct + |> cast(params, [:last_transaction_id]) + |> cast_embed(:order) + end +end diff --git a/lib/models/response/orders/list_orders.ex b/lib/models/response/orders/list_orders.ex new file mode 100644 index 0000000..f03b098 --- /dev/null +++ b/lib/models/response/orders/list_orders.ex @@ -0,0 +1,23 @@ +defmodule ExOanda.ListOrders do + @moduledoc """ + Schema for Oanda list orders response. + """ + + use TypedEctoSchema + import Ecto.Changeset + alias ExOanda.Order + + @primary_key false + + typed_embedded_schema do + embeds_many :orders, Order + field(:last_transaction_id, :string) + end + + @doc false + def changeset(struct, params) do + struct + |> cast(params, [:last_transaction_id]) + |> cast_embed(:orders) + end +end diff --git a/lib/models/response/orders/list_pending_orders.ex b/lib/models/response/orders/list_pending_orders.ex new file mode 100644 index 0000000..32f0906 --- /dev/null +++ b/lib/models/response/orders/list_pending_orders.ex @@ -0,0 +1,23 @@ +defmodule ExOanda.ListPendingOrders do + @moduledoc """ + Schema for Oanda list pending orders response. + """ + + use TypedEctoSchema + import Ecto.Changeset + alias ExOanda.Order + + @primary_key false + + typed_embedded_schema do + embeds_many :orders, Order + field(:last_transaction_id, :string) + end + + @doc false + def changeset(struct, params) do + struct + |> cast(params, [:last_transaction_id]) + |> cast_embed(:orders) + end +end