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.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +50 -34
- data/Rakefile +2 -0
- data/docs/APIError.md +12 -1
- data/docs/CompiledRead.md +13 -0
- data/docs/Cursor.md +11 -1
- data/docs/DraftMetaRead.md +27 -0
- data/docs/DraftRead.md +31 -0
- data/docs/DraftsApi.md +476 -0
- data/docs/DraftsRead.md +19 -0
- data/docs/InlineObject.md +17 -0
- data/docs/LocalizationKeyRead.md +19 -0
- data/docs/LocalizationMetaRead.md +15 -1
- data/docs/LocalizationRead.md +19 -1
- data/docs/LocalizationsApi.md +16 -18
- data/docs/TemplateMetaRead.md +15 -0
- data/docs/TemplateRead.md +16 -0
- data/docs/TemplatesApi.md +39 -40
- data/docs/TemplatesRead.md +10 -0
- data/dyspatch_client.gemspec +10 -16
- data/lib/dyspatch_client.rb +10 -4
- data/lib/dyspatch_client/api/drafts_api.rb +620 -0
- data/lib/dyspatch_client/api/localizations_api.rb +52 -34
- data/lib/dyspatch_client/api/templates_api.rb +100 -69
- data/lib/dyspatch_client/api_client.rb +54 -55
- data/lib/dyspatch_client/api_error.rb +23 -4
- data/lib/dyspatch_client/configuration.rb +49 -10
- data/lib/dyspatch_client/models/api_error.rb +50 -30
- data/lib/dyspatch_client/models/compiled_read.rb +49 -78
- data/lib/dyspatch_client/models/cursor.rb +47 -28
- data/lib/dyspatch_client/models/draft_meta_read.rb +258 -0
- data/lib/dyspatch_client/models/draft_read.rb +279 -0
- data/lib/dyspatch_client/models/drafts_read.rb +219 -0
- data/lib/dyspatch_client/models/inline_object.rb +206 -0
- data/lib/dyspatch_client/models/localization_key_read.rb +216 -0
- data/lib/dyspatch_client/models/localization_meta_read.rb +70 -39
- data/lib/dyspatch_client/models/localization_read.rb +73 -42
- data/lib/dyspatch_client/models/template_meta_read.rb +52 -33
- data/lib/dyspatch_client/models/template_read.rb +53 -34
- data/lib/dyspatch_client/models/templates_read.rb +45 -26
- data/lib/dyspatch_client/version.rb +5 -5
- data/pkg/dyspatch_client-5.0.0.gem +0 -0
- data/pkg/dyspatch_client-5.0.1.gem +0 -0
- data/spec/api/drafts_api_spec.rb +146 -0
- data/spec/api/localizations_api_spec.rb +12 -12
- data/spec/api/templates_api_spec.rb +24 -24
- data/spec/api_client_spec.rb +39 -39
- data/spec/configuration_spec.rb +12 -12
- data/spec/integration_spec.rb +41 -0
- data/spec/models/api_error_spec.rb +12 -13
- data/spec/models/compiled_read_spec.rb +10 -11
- data/spec/models/cursor_spec.rb +7 -8
- data/spec/models/draft_meta_read_spec.rb +77 -0
- data/spec/models/draft_read_spec.rb +83 -0
- data/spec/models/drafts_read_spec.rb +47 -0
- data/spec/models/inline_object_spec.rb +41 -0
- data/spec/models/localization_key_read_spec.rb +47 -0
- data/spec/models/localization_meta_read_spec.rb +18 -13
- data/spec/models/localization_read_spec.rb +20 -15
- data/spec/models/template_meta_read_spec.rb +12 -13
- data/spec/models/template_read_spec.rb +13 -14
- data/spec/models/templates_read_spec.rb +7 -8
- data/spec/spec_helper.rb +4 -4
- metadata +34 -128
- 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
|
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
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
7
|
Contact: support@dyspatch.io
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require
|
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
|
31
|
-
data, _status_code, _headers =
|
32
|
-
|
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
|
-
# @
|
40
|
-
|
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
|
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.
|
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
|
-
|
51
|
-
|
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 =
|
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'] =
|
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.
|
64
|
-
header_params[:'Accept'] =
|
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 =
|
71
|
-
|
72
|
-
|
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 =>
|
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#
|
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
|
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
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
7
|
Contact: support@dyspatch.io
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require
|
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
|
-
#
|
24
|
-
#
|
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 \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
|
25
27
|
# @param [Hash] opts the optional parameters
|
26
|
-
# @
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
#
|
35
|
-
# Gets a
|
34
|
+
# Get Template by ID
|
35
|
+
# Gets a template object with the matching ID. If the template has published content the \"compiled\" 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 \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
|
36
39
|
# @param [Hash] opts the optional parameters
|
37
|
-
# @
|
38
|
-
|
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
|
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 =
|
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[:'
|
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.
|
55
|
-
header_params[:'Accept'] =
|
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 =
|
62
|
-
|
63
|
-
|
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 =>
|
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#
|
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
|
-
#
|
77
|
-
# Gets a
|
78
|
-
# @param
|
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 \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
|
79
106
|
# @param [Hash] opts the optional parameters
|
80
|
-
# @option opts [String] :
|
81
|
-
# @
|
82
|
-
|
83
|
-
|
84
|
-
data
|
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
|
-
#
|
89
|
-
# Gets a
|
90
|
-
# @param
|
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 \"2020.04\", set the value to \"application/vnd.dyspatch.2020.04+json\"
|
91
117
|
# @param [Hash] opts the optional parameters
|
92
|
-
# @option opts [String] :
|
93
|
-
# @
|
94
|
-
|
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
|
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
|
-
|
104
|
-
|
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 =
|
129
|
+
local_var_path = '/templates'
|
108
130
|
|
109
131
|
# query parameters
|
110
|
-
query_params = {}
|
111
|
-
query_params[:'
|
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.
|
117
|
-
header_params[:'Accept'] =
|
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 =
|
124
|
-
|
125
|
-
|
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 =>
|
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#
|
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
|
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
|
6
|
+
The version of the OpenAPI document: 2020.04
|
7
7
|
Contact: support@dyspatch.io
|
8
|
-
Generated by: https://
|
9
|
-
|
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 = "
|
33
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
35
34
|
@default_headers = {
|
36
|
-
'Content-Type' =>
|
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,
|
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
|
-
|
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
|
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 '
|
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).
|
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
|
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
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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
|
-
|
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.
|
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
|
-
|
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
|
-
|
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
|