Skip to content

Commit 6df319c

Browse files
authored
feat: initial work
* generate types * basic working state * format script * install sdk generator * install .NET * no need for check install * generate nuspec * actually its csproj * move to just Seam * move Co.Seam -> Seam * package metadata * add publish script * switch publish order
1 parent 7a4157f commit 6df319c

File tree

95 files changed

+17062
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+17062
-191
lines changed

.eslintrc.json

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/actions/setup/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ runs:
3535
with:
3636
node-version: ${{ inputs.node_version }}
3737
registry-url: ${{ inputs.registry_url }}
38+
- name: Setup .NET
39+
uses: actions/setup-dotnet@v3
40+
with:
41+
dotnet-version: '7.0.x'
42+
- name: Setup CSharpier
43+
shell: bash
44+
run: dotnet tool install csharpier -g
3845
- name: Install dependencies
3946
if: inputs.install_dependencies == 'true'
4047
shell: bash

.github/workflows/check.yml

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -57,66 +57,6 @@ jobs:
5757
uses: ./.github/workflows/_build.yml
5858
secrets:
5959
node_auth_token: ${{ secrets.GH_TOKEN }}
60-
install:
61-
name: Install (Node.js v${{ matrix.node }} on ${{ matrix.os_name }})
62-
runs-on: ${{ matrix.os }}
63-
timeout-minutes: 30
64-
needs: build
65-
strategy:
66-
fail-fast: false
67-
matrix:
68-
os:
69-
- ubuntu-latest
70-
node:
71-
- '16'
72-
- '18'
73-
include:
74-
- os: ubuntu-latest
75-
os_name: Linux
76-
steps:
77-
- name: Setup Node.js
78-
uses: actions/setup-node@v3
79-
with:
80-
node-version: ${{ matrix.node }}
81-
- name: Download artifact
82-
uses: actions/download-artifact@v3
83-
with:
84-
name: ${{ needs.build.outputs.artifact_name }}
85-
path: .
86-
- name: Find packages
87-
uses: tj-actions/glob@v16
88-
id: packages
89-
with:
90-
files: '*.tgz'
91-
- name: Create package.json
92-
uses: DamianReeves/write-file-action@v1.2
93-
with:
94-
write-mode: overwrite
95-
path: package.json
96-
contents: |
97-
{"type":"module"}
98-
- name: Create index.js
99-
uses: DamianReeves/write-file-action@v1.2
100-
with:
101-
write-mode: overwrite
102-
path: index.js
103-
contents: |
104-
import '@seamapi/nextlove-sdk-csharp'
105-
- name: Install
106-
run: npm install --ignore-scripts --save ${{ steps.packages.outputs.paths }}
107-
env:
108-
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}
109-
- name: Rebuild Node.js modules
110-
shell: bash
111-
run: npm rebuild
112-
- name: Run postinstall script
113-
shell: bash
114-
run: npm run postinstall --if-present
115-
- name: Run prepare script
116-
shell: bash
117-
run: npm run prepare --if-present
118-
- name: Run
119-
run: node index.js
12060
typecheck:
12161
name: Typecheck (Node.js v${{ matrix.node }})
12262
runs-on: ubuntu-latest

.github/workflows/publish.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ jobs:
2424
uses: actions/checkout@v3
2525
with:
2626
fetch-depth: 0
27-
- name: Download artifact
28-
uses: actions/download-artifact@v3
29-
with:
30-
name: ${{ needs.build.outputs.artifact_name }}
31-
path: .
27+
- name: Package .NET module
28+
shell: bash
29+
run: npm run pack
3230
- name: Generate release notes
3331
id: changelog
3432
run: |
@@ -43,8 +41,13 @@ jobs:
4341
token: ${{ secrets.GH_TOKEN }}
4442
fail_on_unmatched_files: true
4543
prerelease: ${{ contains(github.ref_name, '-') }}
46-
files: '*.tgz'
44+
files: '*.nupkg'
4745
body_path: ${{ github.workspace }}/${{ steps.changelog.outputs.outfile }}
46+
- name: Publish .NET module to nuget
47+
shell: bash
48+
run: dotnet nuget push *.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
49+
env:
50+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
4851
github:
4952
name: GitHub Packages
5053
uses: ./.github/workflows/_publish.yml

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ $RECYCLE.BIN/
197197
.LSOverride
198198

199199
# Icon must end with two \r
200-
Icon
200+
Icon
201201

