refsheet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ =begin
2
+ #Refsheet.net API
3
+
4
+ #The Refsheet.net API allows another application to view and manipulate data on behalf of a user. To get started, [generate an API Key from your account settings](https://refsheet.net/account/settings/api). ## Authentication The API requires two values, `api_key_id` and `api_key_secret` to be sent either as query parameters or via headers. |Field|URL Param|Header| |---|---|---| |API Key ID|`api_key_id`|`X-ApiKeyId`| |API Key Secret|`api_key_secret`|`X-ApiKeySecret`| ``` curl -H \"X-ApiKeyId: YOUR_KEY_ID\" \\ -H \"X-ApiKeySecret: YOUR_KEY_SECRET\" \\ https://refsheet.net/api/v1/users/abc123 ```
5
+
6
+ OpenAPI spec version: v1
7
+
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 Refsheet
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
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #Refsheet.net API
3
+
4
+ #The Refsheet.net API allows another application to view and manipulate data on behalf of a user. To get started, [generate an API Key from your account settings](https://refsheet.net/account/settings/api).
5
+
6
+ OpenAPI spec version: v1
7
+
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 Refsheet
27
+ class Configuration
28
+ # Defines url scheme
29
+ #
30
+ # Defaults to ENV['REFSHEET_SCHEME']
31
+ attr_accessor :scheme
32
+
33
+ # Defines url host
34
+ #
35
+ # Defaults to ENV['REFSHEET_HOST']
36
+ attr_accessor :host
37
+
38
+ # Defines url base path
39
+ attr_accessor :base_path
40
+
41
+ # Defines API key ID to use for authentication
42
+ #
43
+ # Defaults to ENV['REFSHEET_API_KEY_ID']
44
+ #
45
+ # @example API key ID is 'xxx'
46
+ # config.api_key_id = 'xxx'
47
+ attr_accessor :api_key_id
48
+
49
+ # Defines the API key Secret associated with the API key used for authentication
50
+ #
51
+ # Defaults to ENV['REFSHEET_API_KEY_SECRET']
52
+ #
53
+ # @example Secret is 'xxx'
54
+ # config.api_key_secret = 'xxx'
55
+ attr_accessor :api_key_secret
56
+
57
+
58
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
59
+ # details will be logged with `logger.debug` (see the `logger` attribute).
60
+ # Default to false.
61
+ #
62
+ # @return [true, false]
63
+ attr_accessor :debugging
64
+
65
+ # Defines the logger used for debugging.
66
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
67
+ #
68
+ # @return [#debug]
69
+ attr_accessor :logger
70
+
71
+ # Defines the temporary folder to store downloaded files
72
+ # (for API endpoints that have file response).
73
+ # Default to use `Tempfile`.
74
+ #
75
+ # @return [String]
76
+ attr_accessor :temp_folder_path
77
+
78
+ # The time limit for HTTP request in seconds.
79
+ # Default to 0 (never times out).
80
+ attr_accessor :timeout
81
+
82
+ ### TLS/SSL setting
83
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
84
+ # Default to true.
85
+ #
86
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
87
+ #
88
+ # @return [true, false]
89
+ attr_accessor :verify_ssl
90
+
91
+ ### TLS/SSL setting
92
+ # Set this to false to skip verifying SSL host name
93
+ # Default to true.
94
+ #
95
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
96
+ #
97
+ # @return [true, false]
98
+ attr_accessor :verify_ssl_host
99
+
100
+ ### TLS/SSL setting
101
+ # Set this to customize the certificate file to verify the peer.
102
+ #
103
+ # @return [String] the path to the certificate file
104
+ #
105
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
106
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
107
+ attr_accessor :ssl_ca_cert
108
+
109
+ ### TLS/SSL setting
110
+ # Client certificate file (for client certificate)
111
+ attr_accessor :cert_file
112
+
113
+ ### TLS/SSL setting
114
+ # Client private key file (for client certificate)
115
+ attr_accessor :key_file
116
+
117
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
118
+ # Default to nil.
119
+ #
120
+ # @see The params_encoding option of Ethon. Related source code:
121
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
122
+ attr_accessor :params_encoding
123
+
124
+ attr_accessor :inject_format
125
+
126
+ attr_accessor :force_ending_format
127
+
128
+ def initialize
129
+ @scheme = ENV.fetch('REFSHEET_SCHEME', 'https')
130
+ @host = ENV.fetch('REFSHEET_HOST', 'refsheet.net')
131
+ @base_path = '/api/v1'
132
+ @timeout = 0
133
+ @verify_ssl = true
134
+ @verify_ssl_host = true
135
+ @params_encoding = nil
136
+ @cert_file = nil
137
+ @key_file = nil
138
+ @debugging = false
139
+ @inject_format = false
140
+ @force_ending_format = false
141
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
142
+
143
+ # Nongen Things
144
+ @api_key_id = ENV.fetch('REFSHEET_API_KEY_ID', nil)
145
+ @api_key_secret = ENV.fetch('REFSHEET_API_KEY_SECRET', nil)
146
+
147
+ yield(self) if block_given?
148
+ end
149
+
150
+ # The default Configuration object.
151
+ def self.default
152
+ @@default ||= Configuration.new
153
+ end
154
+
155
+ def configure
156
+ yield(self) if block_given?
157
+ end
158
+
159
+ def scheme=(scheme)
160
+ # remove :// from scheme
161
+ @scheme = scheme.sub(/:\/\//, '')
162
+ end
163
+
164
+ def host=(host)
165
+ # remove http(s):// and anything after a slash
166
+ @host = host.sub(/https?:\/\//, '').split('/').first
167
+ end
168
+
169
+ def base_path=(base_path)
170
+ # Add leading and trailing slashes to base_path
171
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
172
+ @base_path = "" if @base_path == "/"
173
+ end
174
+
175
+ def base_url
176
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
177
+ URI.encode(url)
178
+ end
179
+
180
+ # Gets API key (with prefix if set).
181
+ # @param [String] param_name the parameter name of API key auth
182
+ def api_key_with_prefix(param_name)
183
+ if @api_key_prefix[param_name]
184
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
185
+ else
186
+ @api_key[param_name]
187
+ end
188
+ end
189
+
190
+ # Gets Basic Auth token string
191
+ def basic_auth_token
192
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
193
+ end
194
+
195
+ # Returns Auth Settings hash for api client.
196
+ def auth_settings
197
+ {
198
+ 'apiKeySecret' =>
199
+ {
200
+ type: 'api_key',
201
+ in: 'header',
202
+ key: 'X-ApiKeySecret',
203
+ value: @api_key_secret
204
+ },
205
+ 'apiKeyId' =>
206
+ {
207
+ type: 'api_key',
208
+ in: 'header',
209
+ key: 'X-ApiKeyId',
210
+ value: @api_key_id
211
+ },
212
+ }
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,199 @@
1
+ =begin
2
+ #Refsheet.net API
3
+
4
+ #The Refsheet.net API allows another application to view and manipulate data on behalf of a user. To get started, [generate an API Key from your account settings](https://refsheet.net/account/settings/api). ## Authentication The API requires two values, `api_key_id` and `api_key_secret` to be sent either as query parameters or via headers. |Field|URL Param|Header| |---|---|---| |API Key ID|`api_key_id`|`X-ApiKeyId`| |API Key Secret|`api_key_secret`|`X-ApiKeySecret`| ``` curl -H \"X-ApiKeyId: YOUR_KEY_ID\" \\ -H \"X-ApiKeySecret: YOUR_KEY_SECRET\" \\ https://refsheet.net/api/v1/users/abc123 ```
5
+
6
+ OpenAPI spec version: v1
7
+
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
+
26
+ module Refsheet
27
+
28
+ class InlineResponse200
29
+ attr_accessor :data
30
+
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'data' => :'data'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'data' => :'InlineResponse200Data'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'data')
55
+ self.data = attributes[:'data']
56
+ end
57
+
58
+ end
59
+
60
+ # Show invalid properties with the reasons. Usually used together with valid?
61
+ # @return Array for valid properies with the reasons
62
+ def list_invalid_properties
63
+ invalid_properties = Array.new
64
+ return invalid_properties
65
+ end
66
+
67
+ # Check to see if the all the properties in the model are valid
68
+ # @return true if the model is valid
69
+ def valid?
70
+ return true
71
+ end
72
+
73
+ # Checks equality by comparing each attribute.
74
+ # @param [Object] Object to be compared
75
+ def ==(o)
76
+ return true if self.equal?(o)
77
+ self.class == o.class &&
78
+ data == o.data
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(o)
84
+ self == o
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Fixnum] Hash code
89
+ def hash
90
+ [data].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+ self.class.swagger_types.each_pair do |key, type|
99
+ if type =~ /^Array<(.*)>/i
100
+ # check to ensure the input is an array given that the the attribute
101
+ # is documented as an array but the input is not
102
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
103
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
104
+ end
105
+ elsif !attributes[self.class.attribute_map[key]].nil?
106
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
107
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
108
+ end
109
+
110
+ self
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param string type Data type
115
+ # @param string value Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def _deserialize(type, value)
118
+ case type.to_sym
119
+ when :DateTime
120
+ DateTime.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :BOOLEAN
130
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ temp_model = Refsheet.const_get(type).new
151
+ temp_model.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map{ |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+
197
+ end
198
+
199
+ end