@voxgig/create-sdkgen 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +2 -0
  2. package/bin/run-create-sdkgen.js +265 -1
  3. package/bin/run-create-sdkgen.js~ +1 -0
  4. package/dist/create-sdkgen.d.ts +2 -0
  5. package/dist/create-sdkgen.js +51 -2
  6. package/dist/create-sdkgen.js.map +1 -1
  7. package/dist/standard/ModelSdk.d.ts +2 -0
  8. package/dist/standard/ModelSdk.js +71 -0
  9. package/dist/standard/ModelSdk.js.map +1 -0
  10. package/dist/standard/Root.d.ts +2 -0
  11. package/dist/standard/Root.js +76 -0
  12. package/dist/standard/Root.js.map +1 -0
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/package.json +9 -6
  15. package/src/create-sdkgen.ts +71 -3
  16. package/src/standard/ModelSdk.ts +92 -0
  17. package/src/standard/ModelSdk.ts~ +1 -0
  18. package/src/standard/Root.ts +107 -0
  19. package/src/standard/Root.ts~ +3 -0
  20. package/tm/standard/.env.local +2 -0
  21. package/tm/standard/build/sdk.js +25 -0
  22. package/tm/standard/def/DEFINITION.md +2 -0
  23. package/tm/standard/model/.model-config/model-config.jsonic +13 -0
  24. package/tm/standard/model/go.jsonic +6 -0
  25. package/tm/standard/model/js.jsonic +6 -0
  26. package/tm/standard/model/php.jsonic +6 -0
  27. package/tm/standard/model/py.jsonic +7 -0
  28. package/tm/standard/model/rb.jsonic +6 -0
  29. package/tm/standard/model/sdk.jsonic.off +60 -0
  30. package/tm/standard/package.json +30 -0
  31. package/tm/standard/src/Root.ts +60 -0
  32. package/tm/standard/src/go/Entity_go.ts +226 -0
  33. package/tm/standard/src/go/MainEntity_go.ts +26 -0
  34. package/tm/standard/src/go/Main_go.ts +168 -0
  35. package/tm/standard/src/go/Quick_go.ts +108 -0
  36. package/tm/standard/src/go/ReadmeInstall_go.ts +19 -0
  37. package/tm/standard/src/go/ReadmeQuick_go.ts +45 -0
  38. package/tm/standard/src/go/TestAcceptEntity_go.ts +219 -0
  39. package/tm/standard/src/go/TestAccept_go.ts +38 -0
  40. package/tm/standard/src/go/TestEntity_go.ts +79 -0
  41. package/tm/standard/src/go/TestMain_go.ts +61 -0
  42. package/tm/standard/src/go/Test_go.ts +20 -0
  43. package/tm/standard/src/js/Entity_js.ts +135 -0
  44. package/tm/standard/src/js/MainEntity_js.ts +22 -0
  45. package/tm/standard/src/js/Main_js.ts +128 -0
  46. package/tm/standard/src/js/Quick_js.ts +72 -0
  47. package/tm/standard/src/js/ReadmeInstall_js.ts +19 -0
  48. package/tm/standard/src/js/ReadmeQuick_js.ts +27 -0
  49. package/tm/standard/src/js/TestAcceptEntity_js.ts +101 -0
  50. package/tm/standard/src/js/TestAccept_js.ts +60 -0
  51. package/tm/standard/src/js/TestEntity_js.ts +24 -0
  52. package/tm/standard/src/js/TestMain_js.ts +123 -0
  53. package/tm/standard/src/js/Test_js.ts +24 -0
  54. package/tm/standard/src/php/Entity_php.ts +97 -0
  55. package/tm/standard/src/php/MainEntity_php.ts +43 -0
  56. package/tm/standard/src/php/Main_php.ts +50 -0
  57. package/tm/standard/src/php/Quick_php.ts +59 -0
  58. package/tm/standard/src/php/TestAcceptEntity_php.ts +81 -0
  59. package/tm/standard/src/php/TestAccept_php.ts +33 -0
  60. package/tm/standard/src/php/TestEntity_php.ts +64 -0
  61. package/tm/standard/src/php/TestMain_php.ts +120 -0
  62. package/tm/standard/src/php/Test_php.ts +21 -0
  63. package/tm/standard/src/py/Entity_py.ts +98 -0
  64. package/tm/standard/src/py/MainEntity_py.ts +19 -0
  65. package/tm/standard/src/py/Main_py.ts +211 -0
  66. package/tm/standard/src/py/Quick_py.ts +133 -0
  67. package/tm/standard/src/py/TestAcceptEntity_py.ts +47 -0
  68. package/tm/standard/src/py/TestAccept_py.ts +77 -0
  69. package/tm/standard/src/py/TestEntity_py.ts +50 -0
  70. package/tm/standard/src/py/TestMain_py.ts +103 -0
  71. package/tm/standard/src/py/Test_py.ts +28 -0
  72. package/tm/standard/src/rb/Client_rb.ts +142 -0
  73. package/tm/standard/src/rb/Entity_rb.ts +153 -0
  74. package/tm/standard/src/rb/Error_rb.ts +56 -0
  75. package/tm/standard/src/rb/MainEntity_rb.ts +16 -0
  76. package/tm/standard/src/rb/Main_rb.ts +55 -0
  77. package/tm/standard/src/rb/Quick_rb.ts +65 -0
  78. package/tm/standard/src/rb/ReadmeInstall_rb.ts +19 -0
  79. package/tm/standard/src/rb/ReadmeQuick_rb.ts +30 -0
  80. package/tm/standard/src/rb/TestAcceptEntity_rb.ts +83 -0
  81. package/tm/standard/src/rb/TestAccept_rb.ts +45 -0
  82. package/tm/standard/src/rb/TestEntity_rb.ts +82 -0
  83. package/tm/standard/src/rb/TestMain_rb.ts +67 -0
  84. package/tm/standard/src/rb/Test_rb.ts +27 -0
  85. package/tm/standard/src/tsconfig.json +15 -0
  86. package/tm/standard/tm/go/.env.example +2 -0
  87. package/tm/standard/tm/go/LICENSE +22 -0
  88. package/tm/standard/tm/go/go.mod +5 -0
  89. package/tm/standard/tm/go/go.sum +2 -0
  90. package/tm/standard/tm/js/LICENSE +22 -0
  91. package/tm/standard/tm/js/package.json +17 -0
  92. package/tm/standard/tm/php/LICENSE +22 -0
  93. package/tm/standard/tm/py/LICENSE +22 -0
  94. package/tm/standard/tm/py/MANIFEST.in +4 -0
  95. package/tm/standard/tm/py/Makefile +14 -0
  96. package/tm/standard/tm/py/pyproject.toml +4 -0
  97. package/tm/standard/tm/py/pytest.ini +3 -0
  98. package/tm/standard/tm/py/requirements.txt +4 -0
  99. package/tm/standard/tm/py/setup.cfg +2 -0
  100. package/tm/standard/tm/py/setup.py +82 -0
  101. package/tm/standard/tm/rb/.rspec +1 -0
  102. package/tm/standard/tm/rb/Gemfile +21 -0
  103. package/tm/standard/tm/rb/LICENSE +22 -0
  104. package/tm/standard/tm/rb/Rakefile +6 -0
  105. package/tm/standard/tm/rb/spec/spec_helper.rb +22 -0
  106. package/tm/standard/tm/rb/tm.gemspec +39 -0
