stardots-sdk-ruby 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9acf592f766c84067401f7986343db09dd60be9cd552d10a32588b6bb44fedb7
4
+ data.tar.gz: 15abc277dec9cddb81cc24a55815be99c433ff3c8c722f7bf379674746a490fa
5
+ SHA512:
6
+ metadata.gz: 6a2f07e38a8d84527d2050dcda416932d86a50e460977c63652413960cffb5cbf7c684de7a6970481632389835337af9372e741b143082379fec2d10768f351a
7
+ data.tar.gz: 50875c10c013ad874a3319ec999b80a273a10197644ec93c8bef7ba8b65673f77299ee6b2cd0f73cc1160f9b3319a1e934f111ab9817751766721249f1320db0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 stardots.io
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ <div align="center">
2
+ <h1><img src="logo.png" alt="sailboat-solid" title="sailboat-solid" width="300" /></h1>
3
+ </div>
4
+
5
+ # StarDots-SDK-Ruby
6
+
7
+ [![Ruby](https://github.com/stardots-io/stardots-sdk-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/stardots-io/stardots-sdk-ruby/actions/workflows/ruby.yml)
8
+ [![Gem Version](https://badge.fury.io/rb/stardots-sdk-ruby.svg)](https://badge.fury.io/rb/stardots-sdk-ruby)
9
+ [![LICENSE: MIT](https://img.shields.io/github/license/stardots-io/stardots-sdk-ruby.svg?style=flat)](LICENSE)
10
+
11
+ ### Introduction
12
+ This project is used to help developers quickly access the StarDots platform and is written in Ruby.
13
+
14
+ ### Requirement
15
+ > Ruby version >= 2.6.0
16
+
17
+ ### Installation
18
+ ```shell
19
+ gem install stardots-sdk-ruby
20
+ ```
21
+
22
+ Or add it to your Gemfile:
23
+ ```ruby
24
+ gem 'stardots-sdk-ruby'
25
+ ```
26
+
27
+ ### Example
28
+ ```ruby
29
+ require 'stardots_sdk'
30
+
31
+ # Initialize the client
32
+ client_key = "Your client key"
33
+ client_secret = "Your client secret"
34
+ client = StardotsSdk::Client.new(client_key, client_secret)
35
+
36
+ # Get space list
37
+ space_list = client.get_space_list
38
+
39
+ # Create a new space
40
+ create_params = StardotsSdk::CreateSpaceReq.new(space: "my-space", public: true)
41
+ create_result = client.create_space(create_params)
42
+
43
+ # Upload a file
44
+ upload_params = StardotsSdk::UploadFileReq.new(
45
+ filename: "example.txt",
46
+ space: "my-space",
47
+ file_content: "Hello, StarDots!"
48
+ )
49
+ upload_result = client.upload_file(upload_params)
50
+ ```
51
+
52
+ ### Documentation
53
+ [https://stardots.io/en/documentation/openapi](https://stardots.io/en/documentation/openapi)
54
+
55
+ ### Homepage
56
+ [https://stardots.io](https://stardots.io)
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "constants"
5
+ require_relative "helper"
6
+ require_relative "types"
7
+
8
+ module StardotsSdk
9
+ # StarDots SDK client
10
+ class Client
11
+ include Constants
12
+
13
+ attr_reader :endpoint, :client_key, :client_secret
14
+
15
+ # Create a new StarDots client instance
16
+ def initialize(client_key, client_secret, endpoint = ENDPOINT)
17
+ @endpoint = endpoint
18
+ @client_key = client_key
19
+ @client_secret = client_secret
20
+ end
21
+
22
+ # Get space list data
23
+ def get_space_list(params = SpaceListReq.new)
24
+ query_params = "page=#{params.pagination.page}&pageSize=#{params.pagination.page_size}"
25
+ url = Helper.request_url(@endpoint, "/openapi/space/list?#{query_params}")
26
+
27
+ headers = Helper.make_headers(@client_key, @client_secret)
28
+ body, _status_code = Helper.send_request("GET", url, nil, headers)
29
+
30
+ response_data = JSON.parse(body, symbolize_names: true)
31
+ SpaceListResp.new(response_data)
32
+ end
33
+
34
+ # Create a new space
35
+ def create_space(params)
36
+ url = Helper.request_url(@endpoint, "/openapi/space/create")
37
+ json_payload = params.to_json
38
+
39
+ headers = Helper.make_headers(@client_key, @client_secret)
40
+ body, _status_code = Helper.send_request("PUT", url, json_payload, headers)
41
+
42
+ response_data = JSON.parse(body, symbolize_names: true)
43
+ CreateSpaceResp.new(response_data)
44
+ end
45
+
46
+ # Delete an existing space. Note that you must ensure that there are no files in this space, otherwise the deletion will fail
47
+ def delete_space(params)
48
+ url = Helper.request_url(@endpoint, "/openapi/space/delete")
49
+ json_payload = params.to_json
50
+
51
+ headers = Helper.make_headers(@client_key, @client_secret)
52
+ body, _status_code = Helper.send_request("DELETE", url, json_payload, headers)
53
+
54
+ response_data = JSON.parse(body, symbolize_names: true)
55
+ DeleteSpaceResp.new(response_data)
56
+ end
57
+
58
+ # Toggle the accessibility of a space
59
+ def toggle_space_accessibility(params)
60
+ url = Helper.request_url(@endpoint, "/openapi/space/accessibility/toggle")
61
+ json_payload = params.to_json
62
+
63
+ headers = Helper.make_headers(@client_key, @client_secret)
64
+ body, _status_code = Helper.send_request("POST", url, json_payload, headers)
65
+
66
+ response_data = JSON.parse(body, symbolize_names: true)
67
+ ToggleSpaceAccessibilityResp.new(response_data)
68
+ end
69
+
70
+ # Get the list of files in the space. The list is sorted in descending order by file upload time
71
+ def get_space_file_list(params)
72
+ query_params = "page=#{params.pagination.page}&pageSize=#{params.pagination.page_size}&space=#{params.space}"
73
+ url = Helper.request_url(@endpoint, "/openapi/file/list?#{query_params}")
74
+
75
+ headers = Helper.make_headers(@client_key, @client_secret)
76
+ body, _status_code = Helper.send_request("GET", url, nil, headers)
77
+
78
+ response_data = JSON.parse(body, symbolize_names: true)
79
+ SpaceFileListResp.new(response_data)
80
+ end
81
+
82
+ # Get the access ticket for the file. When the accessibility of the space is private, you need to bring the access ticket to access the files under the space, otherwise the request will be rejected
83
+ def file_access_ticket(params)
84
+ url = Helper.request_url(@endpoint, "/openapi/file/ticket")
85
+ json_payload = params.to_json
86
+
87
+ headers = Helper.make_headers(@client_key, @client_secret)
88
+ body, _status_code = Helper.send_request("POST", url, json_payload, headers)
89
+
90
+ response_data = JSON.parse(body, symbolize_names: true)
91
+ FileAccessTicketResp.new(response_data)
92
+ end
93
+
94
+ # Upload the file to the space. Note that this request requires you to initiate the request in the form of a form
95
+ def upload_file(params)
96
+ url = Helper.request_url(@endpoint, "/openapi/file/upload")
97
+
98
+ headers = Helper.make_headers(@client_key, @client_secret)
99
+ body, _status_code = Helper.send_multipart_request(url, headers, params.filename, params.space, params.file_content)
100
+
101
+ response_data = JSON.parse(body, symbolize_names: true)
102
+ UploadFileResp.new(response_data)
103
+ end
104
+
105
+ # Delete files in the space. This interface supports batch operations
106
+ def delete_file(params)
107
+ url = Helper.request_url(@endpoint, "/openapi/file/delete")
108
+ json_payload = params.to_json
109
+
110
+ headers = Helper.make_headers(@client_key, @client_secret)
111
+ body, _status_code = Helper.send_request("DELETE", url, json_payload, headers)
112
+
113
+ response_data = JSON.parse(body, symbolize_names: true)
114
+ DeleteFileResp.new(response_data)
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StardotsSdk
4
+ module Constants
5
+ SDK_VERSION = "1.0.0"
6
+ ENDPOINT = "https://api.stardots.io"
7
+ DEFAULT_REQUEST_TIMEOUT = 30 # seconds
8
+ end
9
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+ require "json"
5
+ require "digest"
6
+ require "securerandom"
7
+
8
+ module StardotsSdk
9
+ module Helper
10
+ include Constants
11
+
12
+ # Generate request URL
13
+ def self.request_url(endpoint, path)
14
+ "#{endpoint}#{path}"
15
+ end
16
+
17
+ # Generate authentication request headers
18
+ def self.make_headers(client_key, client_secret)
19
+ ts = Time.now.to_i.to_s
20
+ nonce = "#{Time.now.to_i * 1000}#{SecureRandom.random_number(10000) + 10000}"
21
+
22
+ need_sign_str = "#{ts}|#{client_secret}|#{nonce}"
23
+ sign = Digest::MD5.hexdigest(need_sign_str).upcase
24
+
25
+ extra_info = {
26
+ sdk: "true",
27
+ language: "ruby",
28
+ version: SDK_VERSION,
29
+ os: RUBY_PLATFORM,
30
+ arch: RUBY_PLATFORM
31
+ }
32
+
33
+ {
34
+ "x-stardots-timestamp" => ts,
35
+ "x-stardots-nonce" => nonce,
36
+ "x-stardots-key" => client_key,
37
+ "x-stardots-sign" => sign,
38
+ "x-stardots-extra" => extra_info.to_json,
39
+ "Content-Type" => "application/json; charset=utf-8"
40
+ }
41
+ end
42
+
43
+ # Send HTTP request
44
+ def self.send_request(method, url, json_payload = nil, headers = {}, timeout = DEFAULT_REQUEST_TIMEOUT)
45
+ options = {
46
+ headers: headers,
47
+ timeout: timeout
48
+ }
49
+
50
+ options[:body] = json_payload if json_payload
51
+
52
+ response = case method.upcase
53
+ when "GET"
54
+ HTTParty.get(url, options)
55
+ when "POST"
56
+ HTTParty.post(url, options)
57
+ when "PUT"
58
+ HTTParty.put(url, options)
59
+ when "DELETE"
60
+ HTTParty.delete(url, options)
61
+ else
62
+ raise ArgumentError, "Unsupported HTTP method: #{method}"
63
+ end
64
+
65
+ [response.body, response.code]
66
+ end
67
+
68
+ # Send multipart form request for file upload
69
+ def self.send_multipart_request(url, headers, filename, space, file_content, timeout = DEFAULT_REQUEST_TIMEOUT)
70
+ # Remove Content-Type header as multipart will set its own
71
+ headers = headers.reject { |k, _| k.downcase == "content-type" }
72
+
73
+ # Create multipart form data
74
+ boundary = "----WebKitFormBoundary#{SecureRandom.hex(16)}"
75
+
76
+ body = []
77
+ body << "--#{boundary}"
78
+ body << "Content-Disposition: form-data; name=\"space\""
79
+ body << ""
80
+ body << space
81
+ body << "--#{boundary}"
82
+ body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{filename}\""
83
+ body << "Content-Type: application/octet-stream"
84
+ body << ""
85
+ body << file_content
86
+ body << "--#{boundary}--"
87
+
88
+ headers["Content-Type"] = "multipart/form-data; boundary=#{boundary}"
89
+
90
+ options = {
91
+ headers: headers,
92
+ body: body.join("\r\n"),
93
+ timeout: timeout
94
+ }
95
+
96
+ response = HTTParty.put(url, options)
97
+ [response.body, response.code]
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,315 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module StardotsSdk
6
+ # Common HTTP response body
7
+ # All interface responses maintain a unified data structure
8
+ class CommonResponse
9
+ attr_accessor :code, :message, :request_id, :success, :ts, :data
10
+
11
+ def initialize(attributes = {})
12
+ @code = attributes[:code]
13
+ @message = attributes[:message]
14
+ @request_id = attributes[:request_id]
15
+ @success = attributes[:success]
16
+ @ts = attributes[:ts]
17
+ @data = attributes[:data]
18
+ end
19
+
20
+ def to_hash
21
+ {
22
+ code: @code,
23
+ message: @message,
24
+ request_id: @request_id,
25
+ success: @success,
26
+ ts: @ts,
27
+ data: @data
28
+ }
29
+ end
30
+
31
+ def to_json(*args)
32
+ to_hash.to_json(*args)
33
+ end
34
+ end
35
+
36
+ # Paginator request parameters
37
+ class PaginationReq
38
+ attr_accessor :page, :page_size
39
+
40
+ def initialize(page: 1, page_size: 20)
41
+ @page = page
42
+ @page_size = page_size
43
+ end
44
+
45
+ def to_hash
46
+ {
47
+ page: @page,
48
+ page_size: @page_size
49
+ }
50
+ end
51
+
52
+ def to_json(*args)
53
+ to_hash.to_json(*args)
54
+ end
55
+ end
56
+
57
+ # Paginator response data structure
58
+ class PaginationResp
59
+ attr_accessor :page, :page_size, :total_count
60
+
61
+ def initialize(attributes = {})
62
+ @page = attributes[:page]
63
+ @page_size = attributes[:page_size]
64
+ @total_count = attributes[:total_count]
65
+ end
66
+ end
67
+
68
+ # Get space list request parameters
69
+ class SpaceListReq
70
+ attr_accessor :pagination
71
+
72
+ def initialize(pagination: PaginationReq.new)
73
+ @pagination = pagination
74
+ end
75
+
76
+ def to_hash
77
+ @pagination.to_hash
78
+ end
79
+
80
+ def to_json(*args)
81
+ to_hash.to_json(*args)
82
+ end
83
+ end
84
+
85
+ # Space information data structure
86
+ class SpaceInfo
87
+ attr_accessor :name, :public, :created_at, :file_count
88
+
89
+ def initialize(attributes = {})
90
+ @name = attributes[:name]
91
+ @public = attributes[:public]
92
+ @created_at = attributes[:created_at]
93
+ @file_count = attributes[:file_count]
94
+ end
95
+ end
96
+
97
+ # Get space list response data structure
98
+ class SpaceListResp
99
+ attr_accessor :common, :data
100
+
101
+ def initialize(attributes = {})
102
+ @common = attributes[:common]
103
+ @data = attributes[:data] || []
104
+ end
105
+ end
106
+
107
+ # Create space request parameters
108
+ class CreateSpaceReq
109
+ attr_accessor :space, :public
110
+
111
+ def initialize(space:, public: false)
112
+ @space = space
113
+ @public = public
114
+ end
115
+
116
+ def to_hash
117
+ {
118
+ space: @space,
119
+ public: @public
120
+ }
121
+ end
122
+
123
+ def to_json(*args)
124
+ to_hash.to_json(*args)
125
+ end
126
+ end
127
+
128
+ # Create space response data structure
129
+ class CreateSpaceResp
130
+ attr_accessor :common
131
+
132
+ def initialize(attributes = {})
133
+ @common = attributes[:common]
134
+ end
135
+ end
136
+
137
+ # Delete space request parameters
138
+ class DeleteSpaceReq
139
+ attr_accessor :space
140
+
141
+ def initialize(space:)
142
+ @space = space
143
+ end
144
+
145
+ def to_hash
146
+ { space: @space }
147
+ end
148
+
149
+ def to_json(*args)
150
+ to_hash.to_json(*args)
151
+ end
152
+ end
153
+
154
+ # Delete space response data structure
155
+ class DeleteSpaceResp
156
+ attr_accessor :common
157
+
158
+ def initialize(attributes = {})
159
+ @common = attributes[:common]
160
+ end
161
+ end
162
+
163
+ # ToggleSpaceAccessibility space request parameters
164
+ class ToggleSpaceAccessibilityReq
165
+ attr_accessor :space, :public
166
+
167
+ def initialize(space:, public: false)
168
+ @space = space
169
+ @public = public
170
+ end
171
+
172
+ def to_hash
173
+ {
174
+ space: @space,
175
+ public: @public
176
+ }
177
+ end
178
+
179
+ def to_json(*args)
180
+ to_hash.to_json(*args)
181
+ end
182
+ end
183
+
184
+ # ToggleSpaceAccessibility space response data structure
185
+ class ToggleSpaceAccessibilityResp
186
+ attr_accessor :common
187
+
188
+ def initialize(attributes = {})
189
+ @common = attributes[:common]
190
+ end
191
+ end
192
+
193
+ # Get space file list request parameters
194
+ class SpaceFileListReq
195
+ attr_accessor :pagination, :space
196
+
197
+ def initialize(pagination: PaginationReq.new, space:)
198
+ @pagination = pagination
199
+ @space = space
200
+ end
201
+
202
+ def to_hash
203
+ @pagination.to_hash.merge(space: @space)
204
+ end
205
+
206
+ def to_json(*args)
207
+ to_hash.to_json(*args)
208
+ end
209
+ end
210
+
211
+ # File information data structure
212
+ class FileInfo
213
+ attr_accessor :name, :byte_size, :size, :uploaded_at, :url
214
+
215
+ def initialize(attributes = {})
216
+ @name = attributes[:name]
217
+ @byte_size = attributes[:byte_size]
218
+ @size = attributes[:size]
219
+ @uploaded_at = attributes[:uploaded_at]
220
+ @url = attributes[:url]
221
+ end
222
+ end
223
+
224
+ # Get space file list response data structure
225
+ class SpaceFileListResp
226
+ attr_accessor :common, :data
227
+
228
+ def initialize(attributes = {})
229
+ @common = attributes[:common]
230
+ @data = attributes[:data] || { list: [] }
231
+ end
232
+ end
233
+
234
+ # Get file access ticket request parameters
235
+ class FileAccessTicketReq
236
+ attr_accessor :filename, :space
237
+
238
+ def initialize(filename:, space:)
239
+ @filename = filename
240
+ @space = space
241
+ end
242
+
243
+ def to_hash
244
+ {
245
+ filename: @filename,
246
+ space: @space
247
+ }
248
+ end
249
+
250
+ def to_json(*args)
251
+ to_hash.to_json(*args)
252
+ end
253
+ end
254
+
255
+ # Get file access ticket response data structure
256
+ class FileAccessTicketResp
257
+ attr_accessor :common, :data
258
+
259
+ def initialize(attributes = {})
260
+ @common = attributes[:common]
261
+ @data = attributes[:data] || {}
262
+ end
263
+ end
264
+
265
+ # Upload file request parameters
266
+ class UploadFileReq
267
+ attr_accessor :filename, :space, :file_content
268
+
269
+ def initialize(filename:, space:, file_content:)
270
+ @filename = filename
271
+ @space = space
272
+ @file_content = file_content
273
+ end
274
+ end
275
+
276
+ # Upload file response data structure
277
+ class UploadFileResp
278
+ attr_accessor :common, :data
279
+
280
+ def initialize(attributes = {})
281
+ @common = attributes[:common]
282
+ @data = attributes[:data] || {}
283
+ end
284
+ end
285
+
286
+ # Delete file request parameters
287
+ class DeleteFileReq
288
+ attr_accessor :filename_list, :space
289
+
290
+ def initialize(filename_list:, space:)
291
+ @filename_list = filename_list
292
+ @space = space
293
+ end
294
+
295
+ def to_hash
296
+ {
297
+ filename_list: @filename_list,
298
+ space: @space
299
+ }
300
+ end
301
+
302
+ def to_json(*args)
303
+ to_hash.to_json(*args)
304
+ end
305
+ end
306
+
307
+ # Delete file response data structure
308
+ class DeleteFileResp
309
+ attr_accessor :common
310
+
311
+ def initialize(attributes = {})
312
+ @common = attributes[:common]
313
+ end
314
+ end
315
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StardotsSdk
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "stardots_sdk/version"
4
+ require_relative "stardots_sdk/constants"
5
+ require_relative "stardots_sdk/types"
6
+ require_relative "stardots_sdk/helper"
7
+ require_relative "stardots_sdk/client"
8
+
9
+ module StardotsSdk
10
+ class Error < StandardError; end
11
+ class ArgumentError < Error; end
12
+ class RequestError < Error; end
13
+ end
data/logo.png ADDED
Binary file
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "stardots_sdk"
5
+ require "webmock/rspec"
6
+
7
+ RSpec.configure do |config|
8
+ # Enable flags like --only-failures and --next-failure
9
+ config.example_status_persistence_file_path = ".rspec_status"
10
+
11
+ # Disable RSpec exposing methods globally on `Module` and `main`
12
+ config.disable_monkey_patching!
13
+
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "stardots_sdk"
5
+
6
+ RSpec.describe StardotsSdk do
7
+ let(:client_key) { "test_client_key" }
8
+ let(:client_secret) { "test_client_secret" }
9
+ let(:client) { StardotsSdk::Client.new(client_key, client_secret) }
10
+
11
+ describe "Client" do
12
+ it "initializes with client key and secret" do
13
+ expect(client.client_key).to eq(client_key)
14
+ expect(client.client_secret).to eq(client_secret)
15
+ expect(client.endpoint).to eq(StardotsSdk::Constants::ENDPOINT)
16
+ end
17
+
18
+ it "initializes with custom endpoint" do
19
+ custom_endpoint = "https://custom.api.stardots.io"
20
+ custom_client = StardotsSdk::Client.new(client_key, client_secret, custom_endpoint)
21
+ expect(custom_client.endpoint).to eq(custom_endpoint)
22
+ end
23
+ end
24
+
25
+ describe "Types" do
26
+ describe "PaginationReq" do
27
+ it "has default values" do
28
+ pagination = StardotsSdk::PaginationReq.new
29
+ expect(pagination.page).to eq(1)
30
+ expect(pagination.page_size).to eq(20)
31
+ end
32
+
33
+ it "accepts custom values" do
34
+ pagination = StardotsSdk::PaginationReq.new(page: 2, page_size: 50)
35
+ expect(pagination.page).to eq(2)
36
+ expect(pagination.page_size).to eq(50)
37
+ end
38
+ end
39
+
40
+ describe "CreateSpaceReq" do
41
+ it "creates with required parameters" do
42
+ req = StardotsSdk::CreateSpaceReq.new(space: "test-space", public: true)
43
+ expect(req.space).to eq("test-space")
44
+ expect(req.public).to be true
45
+ end
46
+
47
+ it "has default public value" do
48
+ req = StardotsSdk::CreateSpaceReq.new(space: "test-space")
49
+ expect(req.public).to be false
50
+ end
51
+ end
52
+
53
+ describe "UploadFileReq" do
54
+ it "creates with required parameters" do
55
+ req = StardotsSdk::UploadFileReq.new(
56
+ filename: "test.txt",
57
+ space: "test-space",
58
+ file_content: "test content"
59
+ )
60
+ expect(req.filename).to eq("test.txt")
61
+ expect(req.space).to eq("test-space")
62
+ expect(req.file_content).to eq("test content")
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "Helper" do
68
+ describe "request_url" do
69
+ it "combines endpoint and path" do
70
+ url = StardotsSdk::Helper.request_url("https://api.example.com", "/test/path")
71
+ expect(url).to eq("https://api.example.com/test/path")
72
+ end
73
+ end
74
+
75
+ describe "make_headers" do
76
+ it "generates authentication headers" do
77
+ headers = StardotsSdk::Helper.make_headers(client_key, client_secret)
78
+
79
+ expect(headers).to include("x-stardots-key")
80
+ expect(headers).to include("x-stardots-sign")
81
+ expect(headers).to include("x-stardots-timestamp")
82
+ expect(headers).to include("x-stardots-nonce")
83
+ expect(headers).to include("x-stardots-extra")
84
+ expect(headers).to include("Content-Type")
85
+
86
+ expect(headers["x-stardots-key"]).to eq(client_key)
87
+ expect(headers["Content-Type"]).to eq("application/json; charset=utf-8")
88
+ end
89
+ end
90
+ end
91
+ end
metadata ADDED
@@ -0,0 +1,226 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stardots-sdk-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - StarDots Team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.21'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.18'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.18'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.50'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.50'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.20'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.20'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.22'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.22'
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.9'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.9'
153
+ - !ruby/object:Gem::Dependency
154
+ name: redcarpet
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.6'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.6'
167
+ description: This gem provides a Ruby interface to the StarDots platform, allowing
168
+ developers to easily manage spaces, upload files, and interact with the StarDots
169
+ API.
170
+ email:
171
+ - support@stardots.io
172
+ executables: []
173
+ extensions: []
174
+ extra_rdoc_files: []
175
+ files:
176
+ - LICENSE
177
+ - README.md
178
+ - lib/stardots_sdk.rb
179
+ - lib/stardots_sdk/client.rb
180
+ - lib/stardots_sdk/constants.rb
181
+ - lib/stardots_sdk/helper.rb
182
+ - lib/stardots_sdk/types.rb
183
+ - lib/stardots_sdk/version.rb
184
+ - logo.png
185
+ - spec/spec_helper.rb
186
+ - spec/stardots_sdk_spec.rb
187
+ homepage: https://stardots.io
188
+ licenses:
189
+ - MIT
190
+ metadata:
191
+ homepage_uri: https://stardots.io
192
+ source_code_uri: https://github.com/stardots-io/stardots-sdk-ruby
193
+ changelog_uri: https://github.com/stardots-io/stardots-sdk-ruby/blob/main/CHANGELOG.md
194
+ documentation_uri: https://stardots.io/en/documentation/openapi
195
+ bug_tracker_uri: https://github.com/stardots-io/stardots-sdk-ruby/issues
196
+ wiki_uri: https://github.com/stardots-io/stardots-sdk-ruby/wiki
197
+ funding_uri: https://stardots.io
198
+ rubygems_mfa_required: 'true'
199
+ post_install_message: |
200
+ Thank you for installing stardots-sdk-ruby!
201
+
202
+ To get started, visit: https://stardots.io/en/documentation/openapi
203
+
204
+ If you encounter any issues, please report them at:
205
+ https://github.com/stardots-io/stardots-sdk-ruby/issues
206
+ rdoc_options: []
207
+ require_paths:
208
+ - lib
209
+ required_ruby_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: 2.6.0
214
+ required_rubygems_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ requirements: []
220
+ rubygems_version: 3.0.1
221
+ signing_key:
222
+ specification_version: 4
223
+ summary: Official Ruby SDK for StarDots platform
224
+ test_files:
225
+ - spec/stardots_sdk_spec.rb
226
+ - spec/spec_helper.rb