dyspatch_client 2.0.0 → 5.0.1

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/README.md +50 -34
  4. data/Rakefile +2 -0
  5. data/docs/APIError.md +12 -1
  6. data/docs/CompiledRead.md +13 -0
  7. data/docs/Cursor.md +11 -1
  8. data/docs/DraftMetaRead.md +27 -0
  9. data/docs/DraftRead.md +31 -0
  10. data/docs/DraftsApi.md +476 -0
  11. data/docs/DraftsRead.md +19 -0
  12. data/docs/InlineObject.md +17 -0
  13. data/docs/LocalizationKeyRead.md +19 -0
  14. data/docs/LocalizationMetaRead.md +15 -1
  15. data/docs/LocalizationRead.md +19 -1
  16. data/docs/LocalizationsApi.md +16 -18
  17. data/docs/TemplateMetaRead.md +15 -0
  18. data/docs/TemplateRead.md +16 -0
  19. data/docs/TemplatesApi.md +39 -40
  20. data/docs/TemplatesRead.md +10 -0
  21. data/dyspatch_client.gemspec +10 -16
  22. data/lib/dyspatch_client.rb +10 -4
  23. data/lib/dyspatch_client/api/drafts_api.rb +620 -0
  24. data/lib/dyspatch_client/api/localizations_api.rb +52 -34
  25. data/lib/dyspatch_client/api/templates_api.rb +100 -69
  26. data/lib/dyspatch_client/api_client.rb +54 -55
  27. data/lib/dyspatch_client/api_error.rb +23 -4
  28. data/lib/dyspatch_client/configuration.rb +49 -10
  29. data/lib/dyspatch_client/models/api_error.rb +50 -30
  30. data/lib/dyspatch_client/models/compiled_read.rb +49 -78
  31. data/lib/dyspatch_client/models/cursor.rb +47 -28
  32. data/lib/dyspatch_client/models/draft_meta_read.rb +258 -0
  33. data/lib/dyspatch_client/models/draft_read.rb +279 -0
  34. data/lib/dyspatch_client/models/drafts_read.rb +219 -0
  35. data/lib/dyspatch_client/models/inline_object.rb +206 -0
  36. data/lib/dyspatch_client/models/localization_key_read.rb +216 -0
  37. data/lib/dyspatch_client/models/localization_meta_read.rb +70 -39
  38. data/lib/dyspatch_client/models/localization_read.rb +73 -42
  39. data/lib/dyspatch_client/models/template_meta_read.rb +52 -33
  40. data/lib/dyspatch_client/models/template_read.rb +53 -34
  41. data/lib/dyspatch_client/models/templates_read.rb +45 -26
  42. data/lib/dyspatch_client/version.rb +5 -5
  43. data/pkg/dyspatch_client-5.0.0.gem +0 -0
  44. data/pkg/dyspatch_client-5.0.1.gem +0 -0
  45. data/spec/api/drafts_api_spec.rb +146 -0
  46. data/spec/api/localizations_api_spec.rb +12 -12
  47. data/spec/api/templates_api_spec.rb +24 -24
  48. data/spec/api_client_spec.rb +39 -39
  49. data/spec/configuration_spec.rb +12 -12
  50. data/spec/integration_spec.rb +41 -0
  51. data/spec/models/api_error_spec.rb +12 -13
  52. data/spec/models/compiled_read_spec.rb +10 -11
  53. data/spec/models/cursor_spec.rb +7 -8
  54. data/spec/models/draft_meta_read_spec.rb +77 -0
  55. data/spec/models/draft_read_spec.rb +83 -0
  56. data/spec/models/drafts_read_spec.rb +47 -0
  57. data/spec/models/inline_object_spec.rb +41 -0
  58. data/spec/models/localization_key_read_spec.rb +47 -0
  59. data/spec/models/localization_meta_read_spec.rb +18 -13
  60. data/spec/models/localization_read_spec.rb +20 -15
  61. data/spec/models/template_meta_read_spec.rb +12 -13
  62. data/spec/models/template_read_spec.rb +13 -14
  63. data/spec/models/templates_read_spec.rb +7 -8
  64. data/spec/spec_helper.rb +4 -4
  65. metadata +34 -128
  66. data/git_push.sh +0 -55