@@ -0,0 +1,103 @@
1
+
2
+ import { cmp, each, File, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ import { TestEntity } from './TestEntity_py'
6
+
7
+
8
+ const TestMain = cmp(function TestMain(props: any) {
9
+ const { build } = props
10
+ const { model } = props.ctx$
11
+
12
+ File({ name: 'Fetch.' + build.extension }, () => {
13
+
14
+ Content(`
15
+ import json
16
+
17
+ def fetch(url, config):
18
+ parts = url.split("/")
19
+ # print('parts: ', parts)
20
+ entname = None
21
+ entid = None
22
+
23
+ try:
24
+ # TODO: PARTS DEPEND ON THE SWAGGERS: add logic
25
+ # A utility for url parsing is needed
26
+ entname = parts[1]
27
+ entid = parts[2]
28
+ except IndexError:
29
+ pass
30
+
31
+ data = config.get("body") or {}
32
+ method = config.get("method") or "GET"
33
+
34
+ req = {
35
+ "url": url,
36
+ "parts": parts,
37
+ "entname": entname,
38
+ "entid": entid,
39
+ "method": method,
40
+ "data": data,
41
+ }
42
+
43
+ json_data = None
44
+ if "GET" == method:
45
+ if None != entid:
46
+ json_data = {"id": entid, "title": "T01"}
47
+ else:
48
+ json_data = {
49
+ "name": entname,
50
+ "list": [{"id": "n01", "title": "N01"}, {"id": "n02", "title": "N02"}],
51
+ }
52
+ elif "PUT" == method or "POST" == method:
53
+ if None != entid:
54
+ json_data = { "id": entid, "title": data.get('title') }
55
+ else:
56
+ json_data = { "id": "n03", "title": data.get('title') or "T03" }
57
+
58
+ return {"req": req, "status": 200, "json": json_data}
59
+ `)
60
+
61
+ })
62
+
63
+ File({ name: 'test_' + model.name + '_sdk.' + build.extension }, () => {
64
+
65
+ Content(`
66
+ import json
67
+
68
+ from dotenv import dotenv_values
69
+
70
+ import ${model.name}_sdk
71
+
72
+ from ${model.name}_sdk import Config
73
+
74
+ from Fetch import fetch
75
+
76
+
77
+ def makeClient(config = {}):
78
+ client = ${model.name}_sdk.${model.Name}SDK.make(Config(
79
+ endpoint=config.get('${model.NAME}_ENDPOINT'),
80
+ apikey=config.get('${model.NAME}_APIKEY'),
81
+ fetch=fetch
82
+ ))
83
+ return client
84
+
85
+ `)
86
+ Content(`
87
+ def test_happy():
88
+ config = dotenv_values('.env.test.local')
89
+ client = makeClient(config)
90
+ `)
91
+ each(model.main.sdk.entity, (entity: any) => {
92
+ TestEntity({ model, build, entity })
93
+ })
94
+
95
+
96
+ })
97
+ })
98
+
99
+
100
+ export {
101
+ TestMain
102
+ }
103
+
@@ -0,0 +1,28 @@
1
+ import { cmp, File, Content, Folder } from '@voxgig/sdkgen'
2
+
3
+
4
+ import { Quick } from './Quick_py'
5
+ import { TestMain } from './TestMain_py'
6
+ import { TestAccept } from './TestAccept_py'
7
+
8
+
9
+ const Test = cmp(function Test_(props: any) {
10
+ const { build } = props
11
+
12
+ Folder({ name: 'tests' }, () => {
13
+
14
+ Quick({ build })
15
+ TestMain({ build })
16
+
17
+ Folder({ name: 'accept' }, () => {
18
+ TestAccept({ build })
19
+ })
20
+
21
+ })
22
+
23
+ })
24
+
25
+
26
+ export {
27
+ Test
28
+ }
@@ -0,0 +1,142 @@
1
+ import {
2
+ cmp,
3
+ each,
4
+ camelify,
5
+ File,
6
+ Content,
7
+ Folder,
8
+ snakify,
9
+ } from '@voxgig/sdkgen';
10
+
11
+
12
+ import { MainEntity } from './MainEntity_rb'
13
+
14
+
15
+ const Client = cmp(async function Client(props: any) {
16
+ const { build } = props;
17
+ const { model } = props.ctx$;
18
+
19
+ const entity = model.main.sdk.entity;
20
+
21
+ Folder({ name: "lib" }, () => {
22
+ Folder({ name: snakify(model.Name) + "_sdk" }, () => {
23
+ File({ name: "client.rb" }, () => {
24
+ Content(`
25
+ # ${model.Name} ${build.Name} SDK
26
+
27
+ require 'json'
28
+ require 'net/http'
29
+ `);
30
+
31
+ each(entity, (entity: any) => {
32
+ entity.Name = camelify(entity.name);
33
+ Content(`
34
+ require_relative './${snakify(entity.Name)}'
35
+ `);
36
+ });
37
+
38
+ const validate_options = each(build.options).reduce(
39
+ (a: string, opt: any) =>
40
+ a +
41
+ ("String" === opt.kind
42
+ ? ` required('String','${opt.name}', @options)\n`
43
+ : ""),
44
+ ""
45
+ );
46
+
47
+ Content(`
48
+ module ${model.Name}SDK
49
+ class Client
50
+ attr_reader :options
51
+
52
+ def initialize(opts = {})
53
+ @options = ${model.Name}SDK.options.merge(opts)
54
+ ${validate_options}
55
+ @options[:fetch] ||= ->(url, method, apikey, body = nil) {
56
+ default_fetch(url, method, apikey, body)
57
+ }
58
+ end
59
+
60
+ def endpoint(op, ent)
61
+ data = ent.data
62
+ definition = ent.def
63
+ base_url = "#{options[:endpoint]}/#{definition[:name]}"
64
+
65
+ if (op == 'load' || op == 'remove') && data[:id] != nil
66
+ "#{base_url}/#{data[:id]}"
67
+ else
68
+ base_url
69
+ end
70
+ end
71
+
72
+ def method(op, ent)
73
+ ent.nil? && op == 'save' ? 'create' : op
74
+ {
75
+ 'create' => 'POST',
76
+ 'save' => 'PUT',
77
+ 'load' => 'GET',
78
+ 'list' => 'GET',
79
+ 'remove' => 'DELETE'
80
+ }[op]
81
+ end
82
+
83
+ def body(op, ent)
84
+ msg = ent.data.dup
85
+ JSON.generate(msg)
86
+ end
87
+
88
+ `);
89
+
90
+ each(entity, (entity: any) => {
91
+ MainEntity({ model, build, entity });
92
+ });
93
+
94
+ Content(`
95
+
96
+ private
97
+
98
+ def required(type, name, options)
99
+ val = options[name.to_sym]
100
+ unless val.is_a?(Object.const_get(type))
101
+ raise ArgumentError, "${model.Name}SDK: Invalid option: #{name}=#{val}: must be of type #{type}"
102
+ end
103
+ end
104
+
105
+ def default_fetch(url, method, apikey, body = nil)
106
+ uri = URI(url)
107
+ http = Net::HTTP.new(uri.host, uri.port)
108
+ http.use_ssl = (uri.scheme == "https")
109
+
110
+ request = build_request(uri, method, apikey, body)
111
+
112
+ begin
113
+ response = http.request(request)
114
+ response
115
+ rescue SocketError => e
116
+ raise ${model.Name}NetworkError.new("Network unreachable: #{e.message}")
117
+ rescue Timeout::Error => e
118
+ raise ${model.Name}TimeoutError.new("Request timed out: #{e.message}")
119
+ rescue StandardError => e
120
+ raise ${model.Name}SDKError.new("Unexpected error: #{e.message}")
121
+ end
122
+ end
123
+
124
+ def build_request(uri, method, apikey, body)
125
+ request = Net::HTTP.const_get(method.capitalize).new(uri)
126
+ request['Content-Type'] = 'application/json'
127
+ request['Authorization'] = "Bearer #{apikey}"
128
+ request.body = body if %i[post put].include?(method.downcase.to_sym) && body
129
+ request
130
+ end
131
+ end
132
+ end
133
+
134
+ `);
135
+ });
136
+ });
137
+ });
138
+ });
139
+
140
+
141
+ export { Client };
142
+
@@ -0,0 +1,153 @@
1
+ import {
2
+ cmp,
3
+ File,
4
+ Content,
5
+ Folder,
6
+ snakify,
7
+ } from '@voxgig/sdkgen';
8
+
9
+ const Entity = cmp(function Entity(props: any) {
10
+ const { build, entity } = props;
11
+ const { model } = props.ctx$;
12
+
13
+ Folder({ name: "lib" }, () => {
14
+ Folder({ name: snakify(model.Name) + "_sdk" }, () => {
15
+ File({ name: snakify(entity.Name) + ".rb" }, () => {
16
+ Content(`
17
+ # ${model.Name} ${build.Name} ${entity.Name}
18
+
19
+ require 'json'
20
+ require 'net/http'
21
+
22
+ class ${entity.Name}
23
+ attr_accessor :sdk, :def, :data
24
+
25
+ def initialize(sdk, data = nil)
26
+ @sdk = sdk
27
+ @def = {
28
+ name: "${entity.name}"
29
+ }
30
+ @data = data
31
+ end
32
+
33
+ def handle_result(op, res, spec)
34
+ status = res.code.to_i
35
+
36
+ case status
37
+ when 200
38
+ json = JSON.parse(res.body, symbolize_names: true)
39
+ yield(json)
40
+ when 400
41
+ raise ${model.Name}BadRequestError.new("Bad request", status, res.body)
42
+ when 401
43
+ raise ${model.Name}AuthenticationError.new("Authentication failed", status, res.body)
44
+ when 404
45
+ raise ${model.Name}NotFoundError.new("Resource not found", status, res.body)
46
+ when 429
47
+ raise ${model.Name}RateLimitError.new("Rate limit exceeded", status, res.body)
48
+ when 400..499
49
+ raise ${model.Name}ClientError.new("Client error", status, res.body)
50
+ when 500..599
51
+ raise ${model.Name}ServerError.new("Server error", status, res.body)
52
+ else
53
+ raise ${model.Name}SDKError.new("HTTP-ERROR: #{op}: ${entity.name}: #{status}", status, res.body)
54
+ end
55
+ end
56
+
57
+ def save(data)
58
+ op = 'save'
59
+ self.data = data
60
+ # TODO: validate data
61
+
62
+ body = sdk.body('save', self)
63
+ method = sdk.method('save', self)
64
+ url = sdk.endpoint('save', self)
65
+
66
+ spec = {}
67
+ res = sdk.options[:fetch].call(url, method, sdk.options[:apikey], body)
68
+
69
+ handle_result(op, res, spec) do |json|
70
+ self.data = json
71
+ self
72
+ end
73
+ end
74
+
75
+ def create(data)
76
+ op = 'create'
77
+ self.data = data
78
+
79
+ body = sdk.body('create', self)
80
+ method = sdk.method('create', self)
81
+ url = sdk.endpoint('create', self)
82
+
83
+ spec = {}
84
+ res = sdk.options[:fetch].call(url, method, sdk.options[:apikey], body)
85
+
86
+ handle_result(op, res, spec) do |json|
87
+ self.data = json
88
+ self
89
+ end
90
+ end
91
+
92
+ def load(data)
93
+ op = 'load'
94
+ self.data = data
95
+ # TODO: check if data.id is defined
96
+
97
+ body = sdk.body('load', self)
98
+ method = sdk.method('load', self)
99
+ url = sdk.endpoint('load', self)
100
+
101
+ spec = {}
102
+ res = sdk.options[:fetch].call(url, method, sdk.options[:apikey], body)
103
+
104
+ handle_result(op, res, spec) do |json|
105
+ self.data = json
106
+ self
107
+ end
108
+ end
109
+
110
+ def list(data = {})
111
+ op = 'list'
112
+ self.data = data
113
+ # TODO: check if data.id is defined
114
+
115
+ body = sdk.body('load', self)
116
+ method = sdk.method('load', self)
117
+ url = sdk.endpoint('load', self)
118
+
119
+ spec = {}
120
+ res = sdk.options[:fetch].call(url, method, sdk.options[:apikey], body)
121
+
122
+ handle_result(op, res, spec) do |json|
123
+ return json[:list].map { |data| sdk.${entity.Name}(data) }
124
+ end
125
+ end
126
+
127
+ def remove(data)
128
+ op = 'remove'
129
+ self.data = data
130
+
131
+ body = sdk.body('remove', self)
132
+ method = sdk.method('remove', self)
133
+ url = sdk.endpoint('remove', self)
134
+
135
+ spec = {}
136
+ res = sdk.options[:fetch].call(url, method, sdk.options[:apikey], body)
137
+
138
+ handle_result(op, res, spec) do |json|
139
+ self.data = json
140
+ self
141
+ end
142
+ end
143
+
144
+ end
145
+
146
+ `);
147
+ });
148
+ });
149
+ });
150
+ });
151
+
152
+
153
+ export { Entity };
@@ -0,0 +1,56 @@
1
+ import {
2
+ cmp,
3
+ File,
4
+ Content,
5
+ Folder,
6
+ snakify,
7
+ } from '@voxgig/sdkgen';
8
+
9
+ const Error = cmp(function Error(props: any) {
10
+ const { build, entity } = props;
11
+ const { model } = props.ctx$;
12
+
13
+ Folder({ name: "lib" }, () => {
14
+ Folder({ name: snakify(model.Name) + "_sdk" }, () => {
15
+ File({ name: "errors.rb" }, () => {
16
+ Content(`
17
+
18
+ module ${model.Name}SDK
19
+ class ${model.Name}SDKError < StandardError
20
+ attr_reader :status, :body, :response
21
+
22
+ def initialize(message, status = nil, body = nil, response = nil)
23
+ super(message)
24
+ @status = status
25
+ @body = body
26
+ @response = response
27
+ end
28
+
29
+ def to_s
30
+ "#{message} (status: #{status || 'N/A'}, response body: #{body || 'N/A'})"
31
+ end
32
+ end
33
+
34
+ # Network errors
35
+ class ${model.Name}NetworkError < ${model.Name}SDKError; end
36
+ class ${model.Name}TimeoutError < ${model.Name}SDKError; end
37
+
38
+ # API errors
39
+ class ${model.Name}BadRequestError < ${model.Name}SDKError; end
40
+ class ${model.Name}AuthenticationError < ${model.Name}SDKError; end
41
+ class ${model.Name}NotFoundError < ${model.Name}SDKError; end
42
+ class ${model.Name}RateLimitError < ${model.Name}SDKError; end
43
+ class ${model.Name}ClientError < ${model.Name}SDKError; end
44
+ class ${model.Name}ServerError < ${model.Name}SDKError; end
45
+ end
46
+
47
+
48
+
49
+ `);
50
+ });
51
+ });
52
+ });
53
+ });
54
+
55
+
56
+ export { Error };
@@ -0,0 +1,16 @@
1
+ import { cmp, Content } from '@voxgig/sdkgen';
2
+
3
+ const MainEntity = cmp(async function MainEntity(props: any) {
4
+ const { entity } = props;
5
+
6
+ const def = JSON.stringify(entity);
7
+
8
+ Content(`
9
+ def ${entity.Name}(data={})
10
+ ${entity.Name}.new(self, data)
11
+ end
12
+
13
+ `);
14
+ });
15
+
16
+ export { MainEntity };
@@ -0,0 +1,55 @@
1
+ import {
2
+ cmp,
3
+ File,
4
+ Content,
5
+ Copy,
6
+ Folder,
7
+ snakify,
8
+ } from '@voxgig/sdkgen';
9
+
10
+ import { Test } from "./Test_rb";
11
+ import { Error } from "./Error_rb";
12
+ import { Client } from './Client_rb';
13
+
14
+ const Main = cmp(async function Main(props: any) {
15
+ const { build } = props;
16
+ const { model } = props.ctx$;
17
+
18
+ Copy({ from: "tm/" + build.name + "/Gemfile", name: "Gemfile" });
19
+ Copy({ from: "tm/" + build.name + "/" + 'tm.gemspec', name: snakify(model.Name) + "_sdk.gemspec" });
20
+ Copy({ from: "tm/" + build.name + "/Rakefile", name: "Rakefile" });
21
+
22
+ Test({ build });
23
+ Error({ model, build });
24
+ Client({ model, build });
25
+
26
+ Folder({ name: "lib" }, () => {
27
+ File({ name: snakify(model.Name) + "_sdk.rb" }, () => {
28
+ Content(`
29
+ # ${model.Name} ${build.Name} SDK
30
+ `);
31
+
32
+ Content(`
33
+
34
+ require_relative "${model.name}_sdk/client"
35
+
36
+ module ${model.Name}SDK
37
+ class << self
38
+ attr_accessor :options
39
+
40
+ def options
41
+ @options ||= {}
42
+ end
43
+
44
+ def configure
45
+ yield self
46
+ end
47
+ end
48
+ end
49
+ `);
50
+ });
51
+ });
52
+ });
53
+
54
+
55
+ export { Main };
@@ -0,0 +1,65 @@
1
+ import { cmp, File, Content } from '@voxgig/sdkgen';
2
+
3
+ const Quick = cmp(function Quick(props: any) {
4
+ const { build } = props;
5
+ const { model } = props.ctx$;
6
+
7
+ File({ name: "quick.rb" }, () => {
8
+ Content(`
9
+ require 'dotenv'
10
+ Dotenv.load
11
+ require_relative '../lib/${model.name}_sdk'
12
+
13
+ def run
14
+
15
+ client = ${model.Name}SDK::Client.new(
16
+ {
17
+ endpoint: ENV['${model.NAME}_ENDPOINT'],
18
+ apikey: ENV['${model.NAME}_APIKEY'],
19
+ }
20
+ )
21
+
22
+ # Test listing assets
23
+ out = client.Geofence.list()
24
+ puts "Geofence.list: #{out.inspect}\n\n"
25
+
26
+ # Test loading an asset
27
+ out = client.Geofence.load({id: 1})
28
+ puts "Geofence.load: #{out.inspect}\n\n"
29
+
30
+ # Check if endpoint includes localhost
31
+ if ENV['${model.NAME}_ENDPOINT'].include? 'localhost'
32
+ # Test creating an asset
33
+ out = client.Geofence.create({
34
+ id: 'CF49B47C-317B-4387-83C3-4A23715B1C45',
35
+ name: 'Geofence 1',
36
+ desc: 'Geofence 1 description',
37
+ custom: { foo: 'bar' },
38
+ extent_id: 'CF49B47C-317B-4387-83C3-4A23715B1C45'
39
+ })
40
+ puts "Geofence.create: #{out.inspect}\n\n"
41
+
42
+ # Test updating an asset
43
+ out = client.Geofence.save({
44
+ id: 'CF49B47C-317B-4387-83C3-4A23715B1C45',
45
+ name: 'Geofence 1',
46
+ desc: 'Geofence 1 description',
47
+ custom: { foo: 'bar' },
48
+ extent_id: 'CF49B47C-317B-4387-83C3-4A23715B1C45'
49
+ })
50
+ puts "Geofence.save: #{out.inspect}\n\n"
51
+
52
+ # Test deleting an asset
53
+ out = client.Geofence.remove({id: 'CF49B47C-317B-4387-83C3-4A23715B1C45'})
54
+ puts "Geofence.remove: #{out.inspect}\n\n"
55
+
56
+ end
57
+ end
58
+
59
+ run
60
+
61
+ `);
62
+ });
63
+ });
64
+
65
+ export { Quick };
@@ -0,0 +1,19 @@
1
+
2
+ import { cmp, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
6
+ const { build } = props
7
+
8
+ Content('```ruby')
9
+ Content(`
10
+ gem install ${build.module.name}
11
+ `)
12
+ Content('```')
13
+
14
+ })
15
+
16
+
17
+ export {
18
+ ReadmeInstall
19
+ }
@@ -0,0 +1,30 @@
1
+
2
+ import { cmp, Content } from '@voxgig/sdkgen'
3
+
4
+
5
+ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
6
+ const { build, ctx$: { model } } = props
7
+
8
+ Content('```ruby')
9
+ Content(`
10
+ require('${build.module.name}')
11
+
12
+ client = ${model.Name}SDK::Client.new(
13
+ {
14
+ endpoint: ENV['${model.NAME}_ENDPOINT'],
15
+ apikey: ENV['${model.NAME}_APIKEY'],
16
+ }
17
+ )
18
+
19
+ # List all buildings
20
+ buildings = client.Building.list()
21
+ puts "Buildings: #{buildings.inspect}"
22
+ `)
23
+ Content('```')
24
+
25
+ })
26
+
27
+
28
+ export {
29
+ ReadmeQuick
30
+ }