Class: Privy::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Privy::Client
- Defined in:
- lib/privy/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0- ENVIRONMENTS =
rubocop:disable Style/MutableConstant
{production: "https://api.privy.io", staging: "https://api.staging.privy.io"}
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
- #accounts ⇒ Privy::Resources::Accounts readonly
- #aggregations ⇒ Privy::Resources::Aggregations readonly
- #analytics ⇒ Privy::Resources::Analytics readonly
-
#app_id ⇒ String
readonly
App secret authentication.
-
#app_secret ⇒ String
readonly
App secret authentication.
-
#apps ⇒ Privy::Resources::Apps
readonly
Operations related to app settings and allowlist management.
- #client_auth ⇒ Privy::Resources::ClientAuth readonly
- #cross_app ⇒ Privy::Resources::CrossApp readonly
- #embedded_wallets ⇒ Privy::Resources::EmbeddedWallets readonly
- #funding ⇒ Privy::Resources::Funding readonly
- #intents ⇒ Privy::Resources::Intents readonly
-
#key_quorums ⇒ Privy::Resources::KeyQuorums
readonly
Operations related to key quorums.
- #kraken_embed ⇒ Privy::Resources::KrakenEmbed readonly
- #organizations ⇒ Privy::Resources::Organizations readonly
-
#policies ⇒ Privy::Resources::Policies
readonly
Operations related to policies.
- #shared ⇒ Privy::Resources::Shared readonly
- #swaps ⇒ Privy::Resources::Swaps readonly
-
#transactions ⇒ Privy::Resources::Transactions
readonly
Operations related to transactions.
-
#users ⇒ Privy::Resources::Users
readonly
Operations related to users.
- #wallet_actions ⇒ Privy::Resources::WalletActions readonly
- #wallets ⇒ Privy::Resources::Wallets readonly
- #webhooks ⇒ Privy::Resources::Webhooks readonly
- #yield_ ⇒ Privy::Resources::Yield readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(app_id: , app_secret: , environment: nil, base_url: , max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(app_id: , app_secret: , environment: nil, base_url: , max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
Each environment maps to a different base URL:
-
‘production` corresponds to `api.privy.io`
-
‘staging` corresponds to `api.staging.privy.io`
‘“api.example.com/v2/”`. Defaults to `ENV`
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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 |
# File 'lib/privy/client.rb', line 132 def initialize( app_id: ENV["PRIVY_APP_ID"], app_secret: ENV["PRIVY_APP_SECRET"], environment: nil, base_url: ENV["PRIVY_API_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= Privy::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do = "environment must be one of #{Privy::Client::ENVIRONMENTS.keys}, got #{environment}" raise ArgumentError.new() end if app_id.nil? raise ArgumentError.new("app_id is required, and can be set via environ: \"PRIVY_APP_ID\"") end if app_secret.nil? raise ArgumentError.new("app_secret is required, and can be set via environ: \"PRIVY_APP_SECRET\"") end headers = { "privy-app-id" => (@app_id = app_id.to_s) } custom_headers_env = ENV["PRIVY_API_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @app_secret = app_secret.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @wallets = Privy::Resources::Wallets.new(client: self) @users = Privy::Resources::Users.new(client: self) @policies = Privy::Resources::Policies.new(client: self) @transactions = Privy::Resources::Transactions.new(client: self) @key_quorums = Privy::Resources::KeyQuorums.new(client: self) @intents = Privy::Resources::Intents.new(client: self) @apps = Privy::Resources::Apps.new(client: self) @webhooks = Privy::Resources::Webhooks.new(client: self) @accounts = Privy::Resources::Accounts.new(client: self) @aggregations = Privy::Resources::Aggregations.new(client: self) @embedded_wallets = Privy::Resources::EmbeddedWallets.new(client: self) @analytics = Privy::Resources::Analytics.new(client: self) @client_auth = Privy::Resources::ClientAuth.new(client: self) @funding = Privy::Resources::Funding.new(client: self) @organizations = Privy::Resources::Organizations.new(client: self) @cross_app = Privy::Resources::CrossApp.new(client: self) @shared = Privy::Resources::Shared.new(client: self) @wallet_actions = Privy::Resources::WalletActions.new(client: self) @yield_ = Privy::Resources::Yield.new(client: self) @kraken_embed = Privy::Resources::KrakenEmbed.new(client: self) @swaps = Privy::Resources::Swaps.new(client: self) end |
Instance Attribute Details
#accounts ⇒ Privy::Resources::Accounts (readonly)
61 62 63 |
# File 'lib/privy/client.rb', line 61 def accounts @accounts end |
#aggregations ⇒ Privy::Resources::Aggregations (readonly)
64 65 66 |
# File 'lib/privy/client.rb', line 64 def aggregations @aggregations end |
#analytics ⇒ Privy::Resources::Analytics (readonly)
70 71 72 |
# File 'lib/privy/client.rb', line 70 def analytics @analytics end |
#app_id ⇒ String (readonly)
App secret authentication.
25 26 27 |
# File 'lib/privy/client.rb', line 25 def app_id @app_id end |
#app_secret ⇒ String (readonly)
App secret authentication.
29 30 31 |
# File 'lib/privy/client.rb', line 29 def app_secret @app_secret end |
#apps ⇒ Privy::Resources::Apps (readonly)
Operations related to app settings and allowlist management
55 56 57 |
# File 'lib/privy/client.rb', line 55 def apps @apps end |
#client_auth ⇒ Privy::Resources::ClientAuth (readonly)
73 74 75 |
# File 'lib/privy/client.rb', line 73 def client_auth @client_auth end |
#cross_app ⇒ Privy::Resources::CrossApp (readonly)
82 83 84 |
# File 'lib/privy/client.rb', line 82 def cross_app @cross_app end |
#embedded_wallets ⇒ Privy::Resources::EmbeddedWallets (readonly)
67 68 69 |
# File 'lib/privy/client.rb', line 67 def @embedded_wallets end |
#funding ⇒ Privy::Resources::Funding (readonly)
76 77 78 |
# File 'lib/privy/client.rb', line 76 def funding @funding end |
#intents ⇒ Privy::Resources::Intents (readonly)
51 52 53 |
# File 'lib/privy/client.rb', line 51 def intents @intents end |
#key_quorums ⇒ Privy::Resources::KeyQuorums (readonly)
Operations related to key quorums
48 49 50 |
# File 'lib/privy/client.rb', line 48 def key_quorums @key_quorums end |
#kraken_embed ⇒ Privy::Resources::KrakenEmbed (readonly)
94 95 96 |
# File 'lib/privy/client.rb', line 94 def @kraken_embed end |
#organizations ⇒ Privy::Resources::Organizations (readonly)
79 80 81 |
# File 'lib/privy/client.rb', line 79 def organizations @organizations end |
#policies ⇒ Privy::Resources::Policies (readonly)
Operations related to policies
40 41 42 |
# File 'lib/privy/client.rb', line 40 def policies @policies end |
#shared ⇒ Privy::Resources::Shared (readonly)
85 86 87 |
# File 'lib/privy/client.rb', line 85 def shared @shared end |
#swaps ⇒ Privy::Resources::Swaps (readonly)
97 98 99 |
# File 'lib/privy/client.rb', line 97 def swaps @swaps end |
#transactions ⇒ Privy::Resources::Transactions (readonly)
Operations related to transactions
44 45 46 |
# File 'lib/privy/client.rb', line 44 def transactions @transactions end |
#users ⇒ Privy::Resources::Users (readonly)
Operations related to users
36 37 38 |
# File 'lib/privy/client.rb', line 36 def users @users end |
#wallet_actions ⇒ Privy::Resources::WalletActions (readonly)
88 89 90 |
# File 'lib/privy/client.rb', line 88 def wallet_actions @wallet_actions end |
#wallets ⇒ Privy::Resources::Wallets (readonly)
32 33 34 |
# File 'lib/privy/client.rb', line 32 def wallets @wallets end |
#webhooks ⇒ Privy::Resources::Webhooks (readonly)
58 59 60 |
# File 'lib/privy/client.rb', line 58 def webhooks @webhooks end |
#yield_ ⇒ Privy::Resources::Yield (readonly)
91 92 93 |
# File 'lib/privy/client.rb', line 91 def yield_ @yield_ end |