@@ -1,16 +1,16 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
- require "uri"
13
+ require 'cgi'
14
14
 
15
15
  module DyspatchClient
16
16
  class LocalizationsApi
@@ -19,67 +19,85 @@ module DyspatchClient
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
-
23
22
  # Get Localization Object by ID
24
23
  # Returns a specific localization object with a matching ID
25
- # @param localization_id A localization ID
24
+ # @param localization_id [String] A localization ID
25
+ # @param target_language [String] The type of templating language to compile as. Should only be used for visual templates.
26
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
26
27
  # @param [Hash] opts the optional parameters
27
- # @option opts [String] :target_language The type of templating language to compile as. Should only be used for visual templates.
28
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
29
28
  # @return [LocalizationRead]
30
- def localizations_localization_id_get(localization_id, opts = {})
31
- data, _status_code, _headers = localizations_localization_id_get_with_http_info(localization_id, opts)
32
- return data
29
+ def get_localization_by_id(localization_id, target_language, accept, opts = {})
30
+ data, _status_code, _headers = get_localization_by_id_with_http_info(localization_id, target_language, accept, opts)
31
+ data
33
32
  end
34
33
 
35
34
  # Get Localization Object by ID
36
35
  # Returns a specific localization object with a matching ID
37
- # @param localization_id A localization ID
36
+ # @param localization_id [String] A localization ID
37
+ # @param target_language [String] The type of templating language to compile as. Should only be used for visual templates.
38
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
38
39
  # @param [Hash] opts the optional parameters
39
- # @option opts [String] :target_language The type of templating language to compile as. Should only be used for visual templates.
40
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
41
- # @return [Array<(LocalizationRead, Fixnum, Hash)>] LocalizationRead data, response status code and response headers
42
- def localizations_localization_id_get_with_http_info(localization_id, opts = {})
40
+ # @return [Array<(LocalizationRead, Integer, Hash)>] LocalizationRead data, response status code and response headers
41
+ def get_localization_by_id_with_http_info(localization_id, target_language, accept, opts = {})
43
42
  if @api_client.config.debugging
44
- @api_client.config.logger.debug "Calling API: LocalizationsApi.localizations_localization_id_get ..."
43
+ @api_client.config.logger.debug 'Calling API: LocalizationsApi.get_localization_by_id ...'
45
44
  end
46
45
  # verify the required parameter 'localization_id' is set
47
46
  if @api_client.config.client_side_validation && localization_id.nil?
48
- fail ArgumentError, "Missing the required parameter 'localization_id' when calling LocalizationsApi.localizations_localization_id_get"
47
+ fail ArgumentError, "Missing the required parameter 'localization_id' when calling LocalizationsApi.get_localization_by_id"
48
+ end
49
+ # verify the required parameter 'target_language' is set
50
+ if @api_client.config.client_side_validation && target_language.nil?
51
+ fail ArgumentError, "Missing the required parameter 'target_language' when calling LocalizationsApi.get_localization_by_id"
49
52
  end
50
- if @api_client.config.client_side_validation && opts[:'target_language'] && !['html', 'jinja', 'handlebars', 'ampscript', 'freemarker', 'cheetah'].include?(opts[:'target_language'])
51
- fail ArgumentError, 'invalid value for "target_language", must be one of html, jinja, handlebars, ampscript, freemarker, cheetah'
53
+ # verify enum value
54
+ allowable_values = ["html", "handlebars", "ampscript", "freemarker", "cheetah", "jinja"]
55
+ if @api_client.config.client_side_validation && !allowable_values.include?(target_language)
56
+ fail ArgumentError, "invalid value for \"target_language\", must be one of #{allowable_values}"
57
+ end
58
+ # verify the required parameter 'accept' is set
59
+ if @api_client.config.client_side_validation && accept.nil?
60
+ fail ArgumentError, "Missing the required parameter 'accept' when calling LocalizationsApi.get_localization_by_id"
52
61
  end
53
62
  # resource path
