- Implement SynorStorage class for decentralized storage operations including upload, download, pinning, and CAR file management. - Create supporting types and models for storage operations such as UploadOptions, Pin, and StorageConfig. - Implement SynorWallet class for wallet operations including wallet creation, address generation, transaction signing, and balance queries. - Create supporting types and models for wallet operations such as Wallet, Address, and Transaction. - Introduce error handling for both storage and wallet operations.
40 lines
1,010 B
Ruby
40 lines
1,010 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "synor_storage/version"
|
|
require_relative "synor_storage/types"
|
|
require_relative "synor_storage/client"
|
|
|
|
# Synor Storage SDK for Ruby
|
|
#
|
|
# Decentralized storage operations including upload, download, pinning, and directory management.
|
|
#
|
|
# @example Quick Start
|
|
# require 'synor_storage'
|
|
#
|
|
# # Create client
|
|
# client = SynorStorage::Client.new(api_key: 'your-api-key')
|
|
#
|
|
# # Upload a file
|
|
# result = client.upload(File.read('document.pdf'), name: 'document.pdf')
|
|
# puts "CID: #{result.cid}"
|
|
#
|
|
# # Download a file
|
|
# data = client.download(result.cid)
|
|
# File.write('downloaded.pdf', data)
|
|
#
|
|
# # Get gateway URL
|
|
# url = client.get_gateway_url(result.cid)
|
|
# puts "URL: #{url}"
|
|
#
|
|
module SynorStorage
|
|
class Error < StandardError; end
|
|
class ApiError < Error
|
|
attr_reader :status_code
|
|
|
|
def initialize(message, status_code: nil)
|
|
super(message)
|
|
@status_code = status_code
|
|
end
|
|
end
|
|
class ClientClosedError < Error; end
|
|
end
|