202202
# Thumbnails
203203
._*
@@ -217,3 +217,5 @@ Icon
217217
Network Trash Folder
218218
Temporary Items
219219
.apdisk
220+
221+
**/*.nupkg

examples/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/todo.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

output/csharp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
obj

output/csharp/csharp-testing.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E1444EB3-69DB-4DC7-B1DA-798B74419077}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seam", "src\Seam\Seam.csproj", "{9A33E809-F95A-4E65-A9F8-145A49A16EBC}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seam.Test", "src\Seam.Test\Seam.Test.csproj", "{B6EDC1FF-9838-4997-B98E-62B768430DF3}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{9A33E809-F95A-4E65-A9F8-145A49A16EBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{9A33E809-F95A-4E65-A9F8-145A49A16EBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{9A33E809-F95A-4E65-A9F8-145A49A16EBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{9A33E809-F95A-4E65-A9F8-145A49A16EBC}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{B6EDC1FF-9838-4997-B98E-62B768430DF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{B6EDC1FF-9838-4997-B98E-62B768430DF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{B6EDC1FF-9838-4997-B98E-62B768430DF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{B6EDC1FF-9838-4997-B98E-62B768430DF3}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{9A33E809-F95A-4E65-A9F8-145A49A16EBC} = {E1444EB3-69DB-4DC7-B1DA-798B74419077}
32+
{B6EDC1FF-9838-4997-B98E-62B768430DF3} = {E1444EB3-69DB-4DC7-B1DA-798B74419077}
33+
EndGlobalSection
34+
EndGlobal
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
namespace Seam.Test;
2+
3+
using Seam.Model;
4+
5+
public class UnitTest1 : SeamConnectTest
6+
{
7+
[Fact]
8+
public void TestGetDeviceList()
9+
{
10+
var device = seam.Devices
11+
.List()
12+
.First(d => d.DeviceType == Device.DeviceTypeEnum.AugustLock);
13+
14+
Assert.NotNull(device);
15+
Assert.Equal("Front Door", device.Properties.Name);
16+
}
17+
18+
[Fact]
19+
public async void TestGetDeviceListAsync()
20+
{
21+
var device = (await seam.Devices.ListAsync()).First(
22+
d => d.DeviceType == Device.DeviceTypeEnum.AugustLock
23+
);
24+
25+
Assert.NotNull(device);
26+
Assert.Equal("Front Door", device.Properties.Name);
27+
}
28+
29+
[Fact]
30+
public void TestCreateAccessCode()
31+
{
32+
var device = seam.Devices
33+
.List()
34+
.First(d => d.DeviceType == Device.DeviceTypeEnum.AugustLock);
35+
36+
var access_code = seam.AccessCodes.Create(deviceId: device.DeviceId, code: "1234");
37+
38+
Assert.Equal(AccessCode.StatusEnum.Setting, access_code.Status);
39+
Assert.Equal("1234", access_code.Code);
40+
}
41+
42+
[Fact]
43+
public async void TestCreateAccessCodeAsync()
44+
{
45+
var device = seam.Devices
46+
.List()
47+
.First(d => d.DeviceType == Device.DeviceTypeEnum.AugustLock);
48+
49+
var access_code = await seam.AccessCodes.CreateAsync(
50+
deviceId: device.DeviceId,
51+
code: "1234"
52+
);
53+
54+
Assert.Equal(AccessCode.StatusEnum.Setting, access_code.Status);
55+
Assert.Equal("1234", access_code.Code);
56+
}
57+
58+
[Fact]
59+
public void TestLockDoor()
60+
{
61+
var device = seam.Devices
62+
.List()
63+
.First(d => d.DeviceType == Device.DeviceTypeEnum.AugustLock);
64+
65+
var action_attempt = seam.Locks.LockDoor(deviceId: device.DeviceId);
66+
67+
Assert.IsType<ActionAttemptPending>(action_attempt);
68+
Assert.Equal("LOCK_DOOR", (action_attempt as ActionAttemptPending)!.ActionType);
69+
}
70+
71+
[Fact]
72+
public async void TestLockDoorAsync()
73+
{
74+
var device = seam.Devices
75+
.List()
76+
.First(d => d.DeviceType == Device.DeviceTypeEnum.AugustLock);
77+
78+
var action_attempt = await seam.Locks.LockDoorAsync(deviceId: device.DeviceId);
79+
80+
Assert.IsType<ActionAttemptPending>(action_attempt);
81+
Assert.Equal("LOCK_DOOR", (action_attempt as ActionAttemptPending)!.ActionType);
82+
}
83+
}

0 commit comments

Comments
 (0)