Class: TemplateFox::TemplatesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/templatefox/api/templates_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TemplatesApi

Returns a new instance of TemplatesApi.



19
20
21
# File 'lib/templatefox/api/templates_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/templatefox/api/templates_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_template_version(template_id, create_version_request, opts = {}) ⇒ VersionItem

Create a version snapshot Create an immutable snapshot of the current template draft.

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • create_version_request (CreateVersionRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



28
29
30
31
# File 'lib/templatefox/api/templates_api.rb', line 28

def create_template_version(template_id, create_version_request, opts = {})
  data, _status_code, _headers = create_template_version_with_http_info(template_id, create_version_request, opts)
  data
end

#create_template_version_with_http_info(template_id, create_version_request, opts = {}) ⇒ Array<(VersionItem, Integer, Hash)>

Create a version snapshot Create an immutable snapshot of the current template draft.

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • create_version_request (CreateVersionRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(VersionItem, Integer, Hash)>)

    VersionItem data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/templatefox/api/templates_api.rb', line 39

def create_template_version_with_http_info(template_id, create_version_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.create_template_version ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.create_template_version"
  end
  # verify the required parameter 'create_version_request' is set
  if @api_client.config.client_side_validation && create_version_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_version_request' when calling TemplatesApi.create_template_version"
  end
  # resource path
  local_var_path = '/v1/templates/{template_id}/versions'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_version_request)

  # return_type
  return_type = opts[:debug_return_type] || 'VersionItem'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.create_template_version",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#create_template_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_template_version(template_id, version_number, opts = {}) ⇒ Object

Delete a version Delete a specific version snapshot.

Parameters:

  • template_id (String)

    Template short ID

  • version_number (Integer)

    Version number to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


102
103
104
105
# File 'lib/templatefox/api/templates_api.rb', line 102

def delete_template_version(template_id, version_number, opts = {})
  data, _status_code, _headers = delete_template_version_with_http_info(template_id, version_number, opts)
  data
end

#delete_template_version_with_http_info(template_id, version_number, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Delete a version Delete a specific version snapshot.

Parameters:

  • template_id (String)

    Template short ID

  • version_number (Integer)

    Version number to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/templatefox/api/templates_api.rb', line 113

def delete_template_version_with_http_info(template_id, version_number, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_template_version ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.delete_template_version"
  end
  # verify the required parameter 'version_number' is set
  if @api_client.config.client_side_validation && version_number.nil?
    fail ArgumentError, "Missing the required parameter 'version_number' when calling TemplatesApi.delete_template_version"
  end
  # resource path
  local_var_path = '/v1/templates/{template_id}/versions/{version_number}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s)).sub('{' + 'version_number' + '}', CGI.escape(version_number.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.delete_template_version",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#delete_template_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_template_fields(template_id, opts = {}) ⇒ Array<TemplateField>

Get template fields Get the dynamic fields for a template. Authentication: API Key required (‘x-api-key` header) or JWT token Usage: This endpoint is designed for no-code tool integrations (Zapier, Make.com). It returns an array of field definitions used to dynamically generate input forms. **Response format:** Array of field objects with: `key`, `label`, `type`, `required`, optional `helpText`, and optional `spec` (for array fields). **Field types:** - `string`: Text input - `integer`: Integer number - `number`: Decimal number - `boolean`: True/False checkbox - `array`: Array of items with nested `spec` defining item structure **Array fields:** When a field is an array of objects, the response includes a `spec` array defining the structure of each item (name, label, type for each nested field). **No credits consumed:** This is a read-only endpoint. **Rate Limits:** 60 requests/min (free), 120 requests/min (paid). Headers included in response.

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



170
171
172
173
# File 'lib/templatefox/api/templates_api.rb', line 170

def get_template_fields(template_id, opts = {})
  data, _status_code, _headers = get_template_fields_with_http_info(template_id, opts)
  data
end

#get_template_fields_with_http_info(template_id, opts = {}) ⇒ Array<(Array<TemplateField>, Integer, Hash)>

Get template fields Get the dynamic fields for a template. Authentication: API Key required (&#x60;x-api-key&#x60; header) or JWT token Usage: This endpoint is designed for no-code tool integrations (Zapier, Make.com). It returns an array of field definitions used to dynamically generate input forms. **Response format:** Array of field objects with: &#x60;key&#x60;, &#x60;label&#x60;, &#x60;type&#x60;, &#x60;required&#x60;, optional &#x60;helpText&#x60;, and optional &#x60;spec&#x60; (for array fields). **Field types:** - &#x60;string&#x60;: Text input - &#x60;integer&#x60;: Integer number - &#x60;number&#x60;: Decimal number - &#x60;boolean&#x60;: True/False checkbox - &#x60;array&#x60;: Array of items with nested &#x60;spec&#x60; defining item structure **Array fields:** When a field is an array of objects, the response includes a &#x60;spec&#x60; array defining the structure of each item (name, label, type for each nested field). **No credits consumed:** This is a read-only endpoint. **Rate Limits:** 60 requests/min (free), 120 requests/min (paid). Headers included in response.

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Array<TemplateField>, Integer, Hash)>)

    Array<TemplateField> data, response status code and response headers



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/templatefox/api/templates_api.rb', line 180

def get_template_fields_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.get_template_fields ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.get_template_fields"
  end
  # resource path
  local_var_path = '/v1/templates/{template_id}/fields'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<TemplateField>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.get_template_fields",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#get_template_fields\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_template_versions(template_id, opts = {}) ⇒ VersionsListResponse

List template versions List all snapshot versions for a template (excludes the working draft).

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



233
234
235
236
# File 'lib/templatefox/api/templates_api.rb', line 233

def list_template_versions(template_id, opts = {})
  data, _status_code, _headers = list_template_versions_with_http_info(template_id, opts)
  data
end

#list_template_versions_with_http_info(template_id, opts = {}) ⇒ Array<(VersionsListResponse, Integer, Hash)>

List template versions List all snapshot versions for a template (excludes the working draft).

Parameters:

  • template_id (String)

    Template short ID (12 characters)

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(VersionsListResponse, Integer, Hash)>)

    VersionsListResponse data, response status code and response headers



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/templatefox/api/templates_api.rb', line 243

def list_template_versions_with_http_info(template_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.list_template_versions ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.list_template_versions"
  end
  # resource path
  local_var_path = '/v1/templates/{template_id}/versions'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'VersionsListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.list_template_versions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#list_template_versions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_templates(opts = {}) ⇒ TemplatesListResponse

List templates List all templates for the authenticated user. Authentication: API Key required (‘x-api-key` header) or JWT token Usage: This endpoint is designed for no-code tools (Zapier, Make, n8n) to populate template selection dropdowns. **No credits consumed:** This is a read-only endpoint. **Rate Limits:** 60 requests/min (free), 120 requests/min (paid). Headers included in response.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



295
296
297
298
# File 'lib/templatefox/api/templates_api.rb', line 295

def list_templates(opts = {})
  data, _status_code, _headers = list_templates_with_http_info(opts)
  data
end

#list_templates_with_http_info(opts = {}) ⇒ Array<(TemplatesListResponse, Integer, Hash)>

List templates List all templates for the authenticated user. Authentication: API Key required (&#x60;x-api-key&#x60; header) or JWT token Usage: This endpoint is designed for no-code tools (Zapier, Make, n8n) to populate template selection dropdowns. **No credits consumed:** This is a read-only endpoint. **Rate Limits:** 60 requests/min (free), 120 requests/min (paid). Headers included in response.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplatesListResponse, Integer, Hash)>)

    TemplatesListResponse data, response status code and response headers



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/templatefox/api/templates_api.rb', line 304

def list_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.list_templates ...'
  end
  # resource path
  local_var_path = '/v1/templates'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TemplatesListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.list_templates",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#list_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_template_version(template_id, version_number, update_version_request, opts = {}) ⇒ VersionItem

Update a version Update a version’s tag or description.

Parameters:

  • template_id (String)

    Template short ID

  • version_number (Integer)

    Version number to update

  • update_version_request (UpdateVersionRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



355
356
357
358
# File 'lib/templatefox/api/templates_api.rb', line 355

def update_template_version(template_id, version_number, update_version_request, opts = {})
  data, _status_code, _headers = update_template_version_with_http_info(template_id, version_number, update_version_request, opts)
  data
end

#update_template_version_with_http_info(template_id, version_number, update_version_request, opts = {}) ⇒ Array<(VersionItem, Integer, Hash)>

Update a version Update a version&#39;s tag or description.

Parameters:

  • template_id (String)

    Template short ID

  • version_number (Integer)

    Version number to update

  • update_version_request (UpdateVersionRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(VersionItem, Integer, Hash)>)

    VersionItem data, response status code and response headers



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/templatefox/api/templates_api.rb', line 367

def update_template_version_with_http_info(template_id, version_number, update_version_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplatesApi.update_template_version ...'
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.update_template_version"
  end
  # verify the required parameter 'version_number' is set
  if @api_client.config.client_side_validation && version_number.nil?
    fail ArgumentError, "Missing the required parameter 'version_number' when calling TemplatesApi.update_template_version"
  end
  # verify the required parameter 'update_version_request' is set
  if @api_client.config.client_side_validation && update_version_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_version_request' when calling TemplatesApi.update_template_version"
  end
  # resource path
  local_var_path = '/v1/templates/{template_id}/versions/{version_number}'.sub('{' + 'template_id' + '}', CGI.escape(template_id.to_s)).sub('{' + 'version_number' + '}', CGI.escape(version_number.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_version_request)

  # return_type
  return_type = opts[:debug_return_type] || 'VersionItem'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"TemplatesApi.update_template_version",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplatesApi#update_template_version\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end