54
- local_var_path = "/localizations/{localizationId}".sub('{' + 'localizationId' + '}', localization_id.to_s)
63
+ local_var_path = '/localizations/{localizationId}'.sub('{' + 'localizationId' + '}', CGI.escape(localization_id.to_s))
55
64
 
56
65
  # query parameters
57
- query_params = {}
58
- query_params[:'targetLanguage'] = opts[:'target_language'] if !opts[:'target_language'].nil?
66
+ query_params = opts[:query_params] || {}
67
+ query_params[:'targetLanguage'] = target_language
59
68
 
60
69
  # header parameters
61
- header_params = {}
70
+ header_params = opts[:header_params] || {}
62
71
  # HTTP header 'Accept' (if needed)
63
- header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2019.03+json'])
64
- header_params[:'Accept'] = opts[:'accept'] if !opts[:'accept'].nil?
72
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2020.04+json', '*/*'])
73
+ header_params[:'Accept'] = accept
65
74
 
66
75
  # form parameters
67
- form_params = {}
76
+ form_params = opts[:form_params] || {}
68
77
 
69
78
  # http body (model)
70
- post_body = nil
71
- auth_names = ['Bearer']
72
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
79
+ post_body = opts[:body]
80
+
81
+ # return_type
82
+ return_type = opts[:return_type] || 'LocalizationRead'
83
+
84
+ # auth_names
85
+ auth_names = opts[:auth_names] || ['Bearer']
86
+
87
+ new_options = opts.merge(
73
88
  :header_params => header_params,
74
89
  :query_params => query_params,
75
90
  :form_params => form_params,
76
91
  :body => post_body,
77
92
  :auth_names => auth_names,
78
- :return_type => 'LocalizationRead')
93
+ :return_type => return_type
94
+ )
95
+
96
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
79
97
  if @api_client.config.debugging
80
- @api_client.config.logger.debug "API called: LocalizationsApi#localizations_localization_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
98
+ @api_client.config.logger.debug "API called: LocalizationsApi#get_localization_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
99
  end
82
100
  return data, status_code, headers
83
101
  end
84
102
  end
85
- end
103
+ end
@@ -1,16 +1,16 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
- require "uri"
13
+ require 'cgi'
14
14
 
15
15
  module DyspatchClient
16
16
  class TemplatesApi
@@ -19,120 +19,151 @@ module DyspatchClient
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
-
23
- # List Templates
24
- # Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated.
22
+ # Get Template by ID
23
+ # Gets a template object with the matching ID. If the template has published content the \"compiled\" field will contain the template .
24
+ # @param template_id [String] A template ID
25
+ # @param target_language [String] The type of templating language to compile as. Should only be used for visual templates.
26
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \&quot;2020.04\&quot;, set the value to \&quot;application/vnd.dyspatch.2020.04+json\&quot;
25
27
  # @param [Hash] opts the optional parameters
26
- # @option opts [String] :cursor A cursor value used to retrieve a specific page from a paginated result set.
27
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
28
- # @return [TemplatesRead]
29
- def templates_get(opts = {})
30
- data, _status_code, _headers = templates_get_with_http_info(opts)
31
- return data
28
+ # @return [TemplateRead]
29
+ def get_template_by_id(template_id, target_language, accept, opts = {})
30
+ data, _status_code, _headers = get_template_by_id_with_http_info(template_id, target_language, accept, opts)
31
+ data
32
32
  end
33
33
 
34
- # List Templates
35
- # Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated.
34
+ # Get Template by ID
35
+ # Gets a template object with the matching ID. If the template has published content the \&quot;compiled\&quot; field will contain the template .
36
+ # @param template_id [String] A template ID
37
+ # @param target_language [String] The type of templating language to compile as. Should only be used for visual templates.
38
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \&quot;2020.04\&quot;, set the value to \&quot;application/vnd.dyspatch.2020.04+json\&quot;
36
39
  # @param [Hash] opts the optional parameters
37
- # @option opts [String] :cursor A cursor value used to retrieve a specific page from a paginated result set.
38
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
39
- # @return [Array<(TemplatesRead, Fixnum, Hash)>] TemplatesRead data, response status code and response headers
40
- def templates_get_with_http_info(opts = {})
40
+ # @return [Array<(TemplateRead, Integer, Hash)>] TemplateRead data, response status code and response headers
41
+ def get_template_by_id_with_http_info(template_id, target_language, accept, opts = {})
41
42
  if @api_client.config.debugging
42
- @api_client.config.logger.debug "Calling API: TemplatesApi.templates_get ..."
43
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.get_template_by_id ...'
44
+ end
45
+ # verify the required parameter 'template_id' is set
46
+ if @api_client.config.client_side_validation && template_id.nil?
47
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.get_template_by_id"
48
+ end
49
+ # verify the required parameter 'target_language' is set
50
+ if @api_client.config.client_side_validation && target_language.nil?
51
+ fail ArgumentError, "Missing the required parameter 'target_language' when calling TemplatesApi.get_template_by_id"
52
+ end
53
+ # verify enum value
54
+ allowable_values = ["html", "handlebars", "ampscript", "freemarker", "cheetah", "jinja"]
55
+ if @api_client.config.client_side_validation && !allowable_values.include?(target_language)
56
+ fail ArgumentError, "invalid value for \"target_language\", must be one of #{allowable_values}"
57
+ end
58
+ # verify the required parameter 'accept' is set
59
+ if @api_client.config.client_side_validation && accept.nil?
60
+ fail ArgumentError, "Missing the required parameter 'accept' when calling TemplatesApi.get_template_by_id"
43
61
  end
44
62
  # resource path
45
- local_var_path = "/templates"
63
+ local_var_path = '/templates/{templateId}'.sub('{' + 'templateId' + '}', CGI.escape(template_id.to_s))
46
64
 
47
65
  # query parameters
48
- query_params = {}
49
- query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
66
+ query_params = opts[:query_params] || {}
67
+ query_params[:'targetLanguage'] = target_language
50
68
 
51
69
  # header parameters
52
- header_params = {}
70
+ header_params = opts[:header_params] || {}
53
71
  # HTTP header 'Accept' (if needed)
54
- header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2019.03+json'])
55
- header_params[:'Accept'] = opts[:'accept'] if !opts[:'accept'].nil?
72
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2020.04+json', '*/*'])
73
+ header_params[:'Accept'] = accept
56
74
 
