# File generated from Twilio's OpenAPI spec — do not edit manually defmodule Twilio.Sync.V1.Service.DocumentService do @moduledoc """ Sync Document objects Operations: `list`, `create`, `fetch`, `update`, `delete` """ alias Twilio.Client alias Twilio.Deserializer @doc """ Operation: `ListDocument` | Tags: SyncV1Document """ @spec list(Client.t(), String.t(), map(), keyword()) :: {:ok, Twilio.Page.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def list(client, service_sid, params \\ %{}, opts \\ []) do case Client.request(client, :get, "/v1/Services/#{service_sid}/Documents", params: params, opts: opts, base_url: "https://sync.twilio.com" ) do {:ok, data} -> page = Twilio.Page.from_response(data, "documents") {:ok, %{ page | items: Deserializer.deserialize_list( page.items, Twilio.Resources.Sync.V1.Service.Document ) }} error -> error end end @doc "Stream: (lazy auto-pagination)." @spec stream(Client.t(), String.t(), map(), keyword()) :: Enumerable.t() def stream(client, service_sid, params \\ %{}, opts \\ []) do Twilio.Page.stream( fn page_opts -> list(client, service_sid, Map.merge(params, page_opts), opts) end, "documents" ) end @doc """ Operation: `CreateDocument` | Tags: SyncV1Document ## Optional Parameters | Parameter | Type | Description | |-----------|------|-------------| # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `Data` | string | A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. | # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `Ttl` | integer | How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (the Sync Document's time-to-live). | | `UniqueName` | string | An application-defined string that uniquely identifies the Sync Document | """ @spec create(Client.t(), String.t(), map(), keyword()) :: {:ok, Twilio.Resources.Sync.V1.Service.Document.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def create(client, service_sid, params \\ %{}, opts \\ []) do with {:ok, data} <- Client.request(client, :post, "/v1/Services/#{service_sid}/Documents", params: params, opts: opts, base_url: "https://sync.twilio.com", content_type: :form ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Sync.V1.Service.Document)} end end @doc """ Operation: `FetchDocument` | Tags: SyncV1Document """ @spec fetch(Client.t(), String.t(), String.t(), keyword()) :: {:ok, Twilio.Resources.Sync.V1.Service.Document.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def fetch(client, service_sid, sid, opts \\ []) do with {:ok, data} <- Client.request(client, :get, "/v1/Services/#{service_sid}/Documents/#{sid}", opts: opts, base_url: "https://sync.twilio.com" ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Sync.V1.Service.Document)} end end @doc """ Operation: `UpdateDocument` | Tags: SyncV1Document ## Optional Parameters | Parameter | Type | Description | |-----------|------|-------------| # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `Data` | string | A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length. | # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength | `Ttl` | integer | How long, [in seconds](https://www.twilio.com/docs/sync/limits#sync-payload-limits), before the Sync Document expires and is deleted (time-to-live). | """ @spec update(Client.t(), String.t(), String.t(), map(), keyword()) :: {:ok, Twilio.Resources.Sync.V1.Service.Document.t()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def update(client, service_sid, sid, params \\ %{}, opts \\ []) do with {:ok, data} <- Client.request(client, :post, "/v1/Services/#{service_sid}/Documents/#{sid}", params: params, opts: opts, base_url: "https://sync.twilio.com", content_type: :form ) do {:ok, Deserializer.deserialize(data, Twilio.Resources.Sync.V1.Service.Document)} end end @doc """ Operation: `DeleteDocument` | Tags: SyncV1Document """ @spec delete(Client.t(), String.t(), String.t(), keyword()) :: {:ok, map()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()} def delete(client, service_sid, sid, opts \\ []) do Client.request(client, :delete, "/v1/Services/#{service_sid}/Documents/#{sid}", opts: opts, base_url: "https://sync.twilio.com" ) end end