Initial commit

This commit is contained in:
bterkuile committed 2025-09-15 15:55:58 -05:00
commit 4b5f7906d7
33 files changed
+933

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# frozen_string_literal: true
module StrikeMe
module API
class Account
include BaseClient
autoload_default :Profile
autoload_default :Balances
autoload_default :Balance
def profile
return @profile if @profile.present?
response = client.get profile_url
if response.success?
body = response.body
body = JSON.parse(body) if body.is_a? String
@profile = Profile.new body.merge(account: self)
else
# if you see this, something went wrong, this is test code
@profile = ResponseError.new(profile_url, response)
end
end
def profile_url
if (account_id = ENV['STRIKE_ACCOUNT_ID'].presence)
"accounts/#{account_id}/profile"
else
account_handle = ENV.fetch('STRIKE_ACCOUNT_HANDLE')
"accounts/handles/#{account_handle}/profile"
end
end
def balances
return @balances if @balances.present?
response = client.get 'balances'
@balances = if response.success?
Balances.new self, response.body
else
# if you see this, something went wrong, this is test code
ResponseError.new('balances', response)
end
end
def inspect
"#<StrikeMe::API::Account profile: #{@profile}, balances: #{@balances}>"
end
end
end
end