57
75
  # form parameters
58
- form_params = {}
76
+ form_params = opts[:form_params] || {}
59
77
 
60
78
  # http body (model)
61
- post_body = nil
62
- auth_names = ['Bearer']
63
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
79
+ post_body = opts[:body]
80
+
81
+ # return_type
82
+ return_type = opts[:return_type] || 'TemplateRead'
83
+
84
+ # auth_names
85
+ auth_names = opts[:auth_names] || ['Bearer']
86
+
87
+ new_options = opts.merge(
64
88
  :header_params => header_params,
65
89
  :query_params => query_params,
66
90
  :form_params => form_params,
67
91
  :body => post_body,
68
92
  :auth_names => auth_names,
69
- :return_type => 'TemplatesRead')
93
+ :return_type => return_type
94
+ )
95
+
96
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
70
97
  if @api_client.config.debugging
71
- @api_client.config.logger.debug "API called: TemplatesApi#templates_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
98
+ @api_client.config.logger.debug "API called: TemplatesApi#get_template_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
72
99
  end
73
100
  return data, status_code, headers
74
101
  end
75
102
 
76
- # Get Template by ID
77
- # Gets a template object with the matching ID. If the template has published content the "compiled" field will contain the template .
78
- # @param template_id A template ID
103
+ # List Templates
104
+ # Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated.
105
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \&quot;2020.04\&quot;, set the value to \&quot;application/vnd.dyspatch.2020.04+json\&quot;
79
106
  # @param [Hash] opts the optional parameters
80
- # @option opts [String] :target_language The type of templating language to compile as. Should only be used for visual templates.
81
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
82
- # @return [TemplateRead]
83
- def templates_template_id_get(template_id, opts = {})
84
- data, _status_code, _headers = templates_template_id_get_with_http_info(template_id, opts)
85
- return data
107
+ # @option opts [String] :cursor A cursor value used to retrieve a specific page from a paginated result set.
108
+ # @return [TemplatesRead]
109
+ def get_templates(accept, opts = {})
110
+ data, _status_code, _headers = get_templates_with_http_info(accept, opts)
111
+ data
86
112
  end
