dialmycalls_client 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +186 -0
  4. data/dialmycalls_client-1.0.0.gem +0 -0
  5. data/dialmycalls_client.gemspec +55 -0
  6. data/docs/Accessaccount.md +12 -0
  7. data/docs/Account.md +9 -0
  8. data/docs/AccountsApi.md +324 -0
  9. data/docs/CallRecipient.md +19 -0
  10. data/docs/CallerIdsApi.md +386 -0
  11. data/docs/Callerid.md +13 -0
  12. data/docs/CallsApi.md +278 -0
  13. data/docs/Callservice.md +17 -0
  14. data/docs/Contact.md +18 -0
  15. data/docs/ContactAttributes.md +11 -0
  16. data/docs/ContactsApi.md +330 -0
  17. data/docs/CreateAccessAccountParameters.md +10 -0
  18. data/docs/CreateCallParameters.md +18 -0
  19. data/docs/CreateCallerIdParameters.md +9 -0
  20. data/docs/CreateContactParameters.md +14 -0
  21. data/docs/CreateGroupParameters.md +8 -0
  22. data/docs/CreateRecordingByPhoneParameters.md +12 -0
  23. data/docs/CreateRecordingByUrlParameters.md +9 -0
  24. data/docs/CreateRecordingParameters.md +11 -0
  25. data/docs/CreateTextParameters.md +17 -0
  26. data/docs/CreateUnverifiedCallerIdParameters.md +9 -0
  27. data/docs/DoNotContactsApi.md +62 -0
  28. data/docs/Donotcontact.md +12 -0
  29. data/docs/Group.md +12 -0
  30. data/docs/GroupsApi.md +277 -0
  31. data/docs/Identifier.md +8 -0
  32. data/docs/Incomingtext.md +13 -0
  33. data/docs/Keyword.md +12 -0
  34. data/docs/KeywordsApi.md +168 -0
  35. data/docs/Polling.md +10 -0
  36. data/docs/PushToListenAgain.md +9 -0
  37. data/docs/PushToOptOut.md +9 -0
  38. data/docs/PushToRecord.md +9 -0
  39. data/docs/PushToTalk.md +12 -0
  40. data/docs/Recording.md +15 -0
  41. data/docs/RecordingsApi.md +383 -0
  42. data/docs/Service.md +16 -0
  43. data/docs/Shortcode.md +11 -0
  44. data/docs/TextRecipient.md +13 -0
  45. data/docs/TextsApi.md +492 -0
  46. data/docs/UpdateAccessAccountByIdParameters.md +10 -0
  47. data/docs/UpdateCallerIdByIdParameters.md +8 -0
  48. data/docs/UpdateContactByIdParameters.md +14 -0
  49. data/docs/UpdateGroupByIdParameters.md +8 -0
  50. data/docs/UpdateRecordingByIdParameters.md +8 -0
  51. data/docs/UpdateVanityNumberByIdParameters.md +12 -0
  52. data/docs/VanityNumbersApi.md +224 -0
  53. data/docs/Vanitynumber.md +16 -0
  54. data/docs/VerifyCallerIdByIdParameters.md +8 -0
  55. data/git_push.sh +67 -0
  56. data/lib/dialmycalls_client/api/accounts_api.rb +375 -0
  57. data/lib/dialmycalls_client/api/caller_ids_api.rb +440 -0
  58. data/lib/dialmycalls_client/api/calls_api.rb +321 -0
  59. data/lib/dialmycalls_client/api/contacts_api.rb +379 -0
  60. data/lib/dialmycalls_client/api/do_not_contacts_api.rb +90 -0
  61. data/lib/dialmycalls_client/api/groups_api.rb +322 -0
  62. data/lib/dialmycalls_client/api/keywords_api.rb +204 -0
  63. data/lib/dialmycalls_client/api/recordings_api.rb +436 -0
  64. data/lib/dialmycalls_client/api/texts_api.rb +547 -0
  65. data/lib/dialmycalls_client/api/vanity_numbers_api.rb +265 -0
  66. data/lib/dialmycalls_client/api_client.rb +379 -0
  67. data/lib/dialmycalls_client/api_error.rb +47 -0
  68. data/lib/dialmycalls_client/configuration.rb +214 -0
  69. data/lib/dialmycalls_client/models/accessaccount.rb +240 -0
  70. data/lib/dialmycalls_client/models/account.rb +210 -0
  71. data/lib/dialmycalls_client/models/call_recipient.rb +310 -0
  72. data/lib/dialmycalls_client/models/callerid.rb +250 -0
  73. data/lib/dialmycalls_client/models/callservice.rb +290 -0
  74. data/lib/dialmycalls_client/models/contact.rb +300 -0
  75. data/lib/dialmycalls_client/models/contact_attributes.rb +230 -0
  76. data/lib/dialmycalls_client/models/create_access_account_parameters.rb +220 -0
  77. data/lib/dialmycalls_client/models/create_call_parameters.rb +304 -0
  78. data/lib/dialmycalls_client/models/create_caller_id_parameters.rb +210 -0
  79. data/lib/dialmycalls_client/models/create_contact_parameters.rb +262 -0
  80. data/lib/dialmycalls_client/models/create_group_parameters.rb +200 -0
  81. data/lib/dialmycalls_client/models/create_recording_by_phone_parameters.rb +240 -0
  82. data/lib/dialmycalls_client/models/create_recording_by_url_parameters.rb +210 -0
  83. data/lib/dialmycalls_client/models/create_recording_parameters.rb +230 -0
  84. data/lib/dialmycalls_client/models/create_text_parameters.rb +294 -0
  85. data/lib/dialmycalls_client/models/create_unverified_caller_id_parameters.rb +210 -0
  86. data/lib/dialmycalls_client/models/donotcontact.rb +240 -0
  87. data/lib/dialmycalls_client/models/group.rb +240 -0
  88. data/lib/dialmycalls_client/models/identifier.rb +200 -0
  89. data/lib/dialmycalls_client/models/incomingtext.rb +250 -0
  90. data/lib/dialmycalls_client/models/keyword.rb +240 -0
  91. data/lib/dialmycalls_client/models/polling.rb +220 -0
  92. data/lib/dialmycalls_client/models/push_to_listen_again.rb +210 -0
  93. data/lib/dialmycalls_client/models/push_to_opt_out.rb +210 -0
  94. data/lib/dialmycalls_client/models/push_to_record.rb +210 -0
  95. data/lib/dialmycalls_client/models/push_to_talk.rb +240 -0
  96. data/lib/dialmycalls_client/models/recording.rb +270 -0
  97. data/lib/dialmycalls_client/models/service.rb +280 -0
  98. data/lib/dialmycalls_client/models/shortcode.rb +230 -0
  99. data/lib/dialmycalls_client/models/text_recipient.rb +250 -0
  100. data/lib/dialmycalls_client/models/update_access_account_by_id_parameters.rb +220 -0
  101. data/lib/dialmycalls_client/models/update_caller_id_by_id_parameters.rb +200 -0
  102. data/lib/dialmycalls_client/models/update_contact_by_id_parameters.rb +262 -0
  103. data/lib/dialmycalls_client/models/update_group_by_id_parameters.rb +200 -0
  104. data/lib/dialmycalls_client/models/update_recording_by_id_parameters.rb +200 -0
  105. data/lib/dialmycalls_client/models/update_vanity_number_by_id_parameters.rb +242 -0
  106. data/lib/dialmycalls_client/models/vanitynumber.rb +280 -0
  107. data/lib/dialmycalls_client/models/verify_caller_id_by_id_parameters.rb +200 -0
  108. data/lib/dialmycalls_client/version.rb +26 -0
  109. data/lib/dialmycalls_client.rb +99 -0
  110. data/spec/api/accounts_api_spec.rb +118 -0
  111. data/spec/api/caller_ids_api_spec.rb +132 -0
  112. data/spec/api/calls_api_spec.rb +107 -0
  113. data/spec/api/contacts_api_spec.rb +119 -0
  114. data/spec/api/do_not_contacts_api_spec.rb +58 -0
  115. data/spec/api/groups_api_spec.rb +107 -0
  116. data/spec/api/keywords_api_spec.rb +82 -0
  117. data/spec/api/recordings_api_spec.rb +131 -0
  118. data/spec/api/texts_api_spec.rb +155 -0
  119. data/spec/api/vanity_numbers_api_spec.rb +95 -0
  120. data/spec/api_client_spec.rb +237 -0
  121. data/spec/configuration_spec.rb +53 -0
  122. data/spec/models/accessaccount_spec.rb +77 -0
  123. data/spec/models/account_spec.rb +59 -0
  124. data/spec/models/call_recipient_spec.rb +119 -0
  125. data/spec/models/callerid_spec.rb +83 -0
  126. data/spec/models/callservice_spec.rb +107 -0
  127. data/spec/models/contact_attributes_spec.rb +71 -0
  128. data/spec/models/contact_spec.rb +113 -0
  129. data/spec/models/create_access_account_parameters_spec.rb +65 -0
  130. data/spec/models/create_call_parameters_spec.rb +113 -0
  131. data/spec/models/create_caller_id_parameters_spec.rb +59 -0
  132. data/spec/models/create_contact_parameters_spec.rb +89 -0
  133. data/spec/models/create_group_parameters_spec.rb +53 -0
  134. data/spec/models/create_recording_by_phone_parameters_spec.rb +77 -0
  135. data/spec/models/create_recording_by_url_parameters_spec.rb +59 -0
  136. data/spec/models/create_recording_parameters_spec.rb +71 -0
  137. data/spec/models/create_text_parameters_spec.rb +107 -0
  138. data/spec/models/create_unverified_caller_id_parameters_spec.rb +59 -0
  139. data/spec/models/donotcontact_spec.rb +77 -0
  140. data/spec/models/group_spec.rb +77 -0
  141. data/spec/models/identifier_spec.rb +53 -0
  142. data/spec/models/incomingtext_spec.rb +83 -0
  143. data/spec/models/keyword_spec.rb +77 -0
  144. data/spec/models/polling_spec.rb +65 -0
  145. data/spec/models/push_to_listen_again_spec.rb +59 -0
  146. data/spec/models/push_to_opt_out_spec.rb +59 -0
  147. data/spec/models/push_to_record_spec.rb +59 -0
  148. data/spec/models/push_to_talk_spec.rb +77 -0
  149. data/spec/models/recording_spec.rb +95 -0
  150. data/spec/models/service_spec.rb +101 -0
  151. data/spec/models/shortcode_spec.rb +71 -0
  152. data/spec/models/text_recipient_spec.rb +83 -0
  153. data/spec/models/update_access_account_by_id_parameters_spec.rb +65 -0
  154. data/spec/models/update_caller_id_by_id_parameters_spec.rb +53 -0
  155. data/spec/models/update_contact_by_id_parameters_spec.rb +89 -0
  156. data/spec/models/update_group_by_id_parameters_spec.rb +53 -0
  157. data/spec/models/update_recording_by_id_parameters_spec.rb +53 -0
  158. data/spec/models/update_vanity_number_by_id_parameters_spec.rb +77 -0
  159. data/spec/models/vanitynumber_spec.rb +101 -0
  160. data/spec/models/verify_caller_id_by_id_parameters_spec.rb +53 -0
  161. data/spec/spec_helper.rb +122 -0
  162. metadata +436 -0
@@ -0,0 +1,265 @@
1
+ =begin
2
+ #DialMyCalls API
3
+
4
+ #The DialMyCalls API
5
+
6
+ OpenAPI spec version: 2.0.1
7
+ Contact: support@dialmycalls.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require "uri"
25
+
26
+ module DialMyCalls
27
+ class VanityNumbersApi
28
+ attr_accessor :api_client
29
+
30
+ def initialize(api_client = ApiClient.default)
31
+ @api_client = api_client
32
+ end
33
+
34
+ # Delete Vanity Number
35
+ # Delete a vanity number. <br><br> Returns the following if a valid identifier was provided, and returns an error otherwise. <br><br> ``` curl -i -H \"Content-Type: application/json\" -X DELETE https://$API_KEY@api.dialmycalls.com/2.0/keyword/$VANITYNUMBER_ID ```
36
+ # @param vanity_number_id VanityNumberId
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [Object]
39
+ def delete_vanity_number_by_id(vanity_number_id, opts = {})
40
+ data, _status_code, _headers = delete_vanity_number_by_id_with_http_info(vanity_number_id, opts)
41
+ return data
42
+ end
43
+
44
+ # Delete Vanity Number
45
+ # Delete a vanity number. &lt;br&gt;&lt;br&gt; Returns the following if a valid identifier was provided, and returns an error otherwise. &lt;br&gt;&lt;br&gt; &#x60;&#x60;&#x60; curl -i -H \&quot;Content-Type: application/json\&quot; -X DELETE https://$API_KEY@api.dialmycalls.com/2.0/keyword/$VANITYNUMBER_ID &#x60;&#x60;&#x60;
46
+ # @param vanity_number_id VanityNumberId
47
+ # @param [Hash] opts the optional parameters
48
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
49
+ def delete_vanity_number_by_id_with_http_info(vanity_number_id, opts = {})
50
+ if @api_client.config.debugging
51
+ @api_client.config.logger.debug "Calling API: VanityNumbersApi.delete_vanity_number_by_id ..."
52
+ end
53
+ # verify the required parameter 'vanity_number_id' is set
54
+ fail ArgumentError, "Missing the required parameter 'vanity_number_id' when calling VanityNumbersApi.delete_vanity_number_by_id" if vanity_number_id.nil?
55
+ # resource path
56
+ local_var_path = "/vanitynumber/{VanityNumberId}".sub('{format}','json').sub('{' + 'VanityNumberId' + '}', vanity_number_id.to_s)
57
+
58
+ # query parameters
59
+ query_params = {}
60
+
61
+ # header parameters
62
+ header_params = {}
63
+
64
+ # HTTP header 'Accept' (if needed)
65
+ local_header_accept = ['application/json', 'application/xml']
66
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
67
+
68
+ # HTTP header 'Content-Type'
69
+ local_header_content_type = ['application/json', 'application/xml']
70
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
71
+
72
+ # form parameters
73
+ form_params = {}
74
+
75
+ # http body (model)
76
+ post_body = nil
77
+ auth_names = ['api_key']
78
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
79
+ :header_params => header_params,
80
+ :query_params => query_params,
81
+ :form_params => form_params,
82
+ :body => post_body,
83
+ :auth_names => auth_names,
84
+ :return_type => 'Object')
85
+ if @api_client.config.debugging
86
+ @api_client.config.logger.debug "API called: VanityNumbersApi#delete_vanity_number_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
87
+ end
88
+ return data, status_code, headers
89
+ end
90
+
91
+ # Get Vanity Number
92
+ # Retrieve a vanity number. <br><br> Returns a vanitynumber object if a valid identifier was provided, and returns an error otherwise. <br><br> ``` curl -i -H \"Content-Type: application/json\" -X GET https://$API_KEY@api.dialmycalls.com/2.0/vanitynumber/$VANITYNUMBER_ID ```
93
+ # @param vanity_number_id VanityNumberId
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [Object]
96
+ def get_vanity_number_by_id(vanity_number_id, opts = {})
97
+ data, _status_code, _headers = get_vanity_number_by_id_with_http_info(vanity_number_id, opts)
98
+ return data
99
+ end
100
+
101
+ # Get Vanity Number
102
+ # Retrieve a vanity number. &lt;br&gt;&lt;br&gt; Returns a vanitynumber object if a valid identifier was provided, and returns an error otherwise. &lt;br&gt;&lt;br&gt; &#x60;&#x60;&#x60; curl -i -H \&quot;Content-Type: application/json\&quot; -X GET https://$API_KEY@api.dialmycalls.com/2.0/vanitynumber/$VANITYNUMBER_ID &#x60;&#x60;&#x60;
103
+ # @param vanity_number_id VanityNumberId
104
+ # @param [Hash] opts the optional parameters
105
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
106
+ def get_vanity_number_by_id_with_http_info(vanity_number_id, opts = {})
107
+ if @api_client.config.debugging
108
+ @api_client.config.logger.debug "Calling API: VanityNumbersApi.get_vanity_number_by_id ..."
109
+ end
110
+ # verify the required parameter 'vanity_number_id' is set
111
+ fail ArgumentError, "Missing the required parameter 'vanity_number_id' when calling VanityNumbersApi.get_vanity_number_by_id" if vanity_number_id.nil?
112
+ # resource path
113
+ local_var_path = "/vanitynumber/{VanityNumberId}".sub('{format}','json').sub('{' + 'VanityNumberId' + '}', vanity_number_id.to_s)
114
+
115
+ # query parameters
116
+ query_params = {}
117
+
118
+ # header parameters
119
+ header_params = {}
120
+
121
+ # HTTP header 'Accept' (if needed)
122
+ local_header_accept = ['application/json', 'application/xml']
123
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
124
+
125
+ # HTTP header 'Content-Type'
126
+ local_header_content_type = ['application/json', 'application/xml']
127
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
128
+
129
+ # form parameters
130
+ form_params = {}
131
+
132
+ # http body (model)
133
+ post_body = nil
134
+ auth_names = ['api_key']
135
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
136
+ :header_params => header_params,
137
+ :query_params => query_params,
138
+ :form_params => form_params,
139
+ :body => post_body,
140
+ :auth_names => auth_names,
141
+ :return_type => 'Object')
142
+ if @api_client.config.debugging
143
+ @api_client.config.logger.debug "API called: VanityNumbersApi#get_vanity_number_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
144
+ end
145
+ return data, status_code, headers
146
+ end
147
+
148
+ # List Vanity Numbers
149
+ # Retrieve a list of vanity numbers. <br><br> Returns a list of vanitynumber objects. <br><br> ``` curl -i -H \"Content-Type: application/json\" -X GET https://$API_KEY@api.dialmycalls.com/2.0/vanitynumbers ```
150
+ # @param [Hash] opts the optional parameters
151
+ # @option opts [String] :range Range (ie \&quot;records&#x3D;201-300\&quot;) of vanitynumbers requested
152
+ # @return [Object]
153
+ def get_vanity_numbers(opts = {})
154
+ data, _status_code, _headers = get_vanity_numbers_with_http_info(opts)
155
+ return data
156
+ end
157
+
158
+ # List Vanity Numbers
159
+ # Retrieve a list of vanity numbers. &lt;br&gt;&lt;br&gt; Returns a list of vanitynumber objects. &lt;br&gt;&lt;br&gt; &#x60;&#x60;&#x60; curl -i -H \&quot;Content-Type: application/json\&quot; -X GET https://$API_KEY@api.dialmycalls.com/2.0/vanitynumbers &#x60;&#x60;&#x60;
160
+ # @param [Hash] opts the optional parameters
161
+ # @option opts [String] :range Range (ie \&quot;records&#x3D;201-300\&quot;) of vanitynumbers requested
162
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
163
+ def get_vanity_numbers_with_http_info(opts = {})
164
+ if @api_client.config.debugging
165
+ @api_client.config.logger.debug "Calling API: VanityNumbersApi.get_vanity_numbers ..."
166
+ end
167
+ # resource path
168
+ local_var_path = "/vanitynumbers".sub('{format}','json')
169
+
170
+ # query parameters
171
+ query_params = {}
172
+
173
+ # header parameters
174
+ header_params = {}
175
+
176
+ # HTTP header 'Accept' (if needed)
177
+ local_header_accept = ['application/json', 'application/xml']
178
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
179
+
180
+ # HTTP header 'Content-Type'
181
+ local_header_content_type = ['application/json', 'application/xml']
182
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
183
+ header_params[:'Range'] = opts[:'range'] if !opts[:'range'].nil?
184
+
185
+ # form parameters
186
+ form_params = {}
187
+
188
+ # http body (model)
189
+ post_body = nil
190
+ auth_names = ['api_key']
191
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
192
+ :header_params => header_params,
193
+ :query_params => query_params,
194
+ :form_params => form_params,
195
+ :body => post_body,
196
+ :auth_names => auth_names,
197
+ :return_type => 'Object')
198
+ if @api_client.config.debugging
199
+ @api_client.config.logger.debug "API called: VanityNumbersApi#get_vanity_numbers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
200
+ end
201
+ return data, status_code, headers
202
+ end
203
+
204
+ # Update Vanity Number
205
+ # Update a vanity number. <br><br> Returns a vanitynumber object if a valid identifier was provided, and returns an error otherwise. <br><br> ``` curl -i -H \"Content-Type: application/json\" -X PUT -d \"{\\\"ptt_number_id\\\":\\\"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee\\\",\\\"call_options\\\":{\\\"voicemail\\\":true}}\" https://$API_KEY@api.dialmycalls.com/2.0/vanitynumber/$VANITYNUMBER_ID ```
206
+ # @param update_vanity_number_by_id_parameters Request body
207
+ # @param vanity_number_id VanityNumberId
208
+ # @param [Hash] opts the optional parameters
209
+ # @return [Object]
210
+ def update_vanity_number_by_id(update_vanity_number_by_id_parameters, vanity_number_id, opts = {})
211
+ data, _status_code, _headers = update_vanity_number_by_id_with_http_info(update_vanity_number_by_id_parameters, vanity_number_id, opts)
212
+ return data
213
+ end
214
+
215
+ # Update Vanity Number
216
+ # Update a vanity number. &lt;br&gt;&lt;br&gt; Returns a vanitynumber object if a valid identifier was provided, and returns an error otherwise. &lt;br&gt;&lt;br&gt; &#x60;&#x60;&#x60; curl -i -H \&quot;Content-Type: application/json\&quot; -X PUT -d \&quot;{\\\&quot;ptt_number_id\\\&quot;:\\\&quot;aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee\\\&quot;,\\\&quot;call_options\\\&quot;:{\\\&quot;voicemail\\\&quot;:true}}\&quot; https://$API_KEY@api.dialmycalls.com/2.0/vanitynumber/$VANITYNUMBER_ID &#x60;&#x60;&#x60;
217
+ # @param update_vanity_number_by_id_parameters Request body
218
+ # @param vanity_number_id VanityNumberId
219
+ # @param [Hash] opts the optional parameters
220
+ # @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
221
+ def update_vanity_number_by_id_with_http_info(update_vanity_number_by_id_parameters, vanity_number_id, opts = {})
222
+ if @api_client.config.debugging
223
+ @api_client.config.logger.debug "Calling API: VanityNumbersApi.update_vanity_number_by_id ..."
224
+ end
225
+ # verify the required parameter 'update_vanity_number_by_id_parameters' is set
226
+ fail ArgumentError, "Missing the required parameter 'update_vanity_number_by_id_parameters' when calling VanityNumbersApi.update_vanity_number_by_id" if update_vanity_number_by_id_parameters.nil?
227
+ # verify the required parameter 'vanity_number_id' is set
228
+ fail ArgumentError, "Missing the required parameter 'vanity_number_id' when calling VanityNumbersApi.update_vanity_number_by_id" if vanity_number_id.nil?
229
+ # resource path
230
+ local_var_path = "/vanitynumber/{VanityNumberId}".sub('{format}','json').sub('{' + 'VanityNumberId' + '}', vanity_number_id.to_s)
231
+
232
+ # query parameters
233
+ query_params = {}
234
+
235
+ # header parameters
236
+ header_params = {}
237
+
238
+ # HTTP header 'Accept' (if needed)
239
+ local_header_accept = ['application/json', 'application/xml']
240
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
241
+
242
+ # HTTP header 'Content-Type'
243
+ local_header_content_type = ['application/json', 'application/xml']
244
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
245
+
246
+ # form parameters
247
+ form_params = {}
248
+
249
+ # http body (model)
250
+ post_body = @api_client.object_to_http_body(update_vanity_number_by_id_parameters)
251
+ auth_names = ['api_key']
252
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
253
+ :header_params => header_params,
254
+ :query_params => query_params,
255
+ :form_params => form_params,
256
+ :body => post_body,
257
+ :auth_names => auth_names,
258
+ :return_type => 'Object')
259
+ if @api_client.config.debugging
260
+ @api_client.config.logger.debug "API called: VanityNumbersApi#update_vanity_number_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
261
+ end
262
+ return data, status_code, headers
263
+ end
264
+ end
265
+ end
@@ -0,0 +1,379 @@
1
+ =begin
2
+ #DialMyCalls API
3
+
4
+ #The DialMyCalls API
5
+
6
+ OpenAPI spec version: 2.0.1
7
+ Contact: support@dialmycalls.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+ require 'json'
26
+ require 'logger'
27
+ require 'tempfile'
28
+ require 'typhoeus'
29
+ require 'uri'
30
+
31
+ module DialMyCalls
32
+ class ApiClient
33
+ # The Configuration object holding settings to be used in the API client.
34
+ attr_accessor :config
35
+
36
+ # Defines the headers to be used in HTTP requests of all API calls by default.
37
+ #
38
+ # @return [Hash]
39
+ attr_accessor :default_headers
40
+
41
+ # Initializes the ApiClient
42
+ # @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
43
+ def initialize(config = Configuration.default)
44
+ @config = config
45
+ @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
46
+ @default_headers = {
47
+ 'Content-Type' => "application/json",
48
+ 'User-Agent' => @user_agent
49
+ }
50
+ end
51
+
52
+ def self.default
53
+ @@default ||= ApiClient.new
54
+ end
55
+
56
+ # Call an API with given options.
57
+ #
58
+ # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
59
+ # the data deserialized from response body (could be nil), response status code and response headers.
60
+ def call_api(http_method, path, opts = {})
61
+ request = build_request(http_method, path, opts)
62
+ response = request.run
63
+
64
+ if @config.debugging
65
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
66
+ end
67
+
68
+ unless response.success?
69
+ fail ApiError.new(:code => response.code,
70
+ :response_headers => response.headers,
71
+ :response_body => response.body),
72
+ response.status_message
73
+ end
74
+
75
+ if opts[:return_type]
76
+ data = deserialize(response, opts[:return_type])
77
+ else
78
+ data = nil
79
+ end
80
+ return data, response.code, response.headers
81
+ end
82
+
83
+ # Builds the HTTP request
84
+ #
85
+ # @param [String] http_method HTTP method/verb (e.g. POST)
86
+ # @param [String] path URL path (e.g. /account/new)
87
+ # @option opts [Hash] :header_params Header parameters
88
+ # @option opts [Hash] :query_params Query parameters
89
+ # @option opts [Hash] :form_params Query parameters
90
+ # @option opts [Object] :body HTTP body (JSON/XML)
91
+ # @return [Typhoeus::Request] A Typhoeus Request
92
+ def build_request(http_method, path, opts = {})
93
+ url = build_request_url(path)
94
+ http_method = http_method.to_sym.downcase
95
+
96
+ header_params = @default_headers.merge(opts[:header_params] || {})
97
+ query_params = opts[:query_params] || {}
98
+ form_params = opts[:form_params] || {}
99
+
100
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
101
+
102
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
103
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
104
+
105
+ req_opts = {
106
+ :method => http_method,
107
+ :headers => header_params,
108
+ :params => query_params,
109
+ :params_encoding => @config.params_encoding,
110
+ :timeout => @config.timeout,
111
+ :ssl_verifypeer => @config.verify_ssl,
112
+ :ssl_verifyhost => _verify_ssl_host,
113
+ :sslcert => @config.cert_file,
114
+ :sslkey => @config.key_file,
115
+ :verbose => @config.debugging
116
+ }
117
+
118
+ # set custom cert, if provided
119
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
120
+
121
+ if [:post, :patch, :put, :delete].include?(http_method)
122
+ req_body = build_request_body(header_params, form_params, opts[:body])
123
+ req_opts.update :body => req_body
124
+ if @config.debugging
125
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
126
+ end
127
+ end
128
+
129
+ Typhoeus::Request.new(url, req_opts)
130
+ end
131
+
132
+ # Check if the given MIME is a JSON MIME.
133
+ # JSON MIME examples:
134
+ # application/json
135
+ # application/json; charset=UTF8
136
+ # APPLICATION/JSON
137
+ # @param [String] mime MIME
138
+ # @return [Boolean] True if the MIME is applicaton/json
139
+ def json_mime?(mime)
140
+ !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
141
+ end
142
+
143
+ # Deserialize the response to the given return type.
144
+ #
145
+ # @param [Response] response HTTP response
146
+ # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
147
+ def deserialize(response, return_type)
148
+ body = response.body
149
+ return nil if body.nil? || body.empty?
150
+
151
+ # return response body directly for String return type
152
+ return body if return_type == 'String'
153
+
154
+ # handle file downloading - save response body into a tmp file and return the File instance
155
+ return download_file(response) if return_type == 'File'
156
+
157
+ # ensuring a default content type
158
+ content_type = response.headers['Content-Type'] || 'application/json'
159
+
160
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
161
+
162
+ begin
163
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
164
+ rescue JSON::ParserError => e
165
+ if %w(String Date DateTime).include?(return_type)
166
+ data = body
167
+ else
168
+ raise e
169
+ end
170
+ end
171
+
172
+ convert_to_type data, return_type
173
+ end
174
+
175
+ # Convert data to the given return type.
176
+ # @param [Object] data Data to be converted
177
+ # @param [String] return_type Return type
178
+ # @return [Mixed] Data in a particular type
179
+ def convert_to_type(data, return_type)
180
+ return nil if data.nil?
181
+ case return_type
182
+ when 'String'
183
+ data.to_s
184
+ when 'Integer'
185
+ data.to_i
186
+ when 'Float'
187
+ data.to_f
188
+ when 'BOOLEAN'
189
+ data == true
190
+ when 'DateTime'
191
+ # parse date time (expecting ISO 8601 format)
192
+ DateTime.parse data
193
+ when 'Date'
194
+ # parse date time (expecting ISO 8601 format)
195
+ Date.parse data
196
+ when 'Object'
197
+ # generic object (usually a Hash), return directly
198
+ data
199
+ when /\AArray<(.+)>\z/
200
+ # e.g. Array<Pet>
201
+ sub_type = $1
202
+ data.map {|item| convert_to_type(item, sub_type) }
203
+ when /\AHash\<String, (.+)\>\z/
204
+ # e.g. Hash<String, Integer>
205
+ sub_type = $1
206
+ {}.tap do |hash|
207
+ data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
208
+ end
209
+ else
210
+ # models, e.g. Pet
211
+ DialMyCalls.const_get(return_type).new.tap do |model|
212
+ model.build_from_hash data
213
+ end
214
+ end
215
+ end
216
+
217
+ # Save response body into a file in (the defined) temporary folder, using the filename
218
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
219
+ #
220
+ # @see Configuration#temp_folder_path
221
+ # @return [Tempfile] the file downloaded
222
+ def download_file(response)
223
+ content_disposition = response.headers['Content-Disposition']
224
+ if content_disposition and content_disposition =~ /filename=/i
225
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
226
+ prefix = sanitize_filename(filename)
227
+ else
228
+ prefix = 'download-'
229
+ end
230
+ prefix = prefix + '-' unless prefix.end_with?('-')
231
+
232
+ tempfile = nil
233
+ encoding = response.body.encoding
234
+ Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
235
+ file.write(response.body)
236
+ tempfile = file
237
+ end
238
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
239
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
240
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
241
+ "explicitly with `tempfile.delete`"
242
+ tempfile
243
+ end
244
+
245
+ # Sanitize filename by removing path.
246
+ # e.g. ../../sun.gif becomes sun.gif
247
+ #
248
+ # @param [String] filename the filename to be sanitized
249
+ # @return [String] the sanitized filename
250
+ def sanitize_filename(filename)
251
+ filename.gsub(/.*[\/\\]/, '')
252
+ end
253
+
254
+ def build_request_url(path)
255
+ # Add leading and trailing slashes to path
256
+ path = "/#{path}".gsub(/\/+/, '/')
257
+ URI.encode(@config.base_url + path)
258
+ end
259
+
260
+ # Builds the HTTP request body
261
+ #
262
+ # @param [Hash] header_params Header parameters
263
+ # @param [Hash] form_params Query parameters
264
+ # @param [Object] body HTTP body (JSON/XML)
265
+ # @return [String] HTTP body data in the form of string
266
+ def build_request_body(header_params, form_params, body)
267
+ # http form
268
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
269
+ header_params['Content-Type'] == 'multipart/form-data'
270
+ data = {}
271
+ form_params.each do |key, value|
272
+ case value
273
+ when File, Array, nil
274
+ # let typhoeus handle File, Array and nil parameters
275
+ data[key] = value
276
+ else
277
+ data[key] = value.to_s
278
+ end
279
+ end
280
+ elsif body
281
+ data = body.is_a?(String) ? body : body.to_json
282
+ else
283
+ data = nil
284
+ end
285
+ data
286
+ end
287
+
288
+ # Update hearder and query params based on authentication settings.
289
+ #
290
+ # @param [Hash] header_params Header parameters
291
+ # @param [Hash] form_params Query parameters
292
+ # @param [String] auth_names Authentication scheme name
293
+ def update_params_for_auth!(header_params, query_params, auth_names)
294
+ Array(auth_names).each do |auth_name|
295
+ auth_setting = @config.auth_settings[auth_name]
296
+ next unless auth_setting
297
+ case auth_setting[:in]
298
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
299
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
300
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
301
+ end
302
+ end
303
+ end
304
+
305
+ # Sets user agent in HTTP header
306
+ #
307
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
308
+ def user_agent=(user_agent)
309
+ @user_agent = user_agent
310
+ @default_headers['User-Agent'] = @user_agent
311
+ end
312
+
313
+ # Return Accept header based on an array of accepts provided.
314
+ # @param [Array] accepts array for Accept
315
+ # @return [String] the Accept header (e.g. application/json)
316
+ def select_header_accept(accepts)
317
+ return nil if accepts.nil? || accepts.empty?
318
+ # use JSON when present, otherwise use all of the provided
319
+ json_accept = accepts.find { |s| json_mime?(s) }
320
+ return json_accept || accepts.join(',')
321
+ end
322
+
323
+ # Return Content-Type header based on an array of content types provided.
324
+ # @param [Array] content_types array for Content-Type
325
+ # @return [String] the Content-Type header (e.g. application/json)
326
+ def select_header_content_type(content_types)
327
+ # use application/json by default
328
+ return 'application/json' if content_types.nil? || content_types.empty?
329
+ # use JSON when present, otherwise use the first one
330
+ json_content_type = content_types.find { |s| json_mime?(s) }
331
+ return json_content_type || content_types.first
332
+ end
333
+
334
+ # Convert object (array, hash, object, etc) to JSON string.
335
+ # @param [Object] model object to be converted into JSON string
336
+ # @return [String] JSON string representation of the object
337
+ def object_to_http_body(model)
338
+ return model if model.nil? || model.is_a?(String)
339
+ local_body = nil
340
+ if model.is_a?(Array)
341
+ local_body = model.map{|m| object_to_hash(m) }
342
+ else
343
+ local_body = object_to_hash(model)
344
+ end
345
+ local_body.to_json
346
+ end
347
+
348
+ # Convert object(non-array) to hash.
349
+ # @param [Object] obj object to be converted into JSON string
350
+ # @return [String] JSON string representation of the object
351
+ def object_to_hash(obj)
352
+ if obj.respond_to?(:to_hash)
353
+ obj.to_hash
354
+ else
355
+ obj
356
+ end
357
+ end
358
+
359
+ # Build parameter value according to the given collection format.
360
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
361
+ def build_collection_param(param, collection_format)
362
+ case collection_format
363
+ when :csv
364
+ param.join(',')
365
+ when :ssv
366
+ param.join(' ')
367
+ when :tsv
368
+ param.join("\t")
369
+ when :pipes
370
+ param.join('|')
371
+ when :multi
372
+ # return the array directly as typhoeus will handle it as expected
373
+ param
374
+ else
375
+ fail "unknown collection format: #{collection_format.inspect}"
376
+ end
377
+ end
378
+ end
379
+ end
@@ -0,0 +1,47 @@
1
+ =begin
2
+ #DialMyCalls API
3
+
4
+ #The DialMyCalls API
5
+
6
+ OpenAPI spec version: 2.0.1
7
+ Contact: support@dialmycalls.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ module DialMyCalls
25
+ class ApiError < StandardError
26
+ attr_reader :code, :response_headers, :response_body
27
+
28
+ # Usage examples:
29
+ # ApiError.new
30
+ # ApiError.new("message")
31
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
32
+ # ApiError.new(:code => 404, :message => "Not Found")
33
+ def initialize(arg = nil)
34
+ if arg.is_a? Hash
35
+ arg.each do |k, v|
36
+ if k.to_s == 'message'
37
+ super v
38
+ else
39
+ instance_variable_set "@#{k}", v
40
+ end
41
+ end
42
+ else
43
+ super arg
44
+ end
45
+ end
46
+ end
47
+ end