rainbow-submarine-test-3356 1.2.2
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 +7 -0
- data/Gemfile +7 -0
- data/README.md +150 -0
- data/Rakefile +8 -0
- data/docs/AppUser.md +14 -0
- data/docs/AppUserApi.md +616 -0
- data/docs/AppUserLink.md +9 -0
- data/docs/AppUserPreCreate.md +14 -0
- data/docs/AppUserResponse.md +8 -0
- data/docs/AppUserUpdate.md +12 -0
- data/docs/Client.md +12 -0
- data/docs/ClientInfo.md +15 -0
- data/docs/ClientResponse.md +8 -0
- data/docs/Conversation.md +9 -0
- data/docs/ConversationApi.md +192 -0
- data/docs/DeviceUpdate.md +10 -0
- data/docs/Event.md +8 -0
- data/docs/GetMessagesResponse.md +10 -0
- data/docs/Menu.md +9 -0
- data/docs/MenuApi.md +163 -0
- data/docs/MenuItem.md +13 -0
- data/docs/MenuResponse.md +8 -0
- data/docs/Message.md +17 -0
- data/docs/MessageResponse.md +9 -0
- data/docs/Postback.md +11 -0
- data/docs/TrackEventResponse.md +8 -0
- data/docs/TypingActivityTrigger.md +11 -0
- data/git_push.sh +55 -0
- data/lib/rainbow-submarine-test-3356.rb +61 -0
- data/lib/rainbow-submarine-test-3356/api/app_user_api.rb +585 -0
- data/lib/rainbow-submarine-test-3356/api/conversation_api.rb +189 -0
- data/lib/rainbow-submarine-test-3356/api/menu_api.rb +173 -0
- data/lib/rainbow-submarine-test-3356/api_client.rb +376 -0
- data/lib/rainbow-submarine-test-3356/api_error.rb +37 -0
- data/lib/rainbow-submarine-test-3356/configuration.rb +209 -0
- data/lib/rainbow-submarine-test-3356/models/app_user.rb +258 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_link.rb +201 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_pre_create.rb +246 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_response.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/app_user_update.rb +223 -0
- data/lib/rainbow-submarine-test-3356/models/client.rb +248 -0
- data/lib/rainbow-submarine-test-3356/models/client_info.rb +250 -0
- data/lib/rainbow-submarine-test-3356/models/client_response.rb +187 -0
- data/lib/rainbow-submarine-test-3356/models/conversation.rb +206 -0
- data/lib/rainbow-submarine-test-3356/models/device_update.rb +205 -0
- data/lib/rainbow-submarine-test-3356/models/event.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/get_messages_response.rb +207 -0
- data/lib/rainbow-submarine-test-3356/models/menu.rb +203 -0
- data/lib/rainbow-submarine-test-3356/models/menu_item.rb +242 -0
- data/lib/rainbow-submarine-test-3356/models/menu_response.rb +192 -0
- data/lib/rainbow-submarine-test-3356/models/message.rb +303 -0
- data/lib/rainbow-submarine-test-3356/models/message_response.rb +206 -0
- data/lib/rainbow-submarine-test-3356/models/postback.rb +229 -0
- data/lib/rainbow-submarine-test-3356/models/track_event_response.rb +187 -0
- data/lib/rainbow-submarine-test-3356/models/typing_activity_trigger.rb +224 -0
- data/lib/rainbow-submarine-test-3356/version.rb +14 -0
- data/lib/swagger_client.rb +61 -0
- data/lib/swagger_client/api/app_user_api.rb +585 -0
- data/lib/swagger_client/api/conversation_api.rb +189 -0
- data/lib/swagger_client/api/menu_api.rb +173 -0
- data/lib/swagger_client/api_client.rb +376 -0
- data/lib/swagger_client/api_error.rb +37 -0
- data/lib/swagger_client/configuration.rb +209 -0
- data/lib/swagger_client/models/app_user.rb +258 -0
- data/lib/swagger_client/models/app_user_link.rb +201 -0
- data/lib/swagger_client/models/app_user_pre_create.rb +246 -0
- data/lib/swagger_client/models/app_user_response.rb +192 -0
- data/lib/swagger_client/models/app_user_update.rb +223 -0
- data/lib/swagger_client/models/client.rb +248 -0
- data/lib/swagger_client/models/client_info.rb +250 -0
- data/lib/swagger_client/models/client_response.rb +187 -0
- data/lib/swagger_client/models/conversation.rb +206 -0
- data/lib/swagger_client/models/device_update.rb +205 -0
- data/lib/swagger_client/models/event.rb +192 -0
- data/lib/swagger_client/models/get_messages_response.rb +207 -0
- data/lib/swagger_client/models/menu.rb +203 -0
- data/lib/swagger_client/models/menu_item.rb +242 -0
- data/lib/swagger_client/models/menu_response.rb +192 -0
- data/lib/swagger_client/models/message.rb +303 -0
- data/lib/swagger_client/models/message_response.rb +206 -0
- data/lib/swagger_client/models/postback.rb +229 -0
- data/lib/swagger_client/models/track_event_response.rb +187 -0
- data/lib/swagger_client/models/typing_activity_trigger.rb +224 -0
- data/lib/swagger_client/version.rb +14 -0
- data/rainbow-submarine-test-3356.gemspec +44 -0
- data/spec/api/app_user_api_spec.rb +162 -0
- data/spec/api/conversation_api_spec.rb +73 -0
- data/spec/api/menu_api_spec.rb +68 -0
- data/spec/api_client_spec.rb +225 -0
- data/spec/configuration_spec.rb +41 -0
- data/spec/models/app_user_link_spec.rb +47 -0
- data/spec/models/app_user_pre_create_spec.rb +77 -0
- data/spec/models/app_user_response_spec.rb +41 -0
- data/spec/models/app_user_spec.rb +77 -0
- data/spec/models/app_user_update_spec.rb +65 -0
- data/spec/models/client_info_spec.rb +83 -0
- data/spec/models/client_response_spec.rb +41 -0
- data/spec/models/client_spec.rb +65 -0
- data/spec/models/conversation_spec.rb +47 -0
- data/spec/models/device_update_spec.rb +53 -0
- data/spec/models/event_spec.rb +41 -0
- data/spec/models/get_messages_response_spec.rb +53 -0
- data/spec/models/menu_item_spec.rb +71 -0
- data/spec/models/menu_response_spec.rb +41 -0
- data/spec/models/menu_spec.rb +47 -0
- data/spec/models/message_response_spec.rb +47 -0
- data/spec/models/message_spec.rb +95 -0
- data/spec/models/postback_spec.rb +59 -0
- data/spec/models/track_event_response_spec.rb +41 -0
- data/spec/models/typing_activity_trigger_spec.rb +59 -0
- data/spec/spec_helper.rb +110 -0
- data/swagger_client.gemspec +45 -0
- metadata +361 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
=begin
|
2
|
+
#Smooch
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require "uri"
|
13
|
+
|
14
|
+
module SwaggerClient
|
15
|
+
class ConversationApi
|
16
|
+
attr_accessor :api_client
|
17
|
+
|
18
|
+
def initialize(api_client = ApiClient.default)
|
19
|
+
@api_client = api_client
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Get the specified app users messages.
|
24
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @option opts [String] :before Timestamp of message. The API will return 100 messages before the specified timestamp (excluding any messages with the provided timestamp).
|
27
|
+
# @option opts [String] :after Timestamp of message. The API will return 100 messages after the specified timestamp (excluding any messages with the provided timestamp).
|
28
|
+
# @return [GetMessagesResponse]
|
29
|
+
def get_messages(user_id, opts = {})
|
30
|
+
data, _status_code, _headers = get_messages_with_http_info(user_id, opts)
|
31
|
+
return data
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Get the specified app users messages.
|
36
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @option opts [String] :before Timestamp of message. The API will return 100 messages before the specified timestamp (excluding any messages with the provided timestamp).
|
39
|
+
# @option opts [String] :after Timestamp of message. The API will return 100 messages after the specified timestamp (excluding any messages with the provided timestamp).
|
40
|
+
# @return [Array<(GetMessagesResponse, Fixnum, Hash)>] GetMessagesResponse data, response status code and response headers
|
41
|
+
def get_messages_with_http_info(user_id, opts = {})
|
42
|
+
if @api_client.config.debugging
|
43
|
+
@api_client.config.logger.debug "Calling API: ConversationApi.get_messages ..."
|
44
|
+
end
|
45
|
+
# verify the required parameter 'user_id' is set
|
46
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.get_messages" if user_id.nil?
|
47
|
+
# resource path
|
48
|
+
local_var_path = "/appusers/{userId}/messages".sub('{' + 'userId' + '}', user_id.to_s)
|
49
|
+
|
50
|
+
# query parameters
|
51
|
+
query_params = {}
|
52
|
+
query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
|
53
|
+
query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
|
54
|
+
|
55
|
+
# header parameters
|
56
|
+
header_params = {}
|
57
|
+
# HTTP header 'Accept' (if needed)
|
58
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
59
|
+
# HTTP header 'Content-Type'
|
60
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
61
|
+
|
62
|
+
# form parameters
|
63
|
+
form_params = {}
|
64
|
+
|
65
|
+
# http body (model)
|
66
|
+
post_body = nil
|
67
|
+
auth_names = ['appToken', 'jwt']
|
68
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
69
|
+
:header_params => header_params,
|
70
|
+
:query_params => query_params,
|
71
|
+
:form_params => form_params,
|
72
|
+
:body => post_body,
|
73
|
+
:auth_names => auth_names,
|
74
|
+
:return_type => 'GetMessagesResponse')
|
75
|
+
if @api_client.config.debugging
|
76
|
+
@api_client.config.logger.debug "API called: ConversationApi#get_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
77
|
+
end
|
78
|
+
return data, status_code, headers
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Reset the unread count of the conversation to 0. If the conversation has not yet been created for the specified app user 404 will be returned.
|
83
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
84
|
+
# @param [Hash] opts the optional parameters
|
85
|
+
# @return [nil]
|
86
|
+
def reset_unread_count(user_id, opts = {})
|
87
|
+
reset_unread_count_with_http_info(user_id, opts)
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Reset the unread count of the conversation to 0. If the conversation has not yet been created for the specified app user 404 will be returned.
|
93
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
94
|
+
# @param [Hash] opts the optional parameters
|
95
|
+
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
96
|
+
def reset_unread_count_with_http_info(user_id, opts = {})
|
97
|
+
if @api_client.config.debugging
|
98
|
+
@api_client.config.logger.debug "Calling API: ConversationApi.reset_unread_count ..."
|
99
|
+
end
|
100
|
+
# verify the required parameter 'user_id' is set
|
101
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.reset_unread_count" if user_id.nil?
|
102
|
+
# resource path
|
103
|
+
local_var_path = "/appusers/{userId}/conversation/read".sub('{' + 'userId' + '}', user_id.to_s)
|
104
|
+
|
105
|
+
# query parameters
|
106
|
+
query_params = {}
|
107
|
+
|
108
|
+
# header parameters
|
109
|
+
header_params = {}
|
110
|
+
# HTTP header 'Accept' (if needed)
|
111
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
112
|
+
# HTTP header 'Content-Type'
|
113
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
114
|
+
|
115
|
+
# form parameters
|
116
|
+
form_params = {}
|
117
|
+
|
118
|
+
# http body (model)
|
119
|
+
post_body = nil
|
120
|
+
auth_names = ['appToken', 'jwt']
|
121
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
122
|
+
:header_params => header_params,
|
123
|
+
:query_params => query_params,
|
124
|
+
:form_params => form_params,
|
125
|
+
:body => post_body,
|
126
|
+
:auth_names => auth_names)
|
127
|
+
if @api_client.config.debugging
|
128
|
+
@api_client.config.logger.debug "API called: ConversationApi#reset_unread_count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
129
|
+
end
|
130
|
+
return data, status_code, headers
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Notify Smooch when an app maker starts or stops typing a response.
|
135
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
136
|
+
# @param typing_activity_trigger Supported properties for a triggerTypingActivity request.
|
137
|
+
# @param [Hash] opts the optional parameters
|
138
|
+
# @return [nil]
|
139
|
+
def trigger_typing_activity(user_id, typing_activity_trigger, opts = {})
|
140
|
+
trigger_typing_activity_with_http_info(user_id, typing_activity_trigger, opts)
|
141
|
+
return nil
|
142
|
+
end
|
143
|
+
|
144
|
+
#
|
145
|
+
# Notify Smooch when an app maker starts or stops typing a response.
|
146
|
+
# @param user_id Identifies the user. Can be either the smoochId or the userId.
|
147
|
+
# @param typing_activity_trigger Supported properties for a triggerTypingActivity request.
|
148
|
+
# @param [Hash] opts the optional parameters
|
149
|
+
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
150
|
+
def trigger_typing_activity_with_http_info(user_id, typing_activity_trigger, opts = {})
|
151
|
+
if @api_client.config.debugging
|
152
|
+
@api_client.config.logger.debug "Calling API: ConversationApi.trigger_typing_activity ..."
|
153
|
+
end
|
154
|
+
# verify the required parameter 'user_id' is set
|
155
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling ConversationApi.trigger_typing_activity" if user_id.nil?
|
156
|
+
# verify the required parameter 'typing_activity_trigger' is set
|
157
|
+
fail ArgumentError, "Missing the required parameter 'typing_activity_trigger' when calling ConversationApi.trigger_typing_activity" if typing_activity_trigger.nil?
|
158
|
+
# resource path
|
159
|
+
local_var_path = "/appusers/{userId}/conversation/activity".sub('{' + 'userId' + '}', user_id.to_s)
|
160
|
+
|
161
|
+
# query parameters
|
162
|
+
query_params = {}
|
163
|
+
|
164
|
+
# header parameters
|
165
|
+
header_params = {}
|
166
|
+
# HTTP header 'Accept' (if needed)
|
167
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
168
|
+
# HTTP header 'Content-Type'
|
169
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
170
|
+
|
171
|
+
# form parameters
|
172
|
+
form_params = {}
|
173
|
+
|
174
|
+
# http body (model)
|
175
|
+
post_body = @api_client.object_to_http_body(typing_activity_trigger)
|
176
|
+
auth_names = ['appToken', 'jwt']
|
177
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
178
|
+
:header_params => header_params,
|
179
|
+
:query_params => query_params,
|
180
|
+
:form_params => form_params,
|
181
|
+
:body => post_body,
|
182
|
+
:auth_names => auth_names)
|
183
|
+
if @api_client.config.debugging
|
184
|
+
@api_client.config.logger.debug "API called: ConversationApi#trigger_typing_activity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
185
|
+
end
|
186
|
+
return data, status_code, headers
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
=begin
|
2
|
+
#Smooch
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require "uri"
|
13
|
+
|
14
|
+
module SwaggerClient
|
15
|
+
class MenuApi
|
16
|
+
attr_accessor :api_client
|
17
|
+
|
18
|
+
def initialize(api_client = ApiClient.default)
|
19
|
+
@api_client = api_client
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Remove the specified app’s menu.
|
24
|
+
# @param [Hash] opts the optional parameters
|
25
|
+
# @return [MenuResponse]
|
26
|
+
def delete_menu(opts = {})
|
27
|
+
data, _status_code, _headers = delete_menu_with_http_info(opts)
|
28
|
+
return data
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Remove the specified app’s menu.
|
33
|
+
# @param [Hash] opts the optional parameters
|
34
|
+
# @return [Array<(MenuResponse, Fixnum, Hash)>] MenuResponse data, response status code and response headers
|
35
|
+
def delete_menu_with_http_info(opts = {})
|
36
|
+
if @api_client.config.debugging
|
37
|
+
@api_client.config.logger.debug "Calling API: MenuApi.delete_menu ..."
|
38
|
+
end
|
39
|
+
# resource path
|
40
|
+
local_var_path = "/menu"
|
41
|
+
|
42
|
+
# query parameters
|
43
|
+
query_params = {}
|
44
|
+
|
45
|
+
# header parameters
|
46
|
+
header_params = {}
|
47
|
+
# HTTP header 'Accept' (if needed)
|
48
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
49
|
+
# HTTP header 'Content-Type'
|
50
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
51
|
+
|
52
|
+
# form parameters
|
53
|
+
form_params = {}
|
54
|
+
|
55
|
+
# http body (model)
|
56
|
+
post_body = nil
|
57
|
+
auth_names = ['appToken', 'jwt']
|
58
|
+
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
|
59
|
+
:header_params => header_params,
|
60
|
+
:query_params => query_params,
|
61
|
+
:form_params => form_params,
|
62
|
+
:body => post_body,
|
63
|
+
:auth_names => auth_names,
|
64
|
+
:return_type => 'MenuResponse')
|
65
|
+
if @api_client.config.debugging
|
66
|
+
@api_client.config.logger.debug "API called: MenuApi#delete_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
67
|
+
end
|
68
|
+
return data, status_code, headers
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Get the specified app’s menu.
|
73
|
+
# @param [Hash] opts the optional parameters
|
74
|
+
# @return [MenuResponse]
|
75
|
+
def get_menu(opts = {})
|
76
|
+
data, _status_code, _headers = get_menu_with_http_info(opts)
|
77
|
+
return data
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Get the specified app’s menu.
|
82
|
+
# @param [Hash] opts the optional parameters
|
83
|
+
# @return [Array<(MenuResponse, Fixnum, Hash)>] MenuResponse data, response status code and response headers
|
84
|
+
def get_menu_with_http_info(opts = {})
|
85
|
+
if @api_client.config.debugging
|
86
|
+
@api_client.config.logger.debug "Calling API: MenuApi.get_menu ..."
|
87
|
+
end
|
88
|
+
# resource path
|
89
|
+
local_var_path = "/menu"
|
90
|
+
|
91
|
+
# query parameters
|
92
|
+
query_params = {}
|
93
|
+
|
94
|
+
# header parameters
|
95
|
+
header_params = {}
|
96
|
+
# HTTP header 'Accept' (if needed)
|
97
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
98
|
+
# HTTP header 'Content-Type'
|
99
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
100
|
+
|
101
|
+
# form parameters
|
102
|
+
form_params = {}
|
103
|
+
|
104
|
+
# http body (model)
|
105
|
+
post_body = nil
|
106
|
+
auth_names = ['jwt']
|
107
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
108
|
+
:header_params => header_params,
|
109
|
+
:query_params => query_params,
|
110
|
+
:form_params => form_params,
|
111
|
+
:body => post_body,
|
112
|
+
:auth_names => auth_names,
|
113
|
+
:return_type => 'MenuResponse')
|
114
|
+
if @api_client.config.debugging
|
115
|
+
@api_client.config.logger.debug "API called: MenuApi#get_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
116
|
+
end
|
117
|
+
return data, status_code, headers
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
# Configure the specified app’s menu.
|
122
|
+
# @param menu_update Supported properties for a updateMenu request.
|
123
|
+
# @param [Hash] opts the optional parameters
|
124
|
+
# @return [MenuResponse]
|
125
|
+
def update_menu(menu_update, opts = {})
|
126
|
+
data, _status_code, _headers = update_menu_with_http_info(menu_update, opts)
|
127
|
+
return data
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Configure the specified app’s menu.
|
132
|
+
# @param menu_update Supported properties for a updateMenu request.
|
133
|
+
# @param [Hash] opts the optional parameters
|
134
|
+
# @return [Array<(MenuResponse, Fixnum, Hash)>] MenuResponse data, response status code and response headers
|
135
|
+
def update_menu_with_http_info(menu_update, opts = {})
|
136
|
+
if @api_client.config.debugging
|
137
|
+
@api_client.config.logger.debug "Calling API: MenuApi.update_menu ..."
|
138
|
+
end
|
139
|
+
# verify the required parameter 'menu_update' is set
|
140
|
+
fail ArgumentError, "Missing the required parameter 'menu_update' when calling MenuApi.update_menu" if menu_update.nil?
|
141
|
+
# resource path
|
142
|
+
local_var_path = "/menu"
|
143
|
+
|
144
|
+
# query parameters
|
145
|
+
query_params = {}
|
146
|
+
|
147
|
+
# header parameters
|
148
|
+
header_params = {}
|
149
|
+
# HTTP header 'Accept' (if needed)
|
150
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
151
|
+
# HTTP header 'Content-Type'
|
152
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
153
|
+
|
154
|
+
# form parameters
|
155
|
+
form_params = {}
|
156
|
+
|
157
|
+
# http body (model)
|
158
|
+
post_body = @api_client.object_to_http_body(menu_update)
|
159
|
+
auth_names = ['jwt']
|
160
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
|
161
|
+
:header_params => header_params,
|
162
|
+
:query_params => query_params,
|
163
|
+
:form_params => form_params,
|
164
|
+
:body => post_body,
|
165
|
+
:auth_names => auth_names,
|
166
|
+
:return_type => 'MenuResponse')
|
167
|
+
if @api_client.config.debugging
|
168
|
+
@api_client.config.logger.debug "API called: MenuApi#update_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
169
|
+
end
|
170
|
+
return data, status_code, headers
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,376 @@
|
|
1
|
+
=begin
|
2
|
+
#Smooch
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
require 'json'
|
14
|
+
require 'logger'
|
15
|
+
require 'tempfile'
|
16
|
+
require 'typhoeus'
|
17
|
+
require 'uri'
|
18
|
+
|
19
|
+
module SwaggerClient
|
20
|
+
class ApiClient
|
21
|
+
# The Configuration object holding settings to be used in the API client.
|
22
|
+
attr_accessor :config
|
23
|
+
|
24
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
25
|
+
#
|
26
|
+
# @return [Hash]
|
27
|
+
attr_accessor :default_headers
|
28
|
+
|
29
|
+
# Initializes the ApiClient
|
30
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
31
|
+
def initialize(config = Configuration.default)
|
32
|
+
@config = config
|
33
|
+
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
34
|
+
@default_headers = {
|
35
|
+
'Content-Type' => "application/json",
|
36
|
+
'User-Agent' => @user_agent
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.default
|
41
|
+
@@default ||= ApiClient.new
|
42
|
+
end
|
43
|
+
|
44
|
+
# Call an API with given options.
|
45
|
+
#
|
46
|
+
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
|
47
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
48
|
+
def call_api(http_method, path, opts = {})
|
49
|
+
request = build_request(http_method, path, opts)
|
50
|
+
response = request.run
|
51
|
+
|
52
|
+
if @config.debugging
|
53
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
unless response.success?
|
57
|
+
if response.timed_out?
|
58
|
+
fail ApiError.new('Connection timed out')
|
59
|
+
elsif response.code == 0
|
60
|
+
# Errors from libcurl will be made visible here
|
61
|
+
fail ApiError.new(:code => 0,
|
62
|
+
:message => response.return_message)
|
63
|
+
else
|
64
|
+
fail ApiError.new(:code => response.code,
|
65
|
+
:response_headers => response.headers,
|
66
|
+
:response_body => response.body),
|
67
|
+
response.status_message
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if opts[:return_type]
|
72
|
+
data = deserialize(response, opts[:return_type])
|
73
|
+
else
|
74
|
+
data = nil
|
75
|
+
end
|
76
|
+
return data, response.code, response.headers
|
77
|
+
end
|
78
|
+
|
79
|
+
# Builds the HTTP request
|
80
|
+
#
|
81
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
82
|
+
# @param [String] path URL path (e.g. /account/new)
|
83
|
+
# @option opts [Hash] :header_params Header parameters
|
84
|
+
# @option opts [Hash] :query_params Query parameters
|
85
|
+
# @option opts [Hash] :form_params Query parameters
|
86
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
87
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
88
|
+
def build_request(http_method, path, opts = {})
|
89
|
+
url = build_request_url(path)
|
90
|
+
http_method = http_method.to_sym.downcase
|
91
|
+
|
92
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
93
|
+
query_params = opts[:query_params] || {}
|
94
|
+
form_params = opts[:form_params] || {}
|
95
|
+
|
96
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
97
|
+
|
98
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
99
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
100
|
+
|
101
|
+
req_opts = {
|
102
|
+
:method => http_method,
|
103
|
+
:headers => header_params,
|
104
|
+
:params => query_params,
|
105
|
+
:params_encoding => @config.params_encoding,
|
106
|
+
:timeout => @config.timeout,
|
107
|
+
:ssl_verifypeer => @config.verify_ssl,
|
108
|
+
:ssl_verifyhost => _verify_ssl_host,
|
109
|
+
:sslcert => @config.cert_file,
|
110
|
+
:sslkey => @config.key_file,
|
111
|
+
:verbose => @config.debugging
|
112
|
+
}
|
113
|
+
|
114
|
+
# set custom cert, if provided
|
115
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
116
|
+
|
117
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
118
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
119
|
+
req_opts.update :body => req_body
|
120
|
+
if @config.debugging
|
121
|
+
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
Typhoeus::Request.new(url, req_opts)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Check if the given MIME is a JSON MIME.
|
129
|
+
# JSON MIME examples:
|
130
|
+
# application/json
|
131
|
+
# application/json; charset=UTF8
|
132
|
+
# APPLICATION/JSON
|
133
|
+
# */*
|
134
|
+
# @param [String] mime MIME
|
135
|
+
# @return [Boolean] True if the MIME is application/json
|
136
|
+
def json_mime?(mime)
|
137
|
+
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
138
|
+
end
|
139
|
+
|
140
|
+
# Deserialize the response to the given return type.
|
141
|
+
#
|
142
|
+
# @param [Response] response HTTP response
|
143
|
+
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
144
|
+
def deserialize(response, return_type)
|
145
|
+
body = response.body
|
146
|
+
return nil if body.nil? || body.empty?
|
147
|
+
|
148
|
+
# return response body directly for String return type
|
149
|
+
return body if return_type == 'String'
|
150
|
+
|
151
|
+
# handle file downloading - save response body into a tmp file and return the File instance
|
152
|
+
return download_file(response) if return_type == 'File'
|
153
|
+
|
154
|
+
# ensuring a default content type
|
155
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
156
|
+
|
157
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
158
|
+
|
159
|
+
begin
|
160
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
161
|
+
rescue JSON::ParserError => e
|
162
|
+
if %w(String Date DateTime).include?(return_type)
|
163
|
+
data = body
|
164
|
+
else
|
165
|
+
raise e
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
convert_to_type data, return_type
|
170
|
+
end
|
171
|
+
|
172
|
+
# Convert data to the given return type.
|
173
|
+
# @param [Object] data Data to be converted
|
174
|
+
# @param [String] return_type Return type
|
175
|
+
# @return [Mixed] Data in a particular type
|
176
|
+
def convert_to_type(data, return_type)
|
177
|
+
return nil if data.nil?
|
178
|
+
case return_type
|
179
|
+
when 'String'
|
180
|
+
data.to_s
|
181
|
+
when 'Integer'
|
182
|
+
data.to_i
|
183
|
+
when 'Float'
|
184
|
+
data.to_f
|
185
|
+
when 'BOOLEAN'
|
186
|
+
data == true
|
187
|
+
when 'DateTime'
|
188
|
+
# parse date time (expecting ISO 8601 format)
|
189
|
+
DateTime.parse data
|
190
|
+
when 'Date'
|
191
|
+
# parse date time (expecting ISO 8601 format)
|
192
|
+
Date.parse data
|
193
|
+
when 'Object'
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
data
|
196
|
+
when /\AArray<(.+)>\z/
|
197
|
+
# e.g. Array<Pet>
|
198
|
+
sub_type = $1
|
199
|
+
data.map {|item| convert_to_type(item, sub_type) }
|
200
|
+
when /\AHash\<String, (.+)\>\z/
|
201
|
+
# e.g. Hash<String, Integer>
|
202
|
+
sub_type = $1
|
203
|
+
{}.tap do |hash|
|
204
|
+
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
205
|
+
end
|
206
|
+
else
|
207
|
+
# models, e.g. Pet
|
208
|
+
SwaggerClient.const_get(return_type).new.tap do |model|
|
209
|
+
model.build_from_hash data
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
215
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
216
|
+
#
|
217
|
+
# @see Configuration#temp_folder_path
|
218
|
+
# @return [Tempfile] the file downloaded
|
219
|
+
def download_file(response)
|
220
|
+
content_disposition = response.headers['Content-Disposition']
|
221
|
+
if content_disposition and content_disposition =~ /filename=/i
|
222
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
223
|
+
prefix = sanitize_filename(filename)
|
224
|
+
else
|
225
|
+
prefix = 'download-'
|
226
|
+
end
|
227
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
228
|
+
|
229
|
+
tempfile = nil
|
230
|
+
encoding = response.body.encoding
|
231
|
+
Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
|
232
|
+
file.write(response.body)
|
233
|
+
tempfile = file
|
234
|
+
end
|
235
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
236
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
237
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
238
|
+
"explicitly with `tempfile.delete`"
|
239
|
+
tempfile
|
240
|
+
end
|
241
|
+
|
242
|
+
# Sanitize filename by removing path.
|
243
|
+
# e.g. ../../sun.gif becomes sun.gif
|
244
|
+
#
|
245
|
+
# @param [String] filename the filename to be sanitized
|
246
|
+
# @return [String] the sanitized filename
|
247
|
+
def sanitize_filename(filename)
|
248
|
+
filename.gsub(/.*[\/\\]/, '')
|
249
|
+
end
|
250
|
+
|
251
|
+
def build_request_url(path)
|
252
|
+
# Add leading and trailing slashes to path
|
253
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
254
|
+
URI.encode(@config.base_url + path)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Builds the HTTP request body
|
258
|
+
#
|
259
|
+
# @param [Hash] header_params Header parameters
|
260
|
+
# @param [Hash] form_params Query parameters
|
261
|
+
# @param [Object] body HTTP body (JSON/XML)
|
262
|
+
# @return [String] HTTP body data in the form of string
|
263
|
+
def build_request_body(header_params, form_params, body)
|
264
|
+
# http form
|
265
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
266
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
267
|
+
data = {}
|
268
|
+
form_params.each do |key, value|
|
269
|
+
case value
|
270
|
+
when File, Array, nil
|
271
|
+
# let typhoeus handle File, Array and nil parameters
|
272
|
+
data[key] = value
|
273
|
+
else
|
274
|
+
data[key] = value.to_s
|
275
|
+
end
|
276
|
+
end
|
277
|
+
elsif body
|
278
|
+
data = body.is_a?(String) ? body : body.to_json
|
279
|
+
else
|
280
|
+
data = nil
|
281
|
+
end
|
282
|
+
data
|
283
|
+
end
|
284
|
+
|
285
|
+
# Update hearder and query params based on authentication settings.
|
286
|
+
#
|
287
|
+
# @param [Hash] header_params Header parameters
|
288
|
+
# @param [Hash] query_params Query parameters
|
289
|
+
# @param [String] auth_names Authentication scheme name
|
290
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
291
|
+
Array(auth_names).each do |auth_name|
|
292
|
+
auth_setting = @config.auth_settings[auth_name]
|
293
|
+
next unless auth_setting
|
294
|
+
case auth_setting[:in]
|
295
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
296
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
297
|
+
else fail ArgumentError, 'Authentication token must be in `query` of `header`'
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
# Sets user agent in HTTP header
|
303
|
+
#
|
304
|
+
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
305
|
+
def user_agent=(user_agent)
|
306
|
+
@user_agent = user_agent
|
307
|
+
@default_headers['User-Agent'] = @user_agent
|
308
|
+
end
|
309
|
+
|
310
|
+
# Return Accept header based on an array of accepts provided.
|
311
|
+
# @param [Array] accepts array for Accept
|
312
|
+
# @return [String] the Accept header (e.g. application/json)
|
313
|
+
def select_header_accept(accepts)
|
314
|
+
return nil if accepts.nil? || accepts.empty?
|
315
|
+
# use JSON when present, otherwise use all of the provided
|
316
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
317
|
+
return json_accept || accepts.join(',')
|
318
|
+
end
|
319
|
+
|
320
|
+
# Return Content-Type header based on an array of content types provided.
|
321
|
+
# @param [Array] content_types array for Content-Type
|
322
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
323
|
+
def select_header_content_type(content_types)
|
324
|
+
# use application/json by default
|
325
|
+
return 'application/json' if content_types.nil? || content_types.empty?
|
326
|
+
# use JSON when present, otherwise use the first one
|
327
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
328
|
+
return json_content_type || content_types.first
|
329
|
+
end
|
330
|
+
|
331
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
332
|
+
# @param [Object] model object to be converted into JSON string
|
333
|
+
# @return [String] JSON string representation of the object
|
334
|
+
def object_to_http_body(model)
|
335
|
+
return model if model.nil? || model.is_a?(String)
|
336
|
+
local_body = nil
|
337
|
+
if model.is_a?(Array)
|
338
|
+
local_body = model.map{|m| object_to_hash(m) }
|
339
|
+
else
|
340
|
+
local_body = object_to_hash(model)
|
341
|
+
end
|
342
|
+
local_body.to_json
|
343
|
+
end
|
344
|
+
|
345
|
+
# Convert object(non-array) to hash.
|
346
|
+
# @param [Object] obj object to be converted into JSON string
|
347
|
+
# @return [String] JSON string representation of the object
|
348
|
+
def object_to_hash(obj)
|
349
|
+
if obj.respond_to?(:to_hash)
|
350
|
+
obj.to_hash
|
351
|
+
else
|
352
|
+
obj
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
# Build parameter value according to the given collection format.
|
357
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
358
|
+
def build_collection_param(param, collection_format)
|
359
|
+
case collection_format
|
360
|
+
when :csv
|
361
|
+
param.join(',')
|
362
|
+
when :ssv
|
363
|
+
param.join(' ')
|
364
|
+
when :tsv
|
365
|
+
param.join("\t")
|
366
|
+
when :pipes
|
367
|
+
param.join('|')
|
368
|
+
when :multi
|
369
|
+
# return the array directly as typhoeus will handle it as expected
|
370
|
+
param
|
371
|
+
else
|
372
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|