87
113
 
88
- # Get Template by ID
89
- # Gets a template object with the matching ID. If the template has published content the "compiled" field will contain the template .
90
- # @param template_id A template ID
114
+ # List Templates
115
+ # Gets a list of Template Metadata objects for all templates. Up to 25 results returned before results are paginated.
116
+ # @param accept [String] A version of the API that should be used for the request. For example, to use version \&quot;2020.04\&quot;, set the value to \&quot;application/vnd.dyspatch.2020.04+json\&quot;
91
117
  # @param [Hash] opts the optional parameters
92
- # @option opts [String] :target_language The type of templating language to compile as. Should only be used for visual templates.
93
- # @option opts [String] :accept A version of the API that should be used for the request. For example, to use version "2019.03", set the value to "application/vnd.dyspatch.2019.03+json"
94
- # @return [Array<(TemplateRead, Fixnum, Hash)>] TemplateRead data, response status code and response headers
95
- def templates_template_id_get_with_http_info(template_id, opts = {})
118
+ # @option opts [String] :cursor A cursor value used to retrieve a specific page from a paginated result set.
119
+ # @return [Array<(TemplatesRead, Integer, Hash)>] TemplatesRead data, response status code and response headers
120
+ def get_templates_with_http_info(accept, opts = {})
96
121
  if @api_client.config.debugging
97
- @api_client.config.logger.debug "Calling API: TemplatesApi.templates_template_id_get ..."
98
- end
99
- # verify the required parameter 'template_id' is set
100
- if @api_client.config.client_side_validation && template_id.nil?
101
- fail ArgumentError, "Missing the required parameter 'template_id' when calling TemplatesApi.templates_template_id_get"
122
+ @api_client.config.logger.debug 'Calling API: TemplatesApi.get_templates ...'
102
123
  end
103
- if @api_client.config.client_side_validation && opts[:'target_language'] && !['html', 'jinja', 'handlebars', 'ampscript', 'freemarker', 'cheetah'].include?(opts[:'target_language'])
104
- fail ArgumentError, 'invalid value for "target_language", must be one of html, jinja, handlebars, ampscript, freemarker, cheetah'
124
+ # verify the required parameter 'accept' is set
125
+ if @api_client.config.client_side_validation && accept.nil?
126
+ fail ArgumentError, "Missing the required parameter 'accept' when calling TemplatesApi.get_templates"
105
127
  end
106
128
  # resource path
107
- local_var_path = "/templates/{templateId}".sub('{' + 'templateId' + '}', template_id.to_s)
129
+ local_var_path = '/templates'
108
130
 
109
131
  # query parameters
110
- query_params = {}
111
- query_params[:'targetLanguage'] = opts[:'target_language'] if !opts[:'target_language'].nil?
132
+ query_params = opts[:query_params] || {}
133
+ query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
112
134
 
113
135
  # header parameters
114
- header_params = {}
136
+ header_params = opts[:header_params] || {}
115
137
  # HTTP header 'Accept' (if needed)
