snowflakeapirb 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +11 -10
- data/Gemfile +9 -8
- data/Gemfile.lock +42 -19
- data/LICENSE +21 -21
- data/README.md +12 -2
- data/Rakefile +4 -4
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/lib/snowflakeapirb.rb +267 -307
- data/snowflakeapirb.gemspec +35 -35
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77df4ed4c99a38f36369c469beffdc9fd964f88930075cb7e2ba8d224488c4b6
|
|
4
|
+
data.tar.gz: deba6983a1d6f48ad69c73e79a1b69977d827e2e59da41f759cee1cec3f96222
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6708d85097bf847edb5008f77484dc4f15681caa9050105cf840abf155dae58b0ac24500527761fa43d73477aa880cabd037c36c582bc773f4ba7cceb039c8ca
|
|
7
|
+
data.tar.gz: d2ce2c917266650fd765c6c221df1f9e6cd6955087a97defe7c7df7558a17117af527de4d9de25a1d527abe3ed39e17b75f3f2c95d655c6ea985378a8f31770b
|
data/.gitignore
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/_yardoc/
|
|
4
|
-
/coverage/
|
|
5
|
-
/doc/
|
|
6
|
-
/pkg/
|
|
7
|
-
/spec/reports/
|
|
8
|
-
/tmp/
|
|
9
|
-
/test/
|
|
10
|
-
/bin/
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/_yardoc/
|
|
4
|
+
/coverage/
|
|
5
|
+
/doc/
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/tmp/
|
|
9
|
+
/test/
|
|
10
|
+
/bin/
|
|
11
|
+
*.gem
|
data/Gemfile
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
# Specify your gem's dependencies in snowflakeapirb.gemspec
|
|
6
|
-
gemspec
|
|
7
|
-
|
|
8
|
-
gem "rake", "~> 13.0"
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in snowflakeapirb.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem "rake", "~> 13.0"
|
|
9
|
+
gem "faraday"
|
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
snowflakeapirb (1.0.0)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
snowflakeapirb (1.0.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
faraday (1.7.0)
|
|
10
|
+
faraday-em_http (~> 1.0)
|
|
11
|
+
faraday-em_synchrony (~> 1.0)
|
|
12
|
+
faraday-excon (~> 1.1)
|
|
13
|
+
faraday-httpclient (~> 1.0.1)
|
|
14
|
+
faraday-net_http (~> 1.0)
|
|
15
|
+
faraday-net_http_persistent (~> 1.1)
|
|
16
|
+
faraday-patron (~> 1.0)
|
|
17
|
+
faraday-rack (~> 1.0)
|
|
18
|
+
multipart-post (>= 1.2, < 3)
|
|
19
|
+
ruby2_keywords (>= 0.0.4)
|
|
20
|
+
faraday-em_http (1.0.0)
|
|
21
|
+
faraday-em_synchrony (1.0.0)
|
|
22
|
+
faraday-excon (1.1.0)
|
|
23
|
+
faraday-httpclient (1.0.1)
|
|
24
|
+
faraday-net_http (1.0.1)
|
|
25
|
+
faraday-net_http_persistent (1.2.0)
|
|
26
|
+
faraday-patron (1.0.0)
|
|
27
|
+
faraday-rack (1.0.0)
|
|
28
|
+
multipart-post (2.1.1)
|
|
29
|
+
rake (13.0.3)
|
|
30
|
+
ruby2_keywords (0.0.5)
|
|
31
|
+
|
|
32
|
+
PLATFORMS
|
|
33
|
+
x64-mingw32
|
|
34
|
+
x86_64-darwin-19
|
|
35
|
+
|
|
36
|
+
DEPENDENCIES
|
|
37
|
+
faraday
|
|
38
|
+
rake (~> 13.0)
|
|
39
|
+
snowflakeapirb!
|
|
40
|
+
|
|
41
|
+
BUNDLED WITH
|
|
42
|
+
2.2.25
|
data/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Snowflake Studio ❄️
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Snowflake Studio ❄️
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
# Snowflake API
|
|
2
|
-
An api wrapper for **[Snowflake API](https://api.snowflakedev.org)** written in Ruby.
|
|
1
|
+
# Snowflake API
|
|
2
|
+
An api wrapper for **[Snowflake API](https://api.snowflakedev.org)** written in Ruby.
|
|
3
|
+
|
|
4
|
+
# Example
|
|
5
|
+
|
|
6
|
+
```ruby
|
|
7
|
+
require "snowflakeapirb"
|
|
8
|
+
|
|
9
|
+
api = SnowflakeAPI.new("API_KEY")
|
|
10
|
+
|
|
11
|
+
puts api.chatbot("Hello")
|
|
12
|
+
```
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler/gem_tasks"
|
|
4
|
-
task default: %i[]
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
task default: %i[]
|
data/bin/console
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "snowflakeapirb"
|
|
6
|
-
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require "pry"
|
|
12
|
-
# Pry.start
|
|
13
|
-
|
|
14
|
-
require "irb"
|
|
15
|
-
IRB.start(__FILE__)
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "snowflakeapirb"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
5
|
-
|
|
6
|
-
bundle install
|
|
7
|
-
|
|
8
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
set -vx
|
|
5
|
+
|
|
6
|
+
bundle install
|
|
7
|
+
|
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/snowflakeapirb.rb
CHANGED
|
@@ -1,307 +1,267 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "faraday"
|
|
4
|
-
require "json"
|
|
5
|
-
require "date"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
#
|
|
113
|
-
# @param message [String] The
|
|
114
|
-
# @return [String]
|
|
115
|
-
def
|
|
116
|
-
resp = @connection.get("morse/
|
|
117
|
-
data = JSON.parse(resp.body)
|
|
118
|
-
|
|
119
|
-
if data["error"] and data["code"] and data["code"] != 200
|
|
120
|
-
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
121
|
-
else
|
|
122
|
-
return data["data"]
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
#
|
|
127
|
-
# @param
|
|
128
|
-
# @return [
|
|
129
|
-
def
|
|
130
|
-
resp = @connection.get("
|
|
131
|
-
data = JSON.parse(resp.body)
|
|
132
|
-
|
|
133
|
-
if data["error"] and data["code"] and data["code"] != 200
|
|
134
|
-
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
135
|
-
else
|
|
136
|
-
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# Returns package information from
|
|
141
|
-
# @param module [String] The module name
|
|
142
|
-
# @return [
|
|
143
|
-
def
|
|
144
|
-
resp = @connection.get("registry/
|
|
145
|
-
data = JSON.parse(resp.body)
|
|
146
|
-
|
|
147
|
-
if data["error"] and data["code"] and data["code"] != 200
|
|
148
|
-
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
149
|
-
else
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
#
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if data["error"] and data["code"] and data["code"] != 200
|
|
270
|
-
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
271
|
-
else
|
|
272
|
-
return data["data"]
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
# Returns information about a discord token
|
|
277
|
-
# @param token [String] The discord token
|
|
278
|
-
# @return [Hash]
|
|
279
|
-
def tokeninfo(token)
|
|
280
|
-
resp = @connection.get("tokeninfo", { "token" => token })
|
|
281
|
-
data = JSON.parse(resp.body)
|
|
282
|
-
|
|
283
|
-
if data["error"] and data["code"] and data["code"] != 200
|
|
284
|
-
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
285
|
-
else
|
|
286
|
-
return {
|
|
287
|
-
"type" => data["type"],
|
|
288
|
-
"token" => data["token"],
|
|
289
|
-
"id" => data["id"],
|
|
290
|
-
"username" => data["username"],
|
|
291
|
-
"discriminator" => data["discriminator"],
|
|
292
|
-
"avatar" => data["avatar"],
|
|
293
|
-
"avatar_url" => data["avatarURL"],
|
|
294
|
-
"snowflake_info" => {
|
|
295
|
-
"epoch" => data["snowflakeInfo"]["epoch"],
|
|
296
|
-
"timestamp" => data["snowflakeInfo"]["timestamp"],
|
|
297
|
-
"worker_id" => data["snowflakeInfo"]["workerID"],
|
|
298
|
-
"process_id" => data["snowflakeInfo"]["processID"],
|
|
299
|
-
"increment" => data["snowflakeInfo"]["increment"],
|
|
300
|
-
"binary" => data["snowflakeInfo"]["binary"],
|
|
301
|
-
"date" => Date.parse(data["snowflakeInfo"]["date"]),
|
|
302
|
-
"snowflake" => data["snowflakeInfo"]["snowflake"]
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "json"
|
|
5
|
+
require "date"
|
|
6
|
+
require_relative "snowflakeapirb/meme"
|
|
7
|
+
require_relative "snowflakeapirb/pokemon"
|
|
8
|
+
require_relative "snowflakeapirb/deno"
|
|
9
|
+
require_relative "snowflakeapirb/npm"
|
|
10
|
+
require_relative "snowflakeapirb/me"
|
|
11
|
+
require_relative "snowflakeapirb/github"
|
|
12
|
+
require_relative "snowflakeapirb/pypi"
|
|
13
|
+
require_relative "snowflakeapirb/token_info"
|
|
14
|
+
class SnowflakeAPI
|
|
15
|
+
def initialize(api_key)
|
|
16
|
+
@token = api_key
|
|
17
|
+
@connection = Faraday.new(
|
|
18
|
+
url: "https://api.snowflakedev.org/api",
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type" => "application/json",
|
|
21
|
+
"Authorization" => @token
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Get response from the chatbot
|
|
27
|
+
# @param message [String] The message
|
|
28
|
+
# @param name [String] The chatbot's name
|
|
29
|
+
# @param age [String] The chatbot's age
|
|
30
|
+
# @param gender [String] The bot's gender
|
|
31
|
+
# @param user [String] The user identifier
|
|
32
|
+
# @return [String]
|
|
33
|
+
def chatbot(message, name: nil, age: nil, gender: nil, user: nil)
|
|
34
|
+
resp = @connection.get("chatbot", { message: message, name: name, age: age, gender: gender, user: user })
|
|
35
|
+
data = JSON.parse(resp.body)
|
|
36
|
+
|
|
37
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
38
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
39
|
+
else
|
|
40
|
+
return data["message"]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Generates fake discord bot token
|
|
45
|
+
# @return [String]
|
|
46
|
+
def fake_discord_token
|
|
47
|
+
resp = @connection.get("token")
|
|
48
|
+
data = JSON.parse(resp.body)
|
|
49
|
+
|
|
50
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
51
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
52
|
+
else
|
|
53
|
+
return data["token"]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Returns meme from
|
|
58
|
+
# @param subreddit [String] subreddit to fetch meme from
|
|
59
|
+
# @return [Hash]
|
|
60
|
+
def meme(subreddit)
|
|
61
|
+
resp = @connection.get("meme", { "sbr" => subreddit })
|
|
62
|
+
data = JSON.parse(resp.body)
|
|
63
|
+
|
|
64
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
65
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
66
|
+
else
|
|
67
|
+
Spreader::Meme.new(data)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Returns random roast message
|
|
72
|
+
# @return [String]
|
|
73
|
+
def roast
|
|
74
|
+
resp = @connection.get("roast")
|
|
75
|
+
data = JSON.parse(resp.body)
|
|
76
|
+
|
|
77
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
78
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
79
|
+
else
|
|
80
|
+
return data["roast"]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Returns Pokemon info
|
|
85
|
+
# @param name [String] Pokemon name
|
|
86
|
+
# @return [Spreader::Pokemon]
|
|
87
|
+
def pokemon(name)
|
|
88
|
+
resp = @connection.get("pokemon", { "name" => name })
|
|
89
|
+
data = JSON.parse(resp.body)
|
|
90
|
+
|
|
91
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
92
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
93
|
+
else
|
|
94
|
+
Spreader::Pokemon.new(data)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Encodes the given text to morse code
|
|
99
|
+
# @param message [String] The message to encode
|
|
100
|
+
# @return [String]
|
|
101
|
+
def morse_encode(message)
|
|
102
|
+
resp = @connection.get("morse/encode", { "text" => message })
|
|
103
|
+
data = JSON.parse(resp.body)
|
|
104
|
+
|
|
105
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
106
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
107
|
+
else
|
|
108
|
+
return data["data"]
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Decodes the given morse code to regular text
|
|
113
|
+
# @param message [String] The morse code to decode
|
|
114
|
+
# @return [String]
|
|
115
|
+
def morse_decode(message)
|
|
116
|
+
resp = @connection.get("morse/decode", { "text" => message })
|
|
117
|
+
data = JSON.parse(resp.body)
|
|
118
|
+
|
|
119
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
120
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
121
|
+
else
|
|
122
|
+
return data["data"]
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Returns package information from denoland registry
|
|
127
|
+
# @param module [String] The module name
|
|
128
|
+
# @return [Spreader::Deno]
|
|
129
|
+
def deno(package)
|
|
130
|
+
resp = @connection.get("registry/deno", { "module" => package })
|
|
131
|
+
data = JSON.parse(resp.body)
|
|
132
|
+
|
|
133
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
134
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
135
|
+
else
|
|
136
|
+
Spreader::Deno.new(data)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Returns package information from npmjs registry
|
|
141
|
+
# @param module [String] The module name
|
|
142
|
+
# @return [Spreader::Npm]
|
|
143
|
+
def npm(package)
|
|
144
|
+
resp = @connection.get("registry/npm", { "module" => package })
|
|
145
|
+
data = JSON.parse(resp.body)
|
|
146
|
+
|
|
147
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
148
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
149
|
+
else
|
|
150
|
+
Spreader::Npm.new(data)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Returns package information from pypi registry
|
|
155
|
+
# @param module [String] The module name
|
|
156
|
+
# @return [Spreader::Pypi]
|
|
157
|
+
def pypi(package)
|
|
158
|
+
resp = @connection.get("registry/pypi", { "module" => package })
|
|
159
|
+
data = JSON.parse(resp.body)
|
|
160
|
+
|
|
161
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
162
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
163
|
+
else
|
|
164
|
+
Spreader::Pypi.new(data)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Reverse the given text
|
|
169
|
+
# @param message [String] The message to reverse
|
|
170
|
+
# @return [String]
|
|
171
|
+
def reverse(message)
|
|
172
|
+
resp = @connection.get("reverse", { "message" => message })
|
|
173
|
+
data = JSON.parse(resp.body)
|
|
174
|
+
|
|
175
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
176
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
177
|
+
else
|
|
178
|
+
return data["message"]
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Encode the given text to base64 string
|
|
183
|
+
# @param message [String] The message to encode
|
|
184
|
+
# @return [String]
|
|
185
|
+
def base64_encode(message)
|
|
186
|
+
resp = @connection.get("base64/encode", { "data" => message })
|
|
187
|
+
data = JSON.parse(resp.body)
|
|
188
|
+
|
|
189
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
190
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
191
|
+
else
|
|
192
|
+
return data["data"]
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Decode the given text to base64 string
|
|
197
|
+
# @param message [String] The message to decode
|
|
198
|
+
# @return [String]
|
|
199
|
+
def base64_decode(message)
|
|
200
|
+
resp = @connection.get("base64/decode", { "data" => message })
|
|
201
|
+
data = JSON.parse(resp.body)
|
|
202
|
+
|
|
203
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
204
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
205
|
+
else
|
|
206
|
+
return data["data"]
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Returns information about a discord token
|
|
211
|
+
# @param token [String] The discord token
|
|
212
|
+
# @return [Spreader::Token_info]
|
|
213
|
+
def tokeninfo(token)
|
|
214
|
+
resp = @connection.get("tokeninfo", { "token" => token })
|
|
215
|
+
data = JSON.parse(resp.body)
|
|
216
|
+
|
|
217
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
218
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
219
|
+
else
|
|
220
|
+
Spreader::Token_info.new(data)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Returns API server status
|
|
225
|
+
# @return [Hash]
|
|
226
|
+
def stats
|
|
227
|
+
resp = @connection.get("stats")
|
|
228
|
+
data = JSON.parse(resp.body)
|
|
229
|
+
|
|
230
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
231
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
232
|
+
else
|
|
233
|
+
return data
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Returns information about current user
|
|
238
|
+
# @return [Spreader::Me]
|
|
239
|
+
def me
|
|
240
|
+
resp = @connection.get("me")
|
|
241
|
+
data = JSON.parse(resp.body)
|
|
242
|
+
|
|
243
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
244
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
245
|
+
else
|
|
246
|
+
Spreader::Me.new(data)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Returns information about a github user
|
|
251
|
+
# @param user [String] The user's name
|
|
252
|
+
# @return [Spreader::Github_Stats]
|
|
253
|
+
def githubstats(user)
|
|
254
|
+
resp = @connection.get("githubstats", { "username" => user })
|
|
255
|
+
data = JSON.parse(resp.body)
|
|
256
|
+
|
|
257
|
+
if data["error"] and data["code"] and data["code"] != 200
|
|
258
|
+
raise RuntimeError.new("[#{data["code"]}] #{data["error"] or "Rejected with status code #{data["code"]}"}")
|
|
259
|
+
else
|
|
260
|
+
Spreader::Github_Stats.new(data)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
worker = SnowflakeAPI.new('NzQ5OTM2ODMwMDk4NTcxMzM1.MTYyODcwMDcwNDA0Ng==.5a4557b6bd37ec088e79e2fa83445a9f')
|
|
266
|
+
|
|
267
|
+
p worker.githubstats('rhydderchc').followers
|
data/snowflakeapirb.gemspec
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name = "snowflakeapirb"
|
|
5
|
-
spec.version = "1.0.
|
|
6
|
-
spec.authors = ["DevAndromeda"]
|
|
7
|
-
spec.email = ["devandromeda@snowflakedev.org"]
|
|
8
|
-
|
|
9
|
-
spec.summary = "An api wrapper for snowflake api."
|
|
10
|
-
spec.description = "An api wrapper for snowflake api."
|
|
11
|
-
spec.homepage = "https://github.com/DevSnowflake/snowflakeapirb"
|
|
12
|
-
spec.license = "MIT"
|
|
13
|
-
spec.required_ruby_version = ">= 2.4.0"
|
|
14
|
-
|
|
15
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
16
|
-
|
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/DevSnowflake/snowflakeapirb"
|
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/DevSnowflake/snowflakeapirb/releases/latest"
|
|
20
|
-
|
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
25
|
-
end
|
|
26
|
-
spec.bindir = "exe"
|
|
27
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
|
-
spec.require_paths = ["lib"]
|
|
29
|
-
|
|
30
|
-
# Uncomment to register a new dependency of your gem
|
|
31
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
|
32
|
-
|
|
33
|
-
# For more information and examples about making a new gem, checkout our
|
|
34
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
|
35
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "snowflakeapirb"
|
|
5
|
+
spec.version = "1.0.2"
|
|
6
|
+
spec.authors = ["DevAndromeda"]
|
|
7
|
+
spec.email = ["devandromeda@snowflakedev.org"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "An api wrapper for snowflake api."
|
|
10
|
+
spec.description = "An api wrapper for snowflake api."
|
|
11
|
+
spec.homepage = "https://github.com/DevSnowflake/snowflakeapirb"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
spec.required_ruby_version = ">= 2.4.0"
|
|
14
|
+
|
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/DevSnowflake/snowflakeapirb"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/DevSnowflake/snowflakeapirb/releases/latest"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
# Uncomment to register a new dependency of your gem
|
|
31
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
32
|
+
|
|
33
|
+
# For more information and examples about making a new gem, checkout our
|
|
34
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: snowflakeapirb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DevAndromeda
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-08-
|
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: An api wrapper for snowflake api.
|
|
14
14
|
email:
|
|
@@ -35,7 +35,7 @@ metadata:
|
|
|
35
35
|
homepage_uri: https://github.com/DevSnowflake/snowflakeapirb
|
|
36
36
|
source_code_uri: https://github.com/DevSnowflake/snowflakeapirb
|
|
37
37
|
changelog_uri: https://github.com/DevSnowflake/snowflakeapirb/releases/latest
|
|
38
|
-
post_install_message:
|
|
38
|
+
post_install_message:
|
|
39
39
|
rdoc_options: []
|
|
40
40
|
require_paths:
|
|
41
41
|
- lib
|
|
@@ -50,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
51
|
version: '0'
|
|
52
52
|
requirements: []
|
|
53
|
-
rubygems_version: 3.
|
|
54
|
-
signing_key:
|
|
53
|
+
rubygems_version: 3.0.3
|
|
54
|
+
signing_key:
|
|
55
55
|
specification_version: 4
|
|
56
56
|
summary: An api wrapper for snowflake api.
|
|
57
57
|
test_files: []
|