diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..30e168de --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,28 @@ +ARG VARIANT="18" + +FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT} + +RUN apt-get update + +# Install Python +RUN apt-get install -y python3 python3-pip python-is-python3 + +# Install Ruby +RUN apt-get install -y ruby ruby-dev + +RUN gem install seamapi +RUN pip install seamapi --break-system-packages + +USER node +WORKDIR /home/node + +# Install dotnet +RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ + && chmod +x dotnet-install.sh \ + && ./dotnet-install.sh --channel 7.0 +ENV PATH="$PATH:/home/node/.dotnet" + +RUN mkdir -p .config/git \ + && echo ".vscode/*" >> .config/git/ignore \ + && echo "*.code-workspace" >> .config/git/ignore \ + && echo ".history/" >> .config/git/ignore diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..1e1ff02c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "API Docs", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "18" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "rebornix.Ruby", + "ms-dotnettools.csharp", + "ms-vsliveshare.vsliveshare", + "dbaeumer.vscode-eslint", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode" + ] + } + }, + "postCreateCommand": "cd /workspaces/api-docs/snippet-playground/javascript && npm i seamapi && cd /workspaces/api-docs/snippet-playground/csharp && ./init.sh", + "remoteUser": "node" +} diff --git a/snippet-playground/.editorconfig b/snippet-playground/.editorconfig new file mode 100644 index 00000000..79621be8 --- /dev/null +++ b/snippet-playground/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 diff --git a/snippet-playground/csharp/.gitignore b/snippet-playground/csharp/.gitignore new file mode 100644 index 00000000..76b00d13 --- /dev/null +++ b/snippet-playground/csharp/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!README.md +!Program.cs +!init.sh diff --git a/snippet-playground/csharp/Program.cs b/snippet-playground/csharp/Program.cs new file mode 100644 index 00000000..21a613ec --- /dev/null +++ b/snippet-playground/csharp/Program.cs @@ -0,0 +1,19 @@ +using Seam.Client; + +var r = new string(Enumerable.Range(0, 10).Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)]).ToArray()); + + +// Get a Seam Client +var seam = new SeamClient( + basePath: string.Format("https://{0}.fakeseamconnect.seam.vc", r), + apiToken: "seam_apikey1_token" +); + +var devices = seam.Devices.List(); + +foreach (var device in devices) +{ + // NOTE: in the future Console.WriteLine(device) will print + // something pretty, but currently it doesn't print pretty + Console.WriteLine(device.Properties.Name); +} diff --git a/snippet-playground/csharp/README.md b/snippet-playground/csharp/README.md new file mode 100644 index 00000000..7e94ae70 --- /dev/null +++ b/snippet-playground/csharp/README.md @@ -0,0 +1,3 @@ +# Running C# + +Just run `dotnet run`, the `Program.cs` file will be run diff --git a/snippet-playground/csharp/init.sh b/snippet-playground/csharp/init.sh new file mode 100755 index 00000000..d56c7e31 --- /dev/null +++ b/snippet-playground/csharp/init.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +set -e +set -u + +mv Program.cs Program.cs.bak +dotnet new console --force +dotnet add package seam +mv Program.cs.bak Program.cs diff --git a/snippet-playground/javascript/.gitignore b/snippet-playground/javascript/.gitignore new file mode 100644 index 00000000..6593ef7f --- /dev/null +++ b/snippet-playground/javascript/.gitignore @@ -0,0 +1,4 @@ +* +!.gitignore +!README.md +!main.mjs diff --git a/snippet-playground/javascript/README.md b/snippet-playground/javascript/README.md new file mode 100644 index 00000000..2b4c9ddf --- /dev/null +++ b/snippet-playground/javascript/README.md @@ -0,0 +1,3 @@ +# Running Javascript + +Just run `node main.mjs` diff --git a/snippet-playground/javascript/main.mjs b/snippet-playground/javascript/main.mjs new file mode 100755 index 00000000..5bfe0790 --- /dev/null +++ b/snippet-playground/javascript/main.mjs @@ -0,0 +1,12 @@ +#!/usr/bin/env node + +import Seam from "seamapi" + +const seam = new Seam({ + endpoint: `https://r${Math.random() + .toString(16) + .slice(2)}.fakeseamconnect.seam.vc`, + apiKey: "seam_apikey1_token", +}) + +console.log(await seam.devices.list()) diff --git a/snippet-playground/python/README.md b/snippet-playground/python/README.md new file mode 100644 index 00000000..576f9c9b --- /dev/null +++ b/snippet-playground/python/README.md @@ -0,0 +1,3 @@ +# Running Python + +Just run `python main.py` diff --git a/snippet-playground/python/main.py b/snippet-playground/python/main.py new file mode 100755 index 00000000..d4d63118 --- /dev/null +++ b/snippet-playground/python/main.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +import random +from seamapi import Seam +from pprint import pprint + +seam = Seam( + api_url=f"https://pws{random.randint(0,1e6)}{random.randint(0,1e6)}.fakeseamconnect.seam.vc", + api_key="seam_apikey1_token" +) + +pprint(seam.devices.list()) diff --git a/snippet-playground/ruby/README.md b/snippet-playground/ruby/README.md new file mode 100644 index 00000000..d69ed578 --- /dev/null +++ b/snippet-playground/ruby/README.md @@ -0,0 +1,3 @@ +# Running Ruby + +Just run `ruby main.rb` diff --git a/snippet-playground/ruby/main.rb b/snippet-playground/ruby/main.rb new file mode 100755 index 00000000..e2422ce2 --- /dev/null +++ b/snippet-playground/ruby/main.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +require 'seamapi' + +random_number = rand(1e6).to_i +api_url = "https://pws#{random_number}#{random_number}.fakeseamconnect.seam.vc" + +client = Seam::Client.new(base_uri: api_url, api_key: 'seam_apikey1_token') + +print client.devices.list