116
- header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2019.03+json'])
117
- header_params[:'Accept'] = opts[:'accept'] if !opts[:'accept'].nil?
138
+ header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2020.04+json', '*/*'])
139
+ header_params[:'Accept'] = accept
118
140
 
119
141
  # form parameters
120
- form_params = {}
142
+ form_params = opts[:form_params] || {}
121
143
 
122
144
  # http body (model)
123
- post_body = nil
124
- auth_names = ['Bearer']
125
- data, status_code, headers = @api_client.call_api(:GET, local_var_path,
145
+ post_body = opts[:body]
146
+
147
+ # return_type
148
+ return_type = opts[:return_type] || 'TemplatesRead'
149
+
150
+ # auth_names
151
+ auth_names = opts[:auth_names] || ['Bearer']
152
+
153
+ new_options = opts.merge(
126
154
  :header_params => header_params,
127
155
  :query_params => query_params,
128
156
  :form_params => form_params,
129
157
  :body => post_body,
130
158
  :auth_names => auth_names,
131
- :return_type => 'TemplateRead')
159
+ :return_type => return_type
160
+ )
161
+
162
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
132
163
  if @api_client.config.debugging
133
- @api_client.config.logger.debug "API called: TemplatesApi#templates_template_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
164
+ @api_client.config.logger.debug "API called: TemplatesApi#get_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
134
165
  end
135
166
  return data, status_code, headers
136
167
  end
137
168
  end
138
- end
169
+ end
@@ -1,12 +1,12 @@
1
1
  =begin
2
2
  #Dyspatch API
3
3
 
4
- ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python) - [C#](https://github.com/getdyspatch/dyspatch-dotnet) - [Go](https://github.com/getdyspatch/dyspatch-golang) - [Ruby](https://github.com/getdyspatch/dyspatch-ruby)
5
5
 
6
- OpenAPI spec version: 2019.03
6
+ The version of the OpenAPI document: 2020.04
7
7
  Contact: support@dyspatch.io
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
@@ -15,7 +15,6 @@ require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
17
  require 'typhoeus'
18
- require 'uri'
19
18
 
20
19
  module DyspatchClient
21
20
  class ApiClient
@@ -31,9 +30,9 @@ module DyspatchClient
31
30
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
31
  def initialize(config = Configuration.default)
33
32
  @config = config
34
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
33
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
35
34
  @default_headers = {
36
- 'Content-Type' => "application/json",
35
+ 'Content-Type' => 'application/json',
37
36
  'User-Agent' => @user_agent
38
37
  }
39
38
  end
@@ -44,7 +43,7 @@ module DyspatchClient
44
43
 
45
44
  # Call an API with given options.
46
45
  #
47
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
48
47
  # the data deserialized from response body (could be nil), response status code and response headers.
49
48
  def call_api(http_method, path, opts = {})
50
49
  request = build_request(http_method, path, opts)
@@ -128,6 +127,34 @@ module DyspatchClient
128
127
  request
129
128
  end
130
129
 
130
+ # Builds the HTTP request body
131
+ #
132
+ # @param [Hash] header_params Header parameters
133
+ # @param [Hash] form_params Query parameters
134
+ # @param [Object] body HTTP body (JSON/XML)
135
+ # @return [String] HTTP body data in the form of string
136
+ def build_request_body(header_params, form_params, body)
137
+ # http form
138
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
139
+ header_params['Content-Type'] == 'multipart/form-data'
140
+ data = {}
141
+ form_params.each do |key, value|
142
+ case value
143
+ when ::File, ::Array, nil
144
+ # let typhoeus handle File, Array and nil parameters
145
+ data[key] = value
146
+ else
147
+ data[key] = value.to_s
148
+ end
149
+ end
150
+ elsif body
151
+ data = body.is_a?(String) ? body : body.to_json
152
+ else
153
+ data = nil
154
+ end
155
+ data
156
+ end
157
+
131
158
  # Check if the given MIME is a JSON MIME.
132
159
  # JSON MIME examples:
133
160
  # application/json
@@ -137,13 +164,13 @@ module DyspatchClient
137
164
  # @param [String] mime MIME
138
165
  # @return [Boolean] True if the MIME is application/json
139
166
  def json_mime?(mime)
140
- (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
167
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
141
168
  end
142
169
 
143
170
  # Deserialize the response to the given return type.
144
171
  #
145
172
  # @param [Response] response HTTP response
146
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
173
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
147
174
  def deserialize(response, return_type)
148
175
  body = response.body
149
176
 
@@ -187,7 +214,7 @@ module DyspatchClient
187
214
  data.to_i
188
215
  when 'Float'
189
216
  data.to_f
190
- when 'BOOLEAN'
217
+ when 'Boolean'
191
218
  data == true
192
219
  when 'DateTime'
193
220
  # parse date time (expecting ISO 8601 format)
@@ -201,18 +228,16 @@ module DyspatchClient
201
228
  when /\AArray<(.+)>\z/
202
229
  # e.g. Array<Pet>
203
230
  sub_type = $1
204
- data.map {|item| convert_to_type(item, sub_type) }
231
+ data.map { |item| convert_to_type(item, sub_type) }
205
232
  when /\AHash\<String, (.+)\>\z/
206
233
  # e.g. Hash<String, Integer>
207
234
  sub_type = $1
208
235
  {}.tap do |hash|
209
- data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
236
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
210
237
  end
211
238
  else
212
239
  # models, e.g. Pet
213
- DyspatchClient.const_get(return_type).new.tap do |model|
214
- model.build_from_hash data
215
- end
240
+ DyspatchClient.const_get(return_type).build_from_hash(data)
216
241
  end
217
242
  end
218
243
 
@@ -228,7 +253,7 @@ module DyspatchClient
228
253
  encoding = nil
229
254
  request.on_headers do |response|
230
255
  content_disposition = response.headers['Content-Disposition']
231
- if content_disposition and content_disposition =~ /filename=/i
256
+ if content_disposition && content_disposition =~ /filename=/i
232
257
  filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
233
258
  prefix = sanitize_filename(filename)
234
259
  else
@@ -244,11 +269,13 @@ module DyspatchClient
244
269
  tempfile.write(chunk)
245
270
  end
246
271
  request.on_complete do |response|
247
- tempfile.close
248
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
249
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
250
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
251
- "explicitly with `tempfile.delete`"
272
+ if tempfile
273
+ tempfile.close
274
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
+ "explicitly with `tempfile.delete`"
278
+ end
252
279
  end
253
280
  end
254
281
 
@@ -264,35 +291,7 @@ module DyspatchClient
264
291
  def build_request_url(path)
265
292
  # Add leading and trailing slashes to path
266
293
  path = "/#{path}".gsub(/\/+/, '/')
267
- URI.encode(@config.base_url + path)
268
- end
269
-
270
- # Builds the HTTP request body
271
- #
272
- # @param [Hash] header_params Header parameters
273
- # @param [Hash] form_params Query parameters
274
- # @param [Object] body HTTP body (JSON/XML)
275
- # @return [String] HTTP body data in the form of string
276
- def build_request_body(header_params, form_params, body)
277
- # http form
278
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
279
- header_params['Content-Type'] == 'multipart/form-data'
280
- data = {}
281
- form_params.each do |key, value|
282
- case value
283
- when ::File, ::Array, nil
284
- # let typhoeus handle File, Array and nil parameters
285
- data[key] = value
286
- else
287
- data[key] = value.to_s
288
- end
289
- end
290
- elsif body
291
- data = body.is_a?(String) ? body : body.to_json
292
- else
293
- data = nil
294
- end
295
- data
294
+ @config.base_url + path
296
295
  end
297
296
 
298
297
  # Update hearder and query params based on authentication settings.
@@ -314,7 +313,7 @@ module DyspatchClient
314
313
 
315
314
  # Sets user agent in HTTP header
316
315
  #
317
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
316
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
318
317
  def user_agent=(user_agent)
319
318
  @user_agent = user_agent
320
319
  @default_headers['User-Agent'] = @user_agent
@@ -327,7 +326,7 @@ module DyspatchClient
327
326
  return nil if accepts.nil? || accepts.empty?
328
327
  # use JSON when present, otherwise use all of the provided
329
328
  json_accept = accepts.find { |s| json_mime?(s) }
330
- return json_accept || accepts.join(',')
329
+ json_accept || accepts.join(',')
331
330
  end
332
331
 
333
332
  # Return Content-Type header based on an array of content types provided.
@@ -338,7 +337,7 @@ module DyspatchClient
338
337
  return 'application/json' if content_types.nil? || content_types.empty?
339
338
  # use JSON when present, otherwise use the first one
340
339
  json_content_type = content_types.find { |s| json_mime?(s) }
341
- return json_content_type || content_types.first
340
+ json_content_type || content_types.first
342
341
  end
343
342
 
344
343
  # Convert object (array, hash, object, etc) to JSON string.
@@ -348,7 +347,7 @@ module DyspatchClient
348
347
  return model if model.nil? || model.is_a?(String)
349
348
  local_body = nil
350
349
  if model.is_a?(Array)
351
- local_body = model.map{|m| object_to_hash(m) }
350
+ local_body = model.map { |m| object_to_hash(m) }
352
351
  else
353
352
  local_body = object_to_hash(model)
354
353
  end