khipu-chaski-api-client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/README.md +32 -0
- data/khipu-chaski-api-client.gemspec +31 -0
- data/lib/khipu-chaski-api-client.rb +32 -0
- data/lib/khipu-chaski-api-client/api/push_notifications_api.rb +77 -0
- data/lib/khipu-chaski-api-client/api_client.rb +305 -0
- data/lib/khipu-chaski-api-client/api_error.rb +24 -0
- data/lib/khipu-chaski-api-client/configuration.rb +175 -0
- data/lib/khipu-chaski-api-client/models/authorization_error.rb +45 -0
- data/lib/khipu-chaski-api-client/models/base_object.rb +86 -0
- data/lib/khipu-chaski-api-client/models/service_error.rb +45 -0
- data/lib/khipu-chaski-api-client/models/success_response.rb +37 -0
- data/lib/khipu-chaski-api-client/version.rb +3 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9045d480f192313e4da1c6d3d4cffce495251c28
|
4
|
+
data.tar.gz: 71bcd4701100a22be2c648e735ae324447364c40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fbefd415aa93a4c919a52b407c9aee087a4b9063e80372e52808145c692e4a5e9049e833c51c75ce30766bfcbb8506d00b07d53aea45a482a4b090c2e87ca96c
|
7
|
+
data.tar.gz: ed66f1eb3016669f5f2a5305b604c4225db302ae330fc96797a8433100bb4d28fe34ee72d34711aa5df283269fec6854efd35ae0fdb02231f363c014ea19092c
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## Installation
|
2
|
+
|
3
|
+
```sh
|
4
|
+
gem install khipu-chaski-api-client
|
5
|
+
```
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Basic configuration
|
10
|
+
```ruby
|
11
|
+
require 'khipu-chaski-api-client'
|
12
|
+
|
13
|
+
KhipuChaski.configure do |c|
|
14
|
+
c.secret = 'abc123'
|
15
|
+
c.receiver_id = 1234
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
### Basic usage
|
20
|
+
|
21
|
+
#### Send push message
|
22
|
+
```ruby
|
23
|
+
api = KhipuChaski::PushNotificationsApi.new()
|
24
|
+
response = api.msg_post('recipientId', 'subject', 'Hello!!')
|
25
|
+
|
26
|
+
print response
|
27
|
+
|
28
|
+
```
|
29
|
+
|
30
|
+
### Documentation
|
31
|
+
|
32
|
+
- [gem docs](http://www.rubydoc.info/gems/khipu-chaski-api-client/)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "khipu-chaski-api-client/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "khipu-chaski-api-client"
|
7
|
+
s.version = KhipuChaski::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["khipu"]
|
10
|
+
s.email = ["developers@khipu.com"]
|
11
|
+
s.homepage = "https://github.com/khipu/khipu-chaski-api-ruby-client"
|
12
|
+
s.summary = %q{A ruby wrapper for the khipu chaski APIs}
|
13
|
+
s.description = %q{This gem maps to a swagger API}
|
14
|
+
s.license = "Apache-2.0"
|
15
|
+
|
16
|
+
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
17
|
+
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
18
|
+
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
20
|
+
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
21
|
+
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
22
|
+
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
23
|
+
s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
|
24
|
+
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
|
25
|
+
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
|
26
|
+
|
27
|
+
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
|
28
|
+
s.test_files = `find spec/*`.split("\n")
|
29
|
+
s.executables = []
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Common files
|
2
|
+
require 'khipu-chaski-api-client/api_client'
|
3
|
+
require 'khipu-chaski-api-client/api_error'
|
4
|
+
require 'khipu-chaski-api-client/version'
|
5
|
+
require 'khipu-chaski-api-client/configuration'
|
6
|
+
|
7
|
+
# Models
|
8
|
+
require 'khipu-chaski-api-client/models/base_object'
|
9
|
+
require 'khipu-chaski-api-client/models/success_response'
|
10
|
+
require 'khipu-chaski-api-client/models/authorization_error'
|
11
|
+
require 'khipu-chaski-api-client/models/service_error'
|
12
|
+
|
13
|
+
# APIs
|
14
|
+
require 'khipu-chaski-api-client/api/push_notifications_api'
|
15
|
+
|
16
|
+
module KhipuChaski
|
17
|
+
class << self
|
18
|
+
# Configure sdk using block.
|
19
|
+
# KhipuChaski.configure do |config|
|
20
|
+
# config.username = "xxx"
|
21
|
+
# config.password = "xxx"
|
22
|
+
# end
|
23
|
+
# If no block given, return the configuration singleton instance.
|
24
|
+
def configure
|
25
|
+
if block_given?
|
26
|
+
yield Configuration.instance
|
27
|
+
else
|
28
|
+
Configuration.instance
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
module KhipuChaski
|
4
|
+
class PushNotificationsApi
|
5
|
+
attr_accessor :api_client
|
6
|
+
|
7
|
+
def initialize(api_client = nil)
|
8
|
+
@api_client = api_client || Configuration.api_client
|
9
|
+
end
|
10
|
+
|
11
|
+
# Enviar un nuevo mensaje
|
12
|
+
# Encolar un nuevo mensaje para dispositivos moviles.
|
13
|
+
# @param recipient_id_set Receptores del mensaje
|
14
|
+
# @param subject Asunto del mensaje
|
15
|
+
# @param body cuerpo del mensaje
|
16
|
+
# @param [Hash] opts the optional parameters
|
17
|
+
# @return [SuccessResponse]
|
18
|
+
def msg_post(recipient_id_set, subject, body, opts = {})
|
19
|
+
if Configuration.debugging
|
20
|
+
Configuration.logger.debug "Calling API: PushNotificationsApi#msg_post ..."
|
21
|
+
end
|
22
|
+
|
23
|
+
# verify the required parameter 'recipient_id_set' is set
|
24
|
+
fail "Missing the required parameter 'recipient_id_set' when calling msg_post" if recipient_id_set.nil?
|
25
|
+
|
26
|
+
# verify the required parameter 'subject' is set
|
27
|
+
fail "Missing the required parameter 'subject' when calling msg_post" if subject.nil?
|
28
|
+
|
29
|
+
# verify the required parameter 'body' is set
|
30
|
+
fail "Missing the required parameter 'body' when calling msg_post" if body.nil?
|
31
|
+
|
32
|
+
# resource path
|
33
|
+
path = "/msg".sub('{format}','json')
|
34
|
+
|
35
|
+
# query parameters
|
36
|
+
query_params = {}
|
37
|
+
|
38
|
+
# header parameters
|
39
|
+
header_params = {}
|
40
|
+
|
41
|
+
# HTTP header 'Accept' (if needed)
|
42
|
+
_header_accept = ['application/json']
|
43
|
+
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
44
|
+
|
45
|
+
# HTTP header 'Content-Type'
|
46
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
47
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
48
|
+
|
49
|
+
# form parameters
|
50
|
+
form_params = {}
|
51
|
+
form_params["recipientIdSet"] = recipient_id_set
|
52
|
+
form_params["subject"] = subject
|
53
|
+
form_params["body"] = body
|
54
|
+
|
55
|
+
# http body (model)
|
56
|
+
post_body = nil
|
57
|
+
|
58
|
+
|
59
|
+
auth_names = ['khipu']
|
60
|
+
result = @api_client.call_api(:POST, path,
|
61
|
+
:header_params => header_params,
|
62
|
+
:query_params => query_params,
|
63
|
+
:form_params => form_params,
|
64
|
+
:body => post_body,
|
65
|
+
:auth_names => auth_names,
|
66
|
+
:return_type => 'SuccessResponse')
|
67
|
+
if Configuration.debugging
|
68
|
+
Configuration.logger.debug "API called: PushNotificationsApi#msg_post. Result: #{result.inspect}"
|
69
|
+
end
|
70
|
+
return result
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'json'
|
3
|
+
require 'logger'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'typhoeus'
|
6
|
+
require 'uri'
|
7
|
+
require 'net/http'
|
8
|
+
require 'openssl'
|
9
|
+
require 'base64'
|
10
|
+
|
11
|
+
module KhipuChaski
|
12
|
+
class ApiClient
|
13
|
+
|
14
|
+
attr_accessor :host
|
15
|
+
|
16
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
17
|
+
#
|
18
|
+
# @return [Hash]
|
19
|
+
attr_accessor :default_headers
|
20
|
+
|
21
|
+
# Stores the HTTP response from the last API call using this API client.
|
22
|
+
attr_accessor :last_response
|
23
|
+
|
24
|
+
def initialize(host = nil)
|
25
|
+
@host = host || Configuration.base_url
|
26
|
+
@format = 'json'
|
27
|
+
@user_agent = "khipu-api-ruby-client/#{VERSION}" + "|" + (Configuration.platform || '') + "/" + (Configuration.platform_version || '')
|
28
|
+
@default_headers = {
|
29
|
+
'Content-Type' => "application/#{@format.downcase}",
|
30
|
+
'User-Agent' => @user_agent
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def call_api(http_method, path, opts = {})
|
35
|
+
request = build_request(http_method, path, opts)
|
36
|
+
response = request.run
|
37
|
+
|
38
|
+
# record as last response
|
39
|
+
@last_response = response
|
40
|
+
|
41
|
+
if Configuration.debugging
|
42
|
+
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
unless response.success?
|
46
|
+
fail ApiError.new(:code => response.code,
|
47
|
+
:response_headers => response.headers,
|
48
|
+
:response_body => response.body),
|
49
|
+
response.status_message
|
50
|
+
end
|
51
|
+
|
52
|
+
if opts[:return_type]
|
53
|
+
deserialize(response, opts[:return_type])
|
54
|
+
else
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_request(http_method, path, opts = {})
|
60
|
+
url = build_request_url(path)
|
61
|
+
http_method = http_method.to_sym.downcase
|
62
|
+
|
63
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
64
|
+
query_params = opts[:query_params] || {}
|
65
|
+
form_params = opts[:form_params] || {}
|
66
|
+
|
67
|
+
|
68
|
+
update_params_for_auth! @host, path, http_method, header_params, query_params, form_params, opts[:auth_names]
|
69
|
+
|
70
|
+
|
71
|
+
req_opts = {
|
72
|
+
:method => http_method,
|
73
|
+
:headers => header_params,
|
74
|
+
:params => query_params,
|
75
|
+
:ssl_verifypeer => Configuration.verify_ssl,
|
76
|
+
:sslcert => Configuration.cert_file,
|
77
|
+
:sslkey => Configuration.key_file,
|
78
|
+
:cainfo => Configuration.ssl_ca_cert,
|
79
|
+
:verbose => Configuration.debugging
|
80
|
+
}
|
81
|
+
|
82
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
83
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
84
|
+
req_opts.update :body => req_body
|
85
|
+
if Configuration.debugging
|
86
|
+
Configuration.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
Typhoeus::Request.new(url, req_opts)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Deserialize the response to the given return type.
|
94
|
+
#
|
95
|
+
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
96
|
+
def deserialize(response, return_type)
|
97
|
+
body = response.body
|
98
|
+
return nil if body.nil? || body.empty?
|
99
|
+
|
100
|
+
# handle file downloading - save response body into a tmp file and return the File instance
|
101
|
+
return download_file(response) if return_type == 'File'
|
102
|
+
|
103
|
+
# ensuring a default content type
|
104
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
105
|
+
|
106
|
+
unless content_type.start_with?('application/json')
|
107
|
+
fail "Content-Type is not supported: #{content_type}"
|
108
|
+
end
|
109
|
+
|
110
|
+
begin
|
111
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
112
|
+
rescue JSON::ParserError => e
|
113
|
+
if %w(String Date DateTime).include?(return_type)
|
114
|
+
data = body
|
115
|
+
else
|
116
|
+
raise e
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
convert_to_type data, return_type
|
121
|
+
end
|
122
|
+
|
123
|
+
# Convert data to the given return type.
|
124
|
+
def convert_to_type(data, return_type)
|
125
|
+
return nil if data.nil?
|
126
|
+
case return_type
|
127
|
+
when 'String'
|
128
|
+
data.to_s
|
129
|
+
when 'Integer'
|
130
|
+
data.to_i
|
131
|
+
when 'Float'
|
132
|
+
data.to_f
|
133
|
+
when 'BOOLEAN'
|
134
|
+
data == true
|
135
|
+
when 'DateTime'
|
136
|
+
# parse date time (expecting ISO 8601 format)
|
137
|
+
DateTime.parse data
|
138
|
+
when 'Date'
|
139
|
+
# parse date time (expecting ISO 8601 format)
|
140
|
+
Date.parse data
|
141
|
+
when 'Object'
|
142
|
+
# generic object, return directly
|
143
|
+
data
|
144
|
+
when /\AArray<(.+)>\z/
|
145
|
+
# e.g. Array<Pet>
|
146
|
+
sub_type = $1
|
147
|
+
data.map {|item| convert_to_type(item, sub_type) }
|
148
|
+
when /\AHash\<String, (.+)\>\z/
|
149
|
+
# e.g. Hash<String, Integer>
|
150
|
+
sub_type = $1
|
151
|
+
{}.tap do |hash|
|
152
|
+
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
153
|
+
end
|
154
|
+
else
|
155
|
+
# models, e.g. Pet
|
156
|
+
KhipuChaski.const_get(return_type).new.tap do |model|
|
157
|
+
model.build_from_hash data
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
163
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
164
|
+
#
|
165
|
+
# @see Configuration#temp_folder_path
|
166
|
+
# @return [File] the file downloaded
|
167
|
+
def download_file(response)
|
168
|
+
tmp_file = Tempfile.new '', Configuration.temp_folder_path
|
169
|
+
content_disposition = response.headers['Content-Disposition']
|
170
|
+
if content_disposition
|
171
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
172
|
+
path = File.join File.dirname(tmp_file), filename
|
173
|
+
else
|
174
|
+
path = tmp_file.path
|
175
|
+
end
|
176
|
+
# close and delete temp file
|
177
|
+
tmp_file.close!
|
178
|
+
|
179
|
+
File.open(path, 'w') { |file| file.write(response.body) }
|
180
|
+
Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
|
181
|
+
"folder for further processing and delete the temp afterwards"
|
182
|
+
File.new(path)
|
183
|
+
end
|
184
|
+
|
185
|
+
def build_request_url(path)
|
186
|
+
# Add leading and trailing slashes to path
|
187
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
188
|
+
URI.encode(host + path)
|
189
|
+
end
|
190
|
+
|
191
|
+
def build_request_body(header_params, form_params, body)
|
192
|
+
# http form
|
193
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
194
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
195
|
+
data = form_params.dup
|
196
|
+
data.each do |key, value|
|
197
|
+
data[key] = value.to_s if value && !value.is_a?(File)
|
198
|
+
end
|
199
|
+
elsif body
|
200
|
+
data = body.is_a?(String) ? body : body.to_json
|
201
|
+
else
|
202
|
+
data = nil
|
203
|
+
end
|
204
|
+
data
|
205
|
+
end
|
206
|
+
|
207
|
+
def percent_encode(v)
|
208
|
+
return URI::escape(v.to_s.to_str, /[^a-zA-Z0-9\-\.\_\~]/)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Update hearder and query params based on authentication settings.
|
212
|
+
def update_params_for_auth!(host, path, http_method, header_params, query_params, form_params, auth_names)
|
213
|
+
Array(auth_names).each do |auth_name|
|
214
|
+
if auth_name == "khipu"
|
215
|
+
params = query_params.merge(form_params)
|
216
|
+
|
217
|
+
encoded = {}
|
218
|
+
params.each do |k, v|
|
219
|
+
encoded[percent_encode(k)] = percent_encode(v)
|
220
|
+
end
|
221
|
+
|
222
|
+
to_sign = http_method.to_s.upcase + "&" + percent_encode(host + path)
|
223
|
+
|
224
|
+
encoded.keys.sort.each do |key|
|
225
|
+
to_sign += "&#{key}=" + encoded[key]
|
226
|
+
end
|
227
|
+
|
228
|
+
if Configuration.debugging
|
229
|
+
Configuration.logger.debug "encoded params: #{encoded}"
|
230
|
+
Configuration.logger.debug "string to sign: #{to_sign}"
|
231
|
+
end
|
232
|
+
|
233
|
+
hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), Configuration.secret, to_sign)
|
234
|
+
header_params['Authorization'] = Configuration.receiver_id.to_s + ":" + hash
|
235
|
+
|
236
|
+
next
|
237
|
+
end
|
238
|
+
auth_setting = Configuration.auth_settings[auth_name]
|
239
|
+
next unless auth_setting
|
240
|
+
case auth_setting[:in]
|
241
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
242
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
243
|
+
else fail ArgumentError, 'Authentication token must be in `query` of `header`'
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def user_agent=(user_agent)
|
249
|
+
@user_agent = user_agent
|
250
|
+
@default_headers['User-Agent'] = @user_agent
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
# Return Accept header based on an array of accepts provided.
|
255
|
+
# @param [Array] accepts array for Accept
|
256
|
+
# @return [String] the Accept header (e.g. application/json)
|
257
|
+
def select_header_accept(accepts)
|
258
|
+
if accepts.empty?
|
259
|
+
return
|
260
|
+
elsif accepts.any?{ |s| s.casecmp('application/json') == 0 }
|
261
|
+
'application/json' # look for json data by default
|
262
|
+
else
|
263
|
+
accepts.join(',')
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
# Return Content-Type header based on an array of content types provided.
|
268
|
+
# @param [Array] content_types array for Content-Type
|
269
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
270
|
+
def select_header_content_type(content_types)
|
271
|
+
if content_types.empty?
|
272
|
+
'application/json' # use application/json by default
|
273
|
+
elsif content_types.any?{ |s| s.casecmp('application/json')==0 }
|
274
|
+
'application/json' # use application/json if it's included
|
275
|
+
else
|
276
|
+
content_types[0] # otherwise, use the first one
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
281
|
+
# @param [Object] model object to be converted into JSON string
|
282
|
+
# @return [String] JSON string representation of the object
|
283
|
+
def object_to_http_body(model)
|
284
|
+
return if model.nil?
|
285
|
+
_body = nil
|
286
|
+
if model.is_a?(Array)
|
287
|
+
_body = model.map{|m| object_to_hash(m) }
|
288
|
+
else
|
289
|
+
_body = object_to_hash(model)
|
290
|
+
end
|
291
|
+
_body.to_json
|
292
|
+
end
|
293
|
+
|
294
|
+
# Convert object(non-array) to hash.
|
295
|
+
# @param [Object] obj object to be converted into JSON string
|
296
|
+
# @return [String] JSON string representation of the object
|
297
|
+
def object_to_hash(obj)
|
298
|
+
if obj.respond_to?(:to_hash)
|
299
|
+
obj.to_hash
|
300
|
+
else
|
301
|
+
obj
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module KhipuChaski
|
2
|
+
class ApiError < StandardError
|
3
|
+
attr_reader :code, :response_headers, :response_body
|
4
|
+
|
5
|
+
# Usage examples:
|
6
|
+
# ApiError.new
|
7
|
+
# ApiError.new("message")
|
8
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
9
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
10
|
+
def initialize(arg = nil)
|
11
|
+
if arg.is_a? Hash
|
12
|
+
arg.each do |k, v|
|
13
|
+
if k.to_s == 'message'
|
14
|
+
super v
|
15
|
+
else
|
16
|
+
instance_variable_set "@#{k}", v
|
17
|
+
end
|
18
|
+
end
|
19
|
+
else
|
20
|
+
super arg
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module KhipuChaski
|
5
|
+
class Configuration
|
6
|
+
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
# Default api client
|
10
|
+
attr_accessor :api_client
|
11
|
+
|
12
|
+
# Defines url scheme
|
13
|
+
attr_accessor :scheme
|
14
|
+
|
15
|
+
# Defines url host
|
16
|
+
attr_accessor :host
|
17
|
+
|
18
|
+
# Defines url base path
|
19
|
+
attr_accessor :base_path
|
20
|
+
|
21
|
+
# Defines API keys used with API Key authentications.
|
22
|
+
#
|
23
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
24
|
+
#
|
25
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
26
|
+
# config.api_key['api_key'] = 'xxx'
|
27
|
+
attr_accessor :api_key
|
28
|
+
|
29
|
+
# Defines API key prefixes used with API Key authentications.
|
30
|
+
#
|
31
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
32
|
+
#
|
33
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
34
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
35
|
+
attr_accessor :api_key_prefix
|
36
|
+
|
37
|
+
# Defines the username used with HTTP basic authentication.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
attr_accessor :username
|
41
|
+
|
42
|
+
# Defines the password used with HTTP basic authentication.
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
attr_accessor :password
|
46
|
+
|
47
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
48
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
49
|
+
# Default to false.
|
50
|
+
#
|
51
|
+
# @return [true, false]
|
52
|
+
attr_accessor :debugging
|
53
|
+
|
54
|
+
# Defines the logger used for debugging.
|
55
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
56
|
+
#
|
57
|
+
# @return [#debug]
|
58
|
+
attr_accessor :logger
|
59
|
+
|
60
|
+
# Defines the temporary folder to store downloaded files
|
61
|
+
# (for API endpoints that have file response).
|
62
|
+
# Default to use `Tempfile`.
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
attr_accessor :temp_folder_path
|
66
|
+
|
67
|
+
### TLS/SSL
|
68
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
69
|
+
# Default to true.
|
70
|
+
#
|
71
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
72
|
+
#
|
73
|
+
# @return [true, false]
|
74
|
+
attr_accessor :verify_ssl
|
75
|
+
|
76
|
+
# Set this to customize the certificate file to verify the peer.
|
77
|
+
#
|
78
|
+
# @return [String] the path to the certificate file
|
79
|
+
#
|
80
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
81
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
82
|
+
attr_accessor :ssl_ca_cert
|
83
|
+
|
84
|
+
# Client certificate file (for client certificate)
|
85
|
+
attr_accessor :cert_file
|
86
|
+
|
87
|
+
# Client private key file (for client certificate)
|
88
|
+
attr_accessor :key_file
|
89
|
+
|
90
|
+
attr_accessor :inject_format
|
91
|
+
|
92
|
+
attr_accessor :force_ending_format
|
93
|
+
|
94
|
+
attr_accessor :secret
|
95
|
+
|
96
|
+
attr_accessor :receiver_id
|
97
|
+
|
98
|
+
attr_accessor :platform
|
99
|
+
|
100
|
+
attr_accessor :platform_version
|
101
|
+
|
102
|
+
class << self
|
103
|
+
def method_missing(method_name, *args, &block)
|
104
|
+
config = Configuration.instance
|
105
|
+
if config.respond_to?(method_name)
|
106
|
+
config.send(method_name, *args, &block)
|
107
|
+
else
|
108
|
+
super
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def initialize
|
114
|
+
@scheme = 'https'
|
115
|
+
@host = 'khipu.com'
|
116
|
+
@base_path = '/chaski/api/1.0'
|
117
|
+
@api_key = {}
|
118
|
+
@api_key_prefix = {}
|
119
|
+
@verify_ssl = true
|
120
|
+
@cert_file = nil
|
121
|
+
@key_file = nil
|
122
|
+
@debugging = false
|
123
|
+
@inject_format = false
|
124
|
+
@force_ending_format = false
|
125
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
126
|
+
end
|
127
|
+
|
128
|
+
def api_client
|
129
|
+
@api_client ||= ApiClient.new
|
130
|
+
end
|
131
|
+
|
132
|
+
def scheme=(scheme)
|
133
|
+
# remove :// from scheme
|
134
|
+
@scheme = scheme.sub(/:\/\//, '')
|
135
|
+
end
|
136
|
+
|
137
|
+
def host=(host)
|
138
|
+
# remove http(s):// and anything after a slash
|
139
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
140
|
+
end
|
141
|
+
|
142
|
+
def base_path=(base_path)
|
143
|
+
# Add leading and trailing slashes to base_path
|
144
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
145
|
+
@base_path = "" if @base_path == "/"
|
146
|
+
end
|
147
|
+
|
148
|
+
def base_url
|
149
|
+
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
150
|
+
URI.encode(url)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Gets API key (with prefix if set).
|
154
|
+
# @param [String] param_name the parameter name of API key auth
|
155
|
+
def api_key_with_prefix(param_name)
|
156
|
+
if @api_key_prefix[param_name]
|
157
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
158
|
+
else
|
159
|
+
@api_key[param_name]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Gets Basic Auth token string
|
164
|
+
def basic_auth_token
|
165
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns Auth Settings hash for api client.
|
169
|
+
def auth_settings
|
170
|
+
{
|
171
|
+
'khipu' => {}
|
172
|
+
}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module KhipuChaski
|
2
|
+
#
|
3
|
+
class AuthorizationError < BaseObject
|
4
|
+
attr_accessor :status, :message
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# Código del error
|
10
|
+
:'status' => :'status',
|
11
|
+
|
12
|
+
# Mensaje del error
|
13
|
+
:'message' => :'message'
|
14
|
+
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
# attribute type
|
19
|
+
def self.swagger_types
|
20
|
+
{
|
21
|
+
:'status' => :'Integer',
|
22
|
+
:'message' => :'String'
|
23
|
+
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(attributes = {})
|
28
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
29
|
+
|
30
|
+
# convert string to symbol for hash key
|
31
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
32
|
+
|
33
|
+
|
34
|
+
if attributes[:'status']
|
35
|
+
self.status = attributes[:'status']
|
36
|
+
end
|
37
|
+
|
38
|
+
if attributes[:'message']
|
39
|
+
self.message = attributes[:'message']
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module KhipuChaski
|
4
|
+
# base class containing fundamental method such as to_hash, build_from_hash and more
|
5
|
+
class BaseObject
|
6
|
+
|
7
|
+
# build the object from hash
|
8
|
+
def build_from_hash(attributes)
|
9
|
+
return nil unless attributes.is_a?(Hash)
|
10
|
+
self.class.swagger_types.each_pair do |key, type|
|
11
|
+
if type =~ /^Array<(.*)>/i
|
12
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
13
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
14
|
+
else
|
15
|
+
#TODO show warning in debug mode
|
16
|
+
end
|
17
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
18
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
19
|
+
else
|
20
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def _deserialize(type, value)
|
28
|
+
case type.to_sym
|
29
|
+
when :DateTime
|
30
|
+
DateTime.parse(value)
|
31
|
+
when :Date
|
32
|
+
Date.parse(value)
|
33
|
+
when :String
|
34
|
+
value.to_s
|
35
|
+
when :Integer
|
36
|
+
value.to_i
|
37
|
+
when :Float
|
38
|
+
value.to_f
|
39
|
+
when :BOOLEAN
|
40
|
+
if value == true || value =~ /^(true|t|yes|y|1)$/i
|
41
|
+
true
|
42
|
+
else
|
43
|
+
false
|
44
|
+
end
|
45
|
+
else # model
|
46
|
+
_model = KhipuChaski.const_get(type).new
|
47
|
+
_model.build_from_hash(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_s
|
52
|
+
to_hash.to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
# to_body is an alias to to_body (backward compatibility))
|
56
|
+
def to_body
|
57
|
+
to_hash
|
58
|
+
end
|
59
|
+
|
60
|
+
# return the object in the form of hash
|
61
|
+
def to_hash
|
62
|
+
hash = {}
|
63
|
+
self.class.attribute_map.each_pair do |attr, param|
|
64
|
+
value = self.send(attr)
|
65
|
+
next if value.nil?
|
66
|
+
if value.is_a?(Array)
|
67
|
+
hash[param] = value.compact.map{ |v| _to_hash(v) }
|
68
|
+
else
|
69
|
+
hash[param] = _to_hash(value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
hash
|
73
|
+
end
|
74
|
+
|
75
|
+
# Method to output non-array value in the form of hash
|
76
|
+
# For object, use to_hash. Otherwise, just return the value
|
77
|
+
def _to_hash(value)
|
78
|
+
if value.respond_to? :to_hash
|
79
|
+
value.to_hash
|
80
|
+
else
|
81
|
+
value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module KhipuChaski
|
2
|
+
#
|
3
|
+
class ServiceError < BaseObject
|
4
|
+
attr_accessor :status, :message
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# Código del error
|
10
|
+
:'status' => :'status',
|
11
|
+
|
12
|
+
# Mensaje del error
|
13
|
+
:'message' => :'message'
|
14
|
+
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
# attribute type
|
19
|
+
def self.swagger_types
|
20
|
+
{
|
21
|
+
:'status' => :'Integer',
|
22
|
+
:'message' => :'String'
|
23
|
+
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(attributes = {})
|
28
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
29
|
+
|
30
|
+
# convert string to symbol for hash key
|
31
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
32
|
+
|
33
|
+
|
34
|
+
if attributes[:'status']
|
35
|
+
self.status = attributes[:'status']
|
36
|
+
end
|
37
|
+
|
38
|
+
if attributes[:'message']
|
39
|
+
self.message = attributes[:'message']
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module KhipuChaski
|
2
|
+
#
|
3
|
+
class SuccessResponse < BaseObject
|
4
|
+
attr_accessor :message
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# Mensaje a desplegar al usuario
|
10
|
+
:'message' => :'message'
|
11
|
+
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
# attribute type
|
16
|
+
def self.swagger_types
|
17
|
+
{
|
18
|
+
:'message' => :'String'
|
19
|
+
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(attributes = {})
|
24
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
25
|
+
|
26
|
+
# convert string to symbol for hash key
|
27
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
28
|
+
|
29
|
+
|
30
|
+
if attributes[:'message']
|
31
|
+
self.message = attributes[:'message']
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: khipu-chaski-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- khipu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: typhoeus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: json
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.1.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.6'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.6.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.6'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 3.6.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: vcr
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.0'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.1
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.0.1
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: webmock
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.24'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.24.3
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.24'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.24.3
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: autotest
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '4.4'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 4.4.6
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '4.4'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 4.4.6
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: autotest-rails-pure
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '4.1'
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 4.1.2
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '4.1'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 4.1.2
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: autotest-growl
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.2'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.2.16
|
163
|
+
type: :development
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0.2'
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 0.2.16
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: autotest-fsevent
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0.2'
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 0.2.12
|
183
|
+
type: :development
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0.2'
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 0.2.12
|
193
|
+
description: This gem maps to a swagger API
|
194
|
+
email:
|
195
|
+
- developers@khipu.com
|
196
|
+
executables: []
|
197
|
+
extensions: []
|
198
|
+
extra_rdoc_files: []
|
199
|
+
files:
|
200
|
+
- LICENSE
|
201
|
+
- README.md
|
202
|
+
- khipu-chaski-api-client.gemspec
|
203
|
+
- lib/khipu-chaski-api-client.rb
|
204
|
+
- lib/khipu-chaski-api-client/api/push_notifications_api.rb
|
205
|
+
- lib/khipu-chaski-api-client/api_client.rb
|
206
|
+
- lib/khipu-chaski-api-client/api_error.rb
|
207
|
+
- lib/khipu-chaski-api-client/configuration.rb
|
208
|
+
- lib/khipu-chaski-api-client/models/authorization_error.rb
|
209
|
+
- lib/khipu-chaski-api-client/models/base_object.rb
|
210
|
+
- lib/khipu-chaski-api-client/models/service_error.rb
|
211
|
+
- lib/khipu-chaski-api-client/models/success_response.rb
|
212
|
+
- lib/khipu-chaski-api-client/version.rb
|
213
|
+
homepage: https://github.com/khipu/khipu-chaski-api-ruby-client
|
214
|
+
licenses:
|
215
|
+
- Apache-2.0
|
216
|
+
metadata: {}
|
217
|
+
post_install_message:
|
218
|
+
rdoc_options: []
|
219
|
+
require_paths:
|
220
|
+
- lib
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 2.5.2.1
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: A ruby wrapper for the khipu chaski APIs
|
237
|
+
test_files: []
|