rapitapir 2.0.0 → 2.1.0

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +5 -0
  3. data/CHANGELOG.md +29 -1
  4. data/README.md +23 -4
  5. data/RUBY_WEEKLY_LAUNCH_POST.md +43 -62
  6. data/docs/adr/0001-base-class-strategy.md +33 -0
  7. data/docs/adr/0002-type-shortcut-and-type-system.md +30 -0
  8. data/docs/adr/0003-openapi-source-of-truth.md +32 -0
  9. data/docs/adr/0004-client-generation-typescript-first.md +34 -0
  10. data/docs/adr/0005-auth-architecture.md +32 -0
  11. data/docs/adr/0006-observability-defaults.md +30 -0
  12. data/docs/adr/0007-ai-scope-and-boundaries.md +30 -0
  13. data/docs/adr/README.md +46 -0
  14. data/docs/adr/template.md +24 -0
  15. data/docs/blueprint.md +92 -4
  16. data/docs/implementation-status.md +1 -1
  17. data/examples/auto_derivation_ruby_friendly.rb +44 -113
  18. data/examples/cli/user_api_endpoints.rb +63 -36
  19. data/examples/demo_api.rb +57 -18
  20. data/examples/enterprise_extension_demo.rb +13 -13
  21. data/examples/enterprise_rapitapir_api.rb +81 -93
  22. data/examples/nocodb/nocodb_scaffold/Gemfile +22 -0
  23. data/examples/nocodb/nocodb_scaffold/README.md +10 -0
  24. data/examples/nocodb/nocodb_scaffold/Rakefile +7 -0
  25. data/examples/nocodb/nocodb_scaffold/app/api/app.rb +1139 -0
  26. data/examples/nocodb/nocodb_scaffold/app/models/email_template.rb +6 -0
  27. data/examples/nocodb/nocodb_scaffold/app/models/faq.rb +6 -0
  28. data/examples/nocodb/nocodb_scaffold/app/models/feature.rb +6 -0
  29. data/examples/nocodb/nocodb_scaffold/app/models/idea.rb +6 -0
  30. data/examples/nocodb/nocodb_scaffold/app/models/itinerary_day.rb +6 -0
  31. data/examples/nocodb/nocodb_scaffold/app/models/route.rb +6 -0
  32. data/examples/nocodb/nocodb_scaffold/app/models/subscriber.rb +6 -0
  33. data/examples/nocodb/nocodb_scaffold/app/models/tour.rb +6 -0
  34. data/examples/nocodb/nocodb_scaffold/app/models/webhook.rb +6 -0
  35. data/examples/nocodb/nocodb_scaffold/app/models_loader.rb +3 -0
  36. data/examples/nocodb/nocodb_scaffold/config/database.yml +11 -0
  37. data/examples/nocodb/nocodb_scaffold/config.ru +9 -0
  38. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152012_create_features.rb +10 -0
  39. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152013_create_tours.rb +10 -0
  40. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152014_create_routes.rb +10 -0
  41. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152015_create_itinerary_days.rb +10 -0
  42. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152016_create_subscribers.rb +10 -0
  43. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152017_create_email_templates.rb +10 -0
  44. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152018_create_faqs.rb +10 -0
  45. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152019_create_webhooks.rb +10 -0
  46. data/examples/nocodb/nocodb_scaffold/db/migrate/20250808152020_create_ideas.rb +10 -0
  47. data/examples/nocodb/swagger.json +4378 -0
  48. data/examples/production_ready_example.rb +78 -58
  49. data/examples/simple_demo_api.rb +40 -7
  50. data/examples/user_api.rb +130 -132
  51. data/lib/rapitapir/auth/oauth2.rb +1 -1
  52. data/lib/rapitapir/cli/command.rb +30 -4
  53. data/lib/rapitapir/cli/scaffold_generator.rb +639 -0
  54. data/lib/rapitapir/cli/validator.rb +1 -1
  55. data/lib/rapitapir/core/enhanced_endpoint.rb +1 -1
  56. data/lib/rapitapir/dsl/enhanced_structures.rb +1 -1
  57. data/lib/rapitapir/openapi/schema_generator.rb +46 -2
  58. data/lib/rapitapir/server/enhanced_rack_adapter.rb +11 -8
  59. data/lib/rapitapir/server/middleware.rb +2 -2
  60. data/lib/rapitapir/types/auto_derivation.rb +2 -4
  61. data/lib/rapitapir/version.rb +1 -1
  62. data/rapitapir.gemspec +3 -2
  63. metadata +70 -8
@@ -0,0 +1,1139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sinatra/base'
4
+ require 'sinatra/activerecord'
5
+ require 'json'
6
+ require 'rapitapir'
7
+ require 'rapitapir/sinatra_rapitapir'
8
+ require_relative '../models_loader'
9
+
10
+ module API
11
+ class App < RapiTapir::SinatraRapiTapir
12
+ register Sinatra::ActiveRecordExtension
13
+ set :database_file, File.expand_path('../../config/database.yml', __dir__)
14
+
15
+ rapitapir do
16
+ info(title: "nocodb", version: "2.0")
17
+ development_defaults!
18
+ end
19
+
20
+ helpers do
21
+ def json(obj)
22
+ content_type :json
23
+ JSON.dump(obj)
24
+ end
25
+ end
26
+
27
+ # Basic health
28
+ get '/health' do
29
+ json(ok: true)
30
+ end
31
+
32
+ # Generated endpoints (scaffold level)
33
+ endpoint(
34
+ RapiTapir.get('/api/v2/tables/mtt03xolo8m1kve/records')
35
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwa6csrzocx682zu - Default view")
36
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
37
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
38
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
39
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
40
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
41
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
42
+ .header("xc-token", T.string, description: "API token")
43
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "Title" => T.optional(T.string) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
44
+ .summary("Features list")
45
+ .description("List of all rows from Features table and response data fields can be filtered based on query params.")
46
+ .tags("Features")
47
+ .build
48
+ ) do
49
+ Models::Feature.limit(25).all.map(&:attributes)
50
+ end
51
+
52
+
53
+ endpoint(
54
+ RapiTapir.post('/api/v2/tables/mtt03xolo8m1kve/records')
55
+ .header("xc-token", T.string, description: "API token")
56
+ .json_body(T.hash({}))
57
+ .ok(T.hash({ "Id" => T.optional(T.integer), "Title" => T.optional(T.string) }))
58
+ .summary("Features create")
59
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
60
+ .tags("Features")
61
+ .build
62
+ ) do
63
+ payload = JSON.parse(request.body.read) rescue {}
64
+ model = Models::Feature.create(payload)
65
+ model.attributes
66
+ end
67
+
68
+
69
+ endpoint(
70
+ RapiTapir.patch('/api/v2/tables/mtt03xolo8m1kve/records')
71
+ .header("xc-token", T.string, description: "API token")
72
+ .json_body(T.hash({}))
73
+ .ok(T.hash({}))
74
+ .summary("Features update")
75
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
76
+ .tags("Features")
77
+ .build
78
+ ) do
79
+ payload = JSON.parse(request.body.read) rescue {}
80
+ model = Models::Feature.first
81
+ halt 404 unless model
82
+ model.update(payload)
83
+ model.attributes
84
+ end
85
+
86
+
87
+ endpoint(
88
+ RapiTapir.delete('/api/v2/tables/mtt03xolo8m1kve/records')
89
+ .header("xc-token", T.string, description: "API token")
90
+ .json_body(T.hash({}))
91
+ .ok(T.hash({}))
92
+ .summary("Features delete")
93
+ .description("Delete a row by using the **primary key** column value.")
94
+ .tags("Features")
95
+ .build
96
+ ) do
97
+ model = Models::Feature.first
98
+ halt 404 unless model
99
+ model.destroy
100
+ {}
101
+ end
102
+
103
+
104
+ endpoint(
105
+ RapiTapir.get('/api/v2/tables/mtt03xolo8m1kve/records/:recordId')
106
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
107
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
108
+ .header("xc-token", T.string, description: "API token")
109
+ .created(T.hash({ "Id" => T.optional(T.integer), "Title" => T.optional(T.string) }))
110
+ .summary("Features read")
111
+ .description("Read a row data by using the **primary key** column value.")
112
+ .tags("Features")
113
+ .build
114
+ ) do
115
+ rec = Models::Feature.find_by(id: params[:recordId])
116
+ halt 404 unless rec
117
+ rec.attributes
118
+ end
119
+
120
+
121
+ endpoint(
122
+ RapiTapir.get('/api/v2/tables/mtt03xolo8m1kve/records/count')
123
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwa6csrzocx682zu - Default view")
124
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
125
+ .header("xc-token", T.string, description: "API token")
126
+ .ok(T.hash({ "count" => T.optional(T.float) }))
127
+ .summary("Features count")
128
+ .description("Get rows count of a table by applying optional filters.")
129
+ .tags("Features")
130
+ .build
131
+ ) do
132
+ Models::Feature.limit(25).all.map(&:attributes)
133
+ end
134
+
135
+
136
+ endpoint(
137
+ RapiTapir.get('/api/v2/tables/mk3tjsn0g0141aj/records')
138
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwt2z2kv3xnny2rn - Default view")
139
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
140
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
141
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
142
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
143
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
144
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
145
+ .header("xc-token", T.string, description: "API token")
146
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string), "stages" => T.optional(T.integer) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
147
+ .summary("Tours list")
148
+ .description("List of all rows from Tours table and response data fields can be filtered based on query params.")
149
+ .tags("Tours")
150
+ .build
151
+ ) do
152
+ Models::Tour.limit(25).all.map(&:attributes)
153
+ end
154
+
155
+
156
+ endpoint(
157
+ RapiTapir.post('/api/v2/tables/mk3tjsn0g0141aj/records')
158
+ .header("xc-token", T.string, description: "API token")
159
+ .json_body(T.hash({}))
160
+ .ok(T.hash({ "Id" => T.optional(T.integer), "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string), "stages" => T.optional(T.integer) }))
161
+ .summary("Tours create")
162
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
163
+ .tags("Tours")
164
+ .build
165
+ ) do
166
+ payload = JSON.parse(request.body.read) rescue {}
167
+ model = Models::Tour.create(payload)
168
+ model.attributes
169
+ end
170
+
171
+
172
+ endpoint(
173
+ RapiTapir.patch('/api/v2/tables/mk3tjsn0g0141aj/records')
174
+ .header("xc-token", T.string, description: "API token")
175
+ .json_body(T.hash({}))
176
+ .ok(T.hash({}))
177
+ .summary("Tours update")
178
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
179
+ .tags("Tours")
180
+ .build
181
+ ) do
182
+ payload = JSON.parse(request.body.read) rescue {}
183
+ model = Models::Tour.first
184
+ halt 404 unless model
185
+ model.update(payload)
186
+ model.attributes
187
+ end
188
+
189
+
190
+ endpoint(
191
+ RapiTapir.delete('/api/v2/tables/mk3tjsn0g0141aj/records')
192
+ .header("xc-token", T.string, description: "API token")
193
+ .json_body(T.hash({}))
194
+ .ok(T.hash({}))
195
+ .summary("Tours delete")
196
+ .description("Delete a row by using the **primary key** column value.")
197
+ .tags("Tours")
198
+ .build
199
+ ) do
200
+ model = Models::Tour.first
201
+ halt 404 unless model
202
+ model.destroy
203
+ {}
204
+ end
205
+
206
+
207
+ endpoint(
208
+ RapiTapir.get('/api/v2/tables/mk3tjsn0g0141aj/records/:recordId')
209
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
210
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
211
+ .header("xc-token", T.string, description: "API token")
212
+ .created(T.hash({ "Id" => T.optional(T.integer), "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string), "stages" => T.optional(T.integer) }))
213
+ .summary("Tours read")
214
+ .description("Read a row data by using the **primary key** column value.")
215
+ .tags("Tours")
216
+ .build
217
+ ) do
218
+ rec = Models::Tour.find_by(id: params[:recordId])
219
+ halt 404 unless rec
220
+ rec.attributes
221
+ end
222
+
223
+
224
+ endpoint(
225
+ RapiTapir.get('/api/v2/tables/mk3tjsn0g0141aj/records/count')
226
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwt2z2kv3xnny2rn - Default view")
227
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
228
+ .header("xc-token", T.string, description: "API token")
229
+ .ok(T.hash({ "count" => T.optional(T.float) }))
230
+ .summary("Tours count")
231
+ .description("Get rows count of a table by applying optional filters.")
232
+ .tags("Tours")
233
+ .build
234
+ ) do
235
+ Models::Tour.limit(25).all.map(&:attributes)
236
+ end
237
+
238
+
239
+ endpoint(
240
+ RapiTapir.get('/api/v2/tables/mk3tjsn0g0141aj/links/:linkFieldId/records/:recordId')
241
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c03xxobu37h493o - stages")
242
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
243
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
244
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
245
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
246
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
247
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
248
+ .header("xc-token", T.string, description: "API token")
249
+ .ok(T.hash({ "list" => T.array(T.hash({})), "pageInfo" => T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) }) }))
250
+ .summary("Link Records list")
251
+ .description("This API endpoint allows you to retrieve list of linked records for a specific `Link field` and `Record ID`. The response is an array of objects containing Primary Key and its corresponding display value.")
252
+ .tags("Tours")
253
+ .build
254
+ ) do
255
+ rec = Models::Tour.find_by(id: params[:linkFieldId])
256
+ halt 404 unless rec
257
+ rec.attributes
258
+ end
259
+
260
+
261
+ endpoint(
262
+ RapiTapir.post('/api/v2/tables/mk3tjsn0g0141aj/links/:linkFieldId/records/:recordId')
263
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c03xxobu37h493o - stages")
264
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
265
+ .header("xc-token", T.string, description: "API token")
266
+ .json_body(T.hash({}))
267
+ .ok(T.hash({}))
268
+ .summary("Link Records")
269
+ .description("This API endpoint allows you to link records to a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for linking purposes. Note that any existing links, if present, will be unaffected during this operation.")
270
+ .tags("Tours")
271
+ .build
272
+ ) do
273
+ payload = JSON.parse(request.body.read) rescue {}
274
+ model = Models::Tour.create(payload)
275
+ model.attributes
276
+ end
277
+
278
+
279
+ endpoint(
280
+ RapiTapir.delete('/api/v2/tables/mk3tjsn0g0141aj/links/:linkFieldId/records/:recordId')
281
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c03xxobu37h493o - stages")
282
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
283
+ .header("xc-token", T.string, description: "API token")
284
+ .json_body(T.hash({}))
285
+ .ok(T.hash({}))
286
+ .summary("Unlink Records")
287
+ .description("This API endpoint allows you to unlink records from a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for unlinking purposes. Note that, \n- duplicated record-ids will be ignored.\n- non-existent record-ids will be ignored.")
288
+ .tags("Tours")
289
+ .build
290
+ ) do
291
+ model = Models::Tour.find_by(id: params[:linkFieldId])
292
+ halt 404 unless model
293
+ model.destroy
294
+ {}
295
+ end
296
+
297
+
298
+ endpoint(
299
+ RapiTapir.get('/api/v2/tables/mmsajq9ewj2s4ta/records')
300
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwndrz5ffwfgynlb - Default view")
301
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
302
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
303
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
304
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
305
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
306
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
307
+ .header("xc-token", T.string, description: "API token")
308
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string), "scheduled_days" => T.optional(T.integer) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
309
+ .summary("Routes list")
310
+ .description("List of all rows from Routes table and response data fields can be filtered based on query params.")
311
+ .tags("Routes")
312
+ .build
313
+ ) do
314
+ Models::Route.limit(25).all.map(&:attributes)
315
+ end
316
+
317
+
318
+ endpoint(
319
+ RapiTapir.post('/api/v2/tables/mmsajq9ewj2s4ta/records')
320
+ .header("xc-token", T.string, description: "API token")
321
+ .json_body(T.hash({}))
322
+ .ok(T.hash({ "Id" => T.optional(T.integer), "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string), "scheduled_days" => T.optional(T.integer) }))
323
+ .summary("Routes create")
324
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
325
+ .tags("Routes")
326
+ .build
327
+ ) do
328
+ payload = JSON.parse(request.body.read) rescue {}
329
+ model = Models::Route.create(payload)
330
+ model.attributes
331
+ end
332
+
333
+
334
+ endpoint(
335
+ RapiTapir.patch('/api/v2/tables/mmsajq9ewj2s4ta/records')
336
+ .header("xc-token", T.string, description: "API token")
337
+ .json_body(T.hash({}))
338
+ .ok(T.hash({}))
339
+ .summary("Routes update")
340
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
341
+ .tags("Routes")
342
+ .build
343
+ ) do
344
+ payload = JSON.parse(request.body.read) rescue {}
345
+ model = Models::Route.first
346
+ halt 404 unless model
347
+ model.update(payload)
348
+ model.attributes
349
+ end
350
+
351
+
352
+ endpoint(
353
+ RapiTapir.delete('/api/v2/tables/mmsajq9ewj2s4ta/records')
354
+ .header("xc-token", T.string, description: "API token")
355
+ .json_body(T.hash({}))
356
+ .ok(T.hash({}))
357
+ .summary("Routes delete")
358
+ .description("Delete a row by using the **primary key** column value.")
359
+ .tags("Routes")
360
+ .build
361
+ ) do
362
+ model = Models::Route.first
363
+ halt 404 unless model
364
+ model.destroy
365
+ {}
366
+ end
367
+
368
+
369
+ endpoint(
370
+ RapiTapir.get('/api/v2/tables/mmsajq9ewj2s4ta/records/:recordId')
371
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
372
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
373
+ .header("xc-token", T.string, description: "API token")
374
+ .created(T.hash({ "Id" => T.optional(T.integer), "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string), "scheduled_days" => T.optional(T.integer) }))
375
+ .summary("Routes read")
376
+ .description("Read a row data by using the **primary key** column value.")
377
+ .tags("Routes")
378
+ .build
379
+ ) do
380
+ rec = Models::Route.find_by(id: params[:recordId])
381
+ halt 404 unless rec
382
+ rec.attributes
383
+ end
384
+
385
+
386
+ endpoint(
387
+ RapiTapir.get('/api/v2/tables/mmsajq9ewj2s4ta/records/count')
388
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwndrz5ffwfgynlb - Default view")
389
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
390
+ .header("xc-token", T.string, description: "API token")
391
+ .ok(T.hash({ "count" => T.optional(T.float) }))
392
+ .summary("Routes count")
393
+ .description("Get rows count of a table by applying optional filters.")
394
+ .tags("Routes")
395
+ .build
396
+ ) do
397
+ Models::Route.limit(25).all.map(&:attributes)
398
+ end
399
+
400
+
401
+ endpoint(
402
+ RapiTapir.get('/api/v2/tables/mmsajq9ewj2s4ta/links/:linkFieldId/records/:recordId')
403
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c671laqhnzlzs4e - scheduled_days")
404
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
405
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
406
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
407
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
408
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
409
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
410
+ .header("xc-token", T.string, description: "API token")
411
+ .ok(T.hash({ "list" => T.array(T.hash({})), "pageInfo" => T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) }) }))
412
+ .summary("Link Records list")
413
+ .description("This API endpoint allows you to retrieve list of linked records for a specific `Link field` and `Record ID`. The response is an array of objects containing Primary Key and its corresponding display value.")
414
+ .tags("Routes")
415
+ .build
416
+ ) do
417
+ rec = Models::Route.find_by(id: params[:linkFieldId])
418
+ halt 404 unless rec
419
+ rec.attributes
420
+ end
421
+
422
+
423
+ endpoint(
424
+ RapiTapir.post('/api/v2/tables/mmsajq9ewj2s4ta/links/:linkFieldId/records/:recordId')
425
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c671laqhnzlzs4e - scheduled_days")
426
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
427
+ .header("xc-token", T.string, description: "API token")
428
+ .json_body(T.hash({}))
429
+ .ok(T.hash({}))
430
+ .summary("Link Records")
431
+ .description("This API endpoint allows you to link records to a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for linking purposes. Note that any existing links, if present, will be unaffected during this operation.")
432
+ .tags("Routes")
433
+ .build
434
+ ) do
435
+ payload = JSON.parse(request.body.read) rescue {}
436
+ model = Models::Route.create(payload)
437
+ model.attributes
438
+ end
439
+
440
+
441
+ endpoint(
442
+ RapiTapir.delete('/api/v2/tables/mmsajq9ewj2s4ta/links/:linkFieldId/records/:recordId')
443
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c671laqhnzlzs4e - scheduled_days")
444
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
445
+ .header("xc-token", T.string, description: "API token")
446
+ .json_body(T.hash({}))
447
+ .ok(T.hash({}))
448
+ .summary("Unlink Records")
449
+ .description("This API endpoint allows you to unlink records from a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for unlinking purposes. Note that, \n- duplicated record-ids will be ignored.\n- non-existent record-ids will be ignored.")
450
+ .tags("Routes")
451
+ .build
452
+ ) do
453
+ model = Models::Route.find_by(id: params[:linkFieldId])
454
+ halt 404 unless model
455
+ model.destroy
456
+ {}
457
+ end
458
+
459
+
460
+ endpoint(
461
+ RapiTapir.get('/api/v2/tables/mol2r6h3c6fsn3m/records')
462
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw7lp301nw9993p2 - Default view")
463
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
464
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
465
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
466
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
467
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
468
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
469
+ .query(:nested_Tours__fields_, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the in nested column `Tours` result. In array syntax pass it like `fields[]=field1&fields[]=field2.`. Example : `nested[Tours][fields]=field1,field2`")
470
+ .query(:nested_Routes__fields_, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the in nested column `Routes` result. In array syntax pass it like `fields[]=field1&fields[]=field2.`. Example : `nested[Routes][fields]=field1,field2`")
471
+ .header("xc-token", T.string, description: "API token")
472
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "day_number" => T.optional(T.string), "daily_title" => T.optional(T.string), "daily_description" => T.optional(T.string), "Tours_id" => T.optional(T.integer), "Tours" => T.optional(T.hash({ "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string) })), "Routes_id" => T.optional(T.integer), "Routes" => T.optional(T.hash({ "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string) })), "tour_id" => T.optional(T.integer), "route_id" => T.optional(T.integer) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
473
+ .summary("ItineraryDays list")
474
+ .description("List of all rows from ItineraryDays table and response data fields can be filtered based on query params.")
475
+ .tags("ItineraryDays")
476
+ .build
477
+ ) do
478
+ Models::ItineraryDay.limit(25).all.map(&:attributes)
479
+ end
480
+
481
+
482
+ endpoint(
483
+ RapiTapir.post('/api/v2/tables/mol2r6h3c6fsn3m/records')
484
+ .header("xc-token", T.string, description: "API token")
485
+ .json_body(T.hash({}))
486
+ .ok(T.hash({ "Id" => T.optional(T.integer), "day_number" => T.optional(T.string), "daily_title" => T.optional(T.string), "daily_description" => T.optional(T.string), "Tours_id" => T.optional(T.integer), "Tours" => T.optional(T.hash({ "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string) })), "Routes_id" => T.optional(T.integer), "Routes" => T.optional(T.hash({ "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string) })), "tour_id" => T.optional(T.integer), "route_id" => T.optional(T.integer) }))
487
+ .summary("ItineraryDays create")
488
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
489
+ .tags("ItineraryDays")
490
+ .build
491
+ ) do
492
+ payload = JSON.parse(request.body.read) rescue {}
493
+ model = Models::ItineraryDay.create(payload)
494
+ model.attributes
495
+ end
496
+
497
+
498
+ endpoint(
499
+ RapiTapir.patch('/api/v2/tables/mol2r6h3c6fsn3m/records')
500
+ .header("xc-token", T.string, description: "API token")
501
+ .json_body(T.hash({}))
502
+ .ok(T.hash({}))
503
+ .summary("ItineraryDays update")
504
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
505
+ .tags("ItineraryDays")
506
+ .build
507
+ ) do
508
+ payload = JSON.parse(request.body.read) rescue {}
509
+ model = Models::ItineraryDay.first
510
+ halt 404 unless model
511
+ model.update(payload)
512
+ model.attributes
513
+ end
514
+
515
+
516
+ endpoint(
517
+ RapiTapir.delete('/api/v2/tables/mol2r6h3c6fsn3m/records')
518
+ .header("xc-token", T.string, description: "API token")
519
+ .json_body(T.hash({}))
520
+ .ok(T.hash({}))
521
+ .summary("ItineraryDays delete")
522
+ .description("Delete a row by using the **primary key** column value.")
523
+ .tags("ItineraryDays")
524
+ .build
525
+ ) do
526
+ model = Models::ItineraryDay.first
527
+ halt 404 unless model
528
+ model.destroy
529
+ {}
530
+ end
531
+
532
+
533
+ endpoint(
534
+ RapiTapir.get('/api/v2/tables/mol2r6h3c6fsn3m/records/:recordId')
535
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
536
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
537
+ .header("xc-token", T.string, description: "API token")
538
+ .created(T.hash({ "Id" => T.optional(T.integer), "day_number" => T.optional(T.string), "daily_title" => T.optional(T.string), "daily_description" => T.optional(T.string), "Tours_id" => T.optional(T.integer), "Tours" => T.optional(T.hash({ "name" => T.optional(T.string), "type" => T.optional(T.string), "start_date" => T.optional(T.string), "end_date" => T.optional(T.string), "is_featured" => T.optional(T.boolean), "description" => T.optional(T.string), "price" => T.optional(T.string), "old_price" => T.optional(T.string), "deposit_price" => T.optional(T.float), "deposit_payment_link" => T.optional(T.string), "image" => T.optional(T.string), "gallery_images" => T.optional(T.hash({})), "label" => T.optional(T.string), "sold_out" => T.optional(T.boolean), "preview_mode" => T.optional(T.boolean), "total_distance_km" => T.optional(T.integer), "group_size_max" => T.optional(T.integer), "physical_rating" => T.optional(T.string), "start_location" => T.optional(T.string), "region" => T.optional(T.string), "accommodation" => T.optional(T.string), "transport" => T.optional(T.string), "trip_highlights" => T.optional(T.string) })), "Routes_id" => T.optional(T.integer), "Routes" => T.optional(T.hash({ "route_name" => T.optional(T.string), "gpx_url" => T.optional(T.string) })), "tour_id" => T.optional(T.integer), "route_id" => T.optional(T.integer) }))
539
+ .summary("ItineraryDays read")
540
+ .description("Read a row data by using the **primary key** column value.")
541
+ .tags("ItineraryDays")
542
+ .build
543
+ ) do
544
+ rec = Models::ItineraryDay.find_by(id: params[:recordId])
545
+ halt 404 unless rec
546
+ rec.attributes
547
+ end
548
+
549
+
550
+ endpoint(
551
+ RapiTapir.get('/api/v2/tables/mol2r6h3c6fsn3m/records/count')
552
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw7lp301nw9993p2 - Default view")
553
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
554
+ .header("xc-token", T.string, description: "API token")
555
+ .ok(T.hash({ "count" => T.optional(T.float) }))
556
+ .summary("ItineraryDays count")
557
+ .description("Get rows count of a table by applying optional filters.")
558
+ .tags("ItineraryDays")
559
+ .build
560
+ ) do
561
+ Models::ItineraryDay.limit(25).all.map(&:attributes)
562
+ end
563
+
564
+
565
+ endpoint(
566
+ RapiTapir.get('/api/v2/tables/mol2r6h3c6fsn3m/links/:linkFieldId/records/:recordId')
567
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c0905qjoqegx40k - Tours\n* cdlxbup3s8mp8lx - Routes")
568
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
569
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
570
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
571
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
572
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
573
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
574
+ .header("xc-token", T.string, description: "API token")
575
+ .ok(T.hash({ "list" => T.array(T.hash({})), "pageInfo" => T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) }) }))
576
+ .summary("Link Records list")
577
+ .description("This API endpoint allows you to retrieve list of linked records for a specific `Link field` and `Record ID`. The response is an array of objects containing Primary Key and its corresponding display value.")
578
+ .tags("ItineraryDays")
579
+ .build
580
+ ) do
581
+ rec = Models::ItineraryDay.find_by(id: params[:linkFieldId])
582
+ halt 404 unless rec
583
+ rec.attributes
584
+ end
585
+
586
+
587
+ endpoint(
588
+ RapiTapir.post('/api/v2/tables/mol2r6h3c6fsn3m/links/:linkFieldId/records/:recordId')
589
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c0905qjoqegx40k - Tours\n* cdlxbup3s8mp8lx - Routes")
590
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
591
+ .header("xc-token", T.string, description: "API token")
592
+ .json_body(T.hash({}))
593
+ .ok(T.hash({}))
594
+ .summary("Link Records")
595
+ .description("This API endpoint allows you to link records to a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for linking purposes. Note that any existing links, if present, will be unaffected during this operation.")
596
+ .tags("ItineraryDays")
597
+ .build
598
+ ) do
599
+ payload = JSON.parse(request.body.read) rescue {}
600
+ model = Models::ItineraryDay.create(payload)
601
+ model.attributes
602
+ end
603
+
604
+
605
+ endpoint(
606
+ RapiTapir.delete('/api/v2/tables/mol2r6h3c6fsn3m/links/:linkFieldId/records/:recordId')
607
+ .path_param(:linkFieldId, T.string, description: "**Links Field Identifier** corresponding to the relation field `Links` established between tables.\n\nLink Columns:\n* c0905qjoqegx40k - Tours\n* cdlxbup3s8mp8lx - Routes")
608
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
609
+ .header("xc-token", T.string, description: "API token")
610
+ .json_body(T.hash({}))
611
+ .ok(T.hash({}))
612
+ .summary("Unlink Records")
613
+ .description("This API endpoint allows you to unlink records from a specific `Link field` and `Record ID`. The request payload is an array of record-ids from the adjacent table for unlinking purposes. Note that, \n- duplicated record-ids will be ignored.\n- non-existent record-ids will be ignored.")
614
+ .tags("ItineraryDays")
615
+ .build
616
+ ) do
617
+ model = Models::ItineraryDay.find_by(id: params[:linkFieldId])
618
+ halt 404 unless model
619
+ model.destroy
620
+ {}
621
+ end
622
+
623
+
624
+ endpoint(
625
+ RapiTapir.get('/api/v2/tables/mlnp4dupyi870t2/records')
626
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw067mss5rhbw4vx - Default view")
627
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
628
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
629
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
630
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
631
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
632
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
633
+ .header("xc-token", T.string, description: "API token")
634
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
635
+ .summary("Subscribers list")
636
+ .description("List of all rows from Subscribers table and response data fields can be filtered based on query params.")
637
+ .tags("Subscribers")
638
+ .build
639
+ ) do
640
+ Models::Subscriber.limit(25).all.map(&:attributes)
641
+ end
642
+
643
+
644
+ endpoint(
645
+ RapiTapir.post('/api/v2/tables/mlnp4dupyi870t2/records')
646
+ .header("xc-token", T.string, description: "API token")
647
+ .json_body(T.hash({}))
648
+ .ok(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string) }))
649
+ .summary("Subscribers create")
650
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
651
+ .tags("Subscribers")
652
+ .build
653
+ ) do
654
+ payload = JSON.parse(request.body.read) rescue {}
655
+ model = Models::Subscriber.create(payload)
656
+ model.attributes
657
+ end
658
+
659
+
660
+ endpoint(
661
+ RapiTapir.patch('/api/v2/tables/mlnp4dupyi870t2/records')
662
+ .header("xc-token", T.string, description: "API token")
663
+ .json_body(T.hash({}))
664
+ .ok(T.hash({}))
665
+ .summary("Subscribers update")
666
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
667
+ .tags("Subscribers")
668
+ .build
669
+ ) do
670
+ payload = JSON.parse(request.body.read) rescue {}
671
+ model = Models::Subscriber.first
672
+ halt 404 unless model
673
+ model.update(payload)
674
+ model.attributes
675
+ end
676
+
677
+
678
+ endpoint(
679
+ RapiTapir.delete('/api/v2/tables/mlnp4dupyi870t2/records')
680
+ .header("xc-token", T.string, description: "API token")
681
+ .json_body(T.hash({}))
682
+ .ok(T.hash({}))
683
+ .summary("Subscribers delete")
684
+ .description("Delete a row by using the **primary key** column value.")
685
+ .tags("Subscribers")
686
+ .build
687
+ ) do
688
+ model = Models::Subscriber.first
689
+ halt 404 unless model
690
+ model.destroy
691
+ {}
692
+ end
693
+
694
+
695
+ endpoint(
696
+ RapiTapir.get('/api/v2/tables/mlnp4dupyi870t2/records/:recordId')
697
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
698
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
699
+ .header("xc-token", T.string, description: "API token")
700
+ .created(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string) }))
701
+ .summary("Subscribers read")
702
+ .description("Read a row data by using the **primary key** column value.")
703
+ .tags("Subscribers")
704
+ .build
705
+ ) do
706
+ rec = Models::Subscriber.find_by(id: params[:recordId])
707
+ halt 404 unless rec
708
+ rec.attributes
709
+ end
710
+
711
+
712
+ endpoint(
713
+ RapiTapir.get('/api/v2/tables/mlnp4dupyi870t2/records/count')
714
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw067mss5rhbw4vx - Default view")
715
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
716
+ .header("xc-token", T.string, description: "API token")
717
+ .ok(T.hash({ "count" => T.optional(T.float) }))
718
+ .summary("Subscribers count")
719
+ .description("Get rows count of a table by applying optional filters.")
720
+ .tags("Subscribers")
721
+ .build
722
+ ) do
723
+ Models::Subscriber.limit(25).all.map(&:attributes)
724
+ end
725
+
726
+
727
+ endpoint(
728
+ RapiTapir.get('/api/v2/tables/mmbp7kee2ouo5gx/records')
729
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwo0xlmw9imt7j2s - Default view")
730
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
731
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
732
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
733
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
734
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
735
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
736
+ .header("xc-token", T.string, description: "API token")
737
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "template_name" => T.optional(T.string), "subject" => T.optional(T.string), "body" => T.optional(T.string) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
738
+ .summary("Email_Templates list")
739
+ .description("List of all rows from Email_Templates table and response data fields can be filtered based on query params.")
740
+ .tags("Email_Templates")
741
+ .build
742
+ ) do
743
+ Models::EmailTemplate.limit(25).all.map(&:attributes)
744
+ end
745
+
746
+
747
+ endpoint(
748
+ RapiTapir.post('/api/v2/tables/mmbp7kee2ouo5gx/records')
749
+ .header("xc-token", T.string, description: "API token")
750
+ .json_body(T.hash({}))
751
+ .ok(T.hash({ "Id" => T.optional(T.integer), "template_name" => T.optional(T.string), "subject" => T.optional(T.string), "body" => T.optional(T.string) }))
752
+ .summary("Email_Templates create")
753
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
754
+ .tags("Email_Templates")
755
+ .build
756
+ ) do
757
+ payload = JSON.parse(request.body.read) rescue {}
758
+ model = Models::EmailTemplate.create(payload)
759
+ model.attributes
760
+ end
761
+
762
+
763
+ endpoint(
764
+ RapiTapir.patch('/api/v2/tables/mmbp7kee2ouo5gx/records')
765
+ .header("xc-token", T.string, description: "API token")
766
+ .json_body(T.hash({}))
767
+ .ok(T.hash({}))
768
+ .summary("Email_Templates update")
769
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
770
+ .tags("Email_Templates")
771
+ .build
772
+ ) do
773
+ payload = JSON.parse(request.body.read) rescue {}
774
+ model = Models::EmailTemplate.first
775
+ halt 404 unless model
776
+ model.update(payload)
777
+ model.attributes
778
+ end
779
+
780
+
781
+ endpoint(
782
+ RapiTapir.delete('/api/v2/tables/mmbp7kee2ouo5gx/records')
783
+ .header("xc-token", T.string, description: "API token")
784
+ .json_body(T.hash({}))
785
+ .ok(T.hash({}))
786
+ .summary("Email_Templates delete")
787
+ .description("Delete a row by using the **primary key** column value.")
788
+ .tags("Email_Templates")
789
+ .build
790
+ ) do
791
+ model = Models::EmailTemplate.first
792
+ halt 404 unless model
793
+ model.destroy
794
+ {}
795
+ end
796
+
797
+
798
+ endpoint(
799
+ RapiTapir.get('/api/v2/tables/mmbp7kee2ouo5gx/records/:recordId')
800
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
801
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
802
+ .header("xc-token", T.string, description: "API token")
803
+ .created(T.hash({ "Id" => T.optional(T.integer), "template_name" => T.optional(T.string), "subject" => T.optional(T.string), "body" => T.optional(T.string) }))
804
+ .summary("Email_Templates read")
805
+ .description("Read a row data by using the **primary key** column value.")
806
+ .tags("Email_Templates")
807
+ .build
808
+ ) do
809
+ rec = Models::EmailTemplate.find_by(id: params[:recordId])
810
+ halt 404 unless rec
811
+ rec.attributes
812
+ end
813
+
814
+
815
+ endpoint(
816
+ RapiTapir.get('/api/v2/tables/mmbp7kee2ouo5gx/records/count')
817
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwo0xlmw9imt7j2s - Default view")
818
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
819
+ .header("xc-token", T.string, description: "API token")
820
+ .ok(T.hash({ "count" => T.optional(T.float) }))
821
+ .summary("Email_Templates count")
822
+ .description("Get rows count of a table by applying optional filters.")
823
+ .tags("Email_Templates")
824
+ .build
825
+ ) do
826
+ Models::EmailTemplate.limit(25).all.map(&:attributes)
827
+ end
828
+
829
+
830
+ endpoint(
831
+ RapiTapir.get('/api/v2/tables/md5i3700qogsqku/records')
832
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw124o3vdimghkq6 - Default view")
833
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
834
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
835
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
836
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
837
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
838
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
839
+ .header("xc-token", T.string, description: "API token")
840
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "category" => T.optional(T.string), "question_en" => T.optional(T.string), "answer_en" => T.optional(T.string) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
841
+ .summary("Faqs list")
842
+ .description("List of all rows from Faqs table and response data fields can be filtered based on query params.")
843
+ .tags("Faqs")
844
+ .build
845
+ ) do
846
+ Models::Faq.limit(25).all.map(&:attributes)
847
+ end
848
+
849
+
850
+ endpoint(
851
+ RapiTapir.post('/api/v2/tables/md5i3700qogsqku/records')
852
+ .header("xc-token", T.string, description: "API token")
853
+ .json_body(T.hash({}))
854
+ .ok(T.hash({ "Id" => T.optional(T.integer), "category" => T.optional(T.string), "question_en" => T.optional(T.string), "answer_en" => T.optional(T.string) }))
855
+ .summary("Faqs create")
856
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
857
+ .tags("Faqs")
858
+ .build
859
+ ) do
860
+ payload = JSON.parse(request.body.read) rescue {}
861
+ model = Models::Faq.create(payload)
862
+ model.attributes
863
+ end
864
+
865
+
866
+ endpoint(
867
+ RapiTapir.patch('/api/v2/tables/md5i3700qogsqku/records')
868
+ .header("xc-token", T.string, description: "API token")
869
+ .json_body(T.hash({}))
870
+ .ok(T.hash({}))
871
+ .summary("Faqs update")
872
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
873
+ .tags("Faqs")
874
+ .build
875
+ ) do
876
+ payload = JSON.parse(request.body.read) rescue {}
877
+ model = Models::Faq.first
878
+ halt 404 unless model
879
+ model.update(payload)
880
+ model.attributes
881
+ end
882
+
883
+
884
+ endpoint(
885
+ RapiTapir.delete('/api/v2/tables/md5i3700qogsqku/records')
886
+ .header("xc-token", T.string, description: "API token")
887
+ .json_body(T.hash({}))
888
+ .ok(T.hash({}))
889
+ .summary("Faqs delete")
890
+ .description("Delete a row by using the **primary key** column value.")
891
+ .tags("Faqs")
892
+ .build
893
+ ) do
894
+ model = Models::Faq.first
895
+ halt 404 unless model
896
+ model.destroy
897
+ {}
898
+ end
899
+
900
+
901
+ endpoint(
902
+ RapiTapir.get('/api/v2/tables/md5i3700qogsqku/records/:recordId')
903
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
904
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
905
+ .header("xc-token", T.string, description: "API token")
906
+ .created(T.hash({ "Id" => T.optional(T.integer), "category" => T.optional(T.string), "question_en" => T.optional(T.string), "answer_en" => T.optional(T.string) }))
907
+ .summary("Faqs read")
908
+ .description("Read a row data by using the **primary key** column value.")
909
+ .tags("Faqs")
910
+ .build
911
+ ) do
912
+ rec = Models::Faq.find_by(id: params[:recordId])
913
+ halt 404 unless rec
914
+ rec.attributes
915
+ end
916
+
917
+
918
+ endpoint(
919
+ RapiTapir.get('/api/v2/tables/md5i3700qogsqku/records/count')
920
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vw124o3vdimghkq6 - Default view")
921
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
922
+ .header("xc-token", T.string, description: "API token")
923
+ .ok(T.hash({ "count" => T.optional(T.float) }))
924
+ .summary("Faqs count")
925
+ .description("Get rows count of a table by applying optional filters.")
926
+ .tags("Faqs")
927
+ .build
928
+ ) do
929
+ Models::Faq.limit(25).all.map(&:attributes)
930
+ end
931
+
932
+
933
+ endpoint(
934
+ RapiTapir.get('/api/v2/tables/mngmhudvx0kayn6/records')
935
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwb8brs3v286oizx - Default view")
936
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
937
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
938
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
939
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
940
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
941
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
942
+ .header("xc-token", T.string, description: "API token")
943
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string), "Event" => T.optional(T.string), "Amount" => T.optional(T.string), "Tour_Id" => T.optional(T.string), "Phone_Number" => T.optional(T.string) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
944
+ .summary("Webhook list")
945
+ .description("List of all rows from Webhook table and response data fields can be filtered based on query params.")
946
+ .tags("Webhook")
947
+ .build
948
+ ) do
949
+ Models::Webhook.limit(25).all.map(&:attributes)
950
+ end
951
+
952
+
953
+ endpoint(
954
+ RapiTapir.post('/api/v2/tables/mngmhudvx0kayn6/records')
955
+ .header("xc-token", T.string, description: "API token")
956
+ .json_body(T.hash({}))
957
+ .ok(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string), "Event" => T.optional(T.string), "Amount" => T.optional(T.string), "Tour_Id" => T.optional(T.string), "Phone_Number" => T.optional(T.string) }))
958
+ .summary("Webhook create")
959
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
960
+ .tags("Webhook")
961
+ .build
962
+ ) do
963
+ payload = JSON.parse(request.body.read) rescue {}
964
+ model = Models::Webhook.create(payload)
965
+ model.attributes
966
+ end
967
+
968
+
969
+ endpoint(
970
+ RapiTapir.patch('/api/v2/tables/mngmhudvx0kayn6/records')
971
+ .header("xc-token", T.string, description: "API token")
972
+ .json_body(T.hash({}))
973
+ .ok(T.hash({}))
974
+ .summary("Webhook update")
975
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
976
+ .tags("Webhook")
977
+ .build
978
+ ) do
979
+ payload = JSON.parse(request.body.read) rescue {}
980
+ model = Models::Webhook.first
981
+ halt 404 unless model
982
+ model.update(payload)
983
+ model.attributes
984
+ end
985
+
986
+
987
+ endpoint(
988
+ RapiTapir.delete('/api/v2/tables/mngmhudvx0kayn6/records')
989
+ .header("xc-token", T.string, description: "API token")
990
+ .json_body(T.hash({}))
991
+ .ok(T.hash({}))
992
+ .summary("Webhook delete")
993
+ .description("Delete a row by using the **primary key** column value.")
994
+ .tags("Webhook")
995
+ .build
996
+ ) do
997
+ model = Models::Webhook.first
998
+ halt 404 unless model
999
+ model.destroy
1000
+ {}
1001
+ end
1002
+
1003
+
1004
+ endpoint(
1005
+ RapiTapir.get('/api/v2/tables/mngmhudvx0kayn6/records/:recordId')
1006
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
1007
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
1008
+ .header("xc-token", T.string, description: "API token")
1009
+ .created(T.hash({ "Id" => T.optional(T.integer), "Email" => T.optional(T.string), "Event" => T.optional(T.string), "Amount" => T.optional(T.string), "Tour_Id" => T.optional(T.string), "Phone_Number" => T.optional(T.string) }))
1010
+ .summary("Webhook read")
1011
+ .description("Read a row data by using the **primary key** column value.")
1012
+ .tags("Webhook")
1013
+ .build
1014
+ ) do
1015
+ rec = Models::Webhook.find_by(id: params[:recordId])
1016
+ halt 404 unless rec
1017
+ rec.attributes
1018
+ end
1019
+
1020
+
1021
+ endpoint(
1022
+ RapiTapir.get('/api/v2/tables/mngmhudvx0kayn6/records/count')
1023
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vwb8brs3v286oizx - Default view")
1024
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
1025
+ .header("xc-token", T.string, description: "API token")
1026
+ .ok(T.hash({ "count" => T.optional(T.float) }))
1027
+ .summary("Webhook count")
1028
+ .description("Get rows count of a table by applying optional filters.")
1029
+ .tags("Webhook")
1030
+ .build
1031
+ ) do
1032
+ Models::Webhook.limit(25).all.map(&:attributes)
1033
+ end
1034
+
1035
+
1036
+ endpoint(
1037
+ RapiTapir.get('/api/v2/tables/mopr1au7ctkqxmc/records')
1038
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vweo44ubz0sssudn - Default view")
1039
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
1040
+ .query(:sort, T.optional(T.string), description: "Comma separated field names to sort rows, rows will sort in ascending order based on provided columns. To sort in descending order provide `-` prefix along with column name, like `-field`. Example : `sort=field1,-field2`")
1041
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
1042
+ .query(:limit, T.optional(T.float(minimum: 1)), description: "The `limit` parameter used for pagination, the response collection size depends on limit value with default value `25` and maximum value `1000`, which can be overridden by environment variables `DB_QUERY_LIMIT_DEFAULT` and `DB_QUERY_LIMIT_MAX` respectively.")
1043
+ .query(:shuffle, T.optional(T.float(minimum: 0, maximum: 1)), description: "The `shuffle` parameter used for pagination, the response will be shuffled if it is set to 1.")
1044
+ .query(:offset, T.optional(T.float(minimum: 0)), description: "The `offset` parameter used for pagination, the value helps to select collection from a certain index.")
1045
+ .header("xc-token", T.string, description: "API token")
1046
+ .ok(T.hash({ "list" => T.optional(T.array(T.hash({ "Id" => T.optional(T.integer), "title" => T.optional(T.string), "description" => T.optional(T.string), "content" => T.optional(T.string), "json" => T.optional(T.hash({})) }))), "PageInfo" => T.optional(T.hash({ "pageSize" => T.optional(T.integer), "totalRows" => T.optional(T.integer), "isFirstPage" => T.optional(T.boolean), "isLastPage" => T.optional(T.boolean), "page" => T.optional(T.float) })) }))
1047
+ .summary("Ideas list")
1048
+ .description("List of all rows from Ideas table and response data fields can be filtered based on query params.")
1049
+ .tags("Ideas")
1050
+ .build
1051
+ ) do
1052
+ Models::Idea.limit(25).all.map(&:attributes)
1053
+ end
1054
+
1055
+
1056
+ endpoint(
1057
+ RapiTapir.post('/api/v2/tables/mopr1au7ctkqxmc/records')
1058
+ .header("xc-token", T.string, description: "API token")
1059
+ .json_body(T.hash({}))
1060
+ .ok(T.hash({ "Id" => T.optional(T.integer), "title" => T.optional(T.string), "description" => T.optional(T.string), "content" => T.optional(T.string), "json" => T.optional(T.hash({})) }))
1061
+ .summary("Ideas create")
1062
+ .description("Insert a new row in table by providing a key value pair object where key refers to the column alias. All the required fields should be included with payload excluding `autoincrement` and column with default value.")
1063
+ .tags("Ideas")
1064
+ .build
1065
+ ) do
1066
+ payload = JSON.parse(request.body.read) rescue {}
1067
+ model = Models::Idea.create(payload)
1068
+ model.attributes
1069
+ end
1070
+
1071
+
1072
+ endpoint(
1073
+ RapiTapir.patch('/api/v2/tables/mopr1au7ctkqxmc/records')
1074
+ .header("xc-token", T.string, description: "API token")
1075
+ .json_body(T.hash({}))
1076
+ .ok(T.hash({}))
1077
+ .summary("Ideas update")
1078
+ .description("Partial update row in table by providing a key value pair object where key refers to the column alias. You need to only include columns which you want to update.")
1079
+ .tags("Ideas")
1080
+ .build
1081
+ ) do
1082
+ payload = JSON.parse(request.body.read) rescue {}
1083
+ model = Models::Idea.first
1084
+ halt 404 unless model
1085
+ model.update(payload)
1086
+ model.attributes
1087
+ end
1088
+
1089
+
1090
+ endpoint(
1091
+ RapiTapir.delete('/api/v2/tables/mopr1au7ctkqxmc/records')
1092
+ .header("xc-token", T.string, description: "API token")
1093
+ .json_body(T.hash({}))
1094
+ .ok(T.hash({}))
1095
+ .summary("Ideas delete")
1096
+ .description("Delete a row by using the **primary key** column value.")
1097
+ .tags("Ideas")
1098
+ .build
1099
+ ) do
1100
+ model = Models::Idea.first
1101
+ halt 404 unless model
1102
+ model.destroy
1103
+ {}
1104
+ end
1105
+
1106
+
1107
+ endpoint(
1108
+ RapiTapir.get('/api/v2/tables/mopr1au7ctkqxmc/records/:recordId')
1109
+ .path_param(:recordId, T.string, description: "Primary key of the record you want to read. If the table have composite primary key then combine them by using `___` and pass it as primary key.")
1110
+ .query(:fields, T.optional(T.string), description: "Array of field names or comma separated filed names to include in the response objects. In array syntax pass it like `fields[]=field1&fields[]=field2` or alternately `fields=field1,field2`.")
1111
+ .header("xc-token", T.string, description: "API token")
1112
+ .created(T.hash({ "Id" => T.optional(T.integer), "title" => T.optional(T.string), "description" => T.optional(T.string), "content" => T.optional(T.string), "json" => T.optional(T.hash({})) }))
1113
+ .summary("Ideas read")
1114
+ .description("Read a row data by using the **primary key** column value.")
1115
+ .tags("Ideas")
1116
+ .build
1117
+ ) do
1118
+ rec = Models::Idea.find_by(id: params[:recordId])
1119
+ halt 404 unless rec
1120
+ rec.attributes
1121
+ end
1122
+
1123
+
1124
+ endpoint(
1125
+ RapiTapir.get('/api/v2/tables/mopr1au7ctkqxmc/records/count')
1126
+ .query(:viewId, T.optional(T.string), description: "Allows you to fetch records that are currently visible within a specific view.\n\nViews:\n* vweo44ubz0sssudn - Default view")
1127
+ .query(:where, T.optional(T.string), description: "This can be used for filtering rows, which accepts complicated where conditions. For more info visit [here](https://docs.nocodb.com/developer-resources/rest-apis#comparison-operators). Example : `where=(field1,eq,value)`")
1128
+ .header("xc-token", T.string, description: "API token")
1129
+ .ok(T.hash({ "count" => T.optional(T.float) }))
1130
+ .summary("Ideas count")
1131
+ .description("Get rows count of a table by applying optional filters.")
1132
+ .tags("Ideas")
1133
+ .build
1134
+ ) do
1135
+ Models::Idea.limit(25).all.map(&:attributes)
1136
+ end
1137
+
1138
+ end
1139
+ end